Example #1
0
 public function setDefaultPermissions(FileManager $tree)
 {
     $rootNode = $tree->getRootTreeNodeObject();
     $adminGroupEntity = GroupEntity::getOrCreate(Group::getByID(ADMIN_GROUP_ID));
     $pk = CategoryTreeNodeKey::getByHandle('view_category_tree_node');
     $pk->setPermissionObject($rootNode);
     $pa = Access::create($pk);
     $pa->addListItem($adminGroupEntity);
     $pt = $pk->getPermissionAssignmentObject();
     $pt->assignPermissionAccess($pa);
 }
Example #2
0
 public static function add($name)
 {
     // copy permissions from the other node.
     $rootNode = CategoryTreeNode::add();
     $treeID = parent::create($rootNode);
     $tree = self::getByID($treeID);
     $tree->setTopicTreeName($name);
     // by default, topic trees are viewable by all
     $guestGroupEntity = GroupPermissionAccessEntity::getOrCreate(UserGroup::getByID(GUEST_GROUP_ID));
     $pk = CategoryTreeNodePermissionKey::getByHandle('view_category_tree_node');
     if (is_object($pk)) {
         $pk->setPermissionObject($rootNode);
         $pa = PermissionAccess::create($pk);
         $pa->addListItem($guestGroupEntity);
         $pt = $pk->getPermissionAssignmentObject();
         $pt->assignPermissionAccess($pa);
     }
     return $tree;
 }