IMP_Ftree::getParent PHP Method

getParent() public method

Get the parent element for a given element ID.
public getParent ( string $id ) : mixed
$id string Element ID.
return mixed IMP_Ftree_Element object, or null if no parent.
    public function getParent($id)
    {
        $id = strval($id);
        if ($id == self::BASE_ELT) {
            return null;
        }
        foreach ($this->_parent as $key => $val) {
            if (in_array($id, $val, true)) {
                return $this[$key];
            }
        }
        return $this[self::BASE_ELT];
    }

Usage Example

コード例 #1
0
ファイル: Element.php プロジェクト: jubinpatel/horde
 /**
  */
 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);
     }
 }