コード例 #1
0
 /**
  * Renders a role.
  *
  * @param int $roleId Role ID
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function viewRoleAction($roleId)
 {
     $role = $this->roleService->loadRole($roleId);
     $roleAssignments = $this->roleService->getRoleAssignments($role);
     $deleteForm = $this->createForm(new RoleDeleteType(), ['roleId' => $roleId]);
     return $this->render('eZPlatformUIBundle:Role:view_role.html.twig', ['role' => $role, 'role_assignments' => $roleAssignments, 'deleteForm' => $deleteForm->createView(), 'can_edit' => $this->isGranted(new Attribute('role', 'update')), 'can_delete' => $this->isGranted(new Attribute('role', 'delete'))]);
 }
コード例 #2
0
 /**
  * Renders a role.
  *
  * @param int $roleId Role ID
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function viewRoleAction($roleId)
 {
     $role = $this->roleService->loadRole($roleId);
     $roleAssignments = $this->roleService->getRoleAssignments($role);
     $deleteForm = $this->createForm(new RoleDeleteType(), ['roleId' => $roleId]);
     $deleteFormsByPolicyId = [];
     foreach ($role->getPolicies() as $policy) {
         $policyId = $policy->id;
         $deleteFormsByPolicyId[$policyId] = $this->createForm(new PolicyDeleteType(), ['policyId' => $policyId, 'roleId' => $roleId])->createView();
     }
     return $this->render('eZPlatformUIBundle:Role:view_role.html.twig', ['role' => $role, 'deleteFormsByPolicyId' => $deleteFormsByPolicyId, 'role_assignments' => $roleAssignments, 'deleteForm' => $deleteForm->createView(), 'can_edit' => $this->isGranted(new Attribute('role', 'update')), 'can_delete' => $this->isGranted(new Attribute('role', 'delete'))]);
 }
コード例 #3
0
 /**
  * Renders a role.
  *
  * @param int $roleId Role ID
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function viewRoleAction($roleId)
 {
     $role = $this->roleService->loadRole($roleId);
     $roleAssignments = $this->roleService->getRoleAssignments($role);
     $deleteForm = $this->createForm(new RoleDeleteType(), ['roleId' => $roleId]);
     $editablePolicies = [];
     $deleteFormsByPolicyId = [];
     foreach ($role->getPolicies() as $policy) {
         $policyId = $policy->id;
         $deleteFormsByPolicyId[$policyId] = $this->createForm(new PolicyDeleteType(), ['policyId' => $policyId, 'roleId' => $roleId])->createView();
         // We cannot edit policies that don't have a function defined, or that cannot have limitations.
         $limitationTypes = $policy->module ? $this->roleService->getLimitationTypesByModuleFunction($policy->module, $policy->function) : [];
         if (count($limitationTypes) > 0) {
             $editablePolicies[$policyId] = true;
         }
     }
     $deleteFormsByAssignment = [];
     foreach ($roleAssignments as $roleAssignment) {
         $deleteFormsByAssignment[$roleAssignment->id] = $this->createForm(new RoleAssignmentDeleteType(), ['assignmentId' => $roleAssignment->id])->createView();
     }
     return $this->render('eZPlatformUIBundle:Role:view_role.html.twig', ['role' => $role, 'deleteFormsByPolicyId' => $deleteFormsByPolicyId, 'role_assignments' => $roleAssignments, 'deleteForm' => $deleteForm->createView(), 'can_edit' => $this->isGranted(new Attribute('role', 'update')), 'can_assign' => $this->isGranted(new Attribute('role', 'assign')), 'can_delete' => $this->isGranted(new Attribute('role', 'delete')), 'deleteFormsByAssignment' => $deleteFormsByAssignment, 'editablePolicies' => $editablePolicies]);
 }
コード例 #4
0
ファイル: User.php プロジェクト: CG77/ezpublish-kernel
 /**
  * Loads a list of user groups assigned to role
  *
  * @return \eZ\Publish\Core\REST\Server\Values\RestUserGroup[]
  */
 public function loadUserGroupsAssignedToRole()
 {
     $role = $this->roleService->loadRole($this->requestParser->parseHref($this->request->query->get('roleId'), 'roleId'));
     $roleAssignments = $this->roleService->getRoleAssignments($role);
     $restUserGroups = array();
     foreach ($roleAssignments as $roleAssignment) {
         if ($roleAssignment instanceof UserGroupRoleAssignment) {
             $userGroup = $roleAssignment->getUserGroup();
             $userGroupContentInfo = $userGroup->getVersionInfo()->getContentInfo();
             $userGroupLocation = $this->locationService->loadLocation($userGroupContentInfo->mainLocationId);
             $contentType = $this->contentTypeService->loadContentType($userGroupContentInfo->contentTypeId);
             $restUserGroups[] = new Values\RestUserGroup($userGroup, $contentType, $userGroupContentInfo, $userGroupLocation, $this->contentService->loadRelations($userGroup->getVersionInfo()));
         }
     }
     return $restUserGroups;
 }
コード例 #5
0
 /**
  * Returns the assigned user and user groups to this role.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read a role
  *
  * @param \eZ\Publish\API\Repository\Values\User\Role $role
  *
  * @return \eZ\Publish\API\Repository\Values\User\RoleAssignment[]
  */
 public function getRoleAssignments(Role $role)
 {
     return $this->service->getRoleAssignments($role);
 }