Ejemplo n.º 1
0
 /**
  * Generates the layout
  *
  * @return \Zepi\Web\UserInterface\Layout\AbstractContainer
  * 
  * @throws \Zepi\Web\AccessControl\Exception Group is not set.
  */
 protected function generateLayout()
 {
     if ($this->group === null) {
         throw new Exception('Group is not set.');
     }
     $request = $this->framework->getRequest();
     $accessLevelSelectorItems = $this->accessLevelHelper->transformAccessLevels($this->accessLevelManager->getAccessLevels(), $request->getSession()->getUser(), $this->group);
     $rawPermissionsForUuid = $this->accessControlManager->getPermissionsRawForUuid($this->group->getUuid());
     if ($rawPermissionsForUuid === false) {
         $rawPermissionsForUuid = array();
     }
     $page = new Page(array(new Form('edit-group', $request->getFullRoute(), 'post', array(new ErrorBox('edit-group-errors'), new Tabs(array(new Tab(array(new Row(array(new Column(array(new Group('required-data', $this->translate('Required data', '\\Zepi\\Web\\AccessControl'), array(new Text('groupname', $this->translate('Group name', '\\Zepi\\Web\\AccessControl'), true, $this->group->getName(), $this->translate('The group name must be unique. Only one group can use a group name.', '\\Zepi\\Web\\AccessControl'))), 1)), array('col-md-6')), new Column(array(new Group('optional-data', $this->translate('Optional data', '\\Zepi\\Web\\AccessControl'), array(new Textarea('description', $this->translate('Description', '\\Zepi\\Web\\AccessControl'), false, $this->group->getMetaData('description'))), 2)), array('col-md-6'))))), array(), 'group-tab', $this->translate('Group informations', '\\Zepi\\Web\\AccessControl')), new Tab(array(new Selector('access-levels', $this->translate('Access Level Selector', '\\Zepi\\Web\\AccessControl'), false, $rawPermissionsForUuid, $accessLevelSelectorItems, $this->translate('Available Access Levels', '\\Zepi\\Web\\AccessControl'), $this->translate('Granted Access Levels', '\\Zepi\\Web\\AccessControl'), '\\Zepi\\Web\\AccessControl\\Templates\\Form\\Snippet\\AccessLevel')), array(), 'access-tab', $this->translate('Permissions', '\\Zepi\\Web\\AccessControl')))), new Row(array(new Column(array(new ButtonGroup('buttons-left', array(new Button('back', $this->translate('Back', '\\Zepi\\Web\\AccessControl'), array('btn-default'), '', 'a', $request->getFullRoute('/administration/groups/'))), 1000, array('text-left'))), array('col-md-4')), new Column(array(new ButtonGroup('buttons', array(new Submit('submit', $this->translate('Save', '\\Zepi\\Web\\AccessControl'), array('btn-large', 'btn-primary'), 'mdi mdi-save')), 1000)), array('col-md-4'))))))));
     return $page;
 }
Ejemplo n.º 2
0
 /**
  * Returns true if the access level is the edited group.
  * 
  * @access public
  * @param string $accessLevel
  * @param \Zepi\Web\AccessControl\Entity\Group $editedGroup
  * @return boolean
  */
 protected function isEditedGroup($accessLevel, Group $editedGroup)
 {
     $parts = explode('\\', $accessLevel);
     if ($parts[1] === 'Group' && count($parts) === 3 && $parts[2] === $editedGroup->getUuid()) {
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
 /**
  * Validates the group data.
  * 
  * @access protected
  * @param \Zepi\Web\AccessControl\Entity\Group $group
  * @param string $groupname
  */
 protected function validateData(EntityGroup $group, $groupname)
 {
     $errors = array();
     // Groupname
     if ($this->groupManager->hasGroupForName($groupname) && $this->groupManager->getGroupForName($groupname)->getUuid() != $group->getUuid()) {
         $errors[] = new Error(Error::GENERAL_ERROR, $this->translate('The groupname is already in use.', '\\Zepi\\Web\\AccessControl'));
     }
     if (count($errors) > 0) {
         return $errors;
     }
     return true;
 }
Ejemplo n.º 4
0
 /**
  * Deletes the group with the given uuid
  *
  * @param \Zepi\Web\AccessControl\Entity\Group $group
  * @return boolean
  *
  * @throws \Zepi\Core\AccessControl\Exception Cannot delete the group. Group does not exist.
  */
 public function deleteGroup($group)
 {
     // If the uuid does not exists we cannot delete the group
     if (!$this->accessControlManager->hasAccessEntityForUuid(self::ACCESS_ENTITY_TYPE, $group->getUuid())) {
         throw new Exception('Cannot update the group. Group does not exist.');
     }
     // Delete the access entity
     return $this->accessControlManager->deleteAccessEntity($group);
 }