Horde_Kolab_Storage_List_Query_List_Cache_Synchronization::setDefault PHP Method

setDefault() public method

Set the specified folder as default for its current type.
public setDefault ( array $folder, string | boolean $previous = false )
$folder array The folder data.
$previous string | boolean The previous default folder or false if there was none.
    public function setDefault($folder, $previous = false)
    {
        if (!$this->_cache->hasNamespace()) {
            // Cache not synchronized yet.
            return;
        }
        if ($folder['namespace'] !== Horde_Kolab_Storage_Folder_Namespace::PERSONAL) {
            throw new Horde_Kolab_Storage_List_Exception(sprintf("Unable to mark %s as a default folder. It is not within your personal namespace!", $folder['folder']));
        }
        $annotations = $this->_cache->getFolderTypes();
        if (!isset($annotations[$folder['folder']])) {
            throw new Horde_Kolab_Storage_List_Exception(sprintf("The folder %s has no Kolab type. It cannot be marked as 'default' folder!", $folder['folder']));
        }
        if ($previous) {
            $this->_driver->setAnnotation($previous, Horde_Kolab_Storage_List_Query_List::ANNOTATION_FOLDER_TYPE, $folder['type']);
            $annotations[$previous] = $folder['type'];
        }
        $this->_driver->setAnnotation($folder['folder'], Horde_Kolab_Storage_List_Query_List::ANNOTATION_FOLDER_TYPE, $folder['type'] . '.default');
        $annotations[$folder['folder']] = $folder['type'] . '.default';
        $folder_list = $this->_cache->getFolders();
        $namespace = unserialize($this->_cache->getNamespace());
        $this->_synchronize($namespace, $folder_list, $annotations);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Set the specified folder as default for its current type.
  *
  * @param string $folder The folder name.
  */
 public function setDefault($folder)
 {
     $data = $this->folderData($folder);
     $this->_sync->setDefault($data, $this->getDefault($data['type']));
 }
All Usage Examples Of Horde_Kolab_Storage_List_Query_List_Cache_Synchronization::setDefault