Updated filters plugin to work with UID support.
authorthomppj <thomppj@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 15 Aug 2002 04:20:42 +0000 (04:20 +0000)
committerthomppj <thomppj@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 15 Aug 2002 04:20:42 +0000 (04:20 +0000)
Made main header block look prettier in message view.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3306 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/filters/filters.php
plugins/listcommands/setup.php
src/read_body.php

index 8b017c968bbfa85e21d79677a218523ed721fd54..0a022e1af5e0416f15eeab7ac3463f6ab3ac7812 100644 (file)
@@ -249,6 +249,7 @@ function start_filters() {
         $imap_general, $filters, $imap_stream, $imapConnection,
     $UseSeparateImapConnection, $AllowSpamFilters;
 
+# We really want to do this for ALL mailbox.
 #    if ($mailbox == 'INBOX') {
         // Detect if we have already connected to IMAP or not.
         // Also check if we are forced to use a separate IMAP connection
@@ -290,47 +291,57 @@ function user_filters($imap_stream) {
 
     sqimap_mailbox_select($imap_stream, 'INBOX');
 
-    // For every rule
+    /* For every rule */
     for ($i=0; $i < count($filters); $i++) {
         // If it is the "combo" rule
         if ($filters[$i]['where'] == 'To or Cc') {
-            /*
-            *  If it's "TO OR CC", we have to do two searches, one for TO
-            *  and the other for CC.
-            */
-            filter_search_and_delete($imap_stream, 'TO',
-            $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan);
-            filter_search_and_delete($imap_stream, 'CC',
-            $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan);
+
+            /* If it's "TO OR CC", we have to do two     */
+            /* searches one for TO and the other for CC. */
+            filter_search_and_delete($imap_stream,
+                                     'TO',
+                                     $filters[$i]['what'],
+                                     $filters[$i]['folder'],
+                                     $filters_user_scan);
+            filter_search_and_delete($imap_stream,
+                                     'CC',
+                                     $filters[$i]['what'],
+                                     $filters[$i]['folder'],
+                                     $filters_user_scan);
         } else {
-            /*
-            *  If it's a normal TO, CC, SUBJECT, or FROM, then handle it
-            *  normally.
-            */
-            filter_search_and_delete($imap_stream, $filters[$i]['where'],
-            $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan);
+
+            /* If it's a normal TO, CC, SUBJECT, */
+            /* or FROM, then handle it normally. */
+            filter_search_and_delete($imap_stream,
+                                     $filters[$i]['where'],
+                                     $filters[$i]['what'],
+                                     $filters[$i]['folder'],
+                                     $filters_user_scan);
         }
     }
-    // Clean out the mailbox whether or not auto_expunge is on
-    // That way it looks like it was redirected properly
+
+    /* Clean out the mailbox whether or not auto_expunge is */
+    /* on That way it looks like it was redirected properly */
     sqimap_mailbox_expunge($imap_stream, 'INBOX');
 }
 
 function filter_search_and_delete($imap, $where, $what, $where_to, $user_scan) {
-    global $languages, $squirrelmail_language, $allow_charset_search;
+    global $languages, $squirrelmail_language, $allow_charset_search,
+           $uid_support;
     if ($user_scan == 'new') {
         $category = 'UNSEEN';
     } else {
         $category = 'ALL';
     }
 
-    if ($allow_charset_search && isset($languages[$squirrelmail_language]['CHARSET']) &&
-        $languages[$squirrelmail_language]['CHARSET']) {
-        $search_str = "SEARCH CHARSET "
+    if ($allow_charset_search
+     && isset($languages[$squirrelmail_language]['CHARSET'])
+     && $languages[$squirrelmail_language]['CHARSET']) {
+        $search_str = 'SEARCH CHARSET "'
             . strtoupper($languages[$squirrelmail_language]['CHARSET']) 
-            . ' ' . $category . ' ';
+            . '" ' . $category . ' ';
     } else {
-        $search_str = 'SEARCH CHARSET US-ASCII ' . $category . ' ';
+        $search_str = 'SEARCH CHARSET "US-ASCII" ' . $category . ' ';
     }
     if ($where == "Header") {
        $what = explode(':', $what);
@@ -338,21 +349,16 @@ function filter_search_and_delete($imap, $where, $what, $where_to, $user_scan) {
        $what = addslashes(trim($what[1]));
     }
     $search_str .= $where . ' {' . strlen($what) . "}\r\n" . $what . "\r\n";
-    
-    fputs ($imap, "a001 $search_str");
-    $read = filters_sqimap_read_data ($imap, 'a001', true, $response, $message);
-
-    // This may have problems with EIMS due to it being goofy
+    $readin = sqimap_run_command($imap, $search_str, false, $result, $message, $uid_support);
 
-    for ($r=0; $r < count($read) &&
-                substr($read[$r], 0, 8) != '* SEARCH'; $r++) {}
-    if ($response == 'OK') {
-        $ids = explode(' ', $read[$r]);
+    for ($r=0; $r < count($readin) && substr($readin[$r], 0, 8) != '* SEARCH'; ++$r) {}
+    if ($result == 'OK') {
+        $ids = explode(' ', $readin[$r]);
         if (sqimap_mailbox_exists($imap, $where_to)) {
             for ($j=2; $j < count($ids); $j++) {
                 $id = trim($ids[$j]);
                 sqimap_messages_copy ($imap, $id, $id, $where_to);
-                sqimap_messages_flag ($imap, $id, $id, 'Deleted');
+                sqimap_messages_flag ($imap, $id, $id, 'Deleted', true);
             }
         }
     }
index 07e9f7040bd0504d8e7e5867ee4067b5bc3238fb..9fbc1bf43f4a45758829ae2c162752e988f12cf0 100644 (file)
@@ -70,26 +70,23 @@ function plugin_listcommands_menu() {
                 $url .= '&amp;action=reply';
                 if ($compose_new_win == '1') {
                     $output[] = "<A HREF=\"javascript:void(0)\" onClick=\"comp_in_new('$url')\">" . $fieldsdescr['reply'] . '</A>';
-                }
-                else {
+                } else {
                     $output[] = '<A HREF="' . $url . '">' . $fieldsdescr['reply'] . '</A>';
                 }
             }
-        } elseif ($proto == 'href') {
+        } else if ($proto == 'href') {
             $output[] = '<A HREF="' . $act . '" TARGET="_blank">'
                       . $fieldsdescr[$cmd] . '</A>';
         }
     }
 
     if (count($output) > 0) {
-        echo '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
-             ' border="0" bgcolor="'.$color[0].'">'. "\n";
-        echo '<tr>';
-        echo html_tag( 'td', '<b>'._("Mailing List").':&nbsp;&nbsp;</b>', 'right', $color[0], 'valign="top" width="20%"') . "\n";
-        echo html_tag( 'td', 
-                '<small>' . implode('&nbsp;|&nbsp;', $output) . '</small>', 'left', $color[0], 'valign="top" width="80%"');
-        echo "\n</tr>";
-       echo '</table>'."\n";
+        echo '<TR>';
+        echo html_tag('TD', '<B>' . _("Mailing List") . ':&nbsp;&nbsp;</B>',
+                      'right', '', 'VALIGN="MIDDLE" WIDTH="20%"') . "\n";
+        echo html_tag('TD', '<SMALL>' . implode('&nbsp;|&nbsp;', $output) . '</small>',
+                      'left', $color[0], 'VALIGN="MIDDLE" WIDTH="80%"') . "\n";
+        echo "</TR>";
     }
 }
 
index ef50b070b5e69f717af3b3a483d277e8a9ba8a4e..7dcc7ae31cf0819933de4031f729944847c000fa 100644 (file)
@@ -364,18 +364,21 @@ function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
       }                 
    }
 
-   $s = '<table width="100%" cellpadding="0" cellspacing="0" border="0" ' .
-        'align="center">';
+/* BOOKMARK */
+   $s  = '<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"';
+   $s .=       ' ALIGN="center" BGCOLOR="' . $color[0] . '">';
    foreach ($env as $key => $val) {
      if ($val) {      
-        $s .= '<tr>';
-        $s .=  html_tag( 'td', '<b>'.$key.':&nbsp;&nbsp;</b>', 'right', $color[0], 'valign="top" width="20%"') . "\n";
-        $s .=  html_tag( 'td', $val, 'left', $color[0], 'valign="top" width="80%"');
-        $s .=  "\n</tr>";
+        $s .= '<TR>';
+        $s .=   html_tag('TD', '<B>' . $key . ':&nbsp;&nbsp;</B>', 'RIGHT', '', 'VALIGN="MIDDLE" WIDTH="20%"') . "\n";
+        $s .=   html_tag('TD', $val, 'left', '', 'VALIGN="MIDDLE" WIDTH="80%"') . "\n";
+        $s .= '</TR>';
      }
    }
-   $s .= '</table>';
    echo $s;
+   do_hook("read_body_header");   
+   formatToolbar($mailbox,$passed_id,$passed_ent_id,$message, $color);
+   echo '</table>';
 }           
 
 function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) {
@@ -503,18 +506,21 @@ function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
    global $QUERY_STRING, $base_uri;
    
    $urlMailbox = urlencode($mailbox);
-   $s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
-         ' border="0" bgcolor="'.$color[9].'">'. "\n".
-        '<tr align="right"><td valign="top" align="right"><small>';
    $url = $base_uri.'src/view_header.php?'.$QUERY_STRING;
+
+/* BOOKMARK */
+   $s  = "<TR>\n";
+   $s .= '<TD VALIGN="MIDDLE" ALIGN="RIGHT"><B>' . _("Other") . ":&nbsp;&nbsp;</B></TD>\n";
+   $s .= '<TD VALIGN="MIDDLE" ALIGN="LEFT"><SMALL>';
    $s .= '<a href="'.$url.'">'.("View Full Header").'</a>';
-  /* Output the printer friendly link if we are in subtle mode. */
-   $s .= '&nbsp;|&nbsp;'. 
-         printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color);
+
+   /* Output the printer friendly link if we are in subtle mode. */
+   $s .= '&nbsp;|&nbsp;';
+   $s .= printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color);
+   $s .= "</SMALL></TD>\n";
+   $s .= "</TR>\n";
    echo $s;
    do_hook("read_body_header_right");
-   echo '</small></td></tr>';
-   echo '</table>'."\n";
 }
 
 
@@ -621,8 +627,6 @@ displayPageHeader($color, $mailbox);
 do_hook('read_body_top');
 formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response);
 formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
-do_hook("read_body_header");   
-formatToolbar($mailbox,$passed_id,$passed_ent_id,$message, $color);
 echo '<table width="100%" cellpadding="3" cellspacing="3" align="center"'.
       ' border="0" bgcolor="'.$color[4].'">';
 echo '<tr><td>'.$messagebody.'</td></tr>';