Made call for help bring up left_help.php for left frame source.
[squirrelmail.git] / src / left_main.php
CommitLineData
59177427 1<?php
21c3249f 2 /**
a09387f4 3 ** left_main.php
21c3249f 4 **
5 ** This is the code for the left bar. The left bar shows the folders
6 ** available, and has cookie information.
7 **
8 **/
9
2a32fc83 10 session_start();
11
21c3249f 12 if(!isset($username)) {
13 echo "You need a valid user and password to access this page!";
14 exit;
15 }
142499d4 16
b9d121d2 17 // Configure the left frame for the help menu
18 // Maybe this should be a function but since I haven't done one it isn't
80135a88 19
20 $ishelp = substr(getenv(REQUEST_URI),-8); // take the right 8 characters from the requested URL
21 if ($ishelp == "help.php") {
22 if (!isset($config_php))
23 include("../config/config.php");
24 if (!isset($i18n_php))
25 include("../functions/i18n.php");
26 include("../src/load_prefs.php");
27 echo "<HTML BGCOLOR=\"$color[3]\">";
28 echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" BGCOLOR=\"$color[3]\" LINK=\"$color[11]\" VLINK=\"$color[6]\" ALINK=\"$color[11]\">\n";
29 $left_size = 250; //doesn't seem to work
30 /**
31 ** Array used to list the include .hlp files, we could use a dir function
32 ** to step through the directory and list its contents but it doesn't order those.
33 ** This should probably go in config.php but it might mess up conf.pl
34 **/
35 $helpdir[0] = "basic.hlp";
36 $helpdir[1] = "main_folder.hlp";
37 $helpdir[2] = "read_mail.hlp";
38 $helpdir[3] = "addresses.hlp";
39 $helpdir[4] = "compose.hlp";
40 $helpdir[5] = "folders.hlp";
41 $helpdir[6] = "options.hlp";
42 $helpdir[7] = "FAQ.hlp";
43
44 /**
45 ** Build a menu dynamically for the left frame from the HTML tagged right frame include (.hlp) files listed in the $helpdir var.
46 ** This is done by first listing all the .hlp files in the $helpdir array.
47 ** Next, we loop through the array, for every value of $helpdir we loop through the file and look for anchor tags (<A NAME=) and
b9d121d2 48 ** header tags (<H1> or <H3>).
80135a88 49 **/
50
51 if (!file_exists("../help/$user_language")) // If the selected language doesn't exist, use english
52 $user_language = "en";
53
b9d121d2 54
80135a88 55 while ( list( $key, $val ) = each( $helpdir ) ) { // loop through the array of files
56 $fcontents = file("../help/$user_language/$val"); // assign each line of the above file to another array
57 while ( list( $line_num, $line ) = each( $fcontents ) ) { // loop through the second array
58 $temphed="";
59 $tempanc="";
60 if ( eregi("<A NAME=", $line, $tempanc)) { // if a name anchor is found, make a link
61 $tempanc = $line;
62 $tempanc = ereg_replace("<A NAME=", "", $tempanc);
63 $tempanc = ereg_replace("></A>", "", $tempanc);
64 echo "<A HREF=\"help.php#$tempanc\" target=\"right\">";
65 }
66 if ( eregi("<H1>", $line, $temphed)) { // grab a description for the link made above
67 $temphed = $line;
68 $temphed = ereg_replace("<H1>", "", $temphed);
69 $temphed = ereg_replace("</H1>", "", $temphed);
70 echo "<BR>";
71 echo "<FONT SIZE=+1>" . _("$temphed") . "</FONT></A><BR>\n"; // make it bigger since it is a heading type 1
72 }
73 if ( eregi("<H3>", $line, $temphed)) { // grab a description for the link made above
74 $temphed = $line;
75 $temphed = ereg_replace("<H3>", "", $temphed);
76 $temphed = ereg_replace("</H3>", "", $temphed);
77 echo "" . _("$temphed") . "</A><BR>\n"; // keep same size since it is a normal entry
78 }
79 }
80 }
81 } else {
d068c0ec 82 if (!isset($config_php))
83 include("../config/config.php");
84 if (!isset($array_php))
85 include("../functions/array.php");
86 if (!isset($strings_php))
87 include("../functions/strings.php");
88 if (!isset($imap_php))
89 include("../functions/imap.php");
142499d4 90 if (!isset($page_header_php))
91 include("../functions/page_header.php");
9c1852ff 92 if (!isset($i18n_php))
93 include("../functions/i18n.php");
94
142499d4 95
2a833d72 96 displayHtmlHeader();
21c3249f 97
d1941f35 98 function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $unseen) {
1e0628fb 99 global $folder_prefix, $trash_folder, $sent_folder;
100 global $color, $move_to_sent, $move_to_trash;
d92b6f31 101
4c34dac5 102 $mailboxURL = urlencode($real_box);
4bbba0d8 103 if($real_box=="INBOX") {
104 $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box);
105 }
d92b6f31 106
1d4fe45e 107 $line .= "<NOBR>";
d1941f35 108 if ($unseen > 0)
d92b6f31 109 $line .= "<B>";
110
7ce342dc 111 $special_color = false;
1e0628fb 112 if ((strtolower($real_box) == "inbox") ||
113 (($real_box == $trash_folder) && ($move_to_trash)) ||
114 (($real_box == $sent_folder) && ($move_to_sent)))
115 $special_color = true;
7ce342dc 116
117 if ($special_color == true) {
9f2215a1 118 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT COLOR=\"$color[11]\">";
813eba2f 119 $line .= replace_spaces($mailbox);
7ce342dc 120 $line .= "</font></a>";
121 } else {
9f2215a1 122 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
813eba2f 123 $line .= replace_spaces($mailbox);
1d4fe45e 124 $line .= "</a>";
d92b6f31 125 }
7ce342dc 126
d1941f35 127 if ($unseen > 0)
7ce342dc 128 $line .= "</B>";
129
d1941f35 130 if ($unseen > 0) {
131 $line .= "&nbsp;<small>($unseen)</small>";
7ce342dc 132 }
133
1e0628fb 134 if (($move_to_trash == true) && ($real_box == $trash_folder)) {
0ab89329 135 $urlMailbox = urlencode($real_box);
1d4fe45e 136 $line .= "\n<small>\n";
137 $line .= " &nbsp;&nbsp;&nbsp;&nbsp;(<B><A HREF=\"empty_trash.php?numMessages=$numMessages&mailbox=$urlMailbox\" TARGET=right style=\"text-decoration:none\">"._("purge")."</A></B>)";
138 $line .= "\n</small>\n";
d92b6f31 139 }
1d4fe45e 140 $line .= "</NOBR>";
d92b6f31 141 return $line;
142 }
143
21c3249f 144 // open a connection on the imap port (143)
e1469126 145 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
21c3249f 146
f3d17401 147 /** If it was a successful login, lets load their preferences **/
148 include("../src/load_prefs.php");
9c1852ff 149
4c34dac5 150 if (isset($left_refresh) && ($left_refresh != "None") && ($left_refresh != "")) {
1d4fe45e 151 echo "<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">\n";
152 echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n";
153 echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">\n";
469eb37b 154 }
813eba2f 155
1d4fe45e 156 echo "\n<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">\n\n";
f3d17401 157
813eba2f 158 $boxes = sqimap_mailbox_list($imapConnection);
21c3249f 159
1d4fe45e 160 echo "<CENTER><FONT SIZE=4><B>";
161 echo _("Folders") . "</B><BR></FONT>\n\n";
97afcee9 162
9f2215a1 163 echo "<small>(<A HREF=\"../src/left_main.php\" TARGET=\"left\">";
ad6f805c 164 echo _("refresh folder list");
aae41ae9 165 echo "</A>)</small></CENTER><BR>";
813eba2f 166 $delimeter = sqimap_get_delimiter($imapConnection);
4c34dac5 167
7ce342dc 168 for ($i = 0;$i < count($boxes); $i++) {
d92b6f31 169 $line = "";
813eba2f 170 $mailbox = $boxes[$i]["formatted"];
d92b6f31 171
813eba2f 172 if ($boxes[$i]["flags"]) {
7ce342dc 173 $noselect = false;
813eba2f 174 for ($h = 0; $h < count($boxes[$i]["flags"]); $h++) {
175 if (strtolower($boxes[$i]["flags"][$h]) == "noselect")
7ce342dc 176 $noselect = true;
d92b6f31 177 }
7ce342dc 178 if ($noselect == true) {
aae41ae9 179 $line .= "<FONT COLOR=\"$color[10]\">";
813eba2f 180 $line .= replace_spaces(readShortMailboxName($mailbox, $delimeter));
aae41ae9 181 $line .= "</FONT>";
7ce342dc 182 } else {
d1941f35 183 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]);
d92b6f31 184 }
7ce342dc 185 } else {
d1941f35 186 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]);
d92b6f31 187 }
1d4fe45e 188 echo "\n$line<BR>\n";
d92b6f31 189 }
190
21c3249f 191
192 fclose($imapConnection);
b9d121d2 193
80135a88 194 }
21c3249f 195?>
aae41ae9 196</BODY></HTML>