diff options
author | alecpl <alec@alec.pl> | 2011-01-04 10:48:27 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2011-01-04 10:48:27 +0000 |
commit | eabd44876c67239b1f27afc4acadf1d7e2001219 (patch) | |
tree | 0e81124059db3af5df4eaa03dc86eccded3a9547 /program | |
parent | 77437e70f9b40f5018607e1ea74dc367751dafd8 (diff) |
- Extend getCapability() to return caps values or true/false
Diffstat (limited to 'program')
-rw-r--r-- | program/include/rcube_imap_generic.php | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php index 9eeb028bf..b5fd96871 100644 --- a/program/include/rcube_imap_generic.php +++ b/program/include/rcube_imap_generic.php @@ -371,11 +371,44 @@ class rcube_imap_generic return false; } - function getCapability($name) + private function hasCapability($name) { + if (empty($this->capability) || $name == '') { + return false; + } + if (in_array($name, $this->capability)) { return true; } + else if (strpos($name, '=')) { + return false; + } + + $result = array(); + foreach ($this->capability as $cap) { + $entry = explode('=', $cap); + if ($entry[0] == $name) { + $result[] = $entry[1]; + } + } + + return !empty($result) ? $result : false; + } + + /** + * Capabilities checker + * + * @param string $name Capability name + * + * @return mixed Capability values array for key=value pairs, true/false for others + */ + function getCapability($name) + { + $result = $this->hasCapability($name); + + if (!empty($result)) { + return $result; + } else if ($this->capability_readed) { return false; } @@ -390,11 +423,7 @@ class rcube_imap_generic $this->capability_readed = true; - if (in_array($name, $this->capability)) { - return true; - } - - return false; + return $this->hasCapability($name); } function clearCapability() |