X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Faddrbook_search.php;h=4e914beef1ef4f28c5297d4665e19f6148e3510e;hb=0fa230016e399929e51d8e007b1509421424c7de;hp=9557065cf1f74af43075cf0a90a5c0c613912141;hpb=9487c2ff3a9d36af3dc93bd231a6f85fe7a6f762;p=squirrelmail.git diff --git a/src/addrbook_search.php b/src/addrbook_search.php index 9557065c..4e914bee 100644 --- a/src/addrbook_search.php +++ b/src/addrbook_search.php @@ -1,244 +1,291 @@ - + 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.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; + } + } + } +// --> '; - printf(" ". - " %s %s". - " %s", - _("Name"), _("E-mail"), _("Info")); - - if($includesource) - printf(" %s", _("Source")); - - echo "\n"; - - while(list($undef, $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"]); + $line = 0; + echo html_tag( 'table', '', 'center', '', 'border="0" width="98%"' ) . + html_tag( 'tr', '', '', $color[9] ) . + html_tag( 'th', ' ', 'left' ) . + html_tag( 'th', ' ' . _("Name"), 'left' ) . + html_tag( 'th', ' ' . _("E-mail"), 'left' ) . + html_tag( 'th', ' ' . _("Info"), 'left' ); + + if ($includesource) { + echo html_tag( 'th', ' ' . _("Source"), 'left', 'width="10%"' ); + } + echo "\n"; - echo "\n"; - $line++; + while (list($undef, $row) = each($res)) { + $tr_bgcolor = ''; + $email = htmlspecialchars(addcslashes(AddressBook::full_address($row), "'"), ENT_QUOTES); + if ($line % 2) { $tr_bgcolor = $color[0]; } + 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 ''; + + echo "\n"; + $line++; } + echo ''; +} - /* ================= End of functions ================= */ +/* ================= End of functions ================= */ - require_once('../functions/array.php'); - require_once('../functions/strings.php'); - require_once('../functions/addressbook.php'); +require_once('../functions/strings.php'); +require_once('../functions/addressbook.php'); - displayHtmlHeader(); +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"; - } +/* Initialize vars */ +if (!isset($query)) { $query = ''; } +if (!isset($show)) { $show = ''; } +if (!isset($backend)) { $backend = ''; } - // Empty search - if(empty($query) && empty($show) && empty($listall)) { - printf("


%s

\n\n", - _("No persons matching your search was found")); - exit; - } +/* Choose correct colors for top and bottom frame */ +if ($show == 'form' && !isset($listall)) { + echo ''; +} else { + echo '\n"; +} - // Initialize addressbook - $abook = addressbook_init(); - - // Create search form - if($show == 'form') { - echo "
\n"; - echo ''; - echo "
\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 { - print "\n"; +/* Empty search */ +if (empty($query) && empty($show) && empty($listall)) { + echo html_tag( 'p', '
' . + _("No persons matching your search was 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', '', '' ) . + '\n"; + + /* List all backends to allow the user to choose where to search */ + if ($abook->numbackends > 1) { + echo '' . _("in") . ' \n"; + } else { + echo '' . "\n"; + } - printf("", - _("Search")); - printf(" | \n", - _("List all")); - print "
\n"; - printf("\n", - _("Close window")); - print "
\n"; - } else - - // Show personal addressbook - if($show == 'blank' || !empty($listall)) { + 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') + if ($show == 'blank') { $backend = $abook->localbackend; - + } $res = $abook->list_addr($backend); if(is_array($res)) { + usort($res,'alistcmp'); display_result($res, false); } else { - printf("

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

\n", $abook->backends[$backend]->sname); + echo html_tag( 'p', '' . + sprintf(_("Unable to list addresses from %s"), + $abook->backends[$backend]->sname) . '' , + 'center' ) . "\n"; } - } else { - $res = $abook->list_addr(); - display_result($res, true); + $res = $abook->list_addr(); + usort($res,'alistcmp'); + display_result($res, true); } - } else + } else { + if( !empty( $listall ) ){ + $query = '*'; + } - // Do the search - if(!empty($query) && empty($listall)) { + /* Do the search */ + if (!empty($query)) { - if($backend == -1) { - $res = $abook->s_search($query); - } else { - $res = $abook->s_search($query, $backend); - } + 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 (!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) { - printf("


%s.

\n\n", - _("No persons matching your search was found")); - exit; - } + if (sizeof($res) == 0) { + echo html_tag( 'p', '
' . + _("No persons matching your search was found") . "\n" , + 'center' ) . + "\n\n"; + exit; + } - display_result($res); + display_result($res); + } } - echo "\n"; +} + +echo "\n"; -?> \ No newline at end of file +?>