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