Added _() to some strings missing from translation.
[squirrelmail.git] / src / addrbook_search.php
CommitLineData
5100704d 1<?php
2 /**
3 ** addrbook_search.php
4 **
5 ** Handle addressbook searching in the popup window.
6 **
7 **/
8
9 if(!isset($logged_in)) {
138f26f6 10 echo _("You must login first.");
5100704d 11 exit;
12 }
13 if(!isset($username) || !isset($key)) {
14 echo _("You need a valid user and password to access this page!");
15 exit;
16 }
17
18 if (!isset($config_php))
19 include("../config/config.php");
20 if (!isset($array_php))
21 include("../functions/array.php");
22 if (!isset($strings_php))
23 include("../functions/strings.php");
24 if (!isset($imap_php))
25 include("../functions/imap.php");
26 if (!isset($page_header_php))
27 include("../functions/page_header.php");
28 if (!isset($addressbook_php))
29 include("../functions/addressbook.php");
30
31 // Authenticate user and load prefs
32 $imapConnection = sqimap_login($username, $key,
33 $imapServerAddress, $imapPort, 10);
34 include("../src/load_prefs.php");
35 sqimap_logout ($imapConnection);
36
37?>
38<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
39
40<HTML>
41<HEAD>
42<TITLE><?php
43 printf("%s: %s", $org_title, _("Address Book"));
44?></TITLE>
45</HEAD>
46
47<?php
48 // Choose correct colors for top and bottom frame
49 if($show == "form") {
50 echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" ";
51 echo "LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\" ";
52 echo "OnLoad=\"document.sform.query.focus();\">";
53 } else {
54 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" ";
55 echo "LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
56 }
57
58 // Just make a blank page and exit
59 if(($show == "blank") || (empty($query) && empty($show))) {
60 printf("<P ALIGN=center><BR>%s</P>\n</BODY></HTML>\n",
61 _("Search results will display here"));
62 exit;
63 }
64
65 // Create search form
66 if($show == "form") {
67 printf("<FORM NAME=sform TARGET=abookres ACTION=\"%s\" METHOD=GET>\n",
68 $PHP_SELF);
69 printf("<TABLE BORDER=0 WIDTH=\"100%%\" HEIGHT=\"100%%\">");
70 printf("<TR><TD NOWRAP VALIGN=middle>\n");
71 printf(" <STRONG>%s:</STRONG>\n</TD><TD VALIGN=middle>\n",
72 _("Search for"));
73 printf(" <INPUT TYPE=text NAME=query VALUE=\"%s\" SIZE=30>\n",
74 htmlspecialchars($query));
75 printf("</TD><TD VALIGN=middle>\n");
76 printf(" <INPUT TYPE=submit VALUE=\"%s\">",
77 _("Search"));
78 printf("</TD><TD WIDTH=\"50%%\" VALIGN=middle ALIGN=right>\n");
79 printf("<INPUT TYPE=button VALUE=\"%s\" onclick=\"parent.close();\">\n",
80 _("Close window"));
81 printf("</TD></TR></TABLE></FORM>\n");
82 }
83
84 // Include JavaScript code if this is search results
85 if(!empty($query)) {
86?>
87<SCRIPT LANGUAGE="Javascript"><!--
88
89function to_address($addr) {
90 var prefix = "";
91 var pwintype = typeof parent.opener.document.compose;
92
93 if(pwintype != "undefined" ) {
94 if ( parent.opener.document.compose.send_to.value ) {
95 prefix = ", ";
96 parent.opener.document.compose.send_to.value =
97 parent.opener.document.compose.send_to.value + ", " + $addr;
98 } else {
99 parent.opener.document.compose.send_to.value = $addr;
100 }
101 }
102}
103
104function cc_address($addr) {
105 var prefix = "";
106 var pwintype = typeof parent.opener.document.compose;
107
108 if(pwintype != "undefined" ) {
109 if ( parent.opener.document.compose.send_to_cc.value ) {
110 prefix = ", ";
111 parent.opener.document.compose.send_to_cc.value =
112 parent.opener.document.compose.send_to_cc.value + ", " + $addr;
113 } else {
114 parent.opener.document.compose.send_to_cc.value = $addr;
115 }
116 }
117}
118
119function bcc_address($addr) {
120 var prefix = "";
121 var pwintype = typeof parent.opener.document.compose;
122
123 if(pwintype != "undefined" ) {
124 if ( parent.opener.document.compose.bcc.value ) {
125 prefix = ", ";
126 parent.opener.document.compose.bcc.value =
127 parent.opener.document.compose.bcc.value + ", " + $addr;
128 } else {
129 parent.opener.document.compose.bcc.value = $addr;
130 }
131 }
132}
133
134// --></SCRIPT>
135
136<?php
137 } // End of included JavaScript code
138
139 // Do the search
140 if(!empty($query)) {
141 $abook = addressbook_init();
142 $res = $abook->s_search($query);
143
144 if(!is_array($res)) {
145 printf("<P ALIGN=center><BR>%s.</P>\n</BODY></HTML>\n",
146 _("No persons matching your search was found"));
147 exit;
148 }
149
150 // List search results
151 $line = 0;
152 print "<table border=0 width=100%>";
a16d133d 153 printf("<tr bgcolor=\"$color[9]\"><TH align=left>&nbsp;".
154 "<TH align=left>%s<TH align=left>%s<TH align=left>%s".
155 "<TH align=left>%s</tr>\n",
156 _("Name"), _("E-mail"), _("Info"), _("Source"));
5100704d 157
158 while(list($key, $row) = each($res)) {
159 printf("<tr%s nowrap><td nowrap><a href=\"javascript:to_address('%s');\">To</A> | <a href=\"javascript:cc_address('%s');\">Cc</A><td nowrap>%s&nbsp;<td nowrap>%s&nbsp;<td nowrap>%s&nbsp;<td nowrap>%s</tr>\n",
160 ($line % 2) ? " bgcolor=\"$color[0]\"" : "", $row["email"],
161 $row["email"], $row["name"], $row["email"], $row["label"],
162 $row["source"]);
163 $line++;
164 }
165 print "</TABLE>";
166 }
167?>
168
169</BODY></HTML>