getFolder() 공개 메소드

Return an entry from the folder cache.
public getFolder ( string $folder ) : array | boolean
$folder string The folder id to return.
리턴 array | boolean The folder cache array entry, false if not found.
예제 #1
0
파일: Collections.php 프로젝트: horde/horde
 /**
  * Validate and perform some sanity checks on the hierarchy changes before
  * being sent to the client.
  *
  * @param Horde_ActiveSync_Connector_Exporter_FolderSync $exporter  The exporter.
  * @param array $seenFolders                             An array of folders.
  */
 public function validateHierarchyChanges(Horde_ActiveSync_Connector_Exporter_FolderSync $exporter, array $seenFolders)
 {
     if ($this->_as->device->version < Horde_ActiveSync::VERSION_TWELVEONE || count($exporter->changed)) {
         return;
     }
     // Remove unnecessary changes.
     foreach ($exporter->changed as $key => $folder) {
         if (isset($folder->serverid) && ($syncFolder = $this->_cache->getFolder($folder->serverid) && in_array($folder->serverid, $seenfolders) && $syncFolder['parentid'] == $folder->parentid && $syncFolder['displayname'] == $folder->displayname && $syncFolder['type'] == $folder->type)) {
             $this->_logger->info(sprintf('[%s] Ignoring %s from changes because it contains no changes from device.', $this->_procid, $folder->serverid));
             unset($exporter->changed[$key]);
             $exporter->count--;
         }
     }
     // Remove unnecessary deletions.
     foreach ($exporter->deleted as $key => $folder) {
         if (($sid = array_search($folder, $seenfolders)) === false) {
             $this->_logger->info(sprintf('[%s] Ignoring %s from deleted list because the device does not know it', $this->_procid, $folder));
             unset($exporter->deleted[$key]);
             $exporter->count--;
         }
     }
 }
예제 #2
0
 /**
  * Attempt to initialize the sync state.
  *
  * @param array $collection  The collection array.
  * @param boolean $requireSyncKey  Require collection to have a synckey and
  *                                 throw exception if it's not present.
  *
  * @throws Horde_ActiveSync_Exception_InvalidRequest
  */
 public function initCollectionState(array $collection, $requireSyncKey = false)
 {
     // Clear the changes cache.
     $this->_changes = null;
     if (empty($collection['class'])) {
         if (!empty($this->_collections[$collection['id']])) {
             $collection['class'] = $this->_collections[$collection['id']]['class'];
         } else {
             throw new Horde_ActiveSync_Exception_FolderGone('Could not load collection class for ' . $collection['id']);
         }
     }
     // Get the backend serverid.
     if (empty($collection['serverid'])) {
         $f = $this->_cache->getFolder($collection['id']);
         $collection['serverid'] = $f['serverid'];
     }
     if ($requireSyncKey && empty($collection['synckey'])) {
         throw new Horde_ActiveSync_Exception_InvalidRequest(sprintf('[%s] Empty synckey for %s.', $this->_procid, $collection['id']));
     }
     // Initialize the state
     $this->_logger->info(sprintf('[%s] Initializing state for collection: %s, synckey: %s', $this->_procid, $collection['serverid'], $collection['synckey']));
     $this->_as->state->loadState($collection, $collection['synckey'], Horde_ActiveSync::REQUEST_TYPE_SYNC, $collection['id']);
 }
예제 #3
0
파일: Base.php 프로젝트: horde/horde
 protected function _testCacheFoldersPersistence()
 {
     $cache = new Horde_ActiveSync_SyncCache(self::$state, 'dev123', 'mike', self::$logger->getLogger());
     $expected = array('@Contacts@' => array('class' => 'Contacts', 'serverid' => '@Contacts@', 'type' => 9), '519422f1-4c5c-4547-946a-1701c0a8015f' => array('class' => 'Email', 'serverid' => 'INBOX', 'type' => 2));
     $this->assertEquals($expected, $cache->getFolders());
     $expected = array('class' => 'Email', 'serverid' => 'INBOX', 'type' => 2);
     $this->assertEquals($expected, $cache->getFolder('519422f1-4c5c-4547-946a-1701c0a8015f'));
 }