/** * Create the rights for a node. * * array $rights should be defined that way: * array('ROLE_WS_XXX' => array('open' => true, 'edit' => false, ... * 'create' => array('directory', ...), 'role' => $entity)) * * @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $node * @param array $rights */ public function createRights(ResourceNode $node, array $rights = array()) { foreach ($rights as $data) { $resourceTypes = $this->checkResourceTypes($data['create']); $this->rightsManager->create($data, $data['role'], $node, false, $resourceTypes); } if (!array_key_exists('ROLE_ANONYMOUS', $rights)) { $this->rightsManager->create(0, $this->roleRepo->findOneBy(array('name' => 'ROLE_ANONYMOUS')), $node, false, array()); } if (!array_key_exists('ROLE_USER', $rights)) { $this->rightsManager->create(0, $this->roleRepo->findOneBy(array('name' => 'ROLE_USER')), $node, false, array()); } }
/** * @param string $key The translation key * @param \Claroline\CoreBundle\Entity\Workspace\Workspace $workspace * * @return \Claroline\CoreBundle\Entity\Role */ public function getRoleByTranslationKeyAndWorkspace($key, Workspace $workspace) { return $this->roleRepo->findOneBy(array('translationKey' => $key, 'workspace' => $workspace)); }