* @package taoGroups * @license GPLv2 http://www.opensource.org/licenses/gpl-2.0.php */ class Groups extends tao_actions_SaSModule { /** * (non-PHPdoc) * @see tao_actions_SaSModule::getClassService() */ protected function getClassService() { return GroupsService::singleton(); } /** * Edit a group instance * @return void * @throws \common_exception_Error * @throws \common_ext_ExtensionException * @throws \oat\tao\model\security\SecurityException * @throws \tao_models_classes_MissingRequestParameterException * @throws \tao_models_classes_dataBinding_GenerisFormDataBindingException */ public function editGroup() { $this->defaultData(); $clazz = $this->getCurrentClass(); $group = $this->getCurrentInstance(); $formContainer = new SignedFormInstance( $clazz, $group, [ FormContainer::CSRF_PROTECTION_OPTION => true, FormContainer::ATTRIBUTE_VALIDATORS => [ 'data-depends-on-property' => [ $this->getDependsOnPropertyValidator(), ], ], ] ); $myForm = $formContainer->getForm(); if ($myForm->isSubmited() && $myForm->isValid()) { $this->validateInstanceRoot($group->getUri()); $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($group); $group = $binder->bind($myForm->getValues()); $this->setData('selectNode', tao_helpers_Uri::encode($group->getUri())); $this->setData('selectNode', tao_helpers_Uri::encode($group->getUri())); $this->setData('message', __('Group saved')); $this->setData('reload', true); } $memberProperty = $this->getProperty(GroupsService::PROPERTY_MEMBERS_URI); $memberForm = tao_helpers_form_GenerisTreeForm::buildReverseTree($group, $memberProperty); $memberForm->setData('title', __('Select group test takers')); $memberForm->setData('saveUrl', _url('setReverseValues', 'TestTakerGenerisTree', 'taoTestTaker')); $this->setData('memberForm', $memberForm->render()); if ($this->getServiceLocator()->get(common_ext_ExtensionsManager::SERVICE_ID)->isEnabled('taoDeliveryRdf')) { $this->setData('deliveryForm', DeliveryWidget::renderDeliveryTree($group)); } $updatedAt = $this->getServiceLocator()->get(ResourceWatcher::SERVICE_ID)->getUpdatedAt($group); $this->setData('updatedAt', $updatedAt); $this->setData('formTitle', __('Edit group')); $this->setData('myForm', $myForm->render()); $this->setView('form_group.tpl'); } /** * @throws common_exception_Error * @throws common_exception_MethodNotAllowed * @requiresRight classUri WRITE */ public function moveResource() { parent::moveResource(); } private function getDependsOnPropertyValidator(): ValidatorInterface { return $this->getPsrContainer()->get(DependsOnPropertyValidator::class); } }