Patches from Michael Long
[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');
ebe02dfc 20/* sqm_baseuri function */
dbc7cd0a 21include_once(SM_PATH . 'functions/display_messages.php');
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
48879ef0 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
637fbe4d 64// Option: media_recent
65echo html_tag( 'tr' ) .
c435f076 66 html_tag( 'td', _("Count only messages that are RECENT").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 67 html_tag( 'td', '', 'left' ) .
68 '<input type="checkbox" ';
c8f452aa 69if ($newmail_recent == 'on') {
637fbe4d 70 echo 'checked="checked" ';
71}
72echo 'name="media_recent" /></td></tr>' . "\n";
73
74// Option: media_changetitle
75echo html_tag( 'tr' ) .
c435f076 76 html_tag( 'td', _("Change title on supported browsers").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 77 html_tag( 'td', '', 'left' ) .
78 '<input type="checkbox" ';
c8f452aa 79if ($newmail_changetitle == 'on') {
637fbe4d 80 echo 'checked="checked" ';
81}
c8f452aa 82echo 'name="media_changetitle" />&nbsp;<small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
637fbe4d 83
84// Option: media_popup
85echo html_tag( 'tr' ) .
c435f076 86 html_tag( 'td', _("Show popup window on new mail").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 87 html_tag( 'td', '', 'left' ) .
88 '<input type="checkbox" ';
c8f452aa 89if($newmail_popup == 'on') {
637fbe4d 90 echo 'checked="checked" ';
91}
c8f452aa 92echo 'name="media_popup" />&nbsp;<small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
93
94echo html_tag( 'tr' )
95 . html_tag('td',_("Width of popup window:"),'right','', 'style="white-space: nowrap;"')
f8a1ed5a 96 . html_tag('td','<input type="text" name="popup_width" value="'
c8f452aa 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
101echo html_tag( 'tr' )
102 . html_tag('td',_("Height of popup window:"),'right','', 'style="white-space: nowrap;"')
f8a1ed5a 103 . html_tag('td','<input type="text" name="popup_height" value="'
c8f452aa 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";
637fbe4d 107
70e628ef 108if ($newmail_allowsound) {
637fbe4d 109// Option: media_enable
110 echo html_tag( 'tr' ) .
c435f076 111 html_tag( 'td', _("Enable Media Playing").':', 'right', '', 'style="white-space: nowrap;"' ) .
4cf43843 112 html_tag( 'td', '', 'left' ) .
113 '<input type="checkbox" ';
c8f452aa 114 if ($newmail_enable == 'on') {
637fbe4d 115 echo 'checked="checked" ';
3d75ef16 116 }
637fbe4d 117 echo 'name="media_enable" /></td></tr>' . "\n";
3d75ef16 118
637fbe4d 119// Option: media_sel
120 echo html_tag( 'tr' ) .
c435f076 121 html_tag( 'td', _("Select server file").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 122 html_tag( 'td', '', 'left' ) .
123 '<select name="media_sel">' . "\n" .
124 '<option value="(none)"';
c8f452aa 125 if ( $newmail_media == '(none)') {
637fbe4d 126 echo 'selected="selected" ';
127 }
128 echo '>' . _("(none)") . '</option>' . "\n";
3d75ef16 129 // Iterate sound files for options
cd7fc9e6 130 $d = dir(SM_PATH . 'plugins/newmail/sounds');
3d75ef16 131 while($entry=$d->read()) {
f9710f76 132 // $fname = get_location () . '/sounds/' . $entry;
92192507 133 if ($entry != '..' && $entry != '.' && $entry != 'CVS' && $entry != 'index.php') {
692ca6b7 134 echo '<option ';
f9710f76 135 if ($entry == $newmail_media) {
637fbe4d 136 echo 'selected="selected" ';
3d75ef16 137 }
f9710f76 138 echo 'value="' . htmlspecialchars($entry) . '">' .
a9e1e670 139 htmlspecialchars($entry) . "</option>\n";
3d75ef16 140 }
141 }
142 $d->close();
dbc7cd0a 143 // display media selection
144 foreach($newmail_mmedia as $newmail_mm_name => $newmail_mm_data) {
145 echo '<option ';
c8f452aa 146 if ($newmail_media=='mmedia_' . $newmail_mm_name) {
dbc7cd0a 147 echo 'selected="selected" ';
148 }
149 echo 'value="mmedia_' . $newmail_mm_name . '">'
150 .htmlspecialchars($newmail_mm_name) . "</option>\n";
151 }
f9710f76 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
dbc7cd0a 162 }
dbc7cd0a 163
164 // Set media file name
c8f452aa 165 if ($newmail_media == '(none)') {
dbc7cd0a 166 $media_output = _("none");
c8f452aa 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);
dbc7cd0a 171 } else {
f9710f76 172 $media_output = basename($newmail_media);
dbc7cd0a 173 }
174
4cf43843 175 echo '</select>'.
c435f076 176 '<input type="submit" value="' . _("Try") . '" name="test" onclick="' .
637fbe4d 177 "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound'," .
178 "'width=150,height=30,scrollbars=no');" .
179 'return false;' .
dbc7cd0a 180 '" /></td></tr>';
f9710f76 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 }
dbc7cd0a 199 }
200 echo html_tag( 'tr', "\n" .
c435f076 201 html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 202 html_tag( 'td', '<input type="hidden" value="' .
c8f452aa 203 htmlspecialchars($newmail_media) . '" name="media_default" />' .
637fbe4d 204 htmlspecialchars($media_output) . '', 'left' )
205 ) . "\n";
206}
207echo html_tag( 'tr', "\n" .
208 html_tag( 'td', '&nbsp;' ) .
209 html_tag( 'td',
210 '<input type="hidden" name="optmode" value="submit" />' .
ebe02dfc 211 '<input type="hidden" name="optpage" value="newmail" />' .
637fbe4d 212 '<input type="submit" value="' . _("Submit") . '" name="submit_newmail" />',
213 'left' )
214 ) . "\n";
dcc1cc82 215?>
91e0dccc 216</table></form></td></tr></table></td></tr></table></body></html>