/**
  * the singleton pattern
  *
  * @return Expressomail_Controller_Message_Move
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new Expressomail_Controller_Message_Move();
     }
     return self::$_instance;
 }
 /**
  * move message test helper
  *
  * @param mixed $_toMove
  * @param Felamimail_Model_Folder $_folder
  */
 protected function _moveTestHelper($_toMove, $_folder)
 {
     Expressomail_Controller_Message_Move::getInstance()->moveMessages($_toMove, $_folder);
     $message = $this->_searchMessage('multipart/mixed', $_folder);
     $result = $this->_controller->search($this->_getFilter($folder->getId()));
     foreach ($result as $messageInCache) {
         if ($messageInCache->messageuid == $message['uid']) {
             $foundMessage = $messageInCache;
             break;
         }
     }
     $this->assertTrue(isset($foundMessage));
     $this->_createdMessages[] = $foundMessage;
     $completeMessage = $this->_controller->getCompleteMessage($foundMessage);
     $this->assertContains('The attached list notes all of the packages that were added or removed', $completeMessage->body);
 }
 /**
  * (non-PHPdoc)
  * @see ActiveSync_Frontend_Abstract::moveItem()
  */
 public function moveItem($srcFolderId, $serverId, $dstFolderId)
 {
     $folderBackend = Syncroton_Registry::get(Syncroton_Registry::FOLDERBACKEND);
     $srcFolder = $folderBackend->getFolder($this->_device, $srcFolderId);
     $dstFolder = $folderBackend->getFolder($this->_device, $dstFolderId);
     $bigContentId = $this->getBigContentId($srcFolder->id, $serverId);
     $filter = new Expressomail_Model_MessageFilter(array(array('field' => 'id', 'operator' => 'equals', 'value' => $bigContentId)));
     Expressomail_Controller_Message_Move::getInstance()->moveMessages($filter, $dstFolder->bigfolderid);
     return $serverId;
 }
 /**
  * move messsages to folder
  *
  * @param  array $filterData filter data
  * @param  string $targetFolderId
  * @return array source folder status
  */
 public function moveMessages($filterData, $targetFolderId)
 {
     // close session to allow other requests
     Expressomail_Session::getSessionNamespace()->lock();
     $filter = new Expressomail_Model_MessageFilter(array());
     $filter->setFromArrayInUsersTimezone($filterData);
     $updatedFolders = Expressomail_Controller_Message_Move::getInstance()->moveMessages($filter, $targetFolderId);
     $result = $updatedFolders !== NULL ? $this->_multipleRecordsToJson($updatedFolders) : array();
     return $result;
 }