Trimming whitespace and replacing tabs
[squirrelmail.git] / plugins / newmail / newmail_opt.php
CommitLineData
4508b1b6 1<?php
8d6a115b 2/**
ebe02dfc 3 * newmails_opt.php - options page
8d6a115b 4 *
6c84ba1e 5 * Copyright (c) 1999-2005 The SquirrelMail Project Team
8d6a115b 6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * Displays all options relating to new mail sounds
9 *
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
38echo 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',
e2495a9f 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;')
637fbe4d 49 ) . "\n";
70e628ef 50if ($newmail_allowsound) {
637fbe4d 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";
692ca6b7 57}
637fbe4d 58
59echo '</td></tr>' .
60 html_tag( 'tr' ) .
61 html_tag( 'td', '', 'center', $color[4] ) . "\n" . '<hr style="width: 25%; height: 1px;" />' . "\n";
62
dbc7cd0a 63echo '<form action="'.sqm_baseuri().'src/options.php" method="post" enctype="multipart/form-data">' . "\n" .
637fbe4d 64 html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n";
65
66// Option: media_allbox
67echo html_tag( 'tr' ) .
c435f076 68 html_tag( 'td', _("Check all boxes, not just INBOX").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 69 html_tag( 'td', '', 'left' ) .
70 '<input type="checkbox" ';
c8f452aa 71if ($newmail_allbox == 'on') {
637fbe4d 72 echo 'checked="checked" ';
73}
74echo 'name="media_allbox" /></td></tr>' . "\n";
75
76// Option: media_recent
77echo html_tag( 'tr' ) .
c435f076 78 html_tag( 'td', _("Count only messages that are RECENT").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 79 html_tag( 'td', '', 'left' ) .
80 '<input type="checkbox" ';
c8f452aa 81if ($newmail_recent == 'on') {
637fbe4d 82 echo 'checked="checked" ';
83}
84echo 'name="media_recent" /></td></tr>' . "\n";
85
86// Option: media_changetitle
87echo html_tag( 'tr' ) .
c435f076 88 html_tag( 'td', _("Change title on supported browsers").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 89 html_tag( 'td', '', 'left' ) .
90 '<input type="checkbox" ';
c8f452aa 91if ($newmail_changetitle == 'on') {
637fbe4d 92 echo 'checked="checked" ';
93}
c8f452aa 94echo 'name="media_changetitle" />&nbsp;<small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
637fbe4d 95
96// Option: media_popup
97echo html_tag( 'tr' ) .
c435f076 98 html_tag( 'td', _("Show popup window on new mail").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 99 html_tag( 'td', '', 'left' ) .
100 '<input type="checkbox" ';
c8f452aa 101if($newmail_popup == 'on') {
637fbe4d 102 echo 'checked="checked" ';
103}
c8f452aa 104echo 'name="media_popup" />&nbsp;<small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
105
106echo html_tag( 'tr' )
107 . html_tag('td',_("Width of popup window:"),'right','', 'style="white-space: nowrap;"')
f8a1ed5a 108 . html_tag('td','<input type="text" name="popup_width" value="'
c8f452aa 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
113echo html_tag( 'tr' )
114 . html_tag('td',_("Height of popup window:"),'right','', 'style="white-space: nowrap;"')
f8a1ed5a 115 . html_tag('td','<input type="text" name="popup_height" value="'
c8f452aa 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";
637fbe4d 119
70e628ef 120if ($newmail_allowsound) {
637fbe4d 121// Option: media_enable
122 echo html_tag( 'tr' ) .
c435f076 123 html_tag( 'td', _("Enable Media Playing").':', 'right', '', 'style="white-space: nowrap;"' ) .
4cf43843 124 html_tag( 'td', '', 'left' ) .
125 '<input type="checkbox" ';
c8f452aa 126 if ($newmail_enable == 'on') {
637fbe4d 127 echo 'checked="checked" ';
3d75ef16 128 }
637fbe4d 129 echo 'name="media_enable" /></td></tr>' . "\n";
3d75ef16 130
637fbe4d 131// Option: media_sel
132 echo html_tag( 'tr' ) .
c435f076 133 html_tag( 'td', _("Select server file").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 134 html_tag( 'td', '', 'left' ) .
135 '<select name="media_sel">' . "\n" .
136 '<option value="(none)"';
c8f452aa 137 if ( $newmail_media == '(none)') {
637fbe4d 138 echo 'selected="selected" ';
139 }
140 echo '>' . _("(none)") . '</option>' . "\n";
3d75ef16 141 // Iterate sound files for options
cd7fc9e6 142 $d = dir(SM_PATH . 'plugins/newmail/sounds');
3d75ef16 143 while($entry=$d->read()) {
692ca6b7 144 $fname = get_location () . '/sounds/' . $entry;
145 if ($entry != '..' && $entry != '.' && $entry != 'CVS') {
146 echo '<option ';
c8f452aa 147 if ($fname == $newmail_media) {
637fbe4d 148 echo 'selected="selected" ';
3d75ef16 149 }
a9e1e670 150 echo 'value="' . htmlspecialchars($fname) . '">' .
151 htmlspecialchars($entry) . "</option>\n";
3d75ef16 152 }
153 }
154 $d->close();
dbc7cd0a 155 // display media selection
156 foreach($newmail_mmedia as $newmail_mm_name => $newmail_mm_data) {
157 echo '<option ';
c8f452aa 158 if ($newmail_media=='mmedia_' . $newmail_mm_name) {
dbc7cd0a 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 ';
c8f452aa 166 if ($newmail_media=='(userfile)') {
dbc7cd0a 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
c8f452aa 174 if ($newmail_media == '(none)') {
dbc7cd0a 175 $media_output = _("none");
c8f452aa 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);
dbc7cd0a 180 } else {
c8f452aa 181 $media_output = substr($newmail_media, strrpos($newmail_media, '/')+1);
dbc7cd0a 182 }
183
4cf43843 184 echo '</select>'.
c435f076 185 '<input type="submit" value="' . _("Try") . '" name="test" onclick="' .
637fbe4d 186 "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound'," .
187 "'width=150,height=30,scrollbars=no');" .
188 'return false;' .
dbc7cd0a 189 '" /></td></tr>';
c8f452aa 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!='') {
dbc7cd0a 201 echo '<tr>'
202 .'<td colspan="2" align="center">'
c8f452aa 203 .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($newmail_userfile_name))
dbc7cd0a 204 .'</td></tr>';
205 }
206 echo html_tag( 'tr', "\n" .
c435f076 207 html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 208 html_tag( 'td', '<input type="hidden" value="' .
c8f452aa 209 htmlspecialchars($newmail_media) . '" name="media_default" />' .
637fbe4d 210 htmlspecialchars($media_output) . '', 'left' )
211 ) . "\n";
212}
213echo html_tag( 'tr', "\n" .
214 html_tag( 'td', '&nbsp;' ) .
215 html_tag( 'td',
216 '<input type="hidden" name="optmode" value="submit" />' .
ebe02dfc 217 '<input type="hidden" name="optpage" value="newmail" />' .
637fbe4d 218 '<input type="submit" value="' . _("Submit") . '" name="submit_newmail" />',
219 'left' )
220 ) . "\n";
dcc1cc82 221?>
91e0dccc 222</table></form></td></tr></table></td></tr></table></body></html>