/** * Check if the projectId is under the same project or a subproject of him. * * @param integer $projectId The projectId to check. * @param Phprojekt_Tree_Node_Database $node The node of the current project. * * @return boolean False if not. */ private function _isInTheProject($projectId, $node) { $allow = false; if ($node->hasChildren()) { $childrens = $node->getChildren(); foreach ($childrens as $childrenNode) { if ($projectId == $childrenNode->id) { $allow = true; break; } else { if ($this->_isInTheProject($projectId, $childrenNode)) { $allow = true; break; } } } } return $allow; }
/** * Rebuild the paths of a subtree. * * @param Phprojekt_Tree_Node_Database $node Node to rebuild. * @param string $basePath Path of the parent. * * @return void */ protected function _rebuildPaths(Phprojekt_Tree_Node_Database $node, $basePath) { if ($node->_activeRecord->path != $basePath) { $node->getActiveRecord()->path = $basePath; foreach ($node->getChildren() as $id => $child) { $node->_children[$id] = $this->_rebuildPaths($child, $basePath . $node->id . self::NODE_SEPARATOR); $this->getRootNode()->_index[$child->id] = $node->_children[$id]; $node->_children[$id]->getActiveRecord()->parentSave(); self::deleteCache(); } } return $node; }