/**
  * (non-PHPdoc)
  * @see Syncroton_Data_IDataSearch::search()
  */
 public function search(Syncroton_Model_StoreRequest $store)
 {
     $storeResponse = new Syncroton_Model_StoreResponse();
     if (!isset($store->query['and']) || !isset($store->query['and']['freeText'])) {
         $storeResponse->total = 0;
         return $storeResponse;
     }
     $filter = new $this->_contentFilterClass(array(array('field' => 'query', 'operator' => 'contains', 'value' => $store->query['and']['freeText'])));
     if (isset($store->query['and']['collections'])) {
         // @todo search for multiple folders
         $folderId = $store->query['and']['collections'][0];
     } else {
         $folderId = Felamimail_Controller_Folder::getInstance()->getByBackendAndGlobalName(Tinebase_Core::getPreference('Felamimail')->{Felamimail_Preference::DEFAULTACCOUNT}, 'INBOX')->getId();
     }
     $this->_addContainerFilter($filter, $folderId);
     if (isset($store->options['range'])) {
         $pagination = new Tinebase_Model_Pagination(array('start' => $store->options['range'][0], 'limit' => $store->options['range'][1] - $store->options['range'][0]));
     } else {
         $pagination = null;
     }
     $serverIds = $this->_contentController->search($filter, $pagination, false, true, 'sync');
     $totalCount = $this->_contentController->searchCount($filter, 'sync');
     foreach ($serverIds as $serverId) {
         $email = $this->getEntry(new Syncroton_Model_SyncCollection(array('collectionId' => $folderId, 'options' => $store->options)), $serverId);
         $storeResponse->result[] = new Syncroton_Model_StoreResponseResult(array('class' => 'Email', 'longId' => $folderId . ActiveSync_Frontend_Abstract::LONGID_DELIMITER . $serverId, 'collectionId' => $folderId, 'properties' => $email));
     }
     $storeResponse->total = $totalCount;
     if (count($storeResponse->result) > 0) {
         $storeResponse->range = array($store->options['range'][0], $store->options['range'][1]);
     }
     return $storeResponse;
 }
Esempio n. 2
0
 /**
  * get all entries changed between to dates
  *
  * @param unknown_type $_field
  * @param unknown_type $_startTimeStamp
  * @param unknown_type $_endTimeStamp
  * @return array
  */
 public function getChangedEntries($_folderId, DateTime $_startTimeStamp, DateTime $_endTimeStamp = NULL)
 {
     $filter = $this->_getContentFilter(0);
     $this->_addContainerFilter($filter, $_folderId);
     $startTimeStamp = $_startTimeStamp instanceof DateTime ? $_startTimeStamp->format(Tinebase_Record_Abstract::ISO8601LONG) : $_startTimeStamp;
     $endTimeStamp = $_endTimeStamp instanceof DateTime ? $_endTimeStamp->format(Tinebase_Record_Abstract::ISO8601LONG) : $_endTimeStamp;
     $filter->addFilter(new Tinebase_Model_Filter_DateTime('timestamp', 'after', $startTimeStamp));
     if ($endTimeStamp !== NULL) {
         $filter->addFilter(new Tinebase_Model_Filter_DateTime('timestamp', 'before', $endTimeStamp));
     }
     #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " filter " . print_r($filter->toArray(), true));
     $result = $this->_contentController->search($filter, NULL, false, true, 'sync');
     return $result;
 }
 /**
  * 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);
 }
Esempio n. 4
0
 /**
  * move message test helper
  *
  * @param mixed $_toMove
  * @param Felamimail_Model_Folder $_folder
  */
 protected function _moveTestHelper($_toMove, $_folder)
 {
     Felamimail_Controller_Message_Move::getInstance()->moveMessages($_toMove, $_folder);
     $message = $this->_searchMessage('multipart/mixed', $_folder);
     $folder = $this->_cache->updateCache($_folder, 30);
     while ($folder->cache_status === Felamimail_Model_Folder::CACHE_STATUS_INCOMPLETE) {
         $folder = $this->_cache->updateCache($folder, 30);
     }
     $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);
 }