public function transformContent()
 {
     $form = $this->getForm('Permissions');
     $uM = $this->getManager();
     $role = $uM->loadRoleByID($this->getRequest()->getParameter('roleid'));
     $form->getLabel('display-name')->setPlaceHolder('display-name', $role->getDisplayName());
     $permissions = $uM->loadPermissionsWithRole($role);
     if (count($permissions) === 0) {
         $template = $this->getTemplate('NoMorePermissions');
         $template->getLabel('message-1')->setPlaceHolder('display-name', $role->getDisplayName());
         $template->getLabel('message-2')->setPlaceHolder('role-view-link', $this->generateLink(['mainview' => 'role', 'roleview' => null, 'roleid' => null]));
         $template->transformOnPlace();
         return;
     }
     /* @var $permissionControl MultiSelectBoxTag */
     $permissionControl = $form->getFormElementByName('Permissions');
     foreach ($permissions as $permission) {
         $permissionControl->addOption($permission->getDisplayName(), $permission->getObjectId());
     }
     if ($form->isSent() && $form->isValid()) {
         $options = $permissionControl->getSelectedOptions();
         $permissionsToAdd = [];
         foreach ($options as $option) {
             /* @var $option SelectBoxOptionTag */
             $permissionToAdd = new UmgtPermission();
             $permissionToAdd->setObjectId($option->getValue());
             $permissionsToAdd[] = $permissionToAdd;
             unset($permissionToAdd);
         }
         $uM->detachPermissionsFromRole($permissionsToAdd, $role);
         $this->getResponse()->forward($this->generateLink(['mainview' => 'role', 'roleview' => null, 'roleid' => null]));
     } else {
         $form->transformOnPlace();
     }
 }
 public function transformContent()
 {
     $form = $this->getForm('RoleAdd');
     /* @var $permissionControl MultiSelectBoxTag */
     $permissionControl = $form->getFormElementByName('Permission');
     $uM = $this->getManager();
     $roles = $uM->getRoleList();
     $count = count($roles);
     // fill multi-select field
     for ($i = 0; $i < $count; $i++) {
         $permissionControl->addOption($roles[$i]->getDisplayName(), $roles[$i]->getObjectId());
     }
     if ($form->isSent() && $form->isValid()) {
         $uM = $this->getManager();
         $role = new UmgtRole();
         $displayName = $form->getFormElementByName('DisplayName');
         $role->setDisplayName($displayName->getValue());
         $description = $form->getFormElementByName('Description');
         $role->setDescription($description->getValue());
         $options = $permissionControl->getSelectedOptions();
         for ($i = 0; $i < count($options); $i++) {
             $newPermission = new UmgtPermission();
             $newPermission->setObjectId($options[$i]->getAttribute('value'));
             $role->addRelatedObject('Role2Permission', $newPermission);
             unset($newPermission);
         }
         $uM->saveRole($role);
         $this->getResponse()->forward($this->generateLink(['mainview' => 'role', 'roleview' => '', 'roleid' => '']));
     }
     $form->transformOnPlace();
 }
 public function transformContent()
 {
     $uM = $this->getManager();
     $form = $this->getForm('PermissionAdd');
     if ($form->isSent() && $form->isValid()) {
         $displayName = $form->getFormElementByName('DisplayName');
         $name = $form->getFormElementByName('Name');
         $value = $form->getFormElementByName('Value');
         $permission = new UmgtPermission();
         $permission->setDisplayName($displayName->getValue());
         $permission->setName($name->getValue());
         $permission->setValue($value->getValue());
         $uM->savePermission($permission);
         $this->getResponse()->forward($this->generateLink(['mainview' => 'permission', 'permissionview' => '']));
     }
     $form->transformOnPlace();
 }
 public function transformContent()
 {
     $permissionId = $this->getRequest()->getParameter('permissionid');
     $uM = $this->getManager();
     $permission = $uM->loadPermissionByID($permissionId);
     $this->getLabel('display-name')->setPlaceHolder('display-name', $permission->getDisplayName());
     $formNo = $this->getForm('PermissionDelNo');
     $formYes = $this->getForm('PermissionDelYes');
     $response = $this->getResponse();
     if ($formYes->isSent()) {
         $permission = new UmgtPermission();
         $permission->setObjectId($permissionId);
         $uM->deletePermission($permission);
         $response->forward($this->generateLink(['mainview' => 'permission', 'permissionview' => '', 'permissionid' => '']));
     } elseif ($formNo->isSent()) {
         $response->forward($this->generateLink(['mainview' => 'permission', 'permissionview' => '', 'permissionid' => '']));
     } else {
         $formNo->transformOnPlace();
         $formYes->transformOnPlace();
     }
 }
 public function transformContent()
 {
     // get current permission id
     $permissionId = $this->getRequest()->getParameter('permissionid');
     // initialize the form
     $form = $this->getForm('PermissionEdit');
     $permissionIdControl = $form->getFormElementByName('permissionid');
     $permissionIdControl->setAttribute('value', $permissionId);
     $displayName = $form->getFormElementByName('DisplayName');
     $name = $form->getFormElementByName('Name');
     $value = $form->getFormElementByName('Value');
     $uM = $this->getManager();
     if ($form->isSent()) {
         if ($form->isValid()) {
             $permission = new UmgtPermission();
             $permission->setObjectId($permissionId);
             $permission->setDisplayName($displayName->getValue());
             $permission->setName($name->getValue());
             $permission->setValue($value->getValue());
             $uM->savePermission($permission);
             $this->getResponse()->forward($this->generateLink(['mainview' => 'permission', 'permissionview' => '', 'permissionid' => '']));
         } else {
             $form->transformOnPlace();
         }
     } else {
         $permission = $uM->loadPermissionByID($permissionId);
         $displayName->setAttribute('value', $permission->getDisplayName());
         $name->setAttribute('value', $permission->getName());
         $value->setAttribute('value', $permission->getValue());
         $form->transformOnPlace();
     }
 }
Beispiel #6
0
 /**
  * Saves a permission object within the current application.
  *
  * @param UmgtPermission $permission the permission.
  *
  * @return int The id of the permission.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 15.06.2008<br />
  * Version 0.2, 16.06.2008 (The permission set is lazy loaded when not present)<br />
  * Version 0.3, 28.12.2008 (Changed the API concerning the new UML diagram)<br />
  */
 public function savePermission(UmgtPermission &$permission)
 {
     $app = $this->getCurrentApplication();
     $permission->addRelatedObject('Application2Permission', $app);
     return $this->getORMapper()->saveObject($permission);
 }