TreeBehavior::ancestorIdsMatch PHP Метод

ancestorIdsMatch() публичный Метод

* utlity function that will check whether any of the list $ids appear in the trees of any of the $ancestor_ids (including the ancestor ids themselves)
public ancestorIdsMatch ( $ids, $ancestor_ids )
    public function ancestorIdsMatch($ids, $ancestor_ids)
    {
        $obj = $this->getOwner();
        $db = $obj->getDbConnection();
        $tree_table = $obj->treeTable();
        $all_ancestor_ids = array();
        foreach ($ancestor_ids as $aid) {
            if (!in_array($aid, $all_ancestor_ids)) {
                $all_ancestor_ids = array_merge($this->_descendentIds($db, $tree_table, $aid), $all_ancestor_ids);
            }
        }
        // include the ids we're checking for as all the descendents
        $all_ancestors = array_merge($ancestor_ids, $all_ancestor_ids);
        return count(array_intersect($ids, $all_ancestors)) > 0;
    }