5 ** Handle addressbook searching in the popup window.
9 if(!isset($logged_in)) {
10 echo _("You must login first.");
13 if(!isset($username) ||
!isset($key)) {
14 echo _("You need a valid user and password to access this page!");
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");
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);
38 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
43 printf("%s: %s", $org_title, _("Address Book"));
48 // Choose correct colors for top and bottom frame
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();\">";
54 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" ";
55 echo "LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
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"));
67 printf("<FORM NAME=sform TARGET=abookres ACTION=\"%s\" METHOD=GET>\n",
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",
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\">",
78 printf("</TD><TD WIDTH=\"50%%\" VALIGN=middle ALIGN=right>\n");
79 printf("<INPUT TYPE=button VALUE=\"%s\" onclick=\"parent.close();\">\n",
81 printf("</TD></TR></TABLE></FORM>\n");
84 // Include JavaScript code if this is search results
87 <SCRIPT LANGUAGE
="Javascript"><!--
89 function to_address($addr) {
91 var pwintype
= typeof parent
.opener
.document
.compose
;
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;
99 parent
.opener
.document
.compose
.send_to
.value
= $addr;
104 function cc_address($addr) {
106 var pwintype
= typeof parent
.opener
.document
.compose
;
108 if(pwintype
!= "undefined" ) {
109 if ( parent
.opener
.document
.compose
.send_to_cc
.value
) {
111 parent
.opener
.document
.compose
.send_to_cc
.value
=
112 parent
.opener
.document
.compose
.send_to_cc
.value +
", " +
$addr;
114 parent
.opener
.document
.compose
.send_to_cc
.value
= $addr;
119 function bcc_address($addr) {
121 var pwintype
= typeof parent
.opener
.document
.compose
;
123 if(pwintype
!= "undefined" ) {
124 if ( parent
.opener
.document
.compose
.bcc
.value
) {
126 parent
.opener
.document
.compose
.bcc
.value
=
127 parent
.opener
.document
.compose
.bcc
.value +
", " +
$addr;
129 parent
.opener
.document
.compose
.bcc
.value
= $addr;
137 } // End of included JavaScript code
141 $abook = addressbook_init();
142 $res = $abook->s_search($query);
144 if(!is_array($res)) {
145 printf("<P ALIGN=center><BR>%s:<br>%s</P>\n</BODY></HTML>\n",
146 _("Your search failed with the following error(s)"),
151 if(sizeof($res) == 0) {
152 printf("<P ALIGN=center><BR>%s.</P>\n</BODY></HTML>\n",
153 _("No persons matching your search was found"));
157 // List search results
159 print "<table border=0 width=\"98%\" align=center>";
160 printf("<tr bgcolor=\"$color[9]\"><TH align=left> ".
161 "<TH align=left> %s<TH align=left> %s".
162 "<TH align=left> %s<TH align=left width=\"10%%\">".
164 _("Name"), _("E-mail"), _("Info"), _("Source"));
166 while(list($key, $row) = each($res)) {
167 printf("<tr%s nowrap><td nowrap align=center width=\"5%%\">".
168 "<a href=\"javascript:to_address('%s');\">To</A> | ".
169 "<a href=\"javascript:cc_address('%s');\">Cc</A>".
170 "<td nowrap> %s <td nowrap> %s ".
171 "<td nowrap> %s <td nowrap> %s</tr>\n",
172 ($line %
2) ?
" bgcolor=\"$color[0]\"" : "", $row["email"],
173 $row["email"], $row["name"], $row["email"], $row["label"],