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();
 }
Beispiel #2
0
 /**
  * Saves a role object within the current application.
  *
  * @param UmgtRole $role current role.
  *
  * @return int The id of the role.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 15.06.2008<br />
  */
 public function saveRole(UmgtRole &$role)
 {
     $app = $this->getCurrentApplication();
     $role->addRelatedObject('Application2Role', $app);
     return $this->getORMapper()->saveObject($role);
 }