Have flagEntry() accept an IMP_Indices object
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 17 Dec 2010 09:11:31 +0000 (02:11 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 17 Dec 2010 09:17:39 +0000 (02:17 -0700)
imp/lib/Ajax/Application.php
imp/message-dimp.php

index 97e8785..0708cff 100644 (file)
@@ -728,9 +728,9 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
         }
 
         $result = new stdClass;
-        list($mbox, $uids) = $indices->getSingle(true);
-        $result->flag = $this->flagEntry($flags, $this->_vars->add, $mbox, $uids);
+        $result->flag = $this->flagEntry($flags, $this->_vars->add, $indices);
 
+        list($mbox,) = $indices->getSingle();
         if (in_array('\\seen', $flags) && ($poll = $this->pollEntry($mbox))) {
             $result->poll = $poll;
         }
@@ -999,7 +999,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
             }
 
             /* Add changed flag information. */
-            $result->flag = $this->flagEntry(array('\\seen'), true, $mbox, $idx);
+            $result->flag = $this->flagEntry(array('\\seen'), true, $indices);
         } catch (Horde_Imap_Client_Exception $e) {
             $result->preview->error = $e->getMessage();
             $result->preview->errortype = 'horde.error';
@@ -1742,13 +1742,13 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
 
         switch ($imp_compose->getMetadata('reply_type')) {
         case 'forward':
-            $result->flag = $this->flagEntry(array('$forwarded'), true, $result->mbox, $result->uid);
+            $result->flag = $this->flagEntry(array('$forwarded'), true, new IMP_Indices($result->mbox, $result->uid));
             break;
 
         case 'reply':
         case 'reply_all':
         case 'reply_list':
-            $result->flag = $this->flagEntry(array('\\answered'), true, $result->mbox, $result->uid);
+            $result->flag = $this->flagEntry(array('\\answered'), true, new IMP_Indices($result->mbox, $result->uid));
             break;
         }
 
@@ -1812,10 +1812,10 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
     /**
      * Generate flag updated entry.
      *
-     * @param array $flags  List of flags that have changed.
-     * @param boolean $add  Were the flags added?
-     * @param string $mbox  Mailbox where flags changed.
-     * @param string $uids  IMAP UIDs of the changed flags.
+     * @param array $flags    List of flags that have changed.
+     * @param boolean $add    Were the flags added?
+     * @param mixed $indices  Either a mailbox string or an IMP_Indices
+     *                        object.
      *
      * @return stdClass  Object with these properties:
      * <pre>
@@ -1827,7 +1827,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
      *          changed.
      * </pre>
      */
-    static public function flagEntry($flags, $add, $mbox, $uids = null)
+    static public function flagEntry($flags, $add, $indices)
     {
         $changed = $GLOBALS['injector']->getInstance('IMP_Flags')->changed($flags, $add);
 
@@ -1835,12 +1835,15 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
         if (!empty($changed['add'])) {
             $result->add = array_map('strval', $changed['add']);
         }
-        $result->mbox = $mbox;
         if (!empty($changed['remove'])) {
             $result->remove = array_map('strval', $changed['remove']);
         }
-        if (!is_null($uids)) {
-            $result->uids = strval(new IMP_Indices($mbox, $uids));
+
+        if ($indices instanceof IMP_Indices) {
+            list($result->mbox,) = $indices->getSingle();
+            $result->uids = strval($indices);
+        } else {
+            $result->mbox = $indices;
         }
 
         return $result;
index 2c3bf84..618caf1 100644 (file)
@@ -68,7 +68,7 @@ foreach (array('from', 'to', 'cc', 'bcc', 'replyTo', 'log', 'uid', 'mailbox') as
     }
 }
 
-$js_vars['DimpMessage.flag'] = IMP_Ajax_Application::flagEntry(array('\\seen'), true, $vars->folder, $vars->uid);
+$js_vars['DimpMessage.flag'] = IMP_Ajax_Application::flagEntry(array('\\seen'), true, new IMP_Indices($vars->folder, $vars->uid));
 
 if ($poll = IMP_Ajax_Application::pollEntry($vars->folder)) {
     $js_vars['DimpMessage.poll'] = $poll;