added compose_form plugin hook
[squirrelmail.git] / src / left_main.php
1 <?php
2 /**
3 ** left_main.php
4 ** Copyright (c) 1999-2000 The SquirrelMail development team
5 ** Licensed under the GNU GPL. For full terms see the file COPYING.
6 **
7 ** This is the code for the left bar. The left bar shows the folders
8 ** available, and has cookie information.
9 **
10 **/
11
12 session_start();
13
14 if (!isset($i18n_php))
15 include ("../functions/i18n.php");
16
17 if(!isset($username)) {
18 set_up_language($squirrelmail_language, true);
19 include ("../themes/default_theme.php");
20 printf('<html><BODY TEXT="%s" BGCOLOR="%s" LINK="%s" VLINK="%s" ALINK="%s">',
21 $color[8], $color[4], $color[7], $color[7], $color[7]);
22 echo "</body></html>";
23 exit;
24 }
25
26
27 if (!isset($config_php))
28 include("../config/config.php");
29 if (!isset($array_php))
30 include("../functions/array.php");
31 if (!isset($strings_php))
32 include("../functions/strings.php");
33 if (!isset($imap_php))
34 include("../functions/imap.php");
35 if (!isset($page_header_php))
36 include("../functions/page_header.php");
37 if (!isset($i18n_php))
38 include("../functions/i18n.php");
39 if (!isset($plugin_php))
40 include("../functions/plugin.php");
41
42 // open a connection on the imap port (143)
43 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
44
45 /** If it was a successful login, lets load their preferences **/
46 include("../src/load_prefs.php");
47
48 displayHtmlHeader();
49
50 function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $unseen) {
51 global $folder_prefix, $trash_folder, $sent_folder;
52 global $color, $move_to_sent, $move_to_trash;
53 global $unseen_notify, $unseen_type;
54
55 $mailboxURL = urlencode($real_box);
56
57 if ($unseen_notify == 2 && $real_box == "INBOX") {
58 $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box);
59 if ($unseen_type == 1 && $unseen > 0) {
60 $unseen_string = "($unseen)";
61 $unseen_found = true;
62 } else if ($unseen_type == 2) {
63 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
64 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
65 $unseen_found = true;
66 }
67 } else if ($unseen_notify == 3) {
68 $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box);
69 if ($unseen_type == 1 && $unseen > 0) {
70 $unseen_string = "($unseen)";
71 $unseen_found = true;
72 } else if ($unseen_type == 2) {
73 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
74 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
75 $unseen_found = true;
76 }
77 }
78
79 $line .= "<NOBR>";
80 if ($unseen > 0)
81 $line .= "<B>";
82
83 $special_color = false;
84 if ((strtolower($real_box) == "inbox") ||
85 (($real_box == $trash_folder) && ($move_to_trash)) ||
86 (($real_box == $sent_folder) && ($move_to_sent)))
87 $special_color = true;
88
89 if ($special_color == true) {
90 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT COLOR=\"$color[11]\">";
91 $line .= replace_spaces($mailbox);
92 $line .= "</font></a>";
93 } else {
94 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
95 $line .= replace_spaces($mailbox);
96 $line .= "</a>";
97 }
98
99 if ($unseen > 0)
100 $line .= "</B>";
101
102 if ($unseen_found) {
103 $line .= "&nbsp;<small>$unseen_string</small>";
104 }
105
106 if (($move_to_trash == true) && ($real_box == $trash_folder)) {
107 $urlMailbox = urlencode($real_box);
108 $line .= "\n<small>\n";
109 $line .= " &nbsp;&nbsp;(<B><A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A></B>)";
110 $line .= "\n</small>\n";
111 }
112 $line .= "</NOBR>";
113 return $line;
114 }
115
116 if (isset($left_refresh) && ($left_refresh != "None") && ($left_refresh != "")) {
117 echo "<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">\n";
118 echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n";
119 echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">\n";
120 }
121
122 echo "\n<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">\n";
123
124 do_hook("left_main_before");
125
126 $boxes = sqimap_mailbox_list($imapConnection);
127
128 echo "<CENTER><FONT SIZE=4><B>";
129 echo _("Folders") . "</B><BR></FONT>\n\n";
130
131 echo "<small>(<A HREF=\"../src/left_main.php\" TARGET=\"left\">";
132 echo _("refresh folder list");
133 echo "</A>)</small></CENTER><BR>";
134 $delimeter = sqimap_get_delimiter($imapConnection);
135
136 for ($i = 0;$i < count($boxes); $i++) {
137 $line = "";
138 $mailbox = $boxes[$i]["formatted"];
139
140 if ($boxes[$i]["flags"]) {
141 $noselect = false;
142 for ($h = 0; $h < count($boxes[$i]["flags"]); $h++) {
143 if (strtolower($boxes[$i]["flags"][$h]) == "noselect")
144 $noselect = true;
145 }
146 if ($noselect == true) {
147 $line .= "<FONT COLOR=\"$color[10]\">";
148 $line .= replace_spaces($mailbox);
149 $line .= "</FONT>";
150 } else {
151 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]);
152 }
153 } else {
154 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]);
155 }
156 echo "$line<BR>\n";
157 }
158 sqimap_logout($imapConnection);
159 do_hook("left_main_after");
160 ?>
161 </BODY></HTML>