Changeset 4388 in subversion


Ignore:
Timestamp:
Jan 4, 2011 5:48:27 AM (2 years ago)
Author:
alec
Message:
  • Extend getCapability() to return caps values or true/false
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcube_imap_generic.php

    r4384 r4388  
    372372    } 
    373373 
    374     function getCapability($name) 
    375     { 
     374    private function hasCapability($name) 
     375    { 
     376        if (empty($this->capability) || $name == '') { 
     377            return false; 
     378        } 
     379 
    376380        if (in_array($name, $this->capability)) { 
    377381            return true; 
     382        } 
     383        else if (strpos($name, '=')) { 
     384            return false; 
     385        } 
     386 
     387        $result = array(); 
     388        foreach ($this->capability as $cap) { 
     389            $entry = explode('=', $cap); 
     390            if ($entry[0] == $name) { 
     391                $result[] = $entry[1]; 
     392            } 
     393        } 
     394 
     395        return !empty($result) ? $result : false; 
     396    } 
     397 
     398    /** 
     399     * Capabilities checker 
     400     * 
     401     * @param string $name Capability name 
     402     * 
     403     * @return mixed Capability values array for key=value pairs, true/false for others 
     404     */ 
     405    function getCapability($name) 
     406    { 
     407        $result = $this->hasCapability($name); 
     408 
     409        if (!empty($result)) { 
     410            return $result; 
    378411        } 
    379412        else if ($this->capability_readed) { 
     
    391424        $this->capability_readed = true; 
    392425 
    393         if (in_array($name, $this->capability)) { 
    394             return true; 
    395         } 
    396  
    397         return false; 
     426        return $this->hasCapability($name); 
    398427    } 
    399428 
Note: See TracChangeset for help on using the changeset viewer.