X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Faddrbook_search.php;h=4e914beef1ef4f28c5297d4665e19f6148e3510e;hb=98d42122fd9b0346374c5b1468e1c0cbb3767b24;hp=1c172079dcc0ed3c81eee8f52dbdd097b060a74e;hpb=dfadb5533df0c17fa7737d4aaf5738064b55429e;p=squirrelmail.git
diff --git a/src/addrbook_search.php b/src/addrbook_search.php
index 1c172079..4e914bee 100644
--- a/src/addrbook_search.php
+++ b/src/addrbook_search.php
@@ -1,188 +1,291 @@
-
+/**
+ * addrbook_search.php
+ *
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * Handle addressbook searching in the popup window.
+ *
+ * NOTE: A lot of this code is similar to the code in
+ * addrbook_search_html.html -- If you change one,
+ * change the other one too!
+ *
+ * $Id$
+ */
-
-
-
-
+/* Path for SquirrelMail required files. */
+define('SM_PATH','../');
-";
- } 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");
- }
-
- // Include JavaScript code if this is search results
- if(!empty($query)) {
-?>
-
+\n";
+
+ 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 "\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 = ''; }
- $addr = $addr.replace(/ {1,35}$/, "");
+/* Choose correct colors for top and bottom frame */
+if ($show == 'form' && !isset($listall)) {
+ echo '';
+} else {
+ echo '\n";
+}
- 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;
+/* 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";
+} 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);
+ }
-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;
} 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