Some language fixes.
[squirrelmail.git] / plugins / filters / spamoptions.php
CommitLineData
63277aaa 1<?php
15e6162e 2/**
b2d8bc6c 3 * Message and Spam Filter Plugin - Spam Options
15e6162e 4 *
5b4ba967 5 * @version $Id$
6c84ba1e 6 * @copyright (c) 1999-2005 The SquirrelMail Project Team
b2d8bc6c 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
ea5f4b8e 8 * @package plugins
9 * @subpackage filters
15e6162e 10 */
63277aaa 11
5b4ba967 12/**
13 * Path for SquirrelMail required files.
14 * @ignore
15 */
08185f2a 16define('SM_PATH','../../');
17
18/* SquirrelMail required files. */
fca6d99e 19require_once(SM_PATH . 'include/validate.php');
08185f2a 20require_once(SM_PATH . 'functions/page_header.php');
21require_once(SM_PATH . 'functions/imap.php');
fca6d99e 22require_once(SM_PATH . 'include/load_prefs.php');
08185f2a 23require_once(SM_PATH . 'functions/html.php');
fca6d99e 24require_once(SM_PATH . 'plugins/filters/filters.php');
10a26cea 25global $AllowSpamFilters;
26
3c66c567 27/* get globals */
28sqgetGlobalVar('username', $username, SQ_SESSION);
29sqgetGlobalVar('key', $key, SQ_COOKIE);
30sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
31sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
41100fce 32
3c66c567 33sqgetGlobalVar('action', $action, SQ_GET);
34/* end globals */
41100fce 35
10a26cea 36displayPageHeader($color, 'None');
37
0a1dc88e 38if (sqgetGlobalVar('spam_submit',$spam_submit,SQ_POST)) {
10a26cea 39 $spam_filters = load_spam_filters();
0a1dc88e 40
91e0dccc 41 // setting spam folder
0a1dc88e 42 sqgetGlobalVar('filters_spam_folder_set',$filters_spam_folder_set,SQ_POST);
43 if (isset($filters_spam_folder_set)) {
44 setPref($data_dir, $username, 'filters_spam_folder', $filters_spam_folder_set);
45 } else {
91e0dccc 46 echo _("You must select a spam folder.");
0a1dc88e 47 }
48
49 // setting scan type
50 sqgetGlobalVar('filters_spam_scan_set',$filters_spam_scan_set,SQ_POST);
51 if (isset($filters_spam_scan_set)) {
91e0dccc 52 setPref($data_dir, $username, 'filters_spam_scan', $filters_spam_scan_set);
0a1dc88e 53 } else {
91e0dccc 54 echo _("You must select a scan type.");
0a1dc88e 55 }
56
10a26cea 57 foreach ($spam_filters as $Key => $Value) {
58 $input = $spam_filters[$Key]['prefname'] . '_set';
0a1dc88e 59 if ( sqgetGlobalVar($input,$input_key,SQ_POST) ) {
60 setPref( $data_dir, $username, $spam_filters[$Key]['prefname'],$input_key);
51199e7a 61 } else {
62 removePref($data_dir, $username, $spam_filters[$Key]['prefname']);
10a26cea 63 }
64 }
65}
66
67$filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder');
68$filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan');
69$filters = load_filters();
70
b01b21d0 71echo html_tag( 'table',
72 html_tag( 'tr',
73 html_tag( 'th', _("Spam Filtering"), 'center' )
74 ) ,
75 'center', $color[0], 'width="95%" border="0" cellpadding="2" cellspacing="0"' );
10a26cea 76
77if ($SpamFilters_YourHop == ' ') {
0a1dc88e 78 echo '<br />' .
b01b21d0 79 html_tag( 'div', '<b>' .
6d440be5 80 sprintf(_("WARNING! Tell the administrator to set the %s variable."), '&quot;SpamFilters_YourHop&quot;') .
b01b21d0 81 '</b>' ,
82 'center' ) .
0a1dc88e 83 '<br />';
10a26cea 84}
85
86
87if (isset($action) && $action == 'spam') {
88 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
89 $boxes = sqimap_mailbox_list($imapConnection);
90 sqimap_logout($imapConnection);
ae48f757 91 $numboxes = count($boxes);
92
93 for ($i = 0; $i < $numboxes && $filters_spam_folder == ''; $i++) {
41100fce 94 if ((isset($boxes[$i]['flags'][0]) && $boxes[$i]['flags'][0] != 'noselect') &&
95 (isset($boxes[$i]['flags'][1]) && $boxes[$i]['flags'][1] != 'noselect') &&
96 (isset($boxes[$i]['flags'][2]) && $boxes[$i]['flags'][2] != 'noselect')) {
10a26cea 97 $filters_spam_folder = $boxes[$i]['unformatted'];
98 }
5e2e3895 99 }
100
0a1dc88e 101 echo '<form method="post" action="spamoptions.php">'.
10a26cea 102 '<center>'.
b01b21d0 103 html_tag( 'table', '', '', '', 'width="85%" border="0" cellpadding="2" cellspacing="0"' ) .
104 html_tag( 'tr' ) .
c435f076 105 html_tag( 'th', _("Move spam to:"), 'right', '', 'style="white-space: nowrap;"' ) .
b01b21d0 106 html_tag( 'td', '', 'left' ) .
107 '<select name="filters_spam_folder_set">';
10a26cea 108
ae8a7931 109 $selected = 0;
110 if ( isset($filters_spam_folder) )
111 $selected = array(strtolower($filters_spam_folder));
112 echo sqimap_mailbox_option_list(0, $selected, 0, $boxes);
10a26cea 113 echo '</select>'.
114 '</td>'.
115 '</tr>'.
b01b21d0 116 html_tag( 'tr',
117 html_tag( 'td', '&nbsp;' ) .
118 html_tag( 'td',
119 _("Moving spam directly to the trash may not be a good idea at first, since messages from friends and mailing lists might accidentally be marked as spam. Whatever folder you set this to, make sure that it gets cleaned out periodically, so that you don't have an excessively large mailbox hanging around.") ,
120 'left' )
121 ) .
122 html_tag( 'tr' ) .
c435f076 123 html_tag( 'th', _("What to Scan:"), 'right', '', 'style="white-space: nowrap;"' ) .
b01b21d0 124 html_tag( 'td' ) .
125 '<select name="filters_spam_scan_set">'.
10a26cea 126 '<option value=""';
127 if ($filters_spam_scan == '') {
743715c6 128 echo ' selected="selected"';
10a26cea 129 }
130 echo '>' . _("All messages") . '</option>'.
131 '<option value="new"';
132 if ($filters_spam_scan == 'new') {
743715c6 133 echo ' selected="selected"';
10a26cea 134 }
74091b64 135 echo '>' . _("Unread messages only") . '</option>' .
10a26cea 136 '</select>'.
137 '</td>'.
138 '</tr>'.
b01b21d0 139 html_tag( 'tr',
140 html_tag( 'td', '&nbsp;' ) .
141 html_tag( 'td',
74091b64 142 _("The more messages scanned, the longer it takes. It's recommended to scan unread messages only. If a change to the filters is made, it's recommended to set it to scan all messages, then go view the INBOX, then come back and set it to scan unread messages only. That way, the new spam filters will be applied and even the spam you didn't catch with the old filters will be scanned.") ,
b01b21d0 143 'left' )
144 );
10a26cea 145
146 $spam_filters = load_spam_filters();
147
148 foreach ($spam_filters as $Key => $Value) {
b01b21d0 149 echo html_tag( 'tr' ) .
c435f076 150 html_tag( 'th', $Key, 'right', '', 'style="white-space: nowrap;"' ) ."\n" .
b01b21d0 151 html_tag( 'td' ) .
0a1dc88e 152 '<input type="checkbox" name="' .
10a26cea 153 $spam_filters[$Key]['prefname'] .
154 '_set"';
155 if ($spam_filters[$Key]['enabled']) {
9374fbf7 156 echo ' checked="checked"';
10a26cea 157 }
0a1dc88e 158 echo ' /> - ';
10a26cea 159 if ($spam_filters[$Key]['link']) {
160 echo '<a href="' .
161 $spam_filters[$Key]['link'] .
162 '" target="_blank">';
163 }
164 echo $spam_filters[$Key]['name'];
165 if ($spam_filters[$Key]['link']) {
166 echo '</a>';
167 }
b01b21d0 168 echo '</td></tr>' .
169 html_tag( 'tr',
170 html_tag( 'td', '&nbsp;' ) .
171 html_tag( 'td', $spam_filters[$Key]['comment'], 'left' )
172 ) . "\n";
173
10a26cea 174 }
b01b21d0 175 echo html_tag( 'tr',
0a1dc88e 176 html_tag( 'td', '<input type="submit" name="spam_submit" value="' . _("Save") . '" />', 'center', '', 'colspan="2"' )
b01b21d0 177 ) . "\n" .
10a26cea 178 '</table>'.
179 '</center>'.
180 '</form>';
0a1dc88e 181} else {
182 // action is not set or action is not spam
b01b21d0 183 echo html_tag( 'p', '', 'center' ) .
184 '[<a href="spamoptions.php?action=spam">' . _("Edit") . '</a>]' .
0a1dc88e 185 ' - [<a href="../../src/options.php">' . _("Done") . '</a>]</center><br /><br />';
74091b64 186 printf( _("Spam is sent to %s."), ($filters_spam_folder?'<b>'.imap_utf7_decode_local($filters_spam_folder).'</b>':'[<i>'._("not set yet").'</i>]' ) );
187 echo '<br />';
3ee2d2ae 188 printf( _("Spam scan is limited to %s."), '<b>' . ( ($filters_spam_scan == 'new')?_("Unread messages only"):_("All messages") ) . '</b>' );
10a26cea 189 echo '</p>'.
0a1dc88e 190 '<table border="0" cellpadding="3" cellspacing="0" align="center" bgcolor="' . $color[0] . "\">\n";
10a26cea 191
192 $spam_filters = load_spam_filters();
193
194 foreach ($spam_filters as $Key => $Value) {
b01b21d0 195 echo html_tag( 'tr' ) .
196 html_tag( 'th', '', 'center' );
10a26cea 197
198 if ($spam_filters[$Key]['enabled']) {
199 echo _("ON");
200 } else {
201 echo _("OFF");
202 }
203
91e0dccc 204 echo '</th>' .
b01b21d0 205 html_tag( 'td', '&nbsp;-&nbsp;', 'left' ) .
206 html_tag( 'td', '', 'left' );
10a26cea 207
208 if ($spam_filters[$Key]['link']) {
209 echo '<a href="' .
210 $spam_filters[$Key]['link'] .
211 '" target="_blank">';
212 }
213
214 echo $spam_filters[$Key]['name'];
215 if ($spam_filters[$Key]['link']) {
216 echo '</a>';
217 }
218 echo "</td></tr>\n";
219 }
220 echo '</table>';
221}
0a1dc88e 222?>
91e0dccc 223</body></html>