*************************************
-*** Squirrelmail Devel Series 1.3 ***
+*** SquirrelMail Devel Series 1.3 ***
*************************************
-
-Version 1.3.2 -- cvs
+Version 1.3.3 -- cvs
+-------------
+ - Change the way highlighting rules are stored to make them more reliable and
+ easier to manage.
+
+Version 1.3.2
-------------
- Rewrite of message delivery related functions.
- Userinterface modifications.
unset($prefs_cache[$key]);
- if(substr($key, 0, 9) == 'highlight') {
- $this->renumberHighlightList($user);
- }
-
return true;
}
}
}
- /*
- * When a highlight option is deleted the preferences module
- * must renumber the list. This should be done somewhere else,
- * but it is not, so....
- */
- function renumberHighlightList($user) {
- if (!$this->open()) {
- return;
- }
- $query = sprintf("SELECT %s, %s as prefkey, %s as prefval FROM %s WHERE %s='%s' ".
- "AND %s LIKE 'highlight%%' ORDER BY %s",
- $this->user_field,
- $this->key_field,
- $this->val_field,
- $this->table,
- $this->user_field,
- $this->dbh->quoteString($user),
- $this->key_field,
- $this->key_field);
-
- $res = $this->dbh->query($query);
- if(DB::isError($res)) {
- $this->failQuery($res);
- }
-
- /* Store old data in array */
- $rows = Array();
- while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
- $rows[] = $row;
- }
-
- /* Renumber keys of old data */
- $hilinum = 0;
- for($i = 0; $i < count($rows) ; $i++) {
- $oldkey = $rows[$i]['prefkey'];
- $newkey = substr($oldkey, 0, 9) . $hilinum;
- $hilinum++;
-
- if($oldkey != $newkey) {
- $query = sprintf("UPDATE %s SET %s='%s' ".
- "WHERE %s ='%s' AND %s='%s'",
- $this->table,
- $this->key_field,
- $this->dbh->quoteString($newkey),
- $this->user_field,
- $this->dbh->quoteString($user),
- $this->key_field,
- $this->dbh->quoteString($oldkey));
-
- $res = $this->dbh->simpleQuery($query);
- if(DB::isError($res)) {
- $this->failQuery($res);
- }
- }
- }
-
- return;
- }
-
} /* end class dbPrefs */
if ($equalsAt > 0) {
$key = substr($pref, 0, $equalsAt);
$value = substr($pref, $equalsAt + 1);
+ /* this is to 'rescue' old-style highlighting rules. */
if (substr($key, 0, 9) == 'highlight') {
$key = 'highlight' . $highlight_num;
$highlight_num ++;
$sort = getPref($data_dir, $username, 'sort', 6 );
/** Load up the Signature file **/
-$signature_abs = $signature = getSig($data_dir, $username, "g");
-
-/* Highlight comes in with the form: name, color, header, value. */
-for ($i = 0; $hlt = getPref($data_dir, $username, "highlight$i"); ++$i) {
- $highlight_array = explode(',', $hlt);
- $message_highlight_list[$i]['name'] = $highlight_array[0];
- $message_highlight_list[$i]['color'] = $highlight_array[1];
- $message_highlight_list[$i]['value'] = $highlight_array[2];
- $message_highlight_list[$i]['match_type'] = $highlight_array[3];
+$signature_abs = $signature = getSig($data_dir, $username, 'g');
+
+/* use new way of storing highlighting rules */
+if( $ser = getPref($data_dir, $username, 'hililist') ) {
+ $message_highlight_list = unserialize($ser);
+} else {
+ /* use old way */
+ for ($i = 0; $hlt = getPref($data_dir, $username, "highlight$i"); ++$i) {
+ $highlight_array = explode(',', $hlt);
+ $message_highlight_list[$i]['name'] = $highlight_array[0];
+ $message_highlight_list[$i]['color'] = $highlight_array[1];
+ $message_highlight_list[$i]['value'] = $highlight_array[2];
+ $message_highlight_list[$i]['match_type'] = $highlight_array[3];
+ removePref($data_dir, $user_name, "highlight$i");
+ }
+ /* store in new format for the next time */
+ setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
}
/* Index order lets you change the order of the message index */
$value = $_GET['value'];
}
-$SCRIPT_NAME = $_SERVER['SCRIPT_NAME'];
/* end of get globals */
function oh_opt( $val, $sel, $tit ) {
}
if ($action == 'delete' && isset($theid)) {
- removePref($data_dir, $username, "highlight$theid");
- header( "Location: $SCRIPT_NAME" );
+
+ $new_rules = array();
+ foreach($message_highlight_list as $rid => $rule) {
+ if($rid != $theid) {
+ $new_rules[] = $rule;
+ }
+ }
+ $message_highlight_list = $new_rules;
+
+ setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
+
+ header( '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');
"<br>\n";
}
if ($action == 'edit' || $action == 'add') {
- if (!isset($theid))
- {
- $theid = count($message_highlight_list);
- $message_highlight_list[$theid] = array();
- }
$color_list[0] = '4444aa';
$color_list[1] = '44aa44';
for ($i=0; $i < 14; $i++) {
${"selected".$i} = '';
}
- if (isset($message_highlight_list[$theid]['color'])) {
+ if ($action == 'edit' && isset($message_highlight_list[$theid]['color'])) {
for ($i=0; $i < 14; $i++) {
if ($color_list[$i] == $message_highlight_list[$theid]['color']) {
$selected_choose = ' checked';
}
}
- if (isset($message_highlight_list[$theid]['color'])) {
+ if ($action == 'edit' && isset($message_highlight_list[$theid]['color'])) {
$current_color = $message_highlight_list[$theid]['color'];
}
else {
echo '<form name="f" action="options_highlight.php">' . "\n";
echo '<input type="hidden" value="save" name="action">' . "\n";
- echo '<input type="hidden" value="'.$theid.'" name="theid">' . "\n";
+ if($action == 'edit')
+ echo '<input type="hidden" value="'.$theid.'" name="theid">' . "\n";
echo html_tag( 'table', '', 'center', '', 'width="80%" cellpadding="3" cellspacing="0" border="0"' ) . "\n";
echo html_tag( 'tr', '', '', $color[0] ) . "\n";
echo html_tag( 'td', '', 'right', '', 'nowrap' ) . "<b>\n";
echo _("Identifying name") . ":";
echo ' </b></td>' . "\n";
echo html_tag( 'td', '', 'left' ) . "\n";
- if (isset($message_highlight_list[$theid]['name']))
+ if ($action == 'edit' && isset($message_highlight_list[$theid]['name']))
$disp = $message_highlight_list[$theid]['name'];
else
$disp = '';
_("Subject") );
echo " </select>\n";
echo '<b>' . _("Matches") . ':</b> ';
- if (isset($message_highlight_list[$theid]['value']))
+ if ($action == 'edit' && isset($message_highlight_list[$theid]['value']))
$disp = $message_highlight_list[$theid]['value'];
else
$disp = '';
* Copyright (c) 1999-2002 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
- * Displays message highlighting options
+ * Displays messagelist column order options
*
* $Id$
*/
require_once(SM_PATH . 'functions/html.php');
/* get globals */
-if (isset($_GET['action'])) {
- $action = $_GET['action'];
-}
if (isset($_GET['num'])) {
$num = $_GET['num'];
}
}
/* end of get globals */
-if (! isset($action)) { $action = ''; }
-if ($action == 'delete' && isset($theid)) {
- removePref($data_dir, $username, "highlight$theid");
-} elseif ($action == 'save') {
-}
displayPageHeader($color, 'None');
echo