Plugin may be invisible when JS is not detected
[squirrelmail.git] / plugins / newmail / newmail_opt.php
1 <?php
2 /**
3 * newmails_opt.php - options page
4 *
5 * Copyright (c) 1999-2005 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * Displays all options relating to new mail sounds
9 *
10 * @version $Id$
11 * @package plugins
12 * @subpackage newmail
13 */
14
15 /** @ignore */
16 define('SM_PATH','../../');
17
18 /* SquirrelMail required files. */
19 include_once(SM_PATH . 'include/validate.php');
20 /* sqm_baseuri function */
21 include_once(SM_PATH . 'functions/display_messages.php');
22 /** Plugin functions (also loads plugin's config) */
23 include_once(SM_PATH . 'plugins/newmail/functions.php');
24
25 displayPageHeader($color, 'None');
26
27 // plugin uses squirrelmail loading_pref hook.
28 // vars are already loaded in include/validate.php
29
30 echo html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) . "\n" .
31 html_tag( 'tr' ) . "\n" .
32 html_tag( 'td', '', 'center' ) .
33 '<b>' . _("Options") . ' - ' . _("New Mail Notification") . "</b><br />\n" .
34 html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n" .
35 html_tag( 'tr' ) . "\n" .
36 html_tag( 'td', '', 'left', $color[4] ) . "<br />\n";
37
38 echo html_tag( 'p',
39 sprintf(_("The %s option will check ALL of your folders for unseen mail, not just the inbox for notification."), '&quot;'._("Check all boxes, not just INBOX").'&quot;')
40 ) . "\n" .
41 html_tag( 'p',
42 sprintf(_("Selecting the %s option will enable the showing of a popup window when unseen mail is in your folders (requires JavaScript)."), '&quot;'._("Show popup window on new mail").'&quot;')
43 ) . "\n" .
44 html_tag( 'p',
45 sprintf(_("Use the %s option to only check for messages that are recent. Recent messages are those that have just recently showed up and have not been \"viewed\" or checked yet. This can prevent being continuously annoyed by sounds or popups for unseen mail."), '&quot;'._("Count only messages that are RECENT").'&quot;')
46 ) . "\n" .
47 html_tag( 'p',
48 sprintf(_("Selecting the %s option will change the title in some browsers to let you know when you have new mail (requires JavaScript, and only works in IE but you won't see errors with other browsers). This will always tell you if you have new mail, even if you have %s enabled."), '&quot;'._("Change title on supported browsers").'&quot;', '&quot;'._("Count only messages that are RECENT").'&quot;')
49 ) . "\n";
50 if ($newmail_allowsound) {
51 echo html_tag( 'p',
52 sprintf(_("Select %s to turn on playing a media file when unseen mail is in your folders. When enabled, you can specify the media file to play in the provided file box."), '&quot;'._("Enable Media Playing").'&quot;')
53 ) . "\n" .
54 html_tag( 'p',
55 sprintf(_("Select from the list of %s the media file to play when new mail arrives. If no file is specified, %s, no sound will be used."), '&quot;'._("Select server file").'&quot;', '&quot;'._("(none)").'&quot;')
56 ) . "\n";
57 }
58
59 echo '</td></tr>' .
60 html_tag( 'tr' ) .
61 html_tag( 'td', '', 'center', $color[4] ) . "\n" . '<hr style="width: 25%; height: 1px;" />' . "\n";
62
63 echo '<form action="'.sqm_baseuri().'src/options.php" method="post" enctype="multipart/form-data">' . "\n" .
64 html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n";
65
66 // Option: media_allbox
67 echo html_tag( 'tr' ) .
68 html_tag( 'td', _("Check all boxes, not just INBOX").':', 'right', '', 'style="white-space: nowrap;"' ) .
69 html_tag( 'td', '', 'left' ) .
70 '<input type="checkbox" ';
71 if ($newmail_allbox == 'on') {
72 echo 'checked="checked" ';
73 }
74 echo 'name="media_allbox" /></td></tr>' . "\n";
75
76 // Option: media_recent
77 echo html_tag( 'tr' ) .
78 html_tag( 'td', _("Count only messages that are RECENT").':', 'right', '', 'style="white-space: nowrap;"' ) .
79 html_tag( 'td', '', 'left' ) .
80 '<input type="checkbox" ';
81 if ($newmail_recent == 'on') {
82 echo 'checked="checked" ';
83 }
84 echo 'name="media_recent" /></td></tr>' . "\n";
85
86 // Option: media_changetitle
87 echo html_tag( 'tr' ) .
88 html_tag( 'td', _("Change title on supported browsers").':', 'right', '', 'style="white-space: nowrap;"' ) .
89 html_tag( 'td', '', 'left' ) .
90 '<input type="checkbox" ';
91 if ($newmail_changetitle == 'on') {
92 echo 'checked="checked" ';
93 }
94 echo 'name="media_changetitle" />&nbsp;<small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
95
96 // Option: media_popup
97 echo html_tag( 'tr' ) .
98 html_tag( 'td', _("Show popup window on new mail").':', 'right', '', 'style="white-space: nowrap;"' ) .
99 html_tag( 'td', '', 'left' ) .
100 '<input type="checkbox" ';
101 if($newmail_popup == 'on') {
102 echo 'checked="checked" ';
103 }
104 echo 'name="media_popup" />&nbsp;<small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
105
106 echo html_tag( 'tr' )
107 . html_tag('td',_("Width of popup window:"),'right','', 'style="white-space: nowrap;"')
108 . html_tag('td','<input type="text" name="popup_width" value="'
109 . (int)$newmail_popup_width . '" size="3" maxlengh="3" />'
110 . '&nbsp;<small>(' . _("If set to 0, reverts to default value") . ')</small>','left')
111 . "</tr>\n";
112
113 echo html_tag( 'tr' )
114 . html_tag('td',_("Height of popup window:"),'right','', 'style="white-space: nowrap;"')
115 . html_tag('td','<input type="text" name="popup_height" value="'
116 . (int)$newmail_popup_height . '" size="3" maxlengh="3" />'
117 . '&nbsp;<small>(' . _("If set to 0, reverts to default value") . ')</small>','left')
118 . "</tr>\n";
119
120 if ($newmail_allowsound) {
121 // Option: media_enable
122 echo html_tag( 'tr' ) .
123 html_tag( 'td', _("Enable Media Playing").':', 'right', '', 'style="white-space: nowrap;"' ) .
124 html_tag( 'td', '', 'left' ) .
125 '<input type="checkbox" ';
126 if ($newmail_enable == 'on') {
127 echo 'checked="checked" ';
128 }
129 echo 'name="media_enable" /></td></tr>' . "\n";
130
131 // Option: media_sel
132 echo html_tag( 'tr' ) .
133 html_tag( 'td', _("Select server file").':', 'right', '', 'style="white-space: nowrap;"' ) .
134 html_tag( 'td', '', 'left' ) .
135 '<select name="media_sel">' . "\n" .
136 '<option value="(none)"';
137 if ( $newmail_media == '(none)') {
138 echo 'selected="selected" ';
139 }
140 echo '>' . _("(none)") . '</option>' . "\n";
141 // Iterate sound files for options
142 $d = dir(SM_PATH . 'plugins/newmail/sounds');
143 while($entry=$d->read()) {
144 $fname = get_location () . '/sounds/' . $entry;
145 if ($entry != '..' && $entry != '.' && $entry != 'CVS') {
146 echo '<option ';
147 if ($fname == $newmail_media) {
148 echo 'selected="selected" ';
149 }
150 echo 'value="' . htmlspecialchars($fname) . '">' .
151 htmlspecialchars($entry) . "</option>\n";
152 }
153 }
154 $d->close();
155 // display media selection
156 foreach($newmail_mmedia as $newmail_mm_name => $newmail_mm_data) {
157 echo '<option ';
158 if ($newmail_media=='mmedia_' . $newmail_mm_name) {
159 echo 'selected="selected" ';
160 }
161 echo 'value="mmedia_' . $newmail_mm_name . '">'
162 .htmlspecialchars($newmail_mm_name) . "</option>\n";
163 }
164 // display local file option
165 echo '<option ';
166 if ($newmail_media=='(userfile)') {
167 echo 'selected="selected" ';
168 }
169 echo 'value="(userfile)">'.
170 _("uploaded media file") . "</option>\n";
171 // end of local file option
172
173 // Set media file name
174 if ($newmail_media == '(none)') {
175 $media_output = _("none");
176 } elseif ($newmail_media == '(userfile)') {
177 $media_output = basename($newmail_userfile_name);
178 } elseif (preg_match("/^mmedia_+/",$newmail_media)) {
179 $media_output = preg_replace("/^mmedia_/",'',$newmail_media);
180 } else {
181 $media_output = substr($newmail_media, strrpos($newmail_media, '/')+1);
182 }
183
184 echo '</select>'.
185 '<input type="submit" value="' . _("Try") . '" name="test" onclick="' .
186 "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound'," .
187 "'width=150,height=30,scrollbars=no');" .
188 'return false;' .
189 '" /></td></tr>';
190 echo html_tag('tr')
191 . html_tag('td',_("Upload Media File:"),'right','','style="white-space: nowrap;"')
192 . html_tag('td','<input type="file" size="40" name="media_file">')
193 . "</tr>\n";
194
195 echo html_tag('tr')
196 . html_tag('td',_("Uploaded Media File:"),'right','','style="white-space: nowrap;"')
197 . html_tag('td',($newmail_userfile_name!='' ? htmlspecialchars($newmail_userfile_name) : _("unavailable")))
198 ."</tr>\n";
199
200 if ($newmail_userfile_name!='') {
201 echo '<tr>'
202 .'<td colspan="2" align="center">'
203 .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($newmail_userfile_name))
204 .'</td></tr>';
205 }
206 echo html_tag( 'tr', "\n" .
207 html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .
208 html_tag( 'td', '<input type="hidden" value="' .
209 htmlspecialchars($newmail_media) . '" name="media_default" />' .
210 htmlspecialchars($media_output) . '', 'left' )
211 ) . "\n";
212 }
213 echo html_tag( 'tr', "\n" .
214 html_tag( 'td', '&nbsp;' ) .
215 html_tag( 'td',
216 '<input type="hidden" name="optmode" value="submit" />' .
217 '<input type="hidden" name="optpage" value="newmail" />' .
218 '<input type="submit" value="' . _("Submit") . '" name="submit_newmail" />',
219 'left' )
220 ) . "\n";
221 ?>
222 </table></form></td></tr></table></td></tr></table></body></html>