Exemplo n.º 1
0
 public function transformContent()
 {
     $form = $this->getForm('add');
     if ($form->isSent() && $form->isValid()) {
         $proxyName = $form->getFormElementByName('proxytypename');
         $proxyType = new UmgtVisibilityDefinitionType();
         $proxyType->setAppObjectName($proxyName->getAttribute('value'));
         $uM = $this->getManager();
         try {
             $uM->saveVisibilityDefinitionType($proxyType);
             $this->getResponse()->forward($this->generateLink(['mainview' => 'proxy', 'proxyview' => 'typelist']));
         } catch (DatabaseHandlerException $dhe) {
             // mark field as invalid due to the fact, that we have a form error, it is also displayed!
             $proxyName->markAsInvalid();
             $proxyName->appendCssClass(AbstractFormValidator::$DEFAULT_MARKER_CLASS);
         }
     }
     $form->transformOnPlace();
 }
Exemplo n.º 2
0
 /**
  * Saves a visibility definition type used to categorize an application object.
  *
  * @param UmgtVisibilityDefinitionType $proxyType The type to save.
  *
  * @return int The id of the type.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 30.04.2010<br />
  */
 public function saveVisibilityDefinitionType(UmgtVisibilityDefinitionType &$proxyType)
 {
     $app = $this->getCurrentApplication();
     $proxyType->addRelatedObject('Application2AppProxyType', $app);
     return $this->getORMapper()->saveObject($proxyType);
 }
Exemplo n.º 3
0
 public function transformContent()
 {
     $uM = $this->getManager();
     $form = $this->getForm('visibilitydef');
     // pre-fill mode if "proxytypeid" and "appobjectid" are given
     $request = $this->getRequest();
     $proxyTypeId = $request->getParameter('proxytypeid');
     $appObjectId = $request->getParameter('appobjectid');
     $proxyId = $request->getParameter('proxyid');
     $selectedUsers = [];
     $selectedGroups = [];
     if ($proxyTypeId != null && $appObjectId != null) {
         $proxy = new UmgtVisibilityDefinition();
         $proxy->setObjectId($proxyId);
         $selectedUsers = $uM->loadUsersWithVisibilityDefinition($proxy);
         $selectedGroups = $uM->loadGroupsWithVisibilityDefinition($proxy);
     }
     // load the defined visibility types
     $proxyTypes = $uM->loadVisibilityDefinitionTypes();
     /* @var $typeElement SelectBoxTag */
     $typeElement = $form->getFormElementByName('proxytypeid');
     foreach ($proxyTypes as $proxyType) {
         $typeElement->addOption($proxyType->getAppObjectName(), $proxyType->getObjectId());
     }
     // load users
     $userList = $uM->getPagedUserList();
     /* @var $usersElement MultiSelectBoxTag */
     $usersElement = $form->getFormElementByName('users');
     foreach ($userList as $user) {
         $usersElement->addOption($user->getDisplayName(), $user->getObjectId());
     }
     foreach ($selectedUsers as $selectedUser) {
         $usersElement->setOption2Selected($selectedUser->getObjectId());
     }
     // load groups
     $groups = $uM->getPagedGroupList();
     /* @var $groupsElement MultiSelectBoxTag */
     $groupsElement = $form->getFormElementByName('groups');
     foreach ($groups as $group) {
         $groupsElement->addOption($group->getDisplayName(), $group->getObjectId());
     }
     foreach ($selectedGroups as $selectedGroup) {
         $groupsElement->setOption2Selected($selectedGroup->getObjectId());
     }
     // store visibility definition
     if ($form->isSent() && $form->isValid()) {
         // setup type
         $type = new UmgtVisibilityDefinitionType();
         $type->setObjectId($typeElement->getSelectedOption()->getAttribute('value'));
         // setup proxy
         $definition = new UmgtVisibilityDefinition();
         $definition->setAppObjectId($form->getFormElementByName('appobjectid')->getAttribute('value'));
         // setup users
         $users = [];
         foreach ($usersElement->getSelectedOptions() as $option) {
             $user = new UmgtUser();
             $user->setObjectId($option->getAttribute('value'));
             $users[] = $user;
             unset($user);
         }
         // setup groups
         $groups = [];
         foreach ($groupsElement->getSelectedOptions() as $option) {
             $group = new UmgtGroup();
             $group->setObjectId($option->getAttribute('value'));
             $groups[] = $group;
             unset($group);
         }
         // setup access permissions
         $definition->setReadPermission($form->getFormElementByID('read-perm')->isChecked() ? 1 : 0);
         $definition->setWritePermission($form->getFormElementByID('write-perm')->isChecked() ? 1 : 0);
         $definition->setLinkPermission($form->getFormElementByID('link-perm')->isChecked() ? 1 : 0);
         $definition->setDeletePermission($form->getFormElementByID('delete-perm')->isChecked() ? 1 : 0);
         $uM->createVisibilityDefinition($type, $definition, $users, $groups);
         $this->getResponse()->forward($this->generateLink(['mainview' => 'proxy', 'proxyview' => null, 'proxytypeid' => null]));
     } else {
         $form->transformOnPlace();
     }
 }