4b450c7bd0e25fa414c51d14a8b4b557e407e714
[squirrelmail.git] / plugins / newmail / newmail_opt.php
1 <?php
2 /**
3 * newmails_opt.php - options page
4 *
5 * Copyright (c) 1999-2005 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * Displays all options relating to new mail sounds
9 *
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 /* sqm_baseuri function */
21 include_once(SM_PATH . 'functions/display_messages.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 $media_enable = getPref($data_dir,$username, 'newmail_enable', 'FALSE' );
28 $media_popup = getPref($data_dir, $username,'newmail_popup');
29 $media_allbox = getPref($data_dir,$username,'newmail_allbox');
30 $media_recent = getPref($data_dir,$username,'newmail_recent');
31 $media_changetitle = getPref($data_dir,$username,'newmail_changetitle');
32 $media = getPref($data_dir,$username,'newmail_media', '(none)');
33 $media_userfile_name = getPref($data_dir,$username,'newmail_userfile_name','');
34
35 // Set $allowsound to false if you don't want sound files available
36 $allowsound = "true";
37
38 echo html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) . "\n" .
39 html_tag( 'tr' ) . "\n" .
40 html_tag( 'td', '', 'center' ) .
41 '<b>' . _("Options") . ' - ' . _("New Mail Notification") . "</b><br />\n" .
42 html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n" .
43 html_tag( 'tr' ) . "\n" .
44 html_tag( 'td', '', 'left', $color[4] ) . "<br />\n";
45
46 echo html_tag( 'p',
47 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;')
48 ) . "\n" .
49 html_tag( 'p',
50 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;')
51 ) . "\n" .
52 html_tag( 'p',
53 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;')
54 ) . "\n" .
55 html_tag( 'p',
56 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;')
57 ) . "\n";
58 if ($allowsound == "true") {
59 echo html_tag( 'p',
60 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;')
61 ) . "\n" .
62 html_tag( 'p',
63 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;')
64 ) . "\n";
65 }
66
67 echo '</td></tr>' .
68 html_tag( 'tr' ) .
69 html_tag( 'td', '', 'center', $color[4] ) . "\n" . '<hr style="width: 25%; height: 1px;" />' . "\n";
70
71 echo '<form action="'.sqm_baseuri().'src/options.php" method="post" enctype="multipart/form-data">' . "\n" .
72 html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n";
73
74 // Option: media_allbox
75 echo html_tag( 'tr' ) .
76 html_tag( 'td', _("Check all boxes, not just INBOX").':', 'right', '', 'style="white-space: nowrap;"' ) .
77 html_tag( 'td', '', 'left' ) .
78 '<input type="checkbox" ';
79 if ($media_allbox == 'on') {
80 echo 'checked="checked" ';
81 }
82 echo 'name="media_allbox" /></td></tr>' . "\n";
83
84 // Option: media_recent
85 echo html_tag( 'tr' ) .
86 html_tag( 'td', _("Count only messages that are RECENT").':', 'right', '', 'style="white-space: nowrap;"' ) .
87 html_tag( 'td', '', 'left' ) .
88 '<input type="checkbox" ';
89 if ($media_recent == 'on') {
90 echo 'checked="checked" ';
91 }
92 echo 'name="media_recent" /></td></tr>' . "\n";
93
94 // Option: media_changetitle
95 echo html_tag( 'tr' ) .
96 html_tag( 'td', _("Change title on supported browsers").':', 'right', '', 'style="white-space: nowrap;"' ) .
97 html_tag( 'td', '', 'left' ) .
98 '<input type="checkbox" ';
99 if ($media_changetitle == 'on') {
100 echo 'checked="checked" ';
101 }
102 echo 'name="media_changetitle" />&nbsp;('._("requires JavaScript to work").')</td></tr>' . "\n";
103
104 // Option: media_popup
105 echo html_tag( 'tr' ) .
106 html_tag( 'td', _("Show popup window on new mail").':', 'right', '', 'style="white-space: nowrap;"' ) .
107 html_tag( 'td', '', 'left' ) .
108 '<input type="checkbox" ';
109 if($media_popup == 'on') {
110 echo 'checked="checked" ';
111 }
112 echo 'name="media_popup" />&nbsp;('._("requires JavaScript to work").')</td></tr>' . "\n";
113
114 if ($allowsound == "true") {
115 // Option: media_enable
116 echo html_tag( 'tr' ) .
117 html_tag( 'td', _("Enable Media Playing").':', 'right', '', 'style="white-space: nowrap;"' ) .
118 html_tag( 'td', '', 'left' ) .
119 '<input type="checkbox" ';
120 if ($media_enable == 'on') {
121 echo 'checked="checked" ';
122 }
123 echo 'name="media_enable" /></td></tr>' . "\n";
124
125 // Option: media_sel
126 echo html_tag( 'tr' ) .
127 html_tag( 'td', _("Select server file").':', 'right', '', 'style="white-space: nowrap;"' ) .
128 html_tag( 'td', '', 'left' ) .
129 '<select name="media_sel">' . "\n" .
130 '<option value="(none)"';
131 if ( $media == '(none)') {
132 echo 'selected="selected" ';
133 }
134 echo '>' . _("(none)") . '</option>' . "\n";
135 // Iterate sound files for options
136 $d = dir(SM_PATH . 'plugins/newmail/sounds');
137 while($entry=$d->read()) {
138 $fname = get_location () . '/sounds/' . $entry;
139 if ($entry != '..' && $entry != '.' && $entry != 'CVS') {
140 echo '<option ';
141 if ($fname == $media) {
142 echo 'selected="selected" ';
143 }
144 echo 'value="' . htmlspecialchars($fname) . '">' .
145 htmlspecialchars($entry) . "</option>\n";
146 }
147 }
148 $d->close();
149 // display media selection
150 foreach($newmail_mmedia as $newmail_mm_name => $newmail_mm_data) {
151 echo '<option ';
152 if ($media=='mmedia_' . $newmail_mm_name) {
153 echo 'selected="selected" ';
154 }
155 echo 'value="mmedia_' . $newmail_mm_name . '">'
156 .htmlspecialchars($newmail_mm_name) . "</option>\n";
157 }
158 // display local file option
159 echo '<option ';
160 if ($media=='(userfile)') {
161 echo 'selected="selected" ';
162 }
163 echo 'value="(userfile)">'.
164 _("uploaded media file") . "</option>\n";
165 // end of local file option
166
167 // Set media file name
168 if ($media == '(none)') {
169 $media_output = _("none");
170 } elseif ($media == '(userfile)') {
171 $media_output = basename($media_userfile_name);
172 } elseif (preg_match("/^mmedia_+/",$media)) {
173 $media_output = preg_replace("/^mmedia_/",'',$media);
174 } else {
175 $media_output = substr($media, strrpos($media, '/')+1);
176 }
177
178 echo '</select>'.
179 '<input type="submit" value="' . _("Try") . '" name="test" onclick="' .
180 "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound'," .
181 "'width=150,height=30,scrollbars=no');" .
182 'return false;' .
183 '" /></td></tr>';
184 echo '<tr>'.
185 '<td align="right" nowrap>' . _("Upload Media File:") .
186 '</td><td>'.
187 '<input type="file" size="40" name="media_file">'.
188 '</td>'.
189 '</tr>';
190
191 echo '<tr>'.
192 '<td align="right" nowrap>' . _("Uploaded Media File:") .
193 '</td><td>'.
194 ($media_userfile_name!='' ? htmlspecialchars($media_userfile_name) : _("unavailable")).
195 '</td>'.
196 '</tr>';
197
198 if ($media_userfile_name!='') {
199 echo '<tr>'
200 .'<td colspan="2" align="center">'
201 .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($media_userfile_name))
202 .'</td></tr>';
203 }
204 echo html_tag( 'tr', "\n" .
205 html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .
206 html_tag( 'td', '<input type="hidden" value="' .
207 htmlspecialchars($media) . '" name="media_default" />' .
208 htmlspecialchars($media_output) . '', 'left' )
209 ) . "\n";
210 }
211 echo html_tag( 'tr', "\n" .
212 html_tag( 'td', '&nbsp;' ) .
213 html_tag( 'td',
214 '<input type="hidden" name="optmode" value="submit" />' .
215 '<input type="hidden" name="optpage" value="newmail" />' .
216 '<input type="submit" value="' . _("Submit") . '" name="submit_newmail" />',
217 'left' )
218 ) . "\n";
219 ?>
220 </table></form></td></tr></table></td></tr></table></body></html>