IMP_Ftree::getAccount PHP Method

getAccount() public method

Get the account object for a given element ID.
public getAccount ( string $id ) : IMP_Ftree_Account
$id string Element ID.
return IMP_Ftree_Account Account object.
    public function getAccount($id)
    {
        foreach (array_diff(array_keys($this->_accounts), array(self::BASE_ELT)) as $val) {
            if (strpos($id, $val) === 0) {
                return $this->_accounts[$val];
            }
        }
        return $this->_accounts[self::BASE_ELT];
    }

Usage Example

Ejemplo n.º 1
0
 /**
  */
 public function __get($name)
 {
     switch ($name) {
         case 'account':
             return $this->_tree->getAccount($this->_id);
         case 'base_elt':
             return $this->_id == IMP_Ftree::BASE_ELT;
         case 'child_list':
             return $this->_tree->getChildren($this->_id);
         case 'inbox':
             return $this->_id == 'INBOX';
         case 'level':
             if ($this->base_elt) {
                 return 0;
             }
             $i = substr_count($this->_id, $this->namespace_info->delimiter);
             $elt = $this;
             while ($elt = $elt->parent) {
                 if ($elt->namespace) {
                     return $i + 1;
                 } elseif ($elt->remote) {
                     if ($this->remote_mbox) {
                         ++$i;
                     }
                     return $i + 1;
                 }
             }
             return $i;
         case 'mbox_ob':
             return IMP_Mailbox::get($this->_id);
         case 'namespace':
             return $this->namespace_other || $this->namespace_shared;
         case 'namespace_info':
             return $this->mbox_ob->imp_imap->getNamespace($this->_id);
         case 'parent':
             return $this->_tree->getParent($this->_id);
         default:
             return $this->_tree->getAttribute($name, $this->_id);
     }
 }