X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Faddrbook_search.php;h=2adb5ad5a1802616fb0c749af59e9b04912c5ded;hb=00a065a69448f66db8f29fda00961878926a5912;hp=d89d118b5f4043f2c6d6b76dd571b0472a526a7f;hpb=ef8703220ec8e7573417b08881f636082e4b8d58;p=squirrelmail.git diff --git a/src/addrbook_search.php b/src/addrbook_search.php index d89d118b..2adb5ad5 100644 --- a/src/addrbook_search.php +++ b/src/addrbook_search.php @@ -1,261 +1,253 @@ - +' . + ' ' . + ' ' . _("Name") . + ' ' . _("E-mail") . + ' ' . _("Info"); + + if ($includesource) { + echo ' ' . _("Source"); + } + echo "\n"; + + while (list($undef, $row) = each($res)) { + echo '' . + 'To | " . + 'Cc | " . + 'Bcc" . + ' ' . + $row['name'] . ' ' . + ' " . $row['email'] . ' ' . + ' ' . $row['label'] . ' '; + if ($includesource) { + echo ' ' . $row['source']; + } + + echo "\n"; + $line++; } - } + echo ''; } -function cc_address($addr) { - var prefix = ""; - var pwintype = typeof parent.opener.document.compose; +/* ================= End of functions ================= */ + +require_once('../functions/array.php'); +require_once('../functions/strings.php'); +require_once('../functions/addressbook.php'); + +displayHtmlHeader(); + +/* Initialize vars */ +if (!isset($query)) { $query = ''; } +if (!isset($show)) { $show = ''; } + +/* Choose correct colors for top and bottom frame */ +if ($show == 'form') { + echo ''; +} else { + echo '\n"; +} - $addr = $addr.replace(/ {1,35}$/, ""); +/* Empty search */ +if (empty($query) && empty($show) && empty($listall)) { + echo '


' . + _("No persons matching your search was found") . + "

\n\n", + exit; +} - if(pwintype != "undefined" ) { - if ( parent.opener.document.compose.send_to_cc.value ) { - prefix = ", "; - parent.opener.document.compose.send_to_cc.value = - parent.opener.document.compose.send_to_cc.value + ", " + $addr; +/* Initialize addressbook */ +$abook = addressbook_init(); + +/* Create search form */ +if ($show == 'form') { + echo '
' . "\n" . + '' . + '
' . "\n" . + ' ' . _("Search for") . "\n" . + ' \n"; + + /* List all backends to allow the user to choose where to search */ + if ($abook->numbackends > 1) { + echo '' . _("in") . ' \n"; } else { - parent.opener.document.compose.send_to_cc.value = $addr; + echo '' . "\n"; } - } -} - -function bcc_address($addr) { - var prefix = ""; - var pwintype = typeof parent.opener.document.compose; - - $addr = $addr.replace(/ {1,35}$/, ""); + + echo '' . + ' | ' . "\n" . + '' . "\n" . + '' . "\n" . + '
' . "\n"; +} else { + + /* Show personal addressbook */ + if ($show == 'blank' || !empty($listall)) { + + if($backend != -1 || $show == 'blank') { + if ($show == 'blank') { + $backend = $abook->localbackend; + } + $res = $abook->list_addr($backend); + + if(is_array($res)) { + display_result($res, false); + } else { + echo '

' . + sprintf(_("Unable to list addresses from %s"), + $abook->backends[$backend]->sname) . + '

' . "\n"; + } + } else { + $res = $abook->list_addr(); + display_result($res, true); + } - if(pwintype != "undefined" ) { - if ( parent.opener.document.compose.send_to_bcc.value ) { - prefix = ", "; - parent.opener.document.compose.send_to_bcc.value = - parent.opener.document.compose.send_to_bcc.value + ", " + $addr; } else { - parent.opener.document.compose.send_to_bcc.value = $addr; + + /* Do the search */ + if (!empty($query) && empty($listall)) { + + if($backend == -1) { + $res = $abook->s_search($query); + } else { + $res = $abook->s_search($query, $backend); + } + + if (!is_array($res)) { + echo '


' . + _("Your search failed with the following error(s)") . + ':
' . $abook->error . "

\n\n"; + exit; + } + + if (sizeof($res) == 0) { + echo '


' . + _("No persons matching your search was found") . + ".

\n\n"; + exit; + } + + display_result($res); + } } - } + } -// --> - -"; - printf(" ". - " %s %s". - " %s", - _("Name"), _("E-mail"), _("Info")); - - if($includesource) - printf(" %s", _("Source")); - - print "\n"; - - while(list($key, $row) = each($res)) { - printf("". - "To | ". - "Cc | ". - "Bcc". - " %s ". - " %s ". - " %s ", - ($line % 2) ? " bgcolor=\"$color[0]\"" : "", - $row["email"], $row["email"], $row["email"], - $row["name"], $row["email"], $row["email"], - $row["label"]); - - if($includesource) - printf(" %s", $row["source"]); - - print "\n"; - $line++; - } - print ""; - } - - /* ================= End of functions ================= */ - - session_start(); - - if(!isset($logged_in)) { - echo _("You must login first."); - exit; - } - if(!isset($username) || !isset($key)) { - echo _("You need a valid user and password to access this page!"); - exit; - } - - if (!isset($config_php)) - include("../config/config.php"); - if (!isset($array_php)) - include("../functions/array.php"); - if (!isset($auth_php)) - include("../functions/auth.php"); - if (!isset($strings_php)) - include("../functions/strings.php"); - if (!isset($page_header_php)) - include("../functions/page_header.php"); - if (!isset($addressbook_php)) - include("../functions/addressbook.php"); - - is_logged_in(); - include("../src/load_prefs.php"); - - displayHtmlHeader(); - - // Choose correct colors for top and bottom frame - if($show == "form") { - echo ""; - } else { - echo "\n"; - } - - // Empty search - if(empty($query) && empty($show) && empty($listall)) { - printf("


%s

\n\n", - _("No persons matching your search was found")); - exit; - } - - // Initialize addressbook - $abook = addressbook_init(); - - // Create search form - if($show == "form") { - printf("
\n", - $PHP_SELF); - printf(""); - printf("
\n"); - printf(" %s\n", _("Search for")); - printf(" \n", - htmlspecialchars($query)); - - // List all backends to allow the user to choose where to search - if($abook->numbackends > 1) { - printf("%s \n"); - } else { - printf("\n"); - } - - printf("", - _("Search")); - printf(" | \n", - _("List all")); - printf("\n"); - printf("\n", - _("Close window")); - printf("
\n"); - } else - - // Show personal addressbook - if($show == "blank" || !empty($listall)) { - - if($backend != -1 || $show == "blank") { - if($show == "blank") - $backend = $abook->localbackend; - - //printf("

%s

\n", $abook->backends[$backend]->sname); - - $res = $abook->list_addr($backend); - - if(is_array($res)) { - display_result($res, false); - } else { - printf("

"._("Unable to list addresses from %s"). - "

\n", $abook->backends[$backend]->sname); - } - - } else { - $res = $abook->list_addr(); - display_result($res, true); - } - - } else - - // Do the search - if(!empty($query) && empty($listall)) { - - if($backend == -1) { - $res = $abook->s_search($query); - } else { - $res = $abook->s_search($query, $backend); - } - - if(!is_array($res)) { - printf("


%s:
%s

\n\n", - _("Your search failed with the following error(s)"), - $abook->error); - exit; - } - - if(sizeof($res) == 0) { - printf("


%s.

\n\n", - _("No persons matching your search was found")); - exit; - } - - display_result($res); - } +echo "\n"; + ?> - -