phpdoc blocks
[squirrelmail.git] / src / options_highlight.php
index e4803c5477f9d9774f5677c22cd97ca91aeed37d..79e2d2ae8741f0b3fc0e8ca830206e716121dc92 100644 (file)
@@ -9,9 +9,10 @@
  * Displays message highlighting options
  *
  * $Id$
+ * @package squirrelmail
  */
 
-/* Path for SquirrelMail required files. */
+/** Path for SquirrelMail required files. */
 define('SM_PATH','../');
 
 /* SquirrelMail required files. */
@@ -64,19 +65,40 @@ if (! isset($message_highlight_list)) {
     $message_highlight_list = array();
 }
 
-if ($action == 'delete' && isset($theid)) {
-
+if (isset($theid) && ($action == 'delete') ||
+                     ($action == 'up')     ||
+                     ($action == 'down')) {
     $new_rules = array();
-    foreach($message_highlight_list as $rid => $rule) {
-         if($rid != $theid) {
-             $new_rules[] = $rule;
-         }
+    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: options_highlight.php' );
+    header( 'Location: ' .get_location(). '/options_highlight.php' );
     exit;
 } else if ($action == 'save') {
 
@@ -108,16 +130,17 @@ html_tag( 'table', "\n" .
     html_tag( 'tr', "\n" .
         html_tag( 'td', '<center><b>' . _("Options") . ' - ' . _("Message Highlighting") . '</b></center>', 'left')
     ),
-    'center', $color[9], 'width="95% border="0" cellpadding="1" cellspacing="0"' ) . "<br>\n" .
-html_tag( 'table', '', '', '', 'width="100% border="0" cellpadding="1" cellspacing="0"' ) . 
+    'center', $color[9], 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) . "<br>\n" .
+html_tag( 'table', '', '', '', 'width="100%" border="0" cellpadding="1" cellspacing="0"' ) . 
      html_tag( 'tr' ) . "\n" .
          html_tag( 'td', '', 'left' );
 
 echo '<center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]'.
         ' - [<a href="options.php">'._("Done").'</a>]</center><br>'."\n";
-if (count($message_highlight_list) >= 1) {
-    echo html_tag( 'table', '', 'center', '', 'width="80% border="0" cellpadding="3" cellspacing="0"' ) . "\n";
-    for ($i=0; $i < count($message_highlight_list); $i++) {
+$mhl_count = count($message_highlight_list);
+if ($mhl_count > 0) {
+    echo html_tag( 'table', '', 'center', '', 'width="80%" border="0" cellpadding="3" cellspacing="0"' ) . "\n";
+    for ($i=0; $i < $mhl_count; $i++) {
         $match_type = '';
         switch ($message_highlight_list[$i]['match_type'] ) {
             case 'from' :
@@ -137,12 +160,21 @@ if (count($message_highlight_list) >= 1) {
             break;
         }
 
+        $links = '<small>[<a href="options_highlight.php?action=edit&amp;theid=' . $i . '">' .
+                 _("Edit") .
+                 '</a>]&nbsp;[<a href="options_highlight.php?action=delete&amp;theid='.  $i . '">' .
+                 _("Delete");
+        if($i > 0) {
+            $links .= '</a>]&nbsp;[<a href="options_highlight.php?action=up&amp;theid='.  $i . '">' .  _("Up");
+        }
+        if($i+1 < $mhl_count) {
+            $links .= '</a>]&nbsp;[<a href="options_highlight.php?action=down&amp;theid='.  $i . '">' .  _("Down");
+        }
+        $links .= '</a>]</small>';
+
         echo html_tag( 'tr',
                     html_tag( 'td',
-                        '<small>[<a href="options_highlight.php?action=edit&amp;theid=' . $i . '">' .
-                        _("Edit") .
-                        '</a>]&nbsp;[<a href="options_highlight.php?action=delete&amp;theid='.
-                        $i . '">' . _("Delete") . '</a>]</small>' ,
+                        $links,
                     'left', $color[4], 'width="20%" nowrap' ) .
                     html_tag( 'td',
                         htmlspecialchars($message_highlight_list[$i]['name']) ,
@@ -320,6 +352,7 @@ if ($action == 'edit' || $action == 'add') {
         $current_color = '63aa7f';
     }
 
+    $pre_defined_color = 0;
     for($x = 0; $x < 5; $x++) {
         for($y = 0; $y < 19; $y++) {
             $gridindex = "$y,$x";
@@ -436,4 +469,4 @@ if ($action == 'edit' || $action == 'add') {
 }
 do_hook('options_highlight_bottom');
 ?>
-</body></html>
+</table></body></html>