public function transformContent()
 {
     $proxyId = $this->getRequest()->getParameter('proxyid');
     $form = $this->getForm(self::$FORM_NAME);
     $proxyIdControl = $form->getFormElementByName('proxyid');
     $proxyIdControl->setAttribute('value', $proxyId);
     $uM = $this->getManager();
     $proxy = $uM->loadVisibilityDefinitionById($proxyId);
     $proxyType = $uM->loadVisibilityDefinitionType($proxy);
     $form->getLabel('intro-text')->setPlaceHolder('app-object-id', $proxy->getAppObjectId())->setPlaceHolder('proxy-type', $proxyType->getAppObjectName());
     $users = $uM->loadUsersNotWithVisibilityDefinition($proxy);
     if (count($users) === 0) {
         $tmpl = $this->getTemplate('NoMoreUsers');
         $tmpl->getLabel('message-1')->setPlaceHolder('app-object-id', $proxy->getAppObjectId())->setPlaceHolder('object-type', $proxyType->getObjectName());
         $tmpl->getLabel('message-2')->setPlaceHolder('proxy-view-link', $this->generateLink(['mainview' => 'proxy', 'proxyview' => null, 'proxyid' => null]));
         $tmpl->transformOnPlace();
         return;
     }
     /* @var $usersControl MultiSelectBoxTag */
     $usersControl = $form->getFormElementByName('users');
     foreach ($users as $id => $DUMMY) {
         $usersControl->addOption($users[$id]->getDisplayName(), $users[$id]->getObjectId());
     }
     if ($form->isSent() && $form->isValid()) {
         $proxy = new UmgtVisibilityDefinition();
         $proxy->setObjectId($proxyId);
         $uM->attachUsers2VisibilityDefinition($proxy, $this->mapSelectedOptions2DomainObjects('users', 'UmgtUser'));
         $this->getResponse()->forward($this->generateLink(['mainview' => 'proxy', 'proxyview' => null, 'proxyid' => null]));
     }
     $form->transformOnPlace();
 }
 public function transformContent()
 {
     $uM = $this->getManager();
     $request = $this->getRequest();
     $objectId = $request->getParameter('objectid');
     $objectType = $request->getParameter('objecttype');
     $proxyId = $request->getParameter('proxyid');
     $proxy = new UmgtVisibilityDefinition();
     $proxy->setObjectId($proxyId);
     $class = 'APF\\modules\\usermanagement\\biz\\model\\Umgt' . $objectType;
     $object = new $class();
     /* @var $object UmgtUser|UmgtGroup */
     $object->setObjectId($objectId);
     $formYes = $this->getForm('RevokeYes');
     $formNo = $this->getForm('RevokeNo');
     if ($formYes->isSent()) {
         if ($objectType == 'User') {
             $uM->detachUsersFromVisibilityDefinition($proxy, [$object]);
         } else {
             $uM->detachGroupsFromVisibilityDefinition($proxy, [$object]);
         }
     } elseif ($formNo->isSent()) {
     } else {
         $label = $this->getLabel('intro-text');
         $labels = $this->getConfiguration('APF\\modules\\usermanagement\\pres', 'labels.ini')->getSection($this->getLanguage());
         if ($objectType == 'User') {
             $object = $this->getManager()->loadUserByID($objectId);
             $label->setPlaceHolder('object-type', $labels->getValue('frontend.proxy.revoke-access.object-type.user.label'));
         } else {
             $object = $this->getManager()->loadGroupByID($objectId);
             $label->setPlaceHolder('object-type', $labels->getValue('frontend.proxy.revoke-access.object-type.group.label'));
         }
         $label->setPlaceHolder('display-name', $object->getDisplayName());
         $label->setPlaceHolder('proxy-id', $proxyId);
         $proxyType = $uM->loadVisibilityDefinitionType($proxy);
         $label->setPlaceHolder('proxy-type', $proxyType->getAppObjectName());
         $formYes->transformOnPlace();
         $formNo->transformOnPlace();
         return;
     }
     $this->getResponse()->forward($this->generateLink(['mainview' => 'proxy', 'proxyview' => 'details', 'proxyid' => $proxyId]));
 }
 public function transformContent()
 {
     $uM = $this->getManager();
     $proxyId = $this->getRequest()->getParameter('proxyid');
     $proxy = new UmgtVisibilityDefinition();
     $proxy->setObjectId($proxyId);
     $formYes = $this->getForm('DelYes');
     $formNo = $this->getForm('DelNo');
     if ($formYes->isSent()) {
         $uM->deleteVisibilityDefinition($proxy);
     } elseif ($formNo->isSent()) {
     } else {
         $proxyType = $uM->loadVisibilityDefinitionType($proxy);
         $this->getLabel('intro-text')->setPlaceHolder('proxy-type', $proxyType->getAppObjectName())->setPlaceHolder('proxy-id', $proxyId);
         $formYes->transformOnPlace();
         $formNo->transformOnPlace();
         return;
     }
     $this->getResponse()->forward($this->generateLink(['mainview' => 'proxy', 'proxyview' => null]));
 }
Esempio n. 4
0
 /**
  * Creates a visibility definition relating an application proxy object to the users and
  * groups, that should have access to the object.
  *
  * @param UmgtVisibilityDefinitionType $type The visibility type (object type of application's the target object).
  * @param UmgtVisibilityDefinition $definition The visibility definition (object id of application's the target object).
  * @param UmgtUser[] $users The list of users, that should have visibility permissions on the given application object.
  * @param UmgtGroup[] $groups The list of groups, that should have visibility permissions on the given application object.
  *
  * @return int The id of the desired visibility definition.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 26.05.2010<br />
  */
 public function createVisibilityDefinition(UmgtVisibilityDefinitionType $type, UmgtVisibilityDefinition $definition, array $users = [], array $groups = [])
 {
     $orm = $this->getORMapper();
     // try to reuse existing visibility definitions having the same
     // combination of proxy + type!
     $criterion = new GenericCriterionObject();
     $criterion->addPropertyIndicator('AppObjectId', $definition->getAppObjectId());
     $criterion->addRelationIndicator('AppProxy2AppProxyType', $type);
     // Allow best balance between creating new visibility definitions for proxy id, proxy type, and permission setup.
     // For details on the discussion, please refer to http://forum.adventure-php-framework.org/viewtopic.php?f=1&t=5387.
     $criterion->addPropertyIndicator('ReadPermission', $definition->getReadPermission());
     $criterion->addPropertyIndicator('WritePermission', $definition->getWritePermission());
     $criterion->addPropertyIndicator('LinkPermission', $definition->getLinkPermission());
     $criterion->addPropertyIndicator('DeletePermission', $definition->getDeletePermission());
     $storedVisibilityDefinition = $orm->loadObjectByCriterion('AppProxy', $criterion);
     if ($storedVisibilityDefinition !== null) {
         $definition = $storedVisibilityDefinition;
     }
     // append proxy to current application
     $app = $this->getCurrentApplication();
     $definition->addRelatedObject('Application2AppProxy', $app);
     // create domain structure
     $definition->addRelatedObject('AppProxy2AppProxyType', $type);
     foreach ($users as $id => $DUMMY) {
         $definition->addRelatedObject('AppProxy2User', $users[$id]);
     }
     foreach ($groups as $id => $group) {
         $definition->addRelatedObject('AppProxy2Group', $groups[$id]);
     }
     // save domain structure
     return $orm->saveObject($definition);
 }
Esempio n. 5
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();
     }
 }