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])); }
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(); } }