X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Foptions_highlight.php;h=61ac7ddf08bfad44f12bd5e3c859afdef2e2a42e;hb=47ccfad452e8d345542d09e59112cac317cffed8;hp=c6512c65a6fd3aa16f1db1bf8ecaf82a2457df8c;hpb=08185f2a7631c3a12cb1ac085fec3be471b56b00;p=squirrelmail.git diff --git a/src/options_highlight.php b/src/options_highlight.php index c6512c65..61ac7ddf 100644 --- a/src/options_highlight.php +++ b/src/options_highlight.php @@ -3,30 +3,46 @@ /** * 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-2006 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package squirrelmail + * @subpackage prefs */ -/* Path for SquirrelMail required files. */ +/** + * Path for SquirrelMail required files. + * @ignore + */ define('SM_PATH','../'); /* SquirrelMail required files. */ require_once(SM_PATH . 'include/validate.php'); -require_once(SM_PATH . 'functions/display_messages.php'); -require_once(SM_PATH . 'functions/imap.php'); -require_once(SM_PATH . 'functions/array.php'); -require_once(SM_PATH . 'functions/plugin.php'); -require_once(SM_PATH . 'functions/strings.php'); -require_once(SM_PATH . 'functions/html.php'); +include_once(SM_PATH . 'functions/display_messages.php'); +include_once(SM_PATH . 'functions/imap.php'); +include_once(SM_PATH . 'functions/plugin.php'); +include_once(SM_PATH . 'functions/strings.php'); +include_once(SM_PATH . 'functions/html.php'); +include_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"; } @@ -37,28 +53,63 @@ 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'); @@ -67,16 +118,17 @@ html_tag( 'table', "\n" . html_tag( 'tr', "\n" . html_tag( 'td', '