Patches from Michael Long
[squirrelmail.git] / plugins / newmail / newmail_opt.php
1 <?php
2
3 /**
4 * newmails_opt.php - options page
5 *
6 * Displays all options relating to new mail sounds
7 *
8 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
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',"The NewMail plugin will follow the Folder Preferences option &quot;Enable Unread Message Notification&quot;") . "\n" .
39 html_tag( 'p',
40 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;')
41 ) . "\n" .
42 html_tag( 'p',
43 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;')
44 ) . "\n" .
45 html_tag( 'p',
46 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;')
47 ) . "\n";
48 if ($newmail_allowsound) {
49 echo html_tag( 'p',
50 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;')
51 ) . "\n" .
52 html_tag( 'p',
53 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;')
54 ) . "\n";
55 }
56
57 echo '</td></tr>' .
58 html_tag( 'tr' ) .
59 html_tag( 'td', '', 'center', $color[4] ) . "\n" . '<hr style="width: 25%; height: 1px;" />' . "\n";
60
61 echo '<form action="'.sqm_baseuri().'src/options.php" method="post" enctype="multipart/form-data">' . "\n" .
62 html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n";
63
64 // Option: media_recent
65 echo html_tag( 'tr' ) .
66 html_tag( 'td', _("Count only messages that are RECENT").':', 'right', '', 'style="white-space: nowrap;"' ) .
67 html_tag( 'td', '', 'left' ) .
68 '<input type="checkbox" ';
69 if ($newmail_recent == 'on') {
70 echo 'checked="checked" ';
71 }
72 echo 'name="media_recent" /></td></tr>' . "\n";
73
74 // Option: media_changetitle
75 echo html_tag( 'tr' ) .
76 html_tag( 'td', _("Change title on supported browsers").':', 'right', '', 'style="white-space: nowrap;"' ) .
77 html_tag( 'td', '', 'left' ) .
78 '<input type="checkbox" ';
79 if ($newmail_changetitle == 'on') {
80 echo 'checked="checked" ';
81 }
82 echo 'name="media_changetitle" />&nbsp;<small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
83
84 // Option: media_popup
85 echo html_tag( 'tr' ) .
86 html_tag( 'td', _("Show popup window on new mail").':', 'right', '', 'style="white-space: nowrap;"' ) .
87 html_tag( 'td', '', 'left' ) .
88 '<input type="checkbox" ';
89 if($newmail_popup == 'on') {
90 echo 'checked="checked" ';
91 }
92 echo 'name="media_popup" />&nbsp;<small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
93
94 echo html_tag( 'tr' )
95 . html_tag('td',_("Width of popup window:"),'right','', 'style="white-space: nowrap;"')
96 . html_tag('td','<input type="text" name="popup_width" value="'
97 . (int)$newmail_popup_width . '" size="3" maxlengh="3" />'
98 . '&nbsp;<small>(' . _("If set to 0, reverts to default value") . ')</small>','left')
99 . "</tr>\n";
100
101 echo html_tag( 'tr' )
102 . html_tag('td',_("Height of popup window:"),'right','', 'style="white-space: nowrap;"')
103 . html_tag('td','<input type="text" name="popup_height" value="'
104 . (int)$newmail_popup_height . '" size="3" maxlengh="3" />'
105 . '&nbsp;<small>(' . _("If set to 0, reverts to default value") . ')</small>','left')
106 . "</tr>\n";
107
108 if ($newmail_allowsound) {
109 // Option: media_enable
110 echo html_tag( 'tr' ) .
111 html_tag( 'td', _("Enable Media Playing").':', 'right', '', 'style="white-space: nowrap;"' ) .
112 html_tag( 'td', '', 'left' ) .
113 '<input type="checkbox" ';
114 if ($newmail_enable == 'on') {
115 echo 'checked="checked" ';
116 }
117 echo 'name="media_enable" /></td></tr>' . "\n";
118
119 // Option: media_sel
120 echo html_tag( 'tr' ) .
121 html_tag( 'td', _("Select server file").':', 'right', '', 'style="white-space: nowrap;"' ) .
122 html_tag( 'td', '', 'left' ) .
123 '<select name="media_sel">' . "\n" .
124 '<option value="(none)"';
125 if ( $newmail_media == '(none)') {
126 echo 'selected="selected" ';
127 }
128 echo '>' . _("(none)") . '</option>' . "\n";
129 // Iterate sound files for options
130 $d = dir(SM_PATH . 'plugins/newmail/sounds');
131 while($entry=$d->read()) {
132 // $fname = get_location () . '/sounds/' . $entry;
133 if ($entry != '..' && $entry != '.' && $entry != 'CVS' && $entry != 'index.php') {
134 echo '<option ';
135 if ($entry == $newmail_media) {
136 echo 'selected="selected" ';
137 }
138 echo 'value="' . htmlspecialchars($entry) . '">' .
139 htmlspecialchars($entry) . "</option>\n";
140 }
141 }
142 $d->close();
143 // display media selection
144 foreach($newmail_mmedia as $newmail_mm_name => $newmail_mm_data) {
145 echo '<option ';
146 if ($newmail_media=='mmedia_' . $newmail_mm_name) {
147 echo 'selected="selected" ';
148 }
149 echo 'value="mmedia_' . $newmail_mm_name . '">'
150 .htmlspecialchars($newmail_mm_name) . "</option>\n";
151 }
152
153 if($newmail_uploadsounds) {
154 // display local file option
155 echo '<option ';
156 if ($newmail_media=='(userfile)') {
157 echo 'selected="selected" ';
158 }
159 echo 'value="(userfile)">'.
160 _("uploaded media file") . "</option>\n";
161 // end of local file option
162 }
163
164 // Set media file name
165 if ($newmail_media == '(none)') {
166 $media_output = _("none");
167 } elseif ($newmail_media == '(userfile)') {
168 $media_output = basename($newmail_userfile_name);
169 } elseif (preg_match("/^mmedia_+/",$newmail_media)) {
170 $media_output = preg_replace("/^mmedia_/",'',$newmail_media);
171 } else {
172 $media_output = basename($newmail_media);
173 }
174
175 echo '</select>'.
176 '<input type="submit" value="' . _("Try") . '" name="test" onclick="' .
177 "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound'," .
178 "'width=150,height=30,scrollbars=no');" .
179 'return false;' .
180 '" /></td></tr>';
181 if ($newmail_uploadsounds) {
182 // upload form
183 echo html_tag('tr')
184 . html_tag('td',_("Upload Media File:"),'right','','style="white-space: nowrap;"')
185 . html_tag('td','<input type="file" size="40" name="media_file">')
186 . "</tr>\n";
187 // display currently uploaded file information
188 echo html_tag('tr')
189 . html_tag('td',_("Uploaded Media File:"),'right','','style="white-space: nowrap;"')
190 . html_tag('td',($newmail_userfile_name!='' ? htmlspecialchars($newmail_userfile_name) : _("unavailable")))
191 ."</tr>\n";
192
193 if ($newmail_userfile_name!='') {
194 echo '<tr>'
195 .'<td colspan="2" align="center">'
196 .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($newmail_userfile_name))
197 .'</td></tr>';
198 }
199 }
200 echo html_tag( 'tr', "\n" .
201 html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .
202 html_tag( 'td', '<input type="hidden" value="' .
203 htmlspecialchars($newmail_media) . '" name="media_default" />' .
204 htmlspecialchars($media_output) . '', 'left' )
205 ) . "\n";
206 }
207 echo html_tag( 'tr', "\n" .
208 html_tag( 'td', '&nbsp;' ) .
209 html_tag( 'td',
210 '<input type="hidden" name="optmode" value="submit" />' .
211 '<input type="hidden" name="optpage" value="newmail" />' .
212 '<input type="submit" value="' . _("Submit") . '" name="submit_newmail" />',
213 'left' )
214 ) . "\n";
215 ?>
216 </table></form></td></tr></table></td></tr></table></body></html>