Skip to content

Commit

Permalink
Backend support for sending/receiving EAS mail category changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Aug 7, 2014
1 parent 9f1c0a1 commit 1162b29
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
20 changes: 17 additions & 3 deletions framework/Core/lib/Horde/Core/ActiveSync/Driver.php
Expand Up @@ -1093,14 +1093,17 @@ public function getServerChanges(
'flags' => Horde_ActiveSync::FLAG_NEWMESSAGE);
}

// For CLASS_EMAIL, all changes are a change in flags or softdelete.
// For CLASS_EMAIL, all changes are a change in flags, categories or
// softdelete.
if ($folder->collectionClass() == Horde_ActiveSync::CLASS_EMAIL) {
$flags = $folder->flags();
$categories = $folder->categories();
foreach ($changes['modify'] as $uid) {
$results[] = array(
'id' => $uid,
'type' => Horde_ActiveSync::CHANGE_TYPE_FLAGS,
'flags' => $flags[$uid]
'flags' => $flags[$uid],
'categories' => $categories[$uid]
);
}
} else {
Expand Down Expand Up @@ -1608,6 +1611,11 @@ public function moveMessage($folderid, array $ids, $newfolderid)
* @since 2.5.0
*
* @return array|boolean A stat array if successful, otherwise false.
* Contains the following keys:
* - id: (mixed) The UID of the message/item.
* - mod: (mixed) A value to indicate the last modification.
* - flags: (array) an empty array if no flag changes.
* - categories: (array|boolean) false if no changes.
*/
public function changeMessage($folderid, $id, Horde_ActiveSync_Message_Base $message, $device)
{
Expand Down Expand Up @@ -1737,7 +1745,8 @@ public function changeMessage($folderid, $id, Horde_ActiveSync_Message_Base $mes
$stat = array(
'id' => $id,
'mod' => 0,
'flags' => array()
'flags' => array(),
'categories' => false
);
if ($message->read !== '') {
$this->setReadFlag($folderid, $id, $message->read);
Expand All @@ -1749,6 +1758,11 @@ public function changeMessage($folderid, $id, Horde_ActiveSync_Message_Base $mes
$this->_imap->setMessageFlag($folderid, $id, $message->flag);
$stat['flags'] = array_merge($stat['flags'], array('flagged' => $message->flag->flagstatus));
}
if ($message->propertyExists('categories')) {
//$this->_connector->ensureMessageFlags($message->categories);
$this->_imap->categoriesToFlags($folderid, $message->categories, $id);
$stat['categories'] = $message->categories;
}
} else {
$this->_endBuffer();
return false;
Expand Down
18 changes: 18 additions & 0 deletions framework/Core/lib/Horde/Core/ActiveSync/Imap/Factory.php
Expand Up @@ -125,4 +125,22 @@ public function getSpecialMailboxes()
return $this->_specialMailboxlist;
}

/**
* Return a list of user-defined flags.
*
* @return array An array of flags.
*/
public function getMsgFlags()
{
global $registry;

$msgFlags = array();
$flags = unserialize($registry->horde->getPreference($registry->hasInterface('mail'), 'msgflags'));
foreach ($flags as $flag) {
$msgFlags[] = $flag->imapflag;
}

return $msgFlags;
}

}

0 comments on commit 1162b29

Please sign in to comment.