X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Faddrbook_search.php;h=7e2672003d13a49b63283649d77b083c6c25396d;hp=656bee51c7016f1c2c5028beb50dc68c2c707ac4;hb=1a4bc4a62fa812d0e0fa8fd48ea804e045bab040;hpb=716df0e3cadb0e86468b5d5658093e86c0d0f654
diff --git a/src/addrbook_search.php b/src/addrbook_search.php
index 656bee51..7e267200 100644
--- a/src/addrbook_search.php
+++ b/src/addrbook_search.php
@@ -1,113 +1,31 @@
-
-\n";
+ $oTemplate->assign('compose_addr_pop', true);
+ $oTemplate->assign('include_abook_name', $includesource);
+ $oTemplate->assign('addresses', formatAddressList($res));
- 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 '';
+ $oTemplate->display('addrbook_search_list.tpl');
}
/* ================= 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";
-}
+/** lets get the global vars we may need */
-/* Empty search */
-if (empty($query) && empty($show) && empty($listall)) {
- echo html_tag( 'p', '
' .
- _("No persons matching your search were found"),
- 'center' ) .
- "\n\n";
- exit;
+if (! sqgetGlobalVar('show' , $show)) {
+ $show = '';
+}
+if (! sqgetGlobalVar('query', $query, SQ_POST)) {
+ $query = '';
+}
+if (! sqgetGlobalVar('listall', $listall, SQ_POST)) {
+ unset($listall);
}
+if (! sqgetGlobalVar('backend', $backend, SQ_POST)) {
+ $backend = '';
+}
+
+displayHtmlHeader();
+echo "\n";
-/* Initialize addressbook */
-$abook = addressbook_init();
+/** set correct value of $default_charset */
+set_my_charset();
-/* Create search form */
-if ($show == 'form' && empty($listall)) {
- echo '' . "\n";
+/* Create search form (top frame) */
+if ($show == 'form' && ! isset($listall)) {
+ echo "\n";
} else {
-
- /* Show personal addressbook */
- if ($show == 'blank' && empty($listall)) {
+ /**
+ * List addresses (bottom frame)
+ * If listall is set, list all entries in selected backend.
+ * If $show is 'blank' (initial call of address book popup) - list
+ * personal address book.
+ */
+ if ($show == 'blank' || isset($listall)) {
if($backend != -1 || $show == 'blank') {
if ($show == 'blank') {
@@ -254,10 +107,7 @@ if ($show == 'form' && empty($listall)) {
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";
+ plain_error_message(sprintf(_("Unable to list addresses from %s"), $abook->backends[$backend]->sname));
}
} else {
$res = $abook->list_addr();
@@ -265,41 +115,30 @@ if ($show == 'form' && empty($listall)) {
display_result($res, true);
}
- } else {
- if( !empty( $listall ) ){
- $query = '*';
+ } elseif (!empty($query)) {
+ /* Do the search (listall is not set. query is set.)*/
+
+ if($backend == -1) {
+ $res = $abook->s_search($query);
+ } else {
+ $res = $abook->s_search($query, $backend);
}
- /* 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