Example #1
0
 /**
  * Detect special folder associations stored in storage backend
  */
 public function get_special_folders($forced = false)
 {
     $result = parent::get_special_folders();
     if (isset($this->icache['special-use'])) {
         return array_merge($result, $this->icache['special-use']);
     }
     if (!$forced || !$this->get_capability('SPECIAL-USE')) {
         return $result;
     }
     if (!$this->check_connection()) {
         return $result;
     }
     $types = array_map(function ($value) {
         return "\\" . ucfirst($value);
     }, rcube_storage::$folder_types);
     $special = array();
     // request \Subscribed flag in LIST response as performance improvement for folder_exists()
     $folders = $this->conn->listMailboxes('', '*', array('SUBSCRIBED'), array('SPECIAL-USE'));
     if (!empty($folders)) {
         foreach ($folders as $folder) {
             if ($flags = $this->conn->data['LIST'][$folder]) {
                 foreach ($types as $type) {
                     if (in_array($type, $flags)) {
                         $type = strtolower(substr($type, 1));
                         $special[$type] = $folder;
                     }
                 }
             }
         }
     }
     $this->icache['special-use'] = $special;
     unset($this->icache['special-folders']);
     return array_merge($result, $special);
 }