X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Faddrbook_search.php;h=01e4295a9b8b7de7714e8dce3adee10aa717bfc1;hp=5cb11ff1081d385c530e6f61afafeaed7e0ea140;hb=c4faef335b2362c81b8ebf026d4066c12d70536c;hpb=46d38f7894542146367a4b22c63f41564829abd2
diff --git a/src/addrbook_search.php b/src/addrbook_search.php
index 5cb11ff1..01e4295a 100644
--- a/src/addrbook_search.php
+++ b/src/addrbook_search.php
@@ -1,203 +1,101 @@
-
-' .
- '
' .
- ' | ' . _("Name") .
- ' | ' . _("E-mail") .
- ' | ' . _("Info");
- if ($includesource) {
- echo ' | ' . _("Source");
- }
- echo " |
\n";
+ $oTemplate->assign('compose_addr_pop', true);
+ $oTemplate->assign('include_abook_name', $includesource);
+ $oTemplate->assign('addresses', formatAddressList($res));
- 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 '';
+ $oTemplate->display('addrbook_search_list.tpl');
}
/* ================= 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";
+/** lets get the global vars we may need */
+
+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";
+
+/** set correct value of $default_charset */
+set_my_charset();
/* Empty search */
-if (empty($query) && empty($show) && empty($listall)) {
- echo '
' .
- _("No persons matching your search was found") .
- "
\n\n",
- exit;
+if (empty($query) && empty($show) && !isset($listall)) {
+ $oTemplate->assign('note', sm_encode_html_special_chars(_("No persons matching your search were found")));
+ $oTemplate->display('note.tpl');
+# exit;
}
-/* Initialize addressbook */
-$abook = addressbook_init();
+/* Initialize addressbook, show init errors only in bottom frame */
+$showerr=($show=='form' ? false : true);
+$abook = addressbook_init($showerr);
-/* Create search form */
-if ($show == 'form') {
- 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') {
@@ -209,10 +107,7 @@ if ($show == 'form') {
usort($res,'alistcmp');
display_result($res, false);
} else {
- echo '' .
- sprintf(_("Unable to list addresses from %s"),
- $abook->backends[$backend]->sname) .
- '
' . "\n";
+ plain_error_message(sprintf(_("Unable to list addresses from %s"), $abook->backends[$backend]->sname));
}
} else {
$res = $abook->list_addr();
@@ -220,37 +115,30 @@ if ($show == 'form') {
display_result($res, true);
}
- } else {
+ } elseif (!empty($query)) {
+ /* Do the search (listall is not set. query is set.)*/
- /* 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