コード例 #1
0
 function getCurrentLevelIdArrayByHierarchyControlIdAndUserId($tree_id, $user_id, $ignore_self = FALSE)
 {
     if ($tree_id == '') {
         return FALSE;
     }
     if ($user_id == '') {
         return FALSE;
     }
     $this->getFastTreeObject()->setTree($tree_id);
     $parent_id = $this->getFastTreeObject()->getParentId($user_id);
     $children = $this->getFastTreeObject()->getAllChildren($parent_id);
     if ($children === FALSE) {
         return FALSE;
     }
     $ids = array_keys($children);
     //Debug::Arr($ids ,' zNodes at the same level', __FILE__, __LINE__, __METHOD__,10);
     $hslf = new HierarchyShareListFactory();
     //Check if current user is shared, because if it isn't shared, then we can ignore
     //all other shared users in the tree.
     $root_user_id_shared = $hslf->getByHierarchyControlIdAndUserId($tree_id, $user_id)->getRecordCount();
     Debug::Text('Root User ID: ' . $user_id . ' Shared: ' . (int) $root_user_id_shared, __FILE__, __LINE__, __METHOD__, 10);
     $retarr[] = (int) $user_id;
     foreach ($ids as $id) {
         $hierarchy_share = $hslf->getByHierarchyControlIdAndUserId($tree_id, $id)->getCurrent()->isNew();
         if ($root_user_id_shared == TRUE and $hierarchy_share === FALSE) {
             //Debug::Text(' Node IS shared:  '. $id, __FILE__, __LINE__, __METHOD__,10);
             $retarr[] = $id;
         } else {
             //Debug::Text(' Node isnt shared:  '. $id, __FILE__, __LINE__, __METHOD__,10);
         }
     }
     return array_unique($retarr);
 }
コード例 #2
0
 function Delete()
 {
     if ($this->getUser() !== FALSE) {
         $this->StartTransaction();
         $this->getFastTreeObject()->setTree($this->getHierarchyControl());
         $this->getFastTreeObject()->delete($this->getUser(), 'RECURSE');
         //FIXME: When deleting recursively, we don't clear out the hierarhcy share table for all the children.
         $hslf = new HierarchyShareListFactory();
         Debug::Text(' Hierarchy Control ID: ' . $this->getHierarchyControl(), __FILE__, __LINE__, __METHOD__, 10);
         $hslf->getByHierarchyControlIdAndUserId($this->getHierarchyControl(), $this->getUser());
         if ($hslf->getRecordCount() > 0) {
             Debug::Text(' Deleting already set shared flag ', __FILE__, __LINE__, __METHOD__, 10);
             $shared_obj = $hslf->getCurrent();
             $shared_obj->Delete();
         } else {
             Debug::Text(' NOT Deleting already set shared flag ', __FILE__, __LINE__, __METHOD__, 10);
         }
         TTLog::addEntry($this->getUser(), 30, TTi18n::getText('Hierarchy Tree - Control ID: ') . $this->getHierarchyControl(), NULL, $this->getTable());
         $this->CommitTransaction();
         return TRUE;
     }
     return FALSE;
 }