Browse Source

Added ability to keep messages selected on mailbox listing - use 'preselected' query arg or global var from plugins

pdontthink 18 years ago
parent
commit
6e4992889b
4 changed files with 15 additions and 6 deletions
  1. 1 0
      ChangeLog
  2. 2 2
      functions/mailbox_display.php
  3. 7 0
      src/right_main.php
  4. 5 4
      templates/default/message_list.tpl

+ 1 - 0
ChangeLog

@@ -217,6 +217,7 @@ Version 1.5.2 - SVN
   - Added smtp_auth hook
   - Removed "Include CCs when Forwarding Messages", which had no functionality
     whatsoever.
+  - Added "preselected" query argument to mailbox list.
 
 Version 1.5.1 (branched on 2006-02-12)
 --------------------------------------

+ 2 - 2
functions/mailbox_display.php

@@ -427,7 +427,7 @@ function fetchMessageHeaders($imapConnection, &$aMailbox) {
 function prepareMessageList(&$aMailbox, $aProps) {
 
     /* Globalize link attributes so plugins can share in modifying them */
-    global $link, $title, $target, $onclick, $link_extra;
+    global $link, $title, $target, $onclick, $link_extra, $preselected;
 
     /* retrieve the properties */
     $my_email_address = (isset($aProps['email'])) ? $aProps['email'] : false;
@@ -646,7 +646,7 @@ function prepareMessageList(&$aMailbox, $aProps) {
                     $value = (is_array($value) && $value[0] == 'multipart' && $value[1] == 'mixed') ? true : false;
                     break;
                 case SQM_COL_CHECK:
-                    $value = $checkall;
+                    $value = ($checkall || in_array($iUid, $preselected));
                     break;
                 default : break;
                 }

+ 7 - 0
src/right_main.php

@@ -71,6 +71,12 @@ if (!sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
     $checkall = false;
 }
 
+if (!sqgetGlobalVar('preselected', $preselected, SQ_GET) || !is_array($preselected)) {
+    $preselected = array();
+} else {
+    $preselected = array_keys($preselected);
+}
+
 /* future work */
 if ( sqgetGlobalVar('account', $account, SQ_GET) ) {
   $account = (int) $account;
@@ -346,6 +352,7 @@ if ($aMailbox['EXISTS'] > 0) {
     $oTemplate->assign('color', $color);
     $oTemplate->assign('align', $align);
     $oTemplate->assign('checkall', $checkall);
+    $oTemplate->assign('preselected', $preselected);
 
     $oTemplate->display('message_list.tpl');
 

+ 5 - 4
templates/default/message_list.tpl

@@ -63,6 +63,7 @@
  *    $compact_paginator
  *    $aErrors
  *    $checkall
+ *    $preselected
  *
  * @copyright © 1999-2006 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -305,7 +306,7 @@ if ($pageOffset < $end_msg) {
         $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
     }
 
-    $class = ($checkall && $javascript_on && $fancy_index_highlite ? 'clicked_even' : 'even');
+    $class = (($checkall || in_array($iUid, $preselected)) && $javascript_on && $fancy_index_highlite ? 'clicked_even' : 'even');
     $non_clicked_class = 'even';
 
     /**
@@ -313,7 +314,7 @@ if ($pageOffset < $end_msg) {
      */
     if (isset($alt_index_colors) && $alt_index_colors) {
         if (!($i % 2)) {
-            $class = ($checkall && $javascript_on && $fancy_index_highlite ? 'clicked_odd' : 'odd');
+            $class = (($checkall || in_array($iUid, $preselected)) && $javascript_on && $fancy_index_highlite ? 'clicked_odd' : 'odd');
             $non_clicked_class = 'odd';
         }
 
@@ -324,7 +325,7 @@ if ($pageOffset < $end_msg) {
      */
     if (isset($aMsg['row']['color']))
     {
-    	if ($checkall && $javascript_on && $fancy_index_highlite) {
+    	if (($checkall || in_array($iUid, $preselected)) && $javascript_on && $fancy_index_highlite) {
 //FIXME: would be best not to use $color directly here; want to move this to be a CSS style-defined value only, but the problem is that this CSS class is being defined on the fly right here
     	    $bgcolor = $color[16];
     	    $class = 'clicked_misc'.$i;
@@ -432,7 +433,7 @@ if ($non_clicked_class != 'even' && $non_clicked_class != 'odd'
 
         switch ($iCol) {
           case SQM_COL_CHECK:
-            $checked = ($checkall ? ' checked="checked" ' : '');
+            $checked = (($checkall || in_array($iUid, $preselected)) ? ' checked="checked" ' : '');
             if ($javascript_on) {
                 echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
                 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript . $checked;?> /></td>