Changeset View
Changeset View
Standalone View
Standalone View
plugins/libkolab/lib/kolab_storage_folder_api.php
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | abstract class kolab_storage_folder_api | ||||
*/ | */ | ||||
public $default = false; | public $default = false; | ||||
/** | /** | ||||
* List of direct child folders | * List of direct child folders | ||||
* @var array | * @var array | ||||
*/ | */ | ||||
public $children = array(); | public $children = array(); | ||||
/** | /** | ||||
* Name of the parent folder | * Name of the parent folder | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
public $parent = ''; | public $parent = ''; | ||||
protected $imap; | protected $imap; | ||||
protected $owner; | protected $owner; | ||||
protected $info; | protected $info; | ||||
protected $idata; | protected $idata; | ||||
protected $namespace; | protected $namespace; | ||||
protected $metadata; | |||||
/** | /** | ||||
* Private constructor | * Private constructor | ||||
*/ | */ | ||||
protected function __construct($name) | protected function __construct($name) | ||||
{ | { | ||||
$this->name = $name; | $this->name = $name; | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | abstract class kolab_storage_folder_api | ||||
* Getter for the name of the namespace to which the IMAP folder belongs | * Getter for the name of the namespace to which the IMAP folder belongs | ||||
* | * | ||||
* @return string Name of the namespace (personal, other, shared) | * @return string Name of the namespace (personal, other, shared) | ||||
*/ | */ | ||||
public function get_namespace() | public function get_namespace() | ||||
{ | { | ||||
if (!isset($this->namespace)) | if (!isset($this->namespace)) | ||||
$this->namespace = $this->imap->folder_namespace($this->name); | $this->namespace = $this->imap->folder_namespace($this->name); | ||||
return $this->namespace; | return $this->namespace; | ||||
} | } | ||||
/** | /** | ||||
* Get the display name value of this folder | * Get the display name value of this folder | ||||
* | * | ||||
* @return string Folder name | * @return string Folder name | ||||
*/ | */ | ||||
public function get_name() | public function get_name() | ||||
{ | { | ||||
return kolab_storage::object_name($this->name, $this->get_namespace()); | return kolab_storage::object_name($this->name); | ||||
} | } | ||||
/** | /** | ||||
* Getter for the top-end folder name (not the entire path) | * Getter for the top-end folder name (not the entire path) | ||||
* | * | ||||
* @return string Name of this folder | * @return string Name of this folder | ||||
*/ | */ | ||||
public function get_foldername() | public function get_foldername() | ||||
{ | { | ||||
$parts = explode('/', $this->name); | $parts = explode('/', $this->name); | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | abstract class kolab_storage_folder_api | ||||
* Get the color value stored in metadata | * Get the color value stored in metadata | ||||
* | * | ||||
* @param string Default color value to return if not set | * @param string Default color value to return if not set | ||||
* @return mixed Color value from IMAP metadata or $default is not set | * @return mixed Color value from IMAP metadata or $default is not set | ||||
*/ | */ | ||||
public function get_color($default = null) | public function get_color($default = null) | ||||
{ | { | ||||
// color is defined in folder METADATA | // color is defined in folder METADATA | ||||
$metadata = $this->get_metadata(array(kolab_storage::COLOR_KEY_PRIVATE, kolab_storage::COLOR_KEY_SHARED)); | $metadata = $this->get_metadata(); | ||||
if (($color = $metadata[kolab_storage::COLOR_KEY_PRIVATE]) || ($color = $metadata[kolab_storage::COLOR_KEY_SHARED])) { | if (($color = $metadata[kolab_storage::COLOR_KEY_PRIVATE]) || ($color = $metadata[kolab_storage::COLOR_KEY_SHARED])) { | ||||
return $color; | return $color; | ||||
} | } | ||||
return $default; | return $default; | ||||
} | } | ||||
/** | /** | ||||
* Returns IMAP metadata/annotations (GETMETADATA/GETANNOTATION) | * Returns IMAP metadata/annotations (GETMETADATA/GETANNOTATION) | ||||
* supported by kolab_storage | |||||
* | * | ||||
* @param array List of metadata keys to read | |||||
* @return array Metadata entry-value hash array on success, NULL on error | * @return array Metadata entry-value hash array on success, NULL on error | ||||
*/ | */ | ||||
public function get_metadata($keys) | public function get_metadata() | ||||
{ | { | ||||
$metadata = rcube::get_instance()->get_storage()->get_metadata($this->name, (array)$keys); | if ($this->metadata === null) { | ||||
return $metadata[$this->name]; | $this->metadata = kolab_storage::folder_metadata($this->name); | ||||
} | } | ||||
return $this->metadata; | |||||
} | |||||
/** | /** | ||||
* Sets IMAP metadata/annotations (SETMETADATA/SETANNOTATION) | * Sets IMAP metadata/annotations (SETMETADATA/SETANNOTATION) | ||||
* | * | ||||
* @param array $entries Entry-value array (use NULL value as NIL) | * @param array $entries Entry-value array (use NULL value as NIL) | ||||
* @return boolean True on success, False on failure | * @return boolean True on success, False on failure | ||||
*/ | */ | ||||
public function set_metadata($entries) | public function set_metadata($entries) | ||||
{ | { | ||||
$this->metadata = null; | |||||
return $this->imap->set_metadata($this->name, $entries); | return $this->imap->set_metadata($this->name, $entries); | ||||
} | } | ||||
/** | /** | ||||
* | * | ||||
*/ | */ | ||||
public function get_folder_info() | public function get_folder_info() | ||||
{ | { | ||||
if (!isset($this->info)) | if (!isset($this->info)) | ||||
$this->info = $this->imap->folder_info($this->name); | $this->info = $this->imap->folder_info($this->name); | ||||
return $this->info; | return $this->info; | ||||
} | } | ||||
/** | /** | ||||
* Make IMAP folder data available for this folder | * Make IMAP folder data available for this folder | ||||
*/ | */ | ||||
public function get_imap_data() | public function get_imap_data() | ||||
{ | { | ||||
if (!isset($this->idata)) | if (!isset($this->idata)) | ||||
$this->idata = $this->imap->folder_data($this->name); | $this->idata = $this->imap->folder_data($this->name); | ||||
return $this->idata; | return $this->idata; | ||||
} | } | ||||
/** | |||||
* Returns (full) type of IMAP folder | |||||
* | |||||
* @return string Folder type | |||||
*/ | |||||
public function get_type() | |||||
{ | |||||
$metadata = $this->get_metadata(); | |||||
if (!empty($metadata)) { | |||||
return kolab_storage::folder_select_metadata($metadata); | |||||
} | |||||
return $this->type; | |||||
} | |||||
/** | /** | ||||
* Get IMAP ACL information for this folder | * Get IMAP ACL information for this folder | ||||
* | * | ||||
* @return string Permissions as string | * @return string Permissions as string | ||||
*/ | */ | ||||
public function get_myrights() | public function get_myrights() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | abstract class kolab_storage_folder_api | ||||
* | * | ||||
* @return string Full IMAP folder name | * @return string Full IMAP folder name | ||||
*/ | */ | ||||
public function __toString() | public function __toString() | ||||
{ | { | ||||
return $this->name; | return $this->name; | ||||
} | } | ||||
} | } | ||||