Exemplo n.º 1
0
 /**
  * Action dedicated to change the settings of the user (language, ...)
  */
 public function properties()
 {
     $myFormContainer = new tao_actions_form_UserSettings($this->getUserSettings());
     $myForm = $myFormContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $currentUser = $this->userService->getCurrentUser();
             $userSettings = array(PROPERTY_USER_UILG => $myForm->getValue('ui_lang'), PROPERTY_USER_DEFLG => $myForm->getValue('data_lang'), PROPERTY_USER_TIMEZONE => $myForm->getValue('timezone'));
             $uiLang = new core_kernel_classes_Resource($myForm->getValue('ui_lang'));
             $dataLang = new core_kernel_classes_Resource($myForm->getValue('data_lang'));
             $userSettings[PROPERTY_USER_UILG] = $uiLang->getUri();
             $userSettings[PROPERTY_USER_DEFLG] = $dataLang->getUri();
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($currentUser);
             if ($binder->bind($userSettings)) {
                 \common_session_SessionManager::getSession()->refresh();
                 $uiLangCode = tao_models_classes_LanguageService::singleton()->getCode($uiLang);
                 $extension = common_ext_ExtensionsManager::singleton()->getExtensionById('tao');
                 tao_helpers_I18n::init($extension, $uiLangCode);
                 $this->setData('message', __('Settings updated'));
                 $this->setData('reload', true);
             }
         }
     }
     $userLabel = $this->userService->getCurrentUser()->getLabel();
     $this->setData('formTitle', sprintf(__("My settings (%s)"), __($userLabel)));
     $this->setData('myForm', $myForm->render());
     //$this->setView('form.tpl');
     $this->setView('form/settings_user.tpl');
 }
 /**
  * Edit a group instance
  * @return void
  */
 public function editProcess()
 {
     $clazz = $this->getCurrentClass();
     $process = $this->getCurrentInstance();
     $excludedProperties = array(PROPERTY_PROCESS_VARIABLES, PROPERTY_PROCESS_ACTIVITIES, PROPERTY_PROCESS_ROOT_ACTIVITIES);
     $formContainer = new tao_actions_form_Instance($clazz, $process, array('excludedProperties' => $excludedProperties));
     $myForm = $formContainer->getForm();
     //@TODO : put into the process definition service:
     $aclModes = array(tao_helpers_Uri::encode(INSTANCE_ACL_ROLE) => 'Role', tao_helpers_Uri::encode(INSTANCE_ACL_ROLE_RESTRICTED_USER) => 'User');
     $myForm->getElement(tao_helpers_Uri::encode(PROPERTY_PROCESS_INIT_ACL_MODE))->setOptions($aclModes);
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($process);
             $process = $binder->bind($myForm->getValues());
             $this->setData("selectNode", tao_helpers_Uri::encode($process->getUri()));
             $this->setData('message', __('Process saved'));
             $this->setData('reload', true);
         }
     }
     $this->setData('uri', tao_helpers_Uri::encode($process->getUri()));
     $this->setData('classUri', tao_helpers_Uri::encode($clazz->getUri()));
     $this->setData('formTitle', 'Process properties');
     $this->setData('myForm', $myForm->render());
     $this->setView('form_process.tpl');
 }
 /**
  * Edit a Test Center instance
  * @return void
  */
 public function editCenter()
 {
     $clazz = $this->getCurrentClass();
     $testCenter = $this->getCurrentInstance();
     $formContainer = new \tao_actions_form_Instance($clazz, $testCenter);
     $myForm = $formContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($testCenter);
             $testCenter = $binder->bind($myForm->getValues());
             $this->setData("selectNode", \tao_helpers_Uri::encode($testCenter->getUri()));
             $this->setData('message', $this->convert('Test center saved'));
             $this->setData('reload', true);
         }
     }
     $childrenProperty = new \core_kernel_classes_Property(TestCenterService::PROPERTY_CHILDREN_URI);
     $childrenForm = \tao_helpers_form_GenerisTreeForm::buildTree($testCenter, $childrenProperty);
     $childrenForm->setHiddenNodes(array($testCenter->getUri()));
     $childrenForm->setTitle($this->convert('Define sub-centers'));
     $this->setData('childrenForm', $childrenForm->render());
     $administratorProperty = new \core_kernel_classes_Property(TestCenterService::PROPERTY_ADMINISTRATOR_URI);
     $administratorForm = \tao_helpers_form_GenerisTreeForm::buildReverseTree($testCenter, $administratorProperty);
     $administratorForm->setData('title', $this->convert('Assign administrator'));
     $this->setData('administratorForm', $administratorForm->render());
     $proctorProperty = new \core_kernel_classes_Property(ProctorManagementService::PROPERTY_ASSIGNED_PROCTOR_URI);
     $proctorForm = \tao_helpers_form_GenerisTreeForm::buildReverseTree($testCenter, $proctorProperty);
     $proctorForm->setData('title', $this->convert('Assign proctors'));
     $this->setData('proctorForm', $proctorForm->render());
     $this->setData('formTitle', $this->convert('Edit test center'));
     $this->setData('testCenter', $testCenter->getUri());
     $this->setData('myForm', $myForm->render());
     $this->setView('form_test_center.tpl');
 }
 public function editInstance()
 {
     $clazz = $this->getCurrentClass();
     $instance = $this->getCurrentInstance();
     $myFormContainer = new \tao_actions_form_Instance($clazz, $instance);
     $myForm = $myFormContainer->getForm();
     $nameElement = $myForm->getElement(\tao_helpers_Uri::encode(WebBrowserService::PROPERTY_NAME));
     $versionElement = $myForm->getElement(\tao_helpers_Uri::encode(WebBrowserService::PROPERTY_VERSION));
     $nameElement->addClass('select2');
     $versionElement->setHelp("<span class=\"icon-help tooltipstered\" data-tooltip=\".web-browser-form .browser-version-tooltip-content\" data-tooltip-theme=\"info\"></span>");
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $values = $myForm->getValues();
             // save properties
             $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($instance);
             $instance = $binder->bind($values);
             $message = __('Instance saved');
             $this->setData('message', $message);
             $this->setData('reload', true);
         }
     }
     $this->setData('formTitle', __('Edit Authorized Web Browser'));
     $this->setData('myForm', $myForm->render());
     $this->setView('WebBrowsers/form.tpl');
 }
 /**
  * Show the form to edit an instance, show also a preview of the media
  */
 public function editInstance()
 {
     $clazz = $this->getCurrentClass();
     $instance = $this->getCurrentInstance();
     $myFormContainer = new editInstanceForm($clazz, $instance);
     $myForm = $myFormContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $values = $myForm->getValues();
             // save properties
             $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($instance);
             $instance = $binder->bind($values);
             $message = __('Instance saved');
             $this->setData('message', $message);
             $this->setData('reload', true);
         }
     }
     $this->setData('formTitle', __('Edit Instance'));
     $this->setData('myForm', $myForm->render());
     $uri = $this->hasRequestParameter('id') ? $this->getRequestParameter('id') : $this->getRequestParameter('uri');
     try {
         $mediaSource = new MediaSource(array());
         $fileInfo = $mediaSource->getFileInfo($uri);
         $mimeType = $fileInfo['mime'];
         $xml = in_array($mimeType, array('application/xml', 'text/xml'));
         $url = \tao_helpers_Uri::url('getFile', 'MediaManager', 'taoMediaManager', array('uri' => $uri));
         $this->setData('xml', $xml);
         $this->setData('fileurl', $url);
         $this->setData('mimeType', $mimeType);
     } catch (\tao_models_classes_FileNotFoundException $e) {
         $this->setData('error', __('No file found for this media'));
     }
     $this->setView('form.tpl');
 }
 /**
  * Edit a Test Center instance
  * @return void
  */
 public function editCenter()
 {
     $clazz = $this->getCurrentClass();
     $testcenter = $this->getCurrentInstance();
     $formContainer = new \tao_actions_form_Instance($clazz, $testcenter);
     $myForm = $formContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($testcenter);
             $testcenter = $binder->bind($myForm->getValues());
             $this->setData("selectNode", \tao_helpers_Uri::encode($testcenter->getUri()));
             $this->setData('message', __('Test center saved'));
             $this->setData('reload', true);
         }
     }
     $memberProperty = new \core_kernel_classes_Property(TestCenterService::PROPERTY_MEMBERS_URI);
     $memberForm = \tao_helpers_form_GenerisTreeForm::buildReverseTree($testcenter, $memberProperty);
     $memberForm->setData('title', __('Select test takers for the test center'));
     $this->setData('memberForm', $memberForm->render());
     $groupProperty = new \core_kernel_classes_Property(TestCenterService::PROPERTY_DELIVERY_URI);
     $groupForm = \tao_helpers_form_GenerisTreeForm::buildTree($testcenter, $groupProperty);
     $groupForm->setData('title', __('Select deliveries available at the test center'));
     $this->setData('groupForm', $groupForm->render());
     $proctorProperty = new \core_kernel_classes_Property(TestCenterService::PROPERTY_PROCTORS_URI);
     $proctorForm = \tao_helpers_form_GenerisTreeForm::buildReverseTree($testcenter, $proctorProperty);
     $proctorForm->setData('title', __('Select proctors for the test center'));
     $this->setData('proctorForm', $proctorForm->render());
     $this->setData('formTitle', __('Edit test center'));
     $this->setData('myForm', $myForm->render());
     $this->setView('form_test_center.tpl');
 }
 /**
  * Edit a delivery instance
  *
  * @access public
  * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
  * @return void
  */
 public function editDelivery()
 {
     $clazz = $this->getCurrentClass();
     $delivery = $this->getCurrentInstance();
     $formContainer = new taoDelivery_actions_form_Delivery($clazz, $delivery);
     $myForm = $formContainer->getForm();
     $myForm->evaluate();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $propertyValues = $myForm->getValues();
             // then save the property values as usual
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($delivery);
             $delivery = $binder->bind($propertyValues);
             $this->setData("selectNode", tao_helpers_Uri::encode($delivery->getUri()));
             $this->setData('message', __('Delivery saved'));
             $this->setData('reload', true);
         }
     }
     $this->setData('label', $delivery->getLabel());
     // history
     $this->setData('date', taoDelivery_models_classes_DeliveryAssemblyService::singleton()->getCompilationDate($delivery));
     if (taoDelivery_models_classes_execution_ServiceProxy::singleton()->implementsMonitoring()) {
         $execs = taoDelivery_models_classes_execution_ServiceProxy::singleton()->getExecutionsByDelivery($delivery);
         $this->setData('exec', count($execs));
     }
     // define the groups related to the current delivery
     $property = new core_kernel_classes_Property(PROPERTY_GROUP_DELVIERY);
     $tree = tao_helpers_form_GenerisTreeForm::buildReverseTree($delivery, $property);
     $tree->setTitle(__('Assigned to'));
     $tree->setTemplate(Template::getTemplate('widgets/assignGroup.tpl'));
     $this->setData('groupTree', $tree->render());
     // testtaker brick
     $this->setData('assemblyUri', $delivery->getUri());
     // define the subjects excluded from the current delivery
     $property = new core_kernel_classes_Property(TAO_DELIVERY_EXCLUDEDSUBJECTS_PROP);
     $excluded = $delivery->getPropertyValues($property);
     $this->setData('ttexcluded', count($excluded));
     $users = taoDelivery_models_classes_AssignmentService::singleton()->getAssignedUsers($delivery);
     $assigned = array_diff(array_unique($users), $excluded);
     $this->setData('ttassigned', count($assigned));
     $this->setData('formTitle', __('Properties'));
     $this->setData('myForm', $myForm->render());
     if (common_ext_ExtensionsManager::singleton()->isEnabled('taoCampaign')) {
         $this->setData('campaign', taoCampaign_helpers_Campaign::renderCampaignTree($delivery));
     }
     $this->setView('Delivery/editDelivery.tpl');
 }
Exemplo n.º 8
0
 /**
  * edit a test instance
  * @requiresRight id READ
  */
 public function editTest()
 {
     $test = new core_kernel_classes_Resource($this->getRequestParameter('id'));
     if (!$this->isLocked($test)) {
         // my lock
         $lock = LockManager::getImplementation()->getLockData($test);
         if (!is_null($lock) && $lock->getOwnerId() == common_session_SessionManager::getSession()->getUser()->getIdentifier()) {
             $this->setData('lockDate', $lock->getCreationTime());
             $this->setData('id', $lock->getResource()->getUri());
         }
         $clazz = $this->getCurrentClass();
         $formContainer = new tao_actions_form_Instance($clazz, $test);
         $myForm = $formContainer->getForm();
         if ($myForm->isSubmited()) {
             if ($myForm->isValid()) {
                 $propertyValues = $myForm->getValues();
                 // don't hande the testmodel via bindProperties
                 if (array_key_exists(PROPERTY_TEST_TESTMODEL, $propertyValues)) {
                     $modelUri = $propertyValues[PROPERTY_TEST_TESTMODEL];
                     unset($propertyValues[PROPERTY_TEST_TESTMODEL]);
                     if (!empty($modelUri)) {
                         $testModel = new core_kernel_classes_Resource($modelUri);
                         $this->service->setTestModel($test, $testModel);
                     }
                 } else {
                     common_Logger::w('No testmodel on test form', 'taoTests');
                 }
                 //then save the property values as usual
                 $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($test);
                 $test = $binder->bind($propertyValues);
                 //edit process label:
                 $this->service->onChangeTestLabel($test);
                 $this->setData("selectNode", tao_helpers_Uri::encode($test->getUri()));
                 $this->setData('message', __('Test saved'));
                 $this->setData('reload', true);
             }
         }
         $myForm->removeElement(tao_helpers_Uri::encode(TEST_TESTCONTENT_PROP));
         $this->setData('uri', tao_helpers_Uri::encode($test->getUri()));
         $this->setData('classUri', tao_helpers_Uri::encode($clazz->getUri()));
         $this->setData('formTitle', __('Test properties'));
         $this->setData('myForm', $myForm->render());
         $this->setView('Tests/editTest.tpl');
     }
 }
Exemplo n.º 9
0
 /**
  * Edit an instances 
  * @return void
  */
 public function sasEditInstance()
 {
     $clazz = $this->getCurrentClass();
     $instance = $this->getCurrentInstance();
     $formContainer = new tao_actions_form_Instance($clazz, $instance);
     $myForm = $formContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($instance);
             $instance = $binder->bind($myForm->getValues());
             $instance = $this->service->setDefaultItemContent($instance);
             $this->setData('message', __('Item saved'));
         }
     }
     $this->setData('uri', tao_helpers_Uri::encode($instance->getUri()));
     $this->setData('classUri', tao_helpers_Uri::encode($clazz->getUri()));
     $this->setData('formTitle', __('Edit item'));
     $this->setData('myForm', $myForm->render());
     $this->setView('form.tpl', 'tao');
 }
 public function editInstance()
 {
     $clazz = $this->getCurrentClass();
     $instance = $this->getCurrentInstance();
     $myFormContainer = new wfAuthoring_actions_form_InstanceServiceDefinition($clazz, $instance);
     $myForm = $myFormContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $values = $myForm->getValues();
             // save properties
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($instance);
             $instance = $binder->bind($values);
             $message = __('Instance saved');
             $this->setData('message', $message);
             $this->setData('reload', true);
         }
     }
     $this->setData('formTitle', __('Edit Instance'));
     $this->setData('myForm', $myForm->render());
     $this->setView('form.tpl', 'tao');
 }
 /**
  * Edit a delviery instance
  * @return void
  */
 public function editCampaign()
 {
     $clazz = $this->getCurrentClass();
     $campaign = $this->getCurrentInstance();
     $formContainer = new tao_actions_form_Instance($clazz, $campaign);
     $myForm = $formContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($campaign);
             $campaign = $binder->bind($myForm->getValues());
             $this->setData("selectNode", tao_helpers_Uri::encode($campaign->getUri()));
             $this->setData('message', __('Campaign saved'));
             $this->setData('reload', true);
         }
     }
     //get the deliveries related to this delivery campaign
     $prop = new core_kernel_classes_Property(TAO_DELIVERY_CAMPAIGN_PROP);
     $tree = tao_helpers_form_GenerisTreeForm::buildReverseTree($campaign, $prop);
     $this->setData('deliveryTree', $tree->render());
     $this->setData('formTitle', __('Edit Campaign'));
     $this->setData('myForm', $myForm->render());
     $this->setView('form_campaign.tpl');
 }
Exemplo n.º 12
0
 /**
  * Edit a group instance
  * @return void
  */
 public function editRole()
 {
     $clazz = $this->getCurrentClass();
     $role = $this->getCurrentInstance();
     $formContainer = new tao_actions_form_Role($clazz, $role);
     $myForm = $formContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $formValues = $myForm->getValues();
             $roleService = tao_models_classes_RoleService::singleton();
             $includedRolesProperty = new core_kernel_classes_Property(PROPERTY_ROLE_INCLUDESROLE);
             // We have to make the difference between the old list
             // of included roles and the new ones.
             $oldIncludedRolesUris = $role->getPropertyValues($includedRolesProperty);
             $newIncludedRolesUris = $formValues[PROPERTY_ROLE_INCLUDESROLE];
             $removeIncludedRolesUris = array_diff($oldIncludedRolesUris, $newIncludedRolesUris);
             $addIncludedRolesUris = array_diff($newIncludedRolesUris, $oldIncludedRolesUris);
             // Make the changes according to the detected differences.
             foreach ($removeIncludedRolesUris as $rU) {
                 $r = new core_kernel_classes_Resource($rU);
                 $roleService->unincludeRole($role, $r);
             }
             foreach ($addIncludedRolesUris as $aU) {
                 $r = new core_kernel_classes_Resource($aU);
                 $roleService->includeRole($role, $r);
             }
             // Let's deal with other properties the usual way.
             unset($formValues[$includedRolesProperty->getUri()]);
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($role);
             $role = $binder->bind($myForm->getValues());
             core_kernel_users_Cache::removeIncludedRoles($role);
             // flush cache for this role.
             $this->setData('selectNode', tao_helpers_Uri::encode($role->getUri()));
             $this->setData('message', __('Role saved'));
             $this->setData('reload', true);
         }
     }
     $this->setData('uri', tao_helpers_Uri::encode($role->getUri()));
     $this->setData('classUri', tao_helpers_Uri::encode($clazz->getUri()));
     $this->setData('formTitle', 'Edit Role');
     $this->setData('myForm', $myForm->render());
     $this->setView('roles/form.tpl');
 }
 /**
  * Returns the proctor creation form
  */
 public function createProctorForm()
 {
     $myFormContainer = new AddProctor();
     $myForm = $myFormContainer->getForm();
     $valid = false;
     $created = false;
     $form = '';
     if ($myForm->isSubmited()) {
         $valid = $myForm->isValid();
         if ($valid) {
             $values = $myForm->getValues();
             $values[PROPERTY_USER_PASSWORD] = \core_kernel_users_Service::getPasswordHash()->encrypt($values['password1']);
             unset($values['password1']);
             unset($values['password2']);
             //force the new user role to be proctorRole
             $values[PROPERTY_USER_ROLES] = array('http://www.tao.lu/Ontologies/TAOProctor.rdf#ProctorRole');
             //@todo use a constant instead
             $proctor = $myFormContainer->getUser();
             $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($proctor);
             $created = $binder->bind($values);
             if ($created) {
                 //assign then authorize the new proctor to the selected test centers
                 ProctorManagementService::singleton()->assignProctors(array($proctor->getUri()), SessionManager::getSession()->getUserUri());
                 $testCenters = $this->getRequestTestCenters();
                 if (!empty($testCenters)) {
                     ProctorManagementService::singleton()->authorizeProctors(array($proctor->getUri()), $testCenters);
                 }
             }
         } else {
             $form = $myForm->render();
         }
     } else {
         $form = $myForm->render();
     }
     $this->returnJson(array('form' => $form, 'valid' => $valid, 'created' => $created, 'loginId' => tao_helpers_Uri::encode(PROPERTY_USER_LOGIN), 'debug' => array('values' => $myForm->getValues())));
 }
 /**
  * Edit a delivery instance
  * @return void
  */
 public function editResultServer()
 {
     $clazz = $this->getCurrentClass();
     $resultServer = $this->getCurrentResultServer();
     $formContainer = new tao_actions_form_Instance($clazz, $resultServer);
     $myForm = $formContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($resultServer);
             $resultServer = $binder->bind($myForm->getValues());
             $this->setData("selectNode", tao_helpers_Uri::encode($resultServer->getUri()));
             $this->setData('message', __('Result Server saved'));
             $this->setData('reload', true);
         }
     }
     $this->setSessionAttribute("showNodeUri", tao_helpers_Uri::encode($resultServer->getUri()));
     $this->setData('formTitle', __('Edit ResultServer'));
     $this->setData('myForm', $myForm->render());
     $this->setView('form_resultserver.tpl');
 }
 /**
  * Save the delivery.
  * 
  * @param \core_kernel_classes_Class $delivery
  * @param array $params Array of delivery parameters (uri=>value)
  * @return \core_kernel_classes_Class $delivery instance
  */
 public function save(\core_kernel_classes_Class $delivery, array $params)
 {
     if (!empty($params['repeatedDelivery']) && isset($params[RepeatedDeliveryService::PROPERTY_NUMBER_OF_REPETITION])) {
         $repeatedDeliveryService = ServiceManager::getServiceManager()->get(RepeatedDeliveryService::CONFIG_ID);
         $delivery = $repeatedDeliveryService->getDelivery($delivery, $params[RepeatedDeliveryService::PROPERTY_NUMBER_OF_REPETITION], true);
     } else {
         $data = $this->sanitizeParams($params);
         $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($delivery);
         $delivery = $binder->bind($data);
     }
     if (isset($params['groups'])) {
         $groups = array_filter($params['groups']);
         $groups = array_map(array('\\tao_helpers_Uri', 'decode'), $groups);
         ServiceManager::getServiceManager()->get('taoDeliverySchedule/DeliveryGroupsService')->saveGroups($delivery, $groups);
     }
     if (isset($params['ttexcluded'])) {
         $ttExcluded = is_array($params['ttexcluded']) ? $params['ttexcluded'] : array();
         DeliveryTestTakersService::singleton()->saveExcludedTestTakers($delivery, $ttExcluded);
     }
     return $delivery;
 }
Exemplo n.º 16
0
 /**
  * render the repository form
  * @return void
  */
 public function editRepository()
 {
     //$myFormContainer = new tao_actions_form_Versioning();
     $clazz = $this->getCurrentClass();
     $repo = $this->getCurrentInstance();
     $myFormContainer = new tao_actions_form_Repository($clazz, $repo);
     $myForm = $myFormContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $oldState = $repo->getPropertyValues(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_ENABLED));
             $oldState = count($oldState) == 1 ? current($oldState) : GENERIS_FALSE;
             $values = $myForm->getValues();
             $newState = $values[PROPERTY_GENERIS_VERSIONEDREPOSITORY_ENABLED];
             if ($oldState == GENERIS_TRUE && $newState != GENERIS_FALSE) {
                 throw new common_Exception('Cannot change an active Repository');
             }
             $values = $myForm->getValues();
             if (isset($values[PROPERTY_GENERIS_VERSIONEDREPOSITORY_ENABLED])) {
                 unset($values[PROPERTY_GENERIS_VERSIONEDREPOSITORY_ENABLED]);
             }
             // save properties
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($repo);
             $repo = $binder->bind($values);
             $message = __('Repository saved');
             core_kernel_fileSystem_Cache::flushCache();
             // check if enable/disable necessary
             if ($newState == GENERIS_TRUE && $oldState != GENERIS_TRUE) {
                 // enable the repository
                 $success = $repo->enable();
                 $message = $success ? __('Repository saved and enabled') : __('Repository saved, but unable to enable');
             } elseif ($newState != GENERIS_TRUE && $oldState == GENERIS_TRUE) {
                 // disable the repository
                 $success = $repo->disable();
                 $message = $success ? __('Repository saved and disabled') : __('Repository saved, but unable to disable');
             }
             $this->setData('message', $message);
             $this->setData('reload', true);
         }
     }
     $this->setData('formTitle', __('Revision control'));
     $this->setData('myForm', $myForm->render());
     $this->setView('form.tpl', 'tao');
 }
Exemplo n.º 17
0
 /**
  * edit an subject instance
  * 
  */
 public function editSubject()
 {
     $clazz = $this->getCurrentClass();
     // get the subject to edit
     $subject = $this->getCurrentInstance();
     $addMode = false;
     $login = (string) $subject->getOnePropertyValue(new \core_kernel_classes_Property(PROPERTY_USER_LOGIN));
     if (empty($login)) {
         $addMode = true;
         $this->setData('loginUri', \tao_helpers_Uri::encode(PROPERTY_USER_LOGIN));
     }
     if ($this->hasRequestParameter('reload')) {
         $this->setData('reload', true);
     }
     $myFormContainer = new TestTakerForm($clazz, $subject, $addMode, false);
     $myForm = $myFormContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $this->setData('reload', false);
             $values = $myForm->getValues();
             if ($addMode) {
                 $values[PROPERTY_USER_PASSWORD] = \core_kernel_users_Service::getPasswordHash()->encrypt($values['password1']);
                 unset($values['password1']);
                 unset($values['password2']);
             } else {
                 if (!empty($values['password2'])) {
                     $values[PROPERTY_USER_PASSWORD] = \core_kernel_users_Service::getPasswordHash()->encrypt($values['password2']);
                 }
                 unset($values['password2']);
                 unset($values['password3']);
             }
             $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($subject);
             $subject = $binder->bind($values);
             $this->getEventManager()->trigger(new TestTakerUpdatedEvent($subject->getUri(), $values));
             if ($addMode) {
                 // force default subject roles to be the Delivery Role:
                 $this->service->setTestTakerRole($subject);
             }
             // force the data language to be the same as the gui language
             $userService = \tao_models_classes_UserService::singleton();
             $lang = new \core_kernel_classes_Resource($values[PROPERTY_USER_UILG]);
             $userService->bindProperties($subject, array(PROPERTY_USER_DEFLG => $lang->getUri()));
             $message = __('Test taker saved');
             if ($addMode) {
                 $params = array('uri' => \tao_helpers_Uri::encode($subject->getUri()), 'classUri' => \tao_helpers_Uri::encode($clazz->getUri()), 'reload' => true, 'message' => $message);
                 $this->redirect(_url('editSubject', null, null, $params));
             }
             $this->setData("selectNode", \tao_helpers_Uri::encode($subject->getUri()));
             $this->setData('message', $message);
             $this->setData('reload', true);
         }
     }
     if (\common_ext_ExtensionsManager::singleton()->isEnabled('taoGroups')) {
         $this->setData('groupForm', GroupForm::renderGroupTreeForm($subject));
     }
     $this->setData('checkLogin', $addMode);
     $this->setData('formTitle', __('Edit subject'));
     $this->setData('myForm', $myForm->render());
     $this->setView('form_subjects.tpl');
 }
Exemplo n.º 18
0
 /**
  * Form to edit a user
  * User login must be set in parameter
  * @return void
  */
 public function edit()
 {
     if (!$this->hasRequestParameter('uri')) {
         throw new Exception('Please set the user uri in request parameter');
     }
     $user = new core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('uri')));
     $this->checkUser($user->getUri());
     $types = $user->getTypes();
     $myFormContainer = new tao_actions_form_Users(reset($types), $user);
     $myForm = $myFormContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $values = $myForm->getValues();
             if (!empty($values['password2']) && !empty($values['password3'])) {
                 $values[PROPERTY_USER_PASSWORD] = core_kernel_users_Service::getPasswordHash()->encrypt($values['password2']);
             }
             unset($values['password2']);
             unset($values['password3']);
             if (!preg_match("/[A-Z]{2,4}\$/", trim($values[PROPERTY_USER_UILG]))) {
                 unset($values[PROPERTY_USER_UILG]);
             }
             if (!preg_match("/[A-Z]{2,4}\$/", trim($values[PROPERTY_USER_DEFLG]))) {
                 unset($values[PROPERTY_USER_DEFLG]);
             }
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($user);
             if ($binder->bind($values)) {
                 $this->getEventManager()->trigger(new UserUpdatedEvent($user, $values));
                 $this->setData('message', __('User saved'));
             }
         }
     }
     $this->setData('formTitle', __('Edit a user'));
     $this->setData('myForm', $myForm->render());
     $this->setView('user/form.tpl');
 }
Exemplo n.º 19
0
 /**
  * edit an item instance
  * @requiresRight id READ
  */
 public function editItem()
 {
     $itemClass = $this->getCurrentClass();
     $item = $this->getCurrentInstance();
     if (!$this->isLocked($item, 'item_locked.tpl')) {
         // my lock
         $lock = LockManager::getImplementation()->getLockData($item);
         if (!is_null($lock) && $lock->getOwnerId() == common_session_SessionManager::getSession()->getUser()->getIdentifier()) {
             $this->setData('lockDate', $lock->getCreationTime());
             $this->setData('id', $item->getUri());
         }
         $formContainer = new taoItems_actions_form_Item($itemClass, $item);
         $myForm = $formContainer->getForm();
         if ($this->hasWriteAccess($item->getUri())) {
             if ($myForm->isSubmited() && $this->hasWriteAccess($item->getUri())) {
                 if ($myForm->isValid()) {
                     $properties = $myForm->getValues();
                     unset($properties[TAO_ITEM_CONTENT_PROPERTY]);
                     unset($properties['warning']);
                     unset($properties['itemModelLabel']);
                     //bind item properties and set default content:
                     $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($item);
                     $item = $binder->bind($properties);
                     $item = $this->getClassService()->setDefaultItemContent($item);
                     //if item label has been changed, do not use getLabel() to prevent cached value from lazy loading
                     $label = $item->getOnePropertyValue(new core_kernel_classes_Property(RDFS_LABEL));
                     $this->setData("selectNode", tao_helpers_Uri::encode($item->getUri()));
                     $this->setData('label', $label != null ? $label->literal : '');
                     $this->setData('message', __('Item saved'));
                     $this->setData('reload', true);
                 }
             }
         } else {
             $myForm->setActions(array());
         }
         $currentModel = $this->getClassService()->getItemModel($item);
         $hasPreview = false;
         $hasModel = false;
         if (!empty($currentModel)) {
             $hasModel = true;
             $isDeprecated = $this->getClassService()->hasModelStatus($item, array(TAO_ITEM_MODEL_STATUS_DEPRECATED));
             $hasPreview = !$isDeprecated && $this->getClassService()->hasItemContent($item);
         }
         $myForm->removeElement(tao_helpers_Uri::encode(TAO_ITEM_CONTENT_PROPERTY));
         $this->setData('isPreviewEnabled', $hasPreview);
         $this->setData('isAuthoringEnabled', $hasModel);
         $this->setData('formTitle', __('Edit Item'));
         $this->setData('myForm', $myForm->render());
         $this->setView('Items/editItem.tpl');
     }
 }