eb798bfa144e8ccfabaf5f3b8269743f81519716
[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',
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' && $entry != 'index.php') {
146 echo '<option ';
147 if ($entry == $newmail_media) {
148 echo 'selected="selected" ';
149 }
150 echo 'value="' . htmlspecialchars($entry) . '">' .
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
165 if($newmail_uploadsounds) {
166 // display local file option
167 echo '<option ';
168 if ($newmail_media=='(userfile)') {
169 echo 'selected="selected" ';
170 }
171 echo 'value="(userfile)">'.
172 _("uploaded media file") . "</option>\n";
173 // end of local file option
174 }
175
176 // Set media file name
177 if ($newmail_media == '(none)') {
178 $media_output = _("none");
179 } elseif ($newmail_media == '(userfile)') {
180 $media_output = basename($newmail_userfile_name);
181 } elseif (preg_match("/^mmedia_+/",$newmail_media)) {
182 $media_output = preg_replace("/^mmedia_/",'',$newmail_media);
183 } else {
184 $media_output = basename($newmail_media);
185 }
186
187 echo '</select>'.
188 '<input type="submit" value="' . _("Try") . '" name="test" onclick="' .
189 "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound'," .
190 "'width=150,height=30,scrollbars=no');" .
191 'return false;' .
192 '" /></td></tr>';
193 if ($newmail_uploadsounds) {
194 // upload form
195 echo html_tag('tr')
196 . html_tag('td',_("Upload Media File:"),'right','','style="white-space: nowrap;"')
197 . html_tag('td','<input type="file" size="40" name="media_file">')
198 . "</tr>\n";
199 // display currently uploaded file information
200 echo html_tag('tr')
201 . html_tag('td',_("Uploaded Media File:"),'right','','style="white-space: nowrap;"')
202 . html_tag('td',($newmail_userfile_name!='' ? htmlspecialchars($newmail_userfile_name) : _("unavailable")))
203 ."</tr>\n";
204
205 if ($newmail_userfile_name!='') {
206 echo '<tr>'
207 .'<td colspan="2" align="center">'
208 .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($newmail_userfile_name))
209 .'</td></tr>';
210 }
211 }
212 echo html_tag( 'tr', "\n" .
213 html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .
214 html_tag( 'td', '<input type="hidden" value="' .
215 htmlspecialchars($newmail_media) . '" name="media_default" />' .
216 htmlspecialchars($media_output) . '', 'left' )
217 ) . "\n";
218 }
219 echo html_tag( 'tr', "\n" .
220 html_tag( 'td', '&nbsp;' ) .
221 html_tag( 'td',
222 '<input type="hidden" name="optmode" value="submit" />' .
223 '<input type="hidden" name="optpage" value="newmail" />' .
224 '<input type="submit" value="' . _("Submit") . '" name="submit_newmail" />',
225 'left' )
226 ) . "\n";
227 ?>
228 </table></form></td></tr></table></td></tr></table></body></html>