8c62edd0e62de7f77e33592f5ae79358862d6f05
[squirrelmail.git] / plugins / newmail / newmail_opt.php
1 <?php
2
3 /**
4 * newmails_opt.php - options page
5 *
6 * Displays all options relating to new mail sounds
7 *
8 * @copyright &copy; 1999-2006 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 /** @ignore */
16 define('SM_PATH','../../');
17
18 /* SquirrelMail required files. */
19 include_once(SM_PATH . 'include/validate.php');
20 /* form functions */
21 include_once(SM_PATH . 'functions/forms.php');
22 /** Plugin functions (also loads plugin's config) */
23 include_once(SM_PATH . 'plugins/newmail/functions.php');
24
25 displayPageHeader($color, 'None');
26
27 // plugin uses squirrelmail loading_pref hook.
28 // vars are already loaded in include/validate.php
29
30 echo 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
38 echo html_tag( 'p',_("The NewMail plugin will follow the Folder Preferences option &quot;Enable Unread Message Notification&quot;")) . "\n" .
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',
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;')
47 ) . "\n";
48 if ($newmail_allowsound) {
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";
55 }
56
57 echo '</td></tr>' .
58 html_tag( 'tr' ) .
59 html_tag( 'td', '', 'center', $color[4] ) . "\n" . '<hr style="width: 25%; height: 1px;" />' . "\n";
60
61 echo '<form action="'.sqm_baseuri().'src/options.php" method="post" enctype="multipart/form-data">' . "\n" .
62 html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n";
63
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"));
70 echo 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
75 // Option: media_recent
76 echo html_tag( 'tr' ) .
77 html_tag( 'td', _("Count only messages that are RECENT").':', 'right', '', 'style="white-space: nowrap;"' ) .
78 html_tag( 'td', '', 'left' ) .
79 '<input type="checkbox" ';
80 if ($newmail_recent == 'on') {
81 echo 'checked="checked" ';
82 }
83 echo 'name="media_recent" /></td></tr>' . "\n";
84
85 // Option: media_changetitle
86 echo html_tag( 'tr' ) .
87 html_tag( 'td', _("Change title on supported browsers").':', 'right', '', 'style="white-space: nowrap;"' ) .
88 html_tag( 'td', '', 'left' ) .
89 '<input type="checkbox" ';
90 if ($newmail_changetitle == 'on') {
91 echo 'checked="checked" ';
92 }
93 echo 'name="media_changetitle" />&nbsp;<small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
94
95 // Option: media_popup
96 echo html_tag( 'tr' ) .
97 html_tag( 'td', _("Show popup window on new mail").':', 'right', '', 'style="white-space: nowrap;"' ) .
98 html_tag( 'td', '', 'left' ) .
99 '<input type="checkbox" ';
100 if($newmail_popup == 'on') {
101 echo 'checked="checked" ';
102 }
103 echo 'name="media_popup" />&nbsp;<small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
104
105 echo html_tag( 'tr' )
106 . html_tag('td',_("Width of popup window:"),'right','', 'style="white-space: nowrap;"')
107 . html_tag('td','<input type="text" name="popup_width" value="'
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
112 echo html_tag( 'tr' )
113 . html_tag('td',_("Height of popup window:"),'right','', 'style="white-space: nowrap;"')
114 . html_tag('td','<input type="text" name="popup_height" value="'
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";
118
119 if ($newmail_allowsound) {
120 // Option: media_enable
121 echo html_tag( 'tr' ) .
122 html_tag( 'td', _("Enable Media Playing").':', 'right', '', 'style="white-space: nowrap;"' ) .
123 html_tag( 'td', '', 'left' ) .
124 '<input type="checkbox" ';
125 if ($newmail_media_enable == 'on') {
126 echo 'checked="checked" ';
127 }
128 echo 'name="media_enable" /></td></tr>' . "\n";
129
130 // Option: media_sel
131 echo html_tag( 'tr' ) .
132 html_tag( 'td', _("Select server file").':', 'right', '', 'style="white-space: nowrap;"' ) .
133 html_tag( 'td', '', 'left' ) .
134 '<select name="media_sel">' . "\n" .
135 '<option value="(none)"';
136 if ( $newmail_media == '(none)') {
137 echo 'selected="selected" ';
138 }
139 echo '>' . _("(none)") . '</option>' . "\n";
140 // Iterate sound files for options
141 $d = dir(SM_PATH . 'plugins/newmail/sounds');
142 while($entry=$d->read()) {
143 // $fname = get_location () . '/sounds/' . $entry;
144 if ($entry != '..' && $entry != '.' && $entry != 'CVS' && $entry != 'index.php') {
145 echo '<option ';
146 if ($entry == $newmail_media) {
147 echo 'selected="selected" ';
148 }
149 echo 'value="' . htmlspecialchars($entry) . '">' .
150 htmlspecialchars($entry) . "</option>\n";
151 }
152 }
153 $d->close();
154 // display media selection
155 foreach($newmail_mmedia as $newmail_mm_name => $newmail_mm_data) {
156 echo '<option ';
157 if ($newmail_media=='mmedia_' . $newmail_mm_name) {
158 echo 'selected="selected" ';
159 }
160 echo 'value="mmedia_' . $newmail_mm_name . '">'
161 .htmlspecialchars($newmail_mm_name) . "</option>\n";
162 }
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
173 }
174
175 // Set media file name
176 if ($newmail_media == '(none)') {
177 $media_output = _("none");
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);
182 } else {
183 $media_output = basename($newmail_media);
184 }
185
186 echo '</select>'.
187 '<input type="submit" value="' . _("Try") . '" name="test" onclick="' .
188 "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound'," .
189 "'width=150,height=30,scrollbars=no');" .
190 'return false;' .
191 '" /></td></tr>';
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 }
210 }
211 echo html_tag( 'tr', "\n" .
212 html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .
213 html_tag( 'td', '<input type="hidden" value="' .
214 htmlspecialchars($newmail_media) . '" name="media_default" />' .
215 htmlspecialchars($media_output) . '', 'left' )
216 ) . "\n";
217 }
218 echo html_tag( 'tr', "\n" .
219 html_tag( 'td', '&nbsp;' ) .
220 html_tag( 'td',
221 '<input type="hidden" name="optmode" value="submit" />' .
222 '<input type="hidden" name="optpage" value="newmail" />' .
223 '<input type="submit" value="' . _("Submit") . '" name="submit_newmail" />',
224 'left' )
225 ) . "\n";
226 ?>
227 </table></form></td></tr></table></td></tr></table></body></html>