X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Faddrbook_search.php;h=f6d637486f76bcf4299bc2378aaae4629149fcde;hb=4f664925c839b9a9f58e4699718a1254ba35a8d7;hp=46e6cdc743cd6473ae0a565f6f44b026cb8ad367;hpb=a10110a50f284e8afdef868cab40e07e7deeea44;p=squirrelmail.git diff --git a/src/addrbook_search.php b/src/addrbook_search.php index 46e6cdc7..f6d63748 100644 --- a/src/addrbook_search.php +++ b/src/addrbook_search.php @@ -15,7 +15,13 @@ * $Id$ */ -require_once('../src/validate.php'); +/* Path for SquirrelMail required files. */ +define('SM_PATH','../'); + +/* SquirrelMail required files. */ +require_once(SM_PATH . 'include/validate.php'); +require_once(SM_PATH . 'functions/strings.php'); +require_once(SM_PATH . 'functions/html.php'); /* Function to include JavaScript code */ function insert_javascript() { @@ -92,40 +98,45 @@ function display_result($res, $includesource = true) { insert_javascript(); $line = 0; - echo '' . - '\n"; + echo "\n"; while (list($undef, $row) = each($res)) { - echo '\n"; + echo "\n"; $line++; } - echo '
 ' . - ' ' . _("Name") . - ' ' . _("E-mail") . - ' ' . _("Info"); + 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 ' ' . _("Source"); + echo html_tag( 'th', ' ' . _("Source"), 'left', 'width="10%"' ); } - echo "
' . + $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 | " . + "'" . $email . "');\">To | " . 'Cc | " . + "'" . $email . "');\">Cc | " . 'Bcc" . - ' ' . - $row['name'] . ' ' . - ' " . $row['email'] . ' ' . - ' ' . $row['label'] . ' '; + "'" . $email . "');\">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 ' ' . $row['source']; + echo html_tag( 'td', ' ' . $row['source'], 'left', '', 'valign="top" nowrap' ); } - echo "
'; + echo ''; } /* ================= End of functions ================= */ @@ -139,9 +150,10 @@ 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') { +if ($show == 'form' && !isset($listall)) { echo '
' . - _("No persons matching your search was found") . - "

\n\n", + echo html_tag( 'p', '
' . + _("No persons matching your search was found"), + 'center' ) . + "\n\n", exit; } @@ -164,14 +177,15 @@ if (empty($query) && empty($show) && empty($listall)) { $abook = addressbook_init(); /* Create search form */ -if ($show == 'form') { - echo '
' . "\n" . - '' . - '
' . "\n" . - ' ' . _("Search for") . "\n" . - ' \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) { @@ -186,17 +200,22 @@ if ($show == 'form') { echo '' . "\n"; } - echo '' . - ' | ' . "\n" . - '' . "\n" . - '' . "\n" . - '
' . "\n"; + 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 ($show == 'blank' && empty($listall)) { if($backend != -1 || $show == 'blank') { if ($show == 'blank') { @@ -208,10 +227,10 @@ if ($show == 'form') { usort($res,'alistcmp'); display_result($res, false); } else { - echo '

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

' . "\n"; + echo html_tag( 'p', '' . + sprintf(_("Unable to list addresses from %s"), + $abook->backends[$backend]->sname) . '' , + 'center' ) . "\n"; } } else { $res = $abook->list_addr(); @@ -220,9 +239,12 @@ if ($show == 'form') { } } else { + if( !empty( $listall ) ){ + $query = '*'; + } /* Do the search */ - if (!empty($query) && empty($listall)) { + if (!empty($query)) { if($backend == -1) { $res = $abook->s_search($query); @@ -231,16 +253,19 @@ if ($show == 'form') { } if (!is_array($res)) { - echo '


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

\n\n"; + echo html_tag( 'p', '
' . + _("Your search failed with the following error(s)") . + ':
' . $abook->error . "
\n" , + 'center' ) . + "\n\n"; exit; } if (sizeof($res) == 0) { - echo '


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

\n\n"; + echo html_tag( 'p', '
' . + _("No persons matching your search was found") . "\n" , + 'center' ) . + "\n\n"; exit; }