예제 #1
0
파일: Module.php 프로젝트: zepi/turbo-base
 /**
  * Initializes and return an instance of the given class name.
  * 
  * @param string $className
  * @return mixed
  */
 public function getInstance($className)
 {
     switch ($className) {
         case '\\Zepi\\Core\\AccessControl\\Manager\\AccessControlManager':
             if ($this->accessControlManager === null) {
                 $dataSourceManager = $this->framework->getDataSourceManager();
                 $this->accessControlManager = $this->framework->initiateObject($className, array('accessEntitiesDataSource' => $dataSourceManager->getDataSource('\\Zepi\\Core\\AccessControl\\DataSource\\AccessEntitiesDataSourceInterface'), 'permissionsDataSource' => $dataSourceManager->getDataSource('\\Zepi\\Core\\AccessControl\\DataSource\\PermissionsDataSourceInterface')));
             }
             return $this->accessControlManager;
             break;
         case '\\Zepi\\Core\\AccessControl\\Manager\\AccessLevelManager':
             if ($this->accessLevelManager === null) {
                 $accessLevelsObjectBackend = $this->framework->initiateObject('\\Zepi\\Turbo\\Backend\\FileObjectBackend', array('path' => $this->framework->getRootDirectory() . '/data/access-levels.data'));
                 $this->accessLevelManager = $this->framework->initiateObject($className, array('accessLevelObjectBackend' => $accessLevelsObjectBackend));
                 $this->accessLevelManager->initializeAccessLevelManager();
             }
             return $this->accessLevelManager;
             break;
         case '\\Zepi\\Core\\AccessControl\\Manager\\EventAccessManager':
             if ($this->eventAccessManager === null) {
                 $eventAccessObjectBackend = $this->framework->initiateObject('\\Zepi\\Turbo\\Backend\\FileObjectBackend', array('path' => $this->framework->getRootDirectory() . '/data/event-access-levels.data'));
                 $this->eventAccessManager = $this->framework->initiateObject($className, array('eventAccessObjectBackend' => $eventAccessObjectBackend));
                 $this->eventAccessManager->initializeEventAccessManager();
             }
             return $this->eventAccessManager;
             break;
         case '\\Zepi\\Core\\AccessControl\\DataSource\\AccessEntitiesDataSourceDoctrine':
             $dataSourceManager = $this->framework->getDataSourceManager();
             return $this->framework->initiateObject($className, array('permissionsDataSource' => $dataSourceManager->getDataSource('\\Zepi\\Core\\AccessControl\\DataSource\\PermissionsDataSourceInterface')));
             break;
         default:
             return $this->framework->initiateObject($className);
             break;
     }
 }
예제 #2
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;
 }