}
$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;
}
}
/* 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';
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;
}
/**
* 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>
* 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);
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;