PHP 5.3 deprecated ereg() function (#2820952)
[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 *
d4e46166 8 * @copyright &copy; 1999-2009 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
202bcbcc 15/**
16 * Path for SquirrelMail required files.
17 * @ignore
18 */
19require('../../include/init.php');
d0dbdb14 20
c80190fc 21/**
22 * Make sure plugin is activated!
23 */
24global $plugins;
25if (!in_array('newmail', $plugins))
26 exit;
27
dbc7cd0a 28/** Plugin functions (also loads plugin's config) */
29include_once(SM_PATH . 'plugins/newmail/functions.php');
3d75ef16 30
202bcbcc 31include_once(SM_PATH . 'functions/forms.php');
3d75ef16 32
876fdb60 33displayPageHeader($color);
3d75ef16 34
c80190fc 35//FIXME: Remove all HTML from core - put this all into a template file
637fbe4d 36echo html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) . "\n" .
37 html_tag( 'tr' ) . "\n" .
38 html_tag( 'td', '', 'center' ) .
39 '<b>' . _("Options") . ' - ' . _("New Mail Notification") . "</b><br />\n" .
40 html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n" .
41 html_tag( 'tr' ) . "\n" .
42 html_tag( 'td', '', 'left', $color[4] ) . "<br />\n";
43
c80190fc 44echo html_tag( 'p',_("Based on the Folder Preferences option &quot;Enable Unread Message Notification&quot;, you can be notified when new messages arrive in your account.")) . "\n" .
637fbe4d 45 html_tag( 'p',
c80190fc 46 sprintf(_("Selecting the %s option will enable the showing of a popup window when unseen mail is in one of your folders (requires JavaScript)."), '&quot;'._("Show popup window on new mail").'&quot;')
637fbe4d 47 ) . "\n" .
48 html_tag( 'p',
49 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;')
50 ) . "\n" .
51 html_tag( 'p',
c80190fc 52 sprintf(_("Selecting the %s option will change the browser title bar to let you know when you have new mail (requires JavaScript and may only work in some 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 53 ) . "\n";
70e628ef 54if ($newmail_allowsound) {
637fbe4d 55 echo html_tag( 'p',
56 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;')
57 ) . "\n" .
58 html_tag( 'p',
59 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;')
60 ) . "\n";
692ca6b7 61}
637fbe4d 62
63echo '</td></tr>' .
64 html_tag( 'tr' ) .
65 html_tag( 'td', '', 'center', $color[4] ) . "\n" . '<hr style="width: 25%; height: 1px;" />' . "\n";
66
dbc7cd0a 67echo '<form action="'.sqm_baseuri().'src/options.php" method="post" enctype="multipart/form-data">' . "\n" .
637fbe4d 68 html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n";
69
321069a7 70/* newmail_unseen_notify */
71$newmail_unseen_opts = array( 0 => _("Follow folder preferences"),
72 SMPREF_UNSEEN_INBOX => _("INBOX"),
73 SMPREF_UNSEEN_ALL => _("All folders"),
74 SMPREF_UNSEEN_SPECIAL => _("Special folders"),
75 SMPREF_UNSEEN_NORMAL => _("Regular folders"));
76echo html_tag('tr',
77 html_tag('td',_("Check for new messages in:"),'right', '', 'style="white-space: nowrap;"').
78 html_tag('td',addSelect('newmail_unseen_notify',$newmail_unseen_opts,$newmail_unseen_notify,true),'left')
79 );
80
637fbe4d 81// Option: media_recent
82echo html_tag( 'tr' ) .
c80190fc 83 html_tag( 'td', '<label for="media_recent">' . _("Count only messages that are RECENT") . ':</label>', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 84 html_tag( 'td', '', 'left' ) .
85 '<input type="checkbox" ';
c8f452aa 86if ($newmail_recent == 'on') {
637fbe4d 87 echo 'checked="checked" ';
88}
c80190fc 89echo 'name="media_recent" id="media_recent" /></td></tr>' . "\n";
637fbe4d 90
91// Option: media_changetitle
92echo html_tag( 'tr' ) .
c80190fc 93 html_tag( 'td', '<label for="media_changetitle">' . _("Change title on supported browsers") . ':</label>', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 94 html_tag( 'td', '', 'left' ) .
95 '<input type="checkbox" ';
c8f452aa 96if ($newmail_changetitle == 'on') {
637fbe4d 97 echo 'checked="checked" ';
98}
c80190fc 99echo 'name="media_changetitle" id="media_changetitle" />&nbsp;<small><label for="media_changetitle">('._("requires JavaScript to work").')</label></small></td></tr>' . "\n";
637fbe4d 100
101// Option: media_popup
102echo html_tag( 'tr' ) .
c80190fc 103 html_tag( 'td', '<label for="media_popup">' . _("Show popup window on new mail") . ':</label>', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 104 html_tag( 'td', '', 'left' ) .
105 '<input type="checkbox" ';
c8f452aa 106if($newmail_popup == 'on') {
637fbe4d 107 echo 'checked="checked" ';
108}
c80190fc 109echo 'name="media_popup" id="media_popup" />&nbsp;<small><label for="media_popup">('._("requires JavaScript to work").')</label></small></td></tr>' . "\n";
c8f452aa 110
111echo html_tag( 'tr' )
112 . html_tag('td',_("Width of popup window:"),'right','', 'style="white-space: nowrap;"')
f8a1ed5a 113 . html_tag('td','<input type="text" name="popup_width" value="'
c8f452aa 114 . (int)$newmail_popup_width . '" size="3" maxlengh="3" />'
115 . '&nbsp;<small>(' . _("If set to 0, reverts to default value") . ')</small>','left')
116 . "</tr>\n";
117
118echo html_tag( 'tr' )
119 . html_tag('td',_("Height of popup window:"),'right','', 'style="white-space: nowrap;"')
f8a1ed5a 120 . html_tag('td','<input type="text" name="popup_height" value="'
c8f452aa 121 . (int)$newmail_popup_height . '" size="3" maxlengh="3" />'
122 . '&nbsp;<small>(' . _("If set to 0, reverts to default value") . ')</small>','left')
123 . "</tr>\n";
637fbe4d 124
70e628ef 125if ($newmail_allowsound) {
637fbe4d 126// Option: media_enable
127 echo html_tag( 'tr' ) .
c80190fc 128 html_tag( 'td', '<label for="media_enable">' . _("Enable Media Playing") . ':</label>', 'right', '', 'style="white-space: nowrap;"' ) .
4cf43843 129 html_tag( 'td', '', 'left' ) .
130 '<input type="checkbox" ';
0f3d157e 131 if ($newmail_media_enable == 'on') {
637fbe4d 132 echo 'checked="checked" ';
3d75ef16 133 }
c80190fc 134 echo 'name="media_enable" id="media_enable" /></td></tr>' . "\n";
3d75ef16 135
637fbe4d 136// Option: media_sel
137 echo html_tag( 'tr' ) .
c435f076 138 html_tag( 'td', _("Select server file").':', 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 139 html_tag( 'td', '', 'left' ) .
140 '<select name="media_sel">' . "\n" .
141 '<option value="(none)"';
c8f452aa 142 if ( $newmail_media == '(none)') {
637fbe4d 143 echo 'selected="selected" ';
144 }
145 echo '>' . _("(none)") . '</option>' . "\n";
3d75ef16 146 // Iterate sound files for options
cd7fc9e6 147 $d = dir(SM_PATH . 'plugins/newmail/sounds');
3d75ef16 148 while($entry=$d->read()) {
f9710f76 149 // $fname = get_location () . '/sounds/' . $entry;
92192507 150 if ($entry != '..' && $entry != '.' && $entry != 'CVS' && $entry != 'index.php') {
692ca6b7 151 echo '<option ';
f9710f76 152 if ($entry == $newmail_media) {
637fbe4d 153 echo 'selected="selected" ';
3d75ef16 154 }
f9710f76 155 echo 'value="' . htmlspecialchars($entry) . '">' .
a9e1e670 156 htmlspecialchars($entry) . "</option>\n";
3d75ef16 157 }
158 }
159 $d->close();
dbc7cd0a 160 // display media selection
161 foreach($newmail_mmedia as $newmail_mm_name => $newmail_mm_data) {
162 echo '<option ';
c8f452aa 163 if ($newmail_media=='mmedia_' . $newmail_mm_name) {
dbc7cd0a 164 echo 'selected="selected" ';
165 }
166 echo 'value="mmedia_' . $newmail_mm_name . '">'
167 .htmlspecialchars($newmail_mm_name) . "</option>\n";
168 }
f9710f76 169
170 if($newmail_uploadsounds) {
171 // display local file option
172 echo '<option ';
173 if ($newmail_media=='(userfile)') {
174 echo 'selected="selected" ';
175 }
176 echo 'value="(userfile)">'.
177 _("uploaded media file") . "</option>\n";
178 // end of local file option
dbc7cd0a 179 }
dbc7cd0a 180
181 // Set media file name
c8f452aa 182 if ($newmail_media == '(none)') {
dbc7cd0a 183 $media_output = _("none");
c8f452aa 184 } elseif ($newmail_media == '(userfile)') {
185 $media_output = basename($newmail_userfile_name);
186 } elseif (preg_match("/^mmedia_+/",$newmail_media)) {
187 $media_output = preg_replace("/^mmedia_/",'',$newmail_media);
dbc7cd0a 188 } else {
f9710f76 189 $media_output = basename($newmail_media);
dbc7cd0a 190 }
191
4cf43843 192 echo '</select>'.
c435f076 193 '<input type="submit" value="' . _("Try") . '" name="test" onclick="' .
637fbe4d 194 "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound'," .
195 "'width=150,height=30,scrollbars=no');" .
196 'return false;' .
dbc7cd0a 197 '" /></td></tr>';
f9710f76 198 if ($newmail_uploadsounds) {
199 // upload form
200 echo html_tag('tr')
201 . html_tag('td',_("Upload Media File:"),'right','','style="white-space: nowrap;"')
b116fd78 202 . html_tag('td','<input type="file" size="40" name="media_file" />')
f9710f76 203 . "</tr>\n";
204 // display currently uploaded file information
205 echo html_tag('tr')
206 . html_tag('td',_("Uploaded Media File:"),'right','','style="white-space: nowrap;"')
207 . html_tag('td',($newmail_userfile_name!='' ? htmlspecialchars($newmail_userfile_name) : _("unavailable")))
208 ."</tr>\n";
209
210 if ($newmail_userfile_name!='') {
211 echo '<tr>'
212 .'<td colspan="2" align="center">'
213 .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($newmail_userfile_name))
214 .'</td></tr>';
215 }
dbc7cd0a 216 }
217 echo html_tag( 'tr', "\n" .
c435f076 218 html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .
637fbe4d 219 html_tag( 'td', '<input type="hidden" value="' .
c8f452aa 220 htmlspecialchars($newmail_media) . '" name="media_default" />' .
637fbe4d 221 htmlspecialchars($media_output) . '', 'left' )
222 ) . "\n";
223}
224echo html_tag( 'tr', "\n" .
225 html_tag( 'td', '&nbsp;' ) .
226 html_tag( 'td',
227 '<input type="hidden" name="optmode" value="submit" />' .
ebe02dfc 228 '<input type="hidden" name="optpage" value="newmail" />' .
637fbe4d 229 '<input type="submit" value="' . _("Submit") . '" name="submit_newmail" />',
230 'left' )
231 ) . "\n";
dcc1cc82 232?>
202bcbcc 233</table></form></td></tr></table></td></tr></table></body></html>