9202b1375ab8292b5a05725020d5c601fd8a1b71
5 ** Handle addressbook searching in the popup window.
9 if(!isset($logged_in)) {
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);
40 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
45 printf("%s: %s", $org_title, _("Address Book"));
50 // Choose correct colors for top and bottom frame
52 echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" ";
53 echo "LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\" ";
54 echo "OnLoad=\"document.sform.query.focus();\">";
56 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" ";
57 echo "LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
60 // Just make a blank page and exit
61 if(($show == "blank") ||
(empty($query) && empty($show))) {
62 printf("<P ALIGN=center><BR>%s</P>\n</BODY></HTML>\n",
63 _("Search results will display here"));
69 printf("<FORM NAME=sform TARGET=abookres ACTION=\"%s\" METHOD=GET>\n",
71 printf("<TABLE BORDER=0 WIDTH=\"100%%\" HEIGHT=\"100%%\">");
72 printf("<TR><TD NOWRAP VALIGN=middle>\n");
73 printf(" <STRONG>%s:</STRONG>\n</TD><TD VALIGN=middle>\n",
75 printf(" <INPUT TYPE=text NAME=query VALUE=\"%s\" SIZE=30>\n",
76 htmlspecialchars($query));
77 printf("</TD><TD VALIGN=middle>\n");
78 printf(" <INPUT TYPE=submit VALUE=\"%s\">",
80 printf("</TD><TD WIDTH=\"50%%\" VALIGN=middle ALIGN=right>\n");
81 printf("<INPUT TYPE=button VALUE=\"%s\" onclick=\"parent.close();\">\n",
83 printf("</TD></TR></TABLE></FORM>\n");
86 // Include JavaScript code if this is search results
89 <SCRIPT LANGUAGE
="Javascript"><!--
91 function to_address($addr) {
93 var pwintype
= typeof parent
.opener
.document
.compose
;
95 if(pwintype
!= "undefined" ) {
96 if ( parent
.opener
.document
.compose
.send_to
.value
) {
98 parent
.opener
.document
.compose
.send_to
.value
=
99 parent
.opener
.document
.compose
.send_to
.value +
", " +
$addr;
101 parent
.opener
.document
.compose
.send_to
.value
= $addr;
106 function cc_address($addr) {
108 var pwintype
= typeof parent
.opener
.document
.compose
;
110 if(pwintype
!= "undefined" ) {
111 if ( parent
.opener
.document
.compose
.send_to_cc
.value
) {
113 parent
.opener
.document
.compose
.send_to_cc
.value
=
114 parent
.opener
.document
.compose
.send_to_cc
.value +
", " +
$addr;
116 parent
.opener
.document
.compose
.send_to_cc
.value
= $addr;
121 function bcc_address($addr) {
123 var pwintype
= typeof parent
.opener
.document
.compose
;
125 if(pwintype
!= "undefined" ) {
126 if ( parent
.opener
.document
.compose
.bcc
.value
) {
128 parent
.opener
.document
.compose
.bcc
.value
=
129 parent
.opener
.document
.compose
.bcc
.value +
", " +
$addr;
131 parent
.opener
.document
.compose
.bcc
.value
= $addr;
139 } // End of included JavaScript code
143 $abook = addressbook_init();
144 $res = $abook->s_search($query);
146 if(!is_array($res)) {
147 printf("<P ALIGN=center><BR>%s.</P>\n</BODY></HTML>\n",
148 _("No persons matching your search was found"));
152 // List search results
154 print "<table border=0 width=100%>";
155 print "<tr bgcolor=\"$color[9]\"><TH align=left> <TH align=left>Name<TH align=left>E-mail<TH align=left>Info<TH align=left>Source</tr>\n";
157 while(list($key, $row) = each($res)) {
158 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 <td nowrap>%s <td nowrap>%s <td nowrap>%s</tr>\n",
159 ($line %
2) ?
" bgcolor=\"$color[0]\"" : "", $row["email"],
160 $row["email"], $row["name"], $row["email"], $row["label"],