adding option to choose monitored folders. Monitoring according to
[squirrelmail.git] / plugins / newmail / newmail_opt.php
CommitLineData
4508b1b6 1<?php
4b4abf93 2
8d6a115b 3/**
ebe02dfc 4 * newmails_opt.php - options page
8d6a115b 5 *
8d6a115b 6 * Displays all options relating to new mail sounds
7 *
47ccfad4 8 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
4b4abf93 9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
ebe02dfc 10 * @version $Id$
ea5f4b8e 11 * @package plugins
12 * @subpackage newmail
8d6a115b 13 */
4508b1b6 14
ea5f4b8e 15/** @ignore */
8d6a115b 16define('SM_PATH','../../');
d0dbdb14 17
8d6a115b 18/* SquirrelMail required files. */
dbc7cd0a 19include_once(SM_PATH . 'include/validate.php');
321069a7 20/* form functions */
21include_once(SM_PATH . 'functions/forms.php');
dbc7cd0a 22/** Plugin functions (also loads plugin's config) */
23include_once(SM_PATH . 'plugins/newmail/functions.php');
3d75ef16 24
692ca6b7 25displayPageHeader($color, 'None');
3d75ef16 26
c8f452aa 27// plugin uses squirrelmail loading_pref hook.
28// vars are already loaded in include/validate.php
3d75ef16 29
637fbe4d 30echo 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
f7c05ce6 38echo html_tag( 'p',_("The NewMail plugin will follow the Folder Preferences option &quot;Enable Unread Message Notification&quot;")) . "\n" .
637fbe4d 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',
e2495a9f 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;')
637fbe4d 47 ) . "\n";
70e628ef 48if ($newmail_allowsound) {
637fbe4d 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";
692ca6b7 55}
637fbe4d 56
57echo '</td></tr>' .
58 html_tag( 'tr' ) .
59 html_tag( 'td', '', 'center', $color[4] ) . "\n" . '<hr style="width: 25%; height: 1px;" />' . "\n";
60
dbc7cd0a 61echo '<form action="'.sqm_baseuri().'src/options.php" method="post" enctype="multipart/form-data">' . "\n" .
637fbe4d 62 html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n";
63
321069a7 64/* newmail_unseen_notify */
65$newmail_unseen_opts = array( 0 => _("Follow folder preferences"),
66 SMPREF_UNSEEN_INBOX => _("INBOX"),
67 SMPREF_UNSEEN_ALL => _("All folders"),
68 SMPREF_UNSEEN_SPECIAL => _("Special folders"),
69 SMPREF_UNSEEN_NORMAL => _("Regular folders"));
70echo html_tag('tr',
71 html_tag('td',_("Check for new messages in:"),'right', '', 'style="white-space: nowrap;"').
72 html_tag('td',addSelect('newmail_unseen_notify',$newmail_unseen_opts,$newmail_unseen_notify,true),'left')
73 );
74
637fbe4d 75// Option: media_recent
76echo html_tag( 'tr' ) .
c435f076 77 html_tag( 'td', _("Count only messages that are RECENT").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 78 html_tag( 'td', '', 'left' ) .
79 '<input type="checkbox" ';
c8f452aa 80if ($newmail_recent == 'on') {
637fbe4d 81 echo 'checked="checked" ';
82}
83echo 'name="media_recent" /></td></tr>' . "\n";
84
85// Option: media_changetitle
86echo html_tag( 'tr' ) .
c435f076 87 html_tag( 'td', _("Change title on supported browsers").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 88 html_tag( 'td', '', 'left' ) .
89 '<input type="checkbox" ';
c8f452aa 90if ($newmail_changetitle == 'on') {
637fbe4d 91 echo 'checked="checked" ';
92}
c8f452aa 93echo 'name="media_changetitle" />&nbsp;<small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
637fbe4d 94
95// Option: media_popup
96echo html_tag( 'tr' ) .
c435f076 97 html_tag( 'td', _("Show popup window on new mail").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 98 html_tag( 'td', '', 'left' ) .
99 '<input type="checkbox" ';
c8f452aa 100if($newmail_popup == 'on') {
637fbe4d 101 echo 'checked="checked" ';
102}
c8f452aa 103echo 'name="media_popup" />&nbsp;<small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
104
105echo html_tag( 'tr' )
106 . html_tag('td',_("Width of popup window:"),'right','', 'style="white-space: nowrap;"')
f8a1ed5a 107 . html_tag('td','<input type="text" name="popup_width" value="'
c8f452aa 108 . (int)$newmail_popup_width . '" size="3" maxlengh="3" />'
109 . '&nbsp;<small>(' . _("If set to 0, reverts to default value") . ')</small>','left')
110 . "</tr>\n";
111
112echo html_tag( 'tr' )
113 . html_tag('td',_("Height of popup window:"),'right','', 'style="white-space: nowrap;"')
f8a1ed5a 114 . html_tag('td','<input type="text" name="popup_height" value="'
c8f452aa 115 . (int)$newmail_popup_height . '" size="3" maxlengh="3" />'
116 . '&nbsp;<small>(' . _("If set to 0, reverts to default value") . ')</small>','left')
117 . "</tr>\n";
637fbe4d 118
70e628ef 119if ($newmail_allowsound) {
637fbe4d 120// Option: media_enable
121 echo html_tag( 'tr' ) .
c435f076 122 html_tag( 'td', _("Enable Media Playing").':', 'right', '', 'style="white-space: nowrap;"' ) .
4cf43843 123 html_tag( 'td', '', 'left' ) .
124 '<input type="checkbox" ';
0f3d157e 125 if ($newmail_media_enable == 'on') {
637fbe4d 126 echo 'checked="checked" ';
3d75ef16 127 }
637fbe4d 128 echo 'name="media_enable" /></td></tr>' . "\n";
3d75ef16 129
637fbe4d 130// Option: media_sel
131 echo html_tag( 'tr' ) .
c435f076 132 html_tag( 'td', _("Select server file").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 133 html_tag( 'td', '', 'left' ) .
134 '<select name="media_sel">' . "\n" .
135 '<option value="(none)"';
c8f452aa 136 if ( $newmail_media == '(none)') {
637fbe4d 137 echo 'selected="selected" ';
138 }
139 echo '>' . _("(none)") . '</option>' . "\n";
3d75ef16 140 // Iterate sound files for options
cd7fc9e6 141 $d = dir(SM_PATH . 'plugins/newmail/sounds');
3d75ef16 142 while($entry=$d->read()) {
f9710f76 143 // $fname = get_location () . '/sounds/' . $entry;
92192507 144 if ($entry != '..' && $entry != '.' && $entry != 'CVS' && $entry != 'index.php') {
692ca6b7 145 echo '<option ';
f9710f76 146 if ($entry == $newmail_media) {
637fbe4d 147 echo 'selected="selected" ';
3d75ef16 148 }
f9710f76 149 echo 'value="' . htmlspecialchars($entry) . '">' .
a9e1e670 150 htmlspecialchars($entry) . "</option>\n";
3d75ef16 151 }
152 }
153 $d->close();
dbc7cd0a 154 // display media selection
155 foreach($newmail_mmedia as $newmail_mm_name => $newmail_mm_data) {
156 echo '<option ';
c8f452aa 157 if ($newmail_media=='mmedia_' . $newmail_mm_name) {
dbc7cd0a 158 echo 'selected="selected" ';
159 }
160 echo 'value="mmedia_' . $newmail_mm_name . '">'
161 .htmlspecialchars($newmail_mm_name) . "</option>\n";
162 }
f9710f76 163
164 if($newmail_uploadsounds) {
165 // display local file option
166 echo '<option ';
167 if ($newmail_media=='(userfile)') {
168 echo 'selected="selected" ';
169 }
170 echo 'value="(userfile)">'.
171 _("uploaded media file") . "</option>\n";
172 // end of local file option
dbc7cd0a 173 }
dbc7cd0a 174
175 // Set media file name
c8f452aa 176 if ($newmail_media == '(none)') {
dbc7cd0a 177 $media_output = _("none");
c8f452aa 178 } elseif ($newmail_media == '(userfile)') {
179 $media_output = basename($newmail_userfile_name);
180 } elseif (preg_match("/^mmedia_+/",$newmail_media)) {
181 $media_output = preg_replace("/^mmedia_/",'',$newmail_media);
dbc7cd0a 182 } else {
f9710f76 183 $media_output = basename($newmail_media);
dbc7cd0a 184 }
185
4cf43843 186 echo '</select>'.
c435f076 187 '<input type="submit" value="' . _("Try") . '" name="test" onclick="' .
637fbe4d 188 "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound'," .
189 "'width=150,height=30,scrollbars=no');" .
190 'return false;' .
dbc7cd0a 191 '" /></td></tr>';
f9710f76 192 if ($newmail_uploadsounds) {
193 // upload form
194 echo html_tag('tr')
195 . html_tag('td',_("Upload Media File:"),'right','','style="white-space: nowrap;"')
196 . html_tag('td','<input type="file" size="40" name="media_file">')
197 . "</tr>\n";
198 // display currently uploaded file information
199 echo html_tag('tr')
200 . html_tag('td',_("Uploaded Media File:"),'right','','style="white-space: nowrap;"')
201 . html_tag('td',($newmail_userfile_name!='' ? htmlspecialchars($newmail_userfile_name) : _("unavailable")))
202 ."</tr>\n";
203
204 if ($newmail_userfile_name!='') {
205 echo '<tr>'
206 .'<td colspan="2" align="center">'
207 .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($newmail_userfile_name))
208 .'</td></tr>';
209 }
dbc7cd0a 210 }
211 echo html_tag( 'tr', "\n" .
c435f076 212 html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 213 html_tag( 'td', '<input type="hidden" value="' .
c8f452aa 214 htmlspecialchars($newmail_media) . '" name="media_default" />' .
637fbe4d 215 htmlspecialchars($media_output) . '', 'left' )
216 ) . "\n";
217}
218echo html_tag( 'tr', "\n" .
219 html_tag( 'td', '&nbsp;' ) .
220 html_tag( 'td',
221 '<input type="hidden" name="optmode" value="submit" />' .
ebe02dfc 222 '<input type="hidden" name="optpage" value="newmail" />' .
637fbe4d 223 '<input type="submit" value="' . _("Submit") . '" name="submit_newmail" />',
224 'left' )
225 ) . "\n";
dcc1cc82 226?>
91e0dccc 227</table></form></td></tr></table></td></tr></table></body></html>