فهرست منبع

Updated filters plugin to work with UID support.
Made main header block look prettier in message view.

thomppj 23 سال پیش
والد
کامیت
78d3542acb
3فایلهای تغییر یافته به همراه68 افزوده شده و 61 حذف شده
  1. 39 33
      plugins/filters/filters.php
  2. 8 11
      plugins/listcommands/setup.php
  3. 21 17
      src/read_body.php

+ 39 - 33
plugins/filters/filters.php

@@ -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);
             }
         }
     }

+ 8 - 11
plugins/listcommands/setup.php

@@ -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>";
     }
 }
 

+ 21 - 17
src/read_body.php

@@ -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>';