X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Foptions_highlight.php;h=872a5cdc9524453689e2f5fc20d76dd4ade344ae;hp=8d21a7459aca796a92877038049c196a2b7106b9;hb=d3ab62601e195e75cfa8f871a89a380be5ed443e;hpb=545238b1fa274274c9202937c6e82c6432efc45d
diff --git a/src/options_highlight.php b/src/options_highlight.php
index 8d21a745..872a5cdc 100644
--- a/src/options_highlight.php
+++ b/src/options_highlight.php
@@ -3,26 +3,42 @@
/**
* options_highlight.php
*
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
* Displays message highlighting options
*
- * $Id$
+ * @copyright © 1999-2007 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage prefs
*/
-require_once('../src/validate.php');
-require_once('../functions/display_messages.php');
-require_once('../functions/imap.php');
-require_once('../functions/array.php');
-require_once('../functions/plugin.php');
-require_once('../functions/strings.php');
-require_once('../functions/html.php');
+/** This is the options_highlight page */
+define('PAGE_NAME', 'options_highlight');
+
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../include/init.php');
+
+// include_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/forms.php');
+
+/* get globals */
+sqGetGlobalVar('action', $action);
+sqGetGlobalVar('theid', $theid);
+sqGetGlobalVar('identname', $identname);
+sqGetGlobalVar('newcolor_choose', $newcolor_choose);
+sqGetGlobalVar('newcolor_input', $newcolor_input);
+sqGetGlobalVar('color_type', $color_type);
+sqGetGlobalVar('match_type', $match_type);
+sqGetGlobalVar('value', $value);
+
+/* end of get globals */
function oh_opt( $val, $sel, $tit ) {
echo "\n";
}
@@ -33,94 +49,112 @@ if (! isset($message_highlight_list)) {
$message_highlight_list = array();
}
-if ($action == 'delete' && isset($theid)) {
- removePref($data_dir, $username, "highlight$theid");
- header( "Location: $SCRIPT_NAME" );
+if (isset($theid) && ($action == 'delete') ||
+ ($action == 'up') ||
+ ($action == 'down')) {
+ $new_rules = array();
+ switch($action) {
+ case('delete'):
+ foreach($message_highlight_list as $rid => $rule) {
+ if($rid != $theid) {
+ $new_rules[] = $rule;
+ }
+ }
+ break;
+ case('down'):
+ $theid++;
+ case('up'):
+ foreach($message_highlight_list as $rid => $rule) {
+ if($rid == $theid) {
+ $temp_rule = $new_rules[$rid-1];
+ $new_rules[$rid-1] = $rule;
+ $new_rules[$rid] = $temp_rule;
+ } else {
+ $new_rules[$rid] = $rule;
+ }
+ }
+ break;
+ default:
+ $new_rules = $message_highlight_list;
+ break;
+ }
+ $message_highlight_list = $new_rules;
+
+ setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
+
+ header( 'Location: ' .get_location(). '/options_highlight.php' );
exit;
} else if ($action == 'save') {
- if (!$theid) $theid = 0;
- $identname = str_replace(',', ' ', $identname);
+
if ($color_type == 1) $newcolor = $newcolor_choose;
elseif ($color_type == 2) $newcolor = $newcolor_input;
else $newcolor = $color_type;
- $newcolor = str_replace(',', '', $newcolor);
$newcolor = str_replace('#', '', $newcolor);
$newcolor = str_replace('"', '', $newcolor);
$newcolor = str_replace('\'', '', $newcolor);
$value = str_replace(',', ' ', $value);
- setPref($data_dir, $username, "highlight$theid", $identname.','.$newcolor.','.$value.','.$match_type);
- $message_highlight_list[$theid]['name'] = $identname;
- $message_highlight_list[$theid]['color'] = $newcolor;
- $message_highlight_list[$theid]['value'] = $value;
- $message_highlight_list[$theid]['match_type'] = $match_type;
+ if(isset($theid)) {
+ $message_highlight_list[$theid] =
+ array( 'name' => $identname, 'color' => $newcolor,
+ 'value' => $value, 'match_type' => $match_type );
+ } else {
+ $message_highlight_list[] =
+ array( 'name' => $identname, 'color' => $newcolor,
+ 'value' => $value, 'match_type' => $match_type );
+ }
+
+ setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
}
-displayPageHeader($color, 'None');
-
-echo '
' .
-html_tag( 'table', "\n" .
- html_tag( 'tr', "\n" .
- html_tag( 'td', '