ad41bfefa0b50e08634bd5cfd8aabd299b67c530
5 ** Handle addressbook searching in the popup window.
11 if(!isset($logged_in)) {
12 echo _("You must login first.");
15 if(!isset($username) ||
!isset($key)) {
16 echo _("You need a valid user and password to access this page!");
20 if (!isset($config_php))
21 include("../config/config.php");
22 if (!isset($array_php))
23 include("../functions/array.php");
24 if (!isset($strings_php))
25 include("../functions/strings.php");
26 if (!isset($imap_php))
27 include("../functions/imap.php");
28 if (!isset($page_header_php))
29 include("../functions/page_header.php");
30 if (!isset($addressbook_php))
31 include("../functions/addressbook.php");
33 // Authenticate user and load prefs
34 $imapConnection = sqimap_login($username, $key,
35 $imapServerAddress, $imapPort, 10);
36 include("../src/load_prefs.php");
37 sqimap_logout ($imapConnection);
41 // Choose correct colors for top and bottom frame
43 echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" ";
44 echo "LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\" ";
45 echo "OnLoad=\"document.sform.query.focus();\">";
47 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" ";
48 echo "LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
51 // Just make a blank page and exit
52 if(($show == "blank") ||
(empty($query) && empty($show))) {
53 printf("<P ALIGN=center><BR>%s</P>\n</BODY></HTML>\n",
54 _("Search results will display here"));
60 printf("<FORM NAME=sform TARGET=abookres ACTION=\"%s\" METHOD=\"POST\">\n",
62 printf("<TABLE BORDER=0 WIDTH=\"100%%\" HEIGHT=\"100%%\">");
63 printf("<TR><TD NOWRAP VALIGN=middle>\n");
64 printf(" <STRONG>%s:</STRONG>\n</TD><TD VALIGN=middle>\n",
66 printf(" <INPUT TYPE=text NAME=query VALUE=\"%s\" SIZE=30>\n",
67 htmlspecialchars($query));
68 printf("</TD><TD VALIGN=middle>\n");
69 printf(" <INPUT TYPE=submit VALUE=\"%s\">",
71 printf("</TD><TD WIDTH=\"50%%\" VALIGN=middle ALIGN=right>\n");
72 printf("<INPUT TYPE=button VALUE=\"%s\" onclick=\"parent.close();\">\n",
74 printf("</TD></TR></TABLE></FORM>\n");
77 // Include JavaScript code if this is search results
80 <SCRIPT LANGUAGE
="Javascript"><!--
82 function to_and_close($addr) {
87 function to_address($addr) {
89 var pwintype
= typeof parent
.opener
.document
.compose
;
91 $addr = $addr.replace(/ {1,35}$
/, "");
93 if(pwintype
!= "undefined" ) {
94 if ( parent
.opener
.document
.compose
.send_to
.value
) {
96 parent
.opener
.document
.compose
.send_to
.value
=
97 parent
.opener
.document
.compose
.send_to
.value +
", " +
$addr;
100 parent
.opener
.document
.compose
.send_to
.value
= $addr;
105 function cc_address($addr) {
107 var pwintype
= typeof parent
.opener
.document
.compose
;
109 $addr = $addr.replace(/ {1,35}$
/, "");
111 if(pwintype
!= "undefined" ) {
112 if ( parent
.opener
.document
.compose
.send_to_cc
.value
) {
114 parent
.opener
.document
.compose
.send_to_cc
.value
=
115 parent
.opener
.document
.compose
.send_to_cc
.value +
", " +
$addr;
117 parent
.opener
.document
.compose
.send_to_cc
.value
= $addr;
122 function bcc_address($addr) {
124 var pwintype
= typeof parent
.opener
.document
.compose
;
126 $addr = $addr.replace(/ {1,35}$
/, "");
128 if(pwintype
!= "undefined" ) {
129 if ( parent
.opener
.document
.compose
.bcc
.value
) {
131 parent
.opener
.document
.compose
.bcc
.value
=
132 parent
.opener
.document
.compose
.bcc
.value +
", " +
$addr;
134 parent
.opener
.document
.compose
.bcc
.value
= $addr;
142 } // End of included JavaScript code
146 $abook = addressbook_init();
147 $res = $abook->s_search($query);
149 if(!is_array($res)) {
150 printf("<P ALIGN=center><BR>%s:<br>%s</P>\n</BODY></HTML>\n",
151 _("Your search failed with the following error(s)"),
156 if(sizeof($res) == 0) {
157 printf("<P ALIGN=center><BR>%s.</P>\n</BODY></HTML>\n",
158 _("No persons matching your search was found"));
162 // List search results
164 print "<table border=0 width=\"98%\" align=center>";
165 printf("<tr bgcolor=\"$color[9]\"><TH align=left> ".
166 "<TH align=left> %s<TH align=left> %s".
167 "<TH align=left> %s<TH align=left width=\"10%%\">".
169 _("Name"), _("E-mail"), _("Info"), _("Source"));
171 while(list($key, $row) = each($res)) {
172 printf("<tr%s nowrap><td nowrap align=center width=\"5%%\">".
173 "<a href=\"javascript:to_address('%s');\">To</A> | ".
174 "<a href=\"javascript:cc_address('%s');\">Cc</A>".
175 "<td nowrap> %s <td nowrap> ".
176 "<a href=\"javascript:to_and_close('%s');\">%s</A> ".
177 "<td nowrap> %s <td nowrap> %s</tr>\n",
178 ($line %
2) ?
" bgcolor=\"$color[0]\"" : "", $row["email"],
179 $row["email"], $row["name"], $row["email"], $row["email"],
180 $row["label"], $row["source"]);