Add compatibility with Dovecot's bigint UIDs
[squirrelmail.git] / functions / mailbox_display.php
index 987e0ff485395ddade1cddcced6b94adebc2eb49..9fb3725cf0ffbbed200071e9f0c018736a8a7b6f 100644 (file)
@@ -1334,6 +1334,11 @@ function handleMessageListForm($imapConnection, &$aMailbox, $sButton='',
     /* retrieve the check boxes */
     $aUid = (isset($msg) && is_array($msg)) ? array_values($msg) : $aUid;
     if (count($aUid) && $sButton != 'expunge') {
+
+        // make sure message UIDs are sanitized (BIGINT)
+        foreach ($aUid as $i => $uid)
+           $aUid[$i] = (preg_match('/^[0-9]+$/', $uid) ? $uid : '0');
+
         $aUpdatedMsgs = false;
         $bExpunge = false;
         switch ($sButton) {
@@ -1381,7 +1386,8 @@ function handleMessageListForm($imapConnection, &$aMailbox, $sButton='',
             break;
           default:
              // Hook for plugin buttons
-             do_hook('mailbox_display_button_action', $aUid);
+             $temp = array(&$sButton, &$aMailbox, $iAccount, $aMailbox['NAME'], &$aUid);
+             do_hook('mailbox_display_button_action', $temp);
              break;
         }
         /**
@@ -1490,7 +1496,15 @@ function handleMessageListForm($imapConnection, &$aMailbox, $sButton='',
             sqimap_run_command($imapConnection,'CLOSE',false,$result,$message);
             $aMailbox = sqm_api_mailbox_select($imapConnection,$iAccount, $aMailbox['NAME'],array(),array());
         } else {
-            if ($sButton) {
+            // this is the same hook as above, but here it is called in the
+            // context of not having had any messages selected and if any
+            // plugin handles the situation, it should return TRUE so we
+            // know this was not an erroneous user action
+            //
+            global $null;
+            $temp = array(&$sButton, &$aMailbox, $iAccount, $aMailbox['NAME'], $null);
+            if (!boolean_hook_function('mailbox_display_button_action', $temp, 1)
+             && $sButton) {
                 $sError = _("No messages were selected.");
             }
         }
@@ -1549,8 +1563,7 @@ function attachSelectedMessages($imapConnection,$aMsgHeaders) {
             fwrite ($fp, $body);
             fclose($fp);
 
-            $composeMessage->initAttachment('message/rfc822',$subject.'.eml',
-                 $filename);
+            $composeMessage->initAttachment('message/rfc822', $subject . '.eml', $filename);
         }
     }