1809f6f7f7b98f953fc96ed34c76eae65911f201
[squirrelmail.git] / src / addrbook_search_html.php
1 <?php
2 /**
3 ** addrbook_search.php
4 **
5 ** Handle addressbook searching with pure html. This file is included from compose.php
6 **
7 **/
8
9 session_start();
10
11 if (!isset($config_php))
12 include("../config/config.php");
13 if (!isset($strings_php))
14 include("../functions/strings.php");
15 if (!isset($page_header_php))
16 include("../functions/page_header.php");
17 if (!isset($imap_php))
18 include("../functions/imap.php");
19 if (!isset($date_php))
20 include("../functions/date.php");
21 if (!isset($mime_php))
22 include("../functions/mime.php");
23 if (!isset($smtp_php))
24 include("../functions/smtp.php");
25 if (!isset($display_messages_php))
26 include("../functions/display_messages.php");
27 if (!isset($addressbook_php))
28 include("../functions/addressbook.php");
29
30 include("../src/load_prefs.php");
31
32
33 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
34 displayPageHeader($color, "None");
35 //<form method=post action="compose.php?html_addr_search=true">
36
37
38 $body = stripslashes($body);
39 $send_to = stripslashes($send_to);
40 $send_to_cc = stripslashes($send_to_cc);
41 $send_to_bcc = stripslashes($send_to_bcc);
42 $subject = stripslashes($subject);
43
44 echo "<center>";
45 echo "<form method=post action=\"compose.php?html_addr_search=true\">";
46 echo " <input type=text value=\"$query\"name=query>";
47 echo " <input type=submit value=Submit>";
48 echo " <input type=hidden value=\"$body\" name=body>";
49 echo " <input type=hidden value=\"$subject\" name=subject>";
50 echo " <input type=hidden value=\"$send_to\" name=send_to>";
51 echo " <input type=hidden value=\"$send_to_cc\" name=send_to_cc>";
52 echo " <input type=hidden value=\"$send_to_bcc\" name=send_to_bcc>";
53 echo "</form>";
54 echo "</center>";
55
56 echo "<tt>".nl2br($body)."</tt>";
57
58 if(!empty($query)) {
59 $abook = addressbook_init();
60 $res = $abook->s_search($query);
61
62 if(!is_array($res)) {
63 printf("<P ALIGN=center><BR>%s:<br>%s</P>\n</BODY></HTML>\n",
64 _("Your search failed with the following error(s)"),
65 $abook->error);
66 exit;
67 }
68
69 if(sizeof($res) == 0) {
70 printf("<P ALIGN=center><BR>%s.</P>\n</BODY></HTML>\n",
71 _("No persons matching your search was found"));
72 exit;
73 }
74
75 // List search results
76 $line = 0;
77 print "<table border=0 width=\"98%\" align=center>";
78 printf("<tr bgcolor=\"$color[9]\"><TH align=left>&nbsp;".
79 "<TH align=left>&nbsp;%s<TH align=left>&nbsp;%s".
80 "<TH align=left>&nbsp;%s<TH align=left width=\"10%%\">".
81 "&nbsp;%s</tr>\n",
82 _("Name"), _("E-mail"), _("Info"), _("Source"));
83
84 ?>
85 <form method=post action"compose.php?html_addr_search_done=true">
86 <?
87 echo " <input type=hidden value=\"$body\" name=body>";
88 echo " <input type=hidden value=\"$subject\" name=subject>";
89 echo " <input type=hidden value=\"$send_to\" name=send_to>";
90 echo " <input type=hidden value=\"$send_to_cc\" name=send_to_cc>";
91 echo " <input type=hidden value=\"$send_to_bcc\" name=send_to_bcc>";
92
93 while(list($key, $row) = each($res)) {
94 printf("<tr%s nowrap><td nowrap align=center width=\"5%%\">".
95 "<input type=checkbox name=send_to_search[] value=\"%s\">&nbsp;To".
96 "<input type=checkbox name=send_to_cc_search[] value=\"%s\">&nbsp;Cc&nbsp;".
97 "<td nowrap>&nbsp;%s&nbsp;<td nowrap>&nbsp;".
98 "<a href=\"compose.php?send_to_search=%s\">%s</A>&nbsp;".
99 "<td nowrap>&nbsp;%s&nbsp;<td nowrap>&nbsp;%s</tr>\n",
100 ($line % 2) ? " bgcolor=\"$color[0]\"" : "", $row["email"],
101 $row["email"], $row["name"], $row["email"], $row["email"],
102 $row["label"], $row["source"]);
103 $line++;
104 }
105 print "</TABLE>";
106 echo "<input type=hidden value=1 name=html_addr_search_done>";
107 echo "<center><input type=submit value=addr_search_done name=\"Use Addresses\"></center>";
108 echo "</form>";
109 }
110
111 ?>