moveMessage() public method

Move a mail message
public moveMessage ( string $folderid, array $ids, string $newfolderid ) : array
$folderid string The existing folderid.
$ids array The message UIDs of the messages to move.
$newfolderid string The folder id to move $id to.
return array An hash of oldUID => newUID.
Example #1
0
 /**
  * Move message
  *
  * @param string $folderid     Existing folder id.
  * @param array $ids           Message UIDs to move. @todo For H6 this
  *                             should take a single id. We can't bulk
  *                             move them for other reasons.
  * @param string $newfolderid  The new folder id to move to.
  *
  * @return array  An array of successfully moved messages with
  *                the old UIDs as keys and new UIDs as values.
  *
  * @throws Horde_ActiveSync_Exception
  */
 public function moveMessage($folderid, array $ids, $newfolderid)
 {
     $this->_logger->info(sprintf("[%s] Horde_Core_ActiveSync_Driver::moveMessage(%s, [%s], %s)", $this->_pid, $folderid, implode(',', $ids), $newfolderid));
     $parts = $this->_parseFolderId($folderid);
     if (is_array($parts)) {
         $folder_class = $parts[self::FOLDER_PART_CLASS];
         $folder_id = $parts[self::FOLDER_PART_ID];
     } else {
         $folder_class = $parts;
         $folder_id = null;
     }
     $move_res = array();
     ob_start();
     switch ($folder_class) {
         case Horde_ActiveSync::CLASS_CALENDAR:
             $parts = $this->_parseFolderId($newfolderid);
             if (is_array($parts)) {
                 $newfolderid = $parts[self::FOLDER_PART_ID];
             }
             if ($res = $this->_connector->calendar_move(array_pop($ids), $folder_id, $newfolderid)) {
                 $move_res[$res] = $res;
             }
             break;
         case Horde_ActiveSync::CLASS_CONTACTS:
         case Horde_ActiveSync::CLASS_TASKS:
         case Horde_ActiveSync::CLASS_NOTES:
             $this->_endBuffer();
             // Not supported, so just drop through to return the empty array.
             break;
         default:
             $move_res = $this->_imap->moveMessage($folderid, $ids, $newfolderid);
     }
     $this->_endBuffer();
     return $move_res;
 }
Example #2
0
 /**
  * Move message
  *
  * @param string $folderid     Existing folder id.
  * @param array $ids           Message UIDs to move.
  * @param string $newfolderid  The new folder id to move to.
  *
  * @return array  An array of successfully moved messages.
  * @throws Horde_Exception
  */
 public function moveMessage($folderid, array $ids, $newfolderid)
 {
     $this->_logger->info(sprintf("[%s] Horde_Core_ActiveSync_Driver::moveMessage(%s, [%s], %s)", $this->_pid, $folderid, implode(',', $ids), $newfolderid));
     ob_start();
     switch ($folderid) {
         case self::APPOINTMENTS_FOLDER_UID:
         case self::CONTACTS_FOLDER_UID:
         case self::TASKS_FOLDER_UID:
         case self::NOTES_FOLDER_UID:
             $this->_endBuffer();
             throw new Horde_ActiveSync_Exception('Not supported');
         default:
             $move_res = $this->_imap->moveMessage($folderid, $ids, $newfolderid);
     }
     $this->_endBuffer();
     return $move_res;
 }