X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Faddrbook_search.php;h=262bc5e45e6845fc07161b56fec6754813eeabcd;hp=ad41bfefa0b50e08634bd5cfd8aabd299b67c530;hb=91e0dccca7b2452d8b450791cae3aa4125e8889e;hpb=2a833d7253739cb67eb69aa760f7b37fe7aedd8c diff --git a/src/addrbook_search.php b/src/addrbook_search.php index ad41bfef..262bc5e4 100644 --- a/src/addrbook_search.php +++ b/src/addrbook_search.php @@ -1,187 +1,306 @@ "; - } else { - echo "\n"; - } - - // Just make a blank page and exit - if(($show == "blank") || (empty($query) && empty($show))) { - printf("


%s

\n\n", - _("Search results will display here")); - exit; - } - - // Create search form - if($show == "form") { - printf("
\n", - $PHP_SELF); - printf(""); - printf("
\n"); - printf(" %s:\n\n", - _("Search for")); - printf(" \n", - htmlspecialchars($query)); - printf("\n"); - printf(" ", - _("Search")); - printf("\n"); - printf("\n", - _("Close window")); - printf("
\n"); - } - - // Include JavaScript code if this is search results - if(!empty($query)) { -?> - +\n"; + + while (list($undef, $row) = each($res)) { + $email = htmlspecialchars(addcslashes(AddressBook::full_address($row), "'"), ENT_QUOTES); + if ($line % 2) { + $tr_bgcolor = $color[12]; + } else { + $tr_bgcolor = $color[4]; + } + echo html_tag( 'tr', '', '', $tr_bgcolor, 'nowrap' ) . + html_tag( 'td', + '"._("To")." | " . + '"._("Cc")." | " . + '"._("Bcc")."", + 'center', '', 'valign="top" width="5%" nowrap' ) . + html_tag( 'td', ' ' . htmlspecialchars($row['name']), 'left', '', 'valign="top" nowrap' ) . + html_tag( 'td', ' ' . + '" . htmlspecialchars($row['email']) . '' + , 'left', '', 'valign="top"' ) . + html_tag( 'td', htmlspecialchars($row['label']), 'left', '', 'valign="top" nowrap' ); + if ($includesource) { + echo html_tag( 'td', ' ' . $row['source'], 'left', '', 'valign="top" nowrap' ); + } + + echo "\n"; + $line++; } - } + echo ''; } -function cc_address($addr) { - var prefix = ""; - var pwintype = typeof parent.opener.document.compose; +/* ================= End of functions ================= */ + +require_once('../functions/strings.php'); +require_once('../functions/addressbook.php'); + +displayHtmlHeader(); + +/* Initialize vars */ +if (!isset($query)) { $query = ''; } +if (!isset($show)) { $show = ''; } +if (!isset($backend)) { $backend = ''; } + +/* Choose correct colors for top and bottom frame */ +if ($show == 'form' && !isset($listall)) { + echo ''; +} else { + echo '\n"; +} + +/* Empty search */ +if (empty($query) && empty($show) && empty($listall)) { + echo html_tag( 'p', '
' . + _("No persons matching your search were found"), + 'center' ) . + "\n\n"; + exit; +} + +/* Initialize addressbook */ +$abook = addressbook_init(); + +/* Create search form */ +if ($show == 'form' && empty($listall)) { + echo '
' . "\n" . + html_tag( 'table', '', '', '', 'border="0" width="100%" height="100%"' ) . + html_tag( 'tr' ) . + html_tag( 'td', ' ' . _("Search for") . "\n", 'left', '', 'nowrap valign="middle" width="10%"' ) . + html_tag( 'td', '', 'left', '', '' ) . + addInput('query', $query, 28); - $addr = $addr.replace(/ {1,35}$/, ""); + /* List all backends to allow the user to choose where to search */ + if ($abook->numbackends > 1) { + echo '' . _("in") . ' '."\n". + $selopts['-1'] = _("All address books"); - 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; + $ret = $abook->get_backend_list(); + while (list($undef,$v) = each($ret)) { + $selopts[$v->bnum] = $v->sname; + } + echo addSelect('backend', $selopts, '-1', TRUE); } else { - parent.opener.document.compose.send_to_cc.value = $addr; + echo addHidden('backend', '-1'); } - } -} -function bcc_address($addr) { - var prefix = ""; - var pwintype = typeof parent.opener.document.compose; - - $addr = $addr.replace(/ {1,35}$/, ""); - - if(pwintype != "undefined" ) { - if ( parent.opener.document.compose.bcc.value ) { - prefix = ", "; - parent.opener.document.compose.bcc.value = - parent.opener.document.compose.bcc.value + ", " + $addr; + echo '' . + html_tag( 'tr', + html_tag( 'td', '', 'left' ) . + html_tag( 'td', + '' . + ' | ' . "\n" . + ' | ' . "\n" , + 'left' ) + ) . + '
' . "\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)) { + usort($res,'alistcmp'); + display_result($res, false); + } else { + echo html_tag( 'p', '' . + sprintf(_("Unable to list addresses from %s"), + $abook->backends[$backend]->sname) . '' , + 'center' ) . "\n"; + } + } else { + $res = $abook->list_addr(); + usort($res,'alistcmp'); + display_result($res, true); + } + } else { - parent.opener.document.compose.bcc.value = $addr; + if( !empty( $listall ) ){ + $query = '*'; + } + + /* Do the search */ + if (!empty($query)) { + + if($backend == -1) { + $res = $abook->s_search($query); + } else { + $res = $abook->s_search($query, $backend); + } + + if (!is_array($res)) { + echo html_tag( 'p', '
' . + _("Your search failed with the following error(s)") . + ':
' . $abook->error . "
\n" , + 'center' ) . + "\n\n"; + exit; + } + + if (sizeof($res) == 0) { + echo html_tag( 'p', '
' . + _("No persons matching your search were found") . "\n" , + 'center' ) . + "\n\n"; + exit; + } + + display_result($res); + } } - } -} -// --> - -s_search($query); - - 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; - } - - // List search results - $line = 0; - print ""; - printf("\n", - _("Name"), _("E-mail"), _("Info"), _("Source")); - - while(list($key, $row) = each($res)) { - printf("\n", - ($line % 2) ? " bgcolor=\"$color[0]\"" : "", $row["email"], - $row["email"], $row["name"], $row["email"], $row["email"], - $row["label"], $row["source"]); - $line++; - } - print "
 ". - " %s %s". - " %s". - " %s
". - "To | ". - "Cc". - " %s  ". - "%s ". - " %s  %s
"; - } +} ?> - - + \ No newline at end of file