Example #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');
 }
Example #2
0
 /**
  * Short description of method exec
  *
  * @access public
  * @author Cédric Alfonsi, <*****@*****.**>
  * @param  Resource resource
  * @param  string command
  * @return string
  */
 public static function exec(core_kernel_classes_Resource $resource, $command)
 {
     $returnValue = (string) '';
     $username = "";
     $password = "";
     $repository = null;
     try {
         if (empty($command)) {
             throw new Exception(__CLASS__ . ' -> ' . __FUNCTION__ . '() : $command_ must be specified');
         }
         //get context variables
         if ($resource instanceof core_kernel_versioning_File) {
             $repository = $resource->getRepository();
         } else {
             if ($resource instanceof core_kernel_versioning_Repository) {
                 $repository = $resource;
             } else {
                 throw new Exception('The first parameter (resource) should be a File or a Repository');
             }
         }
         if (is_null($repository)) {
             throw new Exception('Unable to find the repository to work with for the reference resource (' . $resource->getUri() . ')');
         }
         $username = $repository->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_LOGIN));
         $password = $repository->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_PASSWORD));
         $returnValue = shell_exec('svn --username ' . $username . ' --password ' . $password . ' ' . $command);
         //                var_dump('svn --username ' . $username . ' --password ' . $password . ' ' . $command);
         //                var_dump($returnValue);
     } catch (Exception $e) {
         die('Error code `svn_error_command` in ' . $e->getMessage());
     }
     return (string) $returnValue;
 }
 /**
  * Short description of method getExpression
  *
  * @access public
  * @author Somsack Sipasseuth, <*****@*****.**>
  * @param  Resource rule
  * @return mixed
  */
 public function getExpression(core_kernel_classes_Resource $rule)
 {
     $returnValue = null;
     $property = new core_kernel_classes_Property(PROPERTY_RULE_IF);
     $returnValue = new core_kernel_rules_Expression($rule->getUniquePropertyValue($property)->getUri(), __METHOD__);
     return $returnValue;
 }
Example #4
0
 /**
  * Search results
  * The search is paginated and initiated by the datatable component.
  */
 public function search()
 {
     $params = $this->getRequestParameter('params');
     $query = $params['query'];
     $class = new core_kernel_classes_Class($params['rootNode']);
     $rows = $this->hasRequestParameter('rows') ? (int) $this->getRequestParameter('rows') : null;
     $page = $this->hasRequestParameter('page') ? (int) $this->getRequestParameter('page') : 1;
     $startRow = is_null($rows) ? 0 : $rows * ($page - 1);
     try {
         $results = SearchService::getSearchImplementation()->query($query, $class, $startRow, $rows);
         $totalPages = is_null($rows) ? 1 : ceil($results->getTotalCount() / $rows);
         $response = new StdClass();
         if (count($results) > 0) {
             foreach ($results as $uri) {
                 $instance = new core_kernel_classes_Resource($uri);
                 $instanceProperties = array('id' => $instance->getUri(), RDFS_LABEL => $instance->getLabel());
                 $response->data[] = $instanceProperties;
             }
         }
         $response->success = true;
         $response->page = empty($response->data) ? 0 : $page;
         $response->total = $totalPages;
         $response->records = count($results);
         $this->returnJson($response, 200);
     } catch (SyntaxException $e) {
         $this->returnJson(array('success' => false, 'msg' => $e->getUserMessage()));
     }
 }
 public function testCompile()
 {
     //test with items
     $config = array('previous' => true);
     $items = array($this->item->getUri());
     $this->testModel->save($this->test, array('itemUris' => $items, 'config' => $config));
     $waitingReport = new \common_report_Report(\common_report_Report::TYPE_SUCCESS);
     $serviceCall = $this->getMockBuilder('tao_models_classes_service_ServiceCall')->disableOriginalConstructor()->setMethods(array('serializeToString'))->getMock();
     $serviceCall->expects($this->once())->method('serializeToString')->willReturn('greatString');
     $waitingReport->setData($serviceCall);
     $testCompiler = $this->getMockBuilder('oat\\taoTestLinear\\model\\TestCompiler')->setConstructorArgs(array($this->test, $this->storage))->setMethods(array('subCompile', 'spawnPrivateDirectory'))->getMock();
     $testCompiler->expects($this->once())->method('subCompile')->willReturn($waitingReport);
     //will spawn a new directory and store the content file
     $directoryMock = $this->getMockBuilder('tao_models_classes_service_StorageDirectory')->disableOriginalConstructor()->setMethods(array('getPath'))->getMock();
     if (!file_exists(sys_get_temp_dir() . '/sample/compile/')) {
         mkdir(sys_get_temp_dir() . '/sample/compile/', 0777, true);
     }
     $directoryMock->expects($this->once())->method('getPath')->willReturn(sys_get_temp_dir() . '/sample/compile/');
     $testCompiler->expects($this->once())->method('spawnPrivateDirectory')->willReturn($directoryMock);
     $report = $testCompiler->compile();
     $this->assertEquals(__('Test Compilation'), $report->getMessage(), __('Compilation should work'));
     $this->assertFileExists(sys_get_temp_dir() . '/sample/compile/data.json', __('Compilation file not created'));
     $compile = '{"items":{"http:\\/\\/myFancyDomain.com\\/myGreatResourceUriForItem":"greatString"},"previous":true}';
     $this->assertEquals($compile, file_get_contents(sys_get_temp_dir() . '/sample/compile/data.json', __('File content error')));
 }
 /**
  * Creates a new delivery
  * 
  * @param core_kernel_classes_Class $deliveryClass
  * @param core_kernel_classes_Resource $test
  * @param array $properties Array of properties of delivery
  * @return common_report_Report
  */
 public static function create(\core_kernel_classes_Class $deliveryClass, \core_kernel_classes_Resource $test, $properties = array())
 {
     \common_Logger::i('Creating delivery with ' . $test->getLabel() . ' under ' . $deliveryClass->getLabel());
     $storage = new TrackedStorage();
     $testCompilerClass = \taoTests_models_classes_TestsService::singleton()->getCompilerClass($test);
     $compiler = new $testCompilerClass($test, $storage);
     $report = $compiler->compile();
     if ($report->getType() == \common_report_Report::TYPE_SUCCESS) {
         //$tz = new \DateTimeZone(\common_session_SessionManager::getSession()->getTimeZone());
         $tz = new \DateTimeZone('UTC');
         if (!empty($properties[TAO_DELIVERY_START_PROP])) {
             $dt = new \DateTime($properties[TAO_DELIVERY_START_PROP], $tz);
             $properties[TAO_DELIVERY_START_PROP] = (string) $dt->getTimestamp();
         }
         if (!empty($properties[TAO_DELIVERY_END_PROP])) {
             $dt = new \DateTime($properties[TAO_DELIVERY_END_PROP], $tz);
             $properties[TAO_DELIVERY_END_PROP] = (string) $dt->getTimestamp();
         }
         $serviceCall = $report->getData();
         $properties[PROPERTY_COMPILEDDELIVERY_DIRECTORY] = $storage->getSpawnedDirectoryIds();
         $compilationInstance = DeliveryAssemblyService::singleton()->createAssemblyFromServiceCall($deliveryClass, $serviceCall, $properties);
         $report->setData($compilationInstance);
     }
     return $report;
 }
 /**
  * Manage permissions
  */
 protected function adminPermissions()
 {
     $resource = new \core_kernel_classes_Resource($this->getRequestParameter('id'));
     $accessRights = AdminService::getUsersPermissions($resource->getUri());
     $userList = $this->getUserList();
     $roleList = $this->getRoleList();
     $this->setData('privileges', PermissionProvider::getRightLabels());
     $userData = array();
     foreach (array_keys($accessRights) as $uri) {
         if (isset($userList[$uri])) {
             $userData[$uri] = array('label' => $userList[$uri], 'isRole' => false);
             unset($userList[$uri]);
         } elseif (isset($roleList[$uri])) {
             $userData[$uri] = array('label' => $roleList[$uri], 'isRole' => true);
             unset($roleList[$uri]);
         } else {
             \common_Logger::d('unknown user ' . $uri);
         }
     }
     $this->setData('users', $userList);
     $this->setData('roles', $roleList);
     $this->setData('userPrivileges', $accessRights);
     $this->setData('userData', $userData);
     $this->setData('uri', $resource->getUri());
     $this->setData('label', _dh($resource->getLabel()));
     $this->setView('AdminAccessController/index.tpl');
 }
 public function tearDown()
 {
     if ($this->item) {
         $this->item->delete();
     }
     parent::tearDown();
 }
 public function testImport()
 {
     $endpoint = ROOT_URL . 'taoQtiTest/RestQtiTests/import';
     $file = __DIR__ . '/samples/archives/QTI 2.1/basic/Basic.zip';
     $this->assertFileExists($file);
     $post_data = array('qtiPackage' => new \CURLFile($file));
     $options = array(CURLOPT_POSTFIELDS => $post_data);
     $content = $this->curl($endpoint, CURLOPT_POST, "data", $options);
     $data = json_decode($content, true);
     $this->assertTrue(is_array($data), 'Should return json encoded array');
     $this->assertTrue($data['success']);
     $this->assertTrue(isset($data['data']));
     $this->assertTrue(is_array($data['data']));
     $this->assertCount(1, $data['data']);
     $testData = reset($data['data']);
     $this->assertTrue(isset($testData['testId']));
     $uri = $testData['testId'];
     $test = new \core_kernel_classes_Resource($uri);
     $this->assertTrue($test->exists());
     $deletionCall = ROOT_URL . 'taoTests/RestTests?uri=' . urlencode($uri);
     $content = $this->curl($deletionCall, 'DELETE', "data");
     $data = json_decode($content, true);
     $this->assertTrue(is_array($data), 'Should return json encoded array');
     $this->assertTrue($data['success']);
     $this->assertFalse($test->exists());
     // should return an error, instance no longer exists
     $content = $this->curl($deletionCall, 'DELETE', "data");
     $data = json_decode($content, true);
     $this->assertTrue(is_array($data), 'Should return json encoded array');
     $this->assertFalse($data['success']);
 }
 public function getResourceDescription(core_kernel_classes_Resource $resource, $fromDefinition = true)
 {
     $returnValue = new stdClass();
     $properties = array();
     if ($fromDefinition) {
         $types = $resource->getTypes();
         foreach ($types as $type) {
             foreach ($type->getProperties(true) as $property) {
                 //$this->$$property->getUri() = array($property->getLabel(),$this->getPropertyValues());
                 $properties[$property->getUri()] = $property;
             }
         }
         //var_dump($properties);
         $properties = array_unique($properties);
         $propertiesValues = $resource->getPropertiesValues($properties);
         if (count($propertiesValues) == 0) {
             throw new common_exception_NoContent();
         }
         $propertiesValuesStdClasses = $this->propertiesValuestoStdClasses($propertiesValues);
     } else {
         $triples = $resource->getRdfTriples();
         if (count($triples) == 0) {
             throw new common_exception_NoContent();
         }
         foreach ($triples as $triple) {
             $properties[$triple->predicate][] = common_Utils::isUri($triple->object) ? new core_kernel_classes_Resource($triple->object) : new core_kernel_classes_Literal($triple->object);
         }
         $propertiesValuesStdClasses = $this->propertiesValuestoStdClasses($properties);
     }
     $returnValue->uri = $resource->getUri();
     $returnValue->properties = $propertiesValuesStdClasses;
     return $returnValue;
 }
Example #11
0
 /**
  * Short description of method getValue
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Resource resource
  * @param  Column column
  * @return string
  */
 public function getValue(core_kernel_classes_Resource $resource, tao_models_classes_table_Column $column)
 {
     $returnValue = (string) '';
     $result = $resource->getOnePropertyValue($column->getProperty());
     $returnValue = $result instanceof core_kernel_classes_Resource ? $result->getLabel() : (string) $result;
     return (string) $returnValue;
 }
 /**
  * Short description of method remove
  *
  * @access public
  * @author Jehan Bihin, <*****@*****.**>
  * @param  string $roleUri
  * @param  string $accessUri
  * @return mixed
  */
 public function remove($roleUri, $accessUri)
 {
     $module = new core_kernel_classes_Resource($accessUri);
     $role = new core_kernel_classes_Class($roleUri);
     $accessProperty = new core_kernel_classes_Property(funcAcl_models_classes_AccessService::PROPERTY_ACL_GRANTACCESS);
     // Retrieve the module ID.
     $uri = explode('#', $module->getUri());
     list($type, $extId, $modId) = explode('_', $uri[1]);
     // access via extension?
     $extAccess = funcAcl_helpers_Cache::getExtensionAccess($extId);
     if (in_array($roleUri, $extAccess)) {
         // remove access to extension
         $extUri = $this->makeEMAUri($extId);
         funcAcl_models_classes_ExtensionAccessService::singleton()->remove($roleUri, $extUri);
         // add access to all other controllers
         foreach (funcAcl_helpers_Model::getModules($extId) as $eModule) {
             if (!$module->equals($eModule)) {
                 $this->add($roleUri, $eModule->getUri());
                 $this->getEventManager()->trigger(new AccessRightRemovedEvent($roleUri, $eModule->getUri()));
                 //$role->setPropertyValue($accessProperty, $eModule->getUri());
             }
         }
         //funcAcl_helpers_Cache::flushExtensionAccess($extId);
     }
     // Remove the access to the module for this role.
     $role->removePropertyValue($accessProperty, $module->getUri());
     $this->getEventManager()->trigger(new AccessRightRemovedEvent($roleUri, $accessUri));
     funcAcl_helpers_Cache::cacheModule($module);
     // Remove the access to the actions corresponding to the module for this role.
     foreach (funcAcl_helpers_Model::getActions($module) as $actionResource) {
         funcAcl_models_classes_ActionAccessService::singleton()->remove($role->getUri(), $actionResource->getUri());
     }
     funcAcl_helpers_Cache::cacheModule($module);
 }
 /**
  *
  * @param unknown $userId
  * @param core_kernel_classes_Resource $assembly
  * @return taoDelivery_models_classes_execution_KVDeliveryExecution
  */
 public static function spawn(common_persistence_KeyValuePersistence $persistence, $userId, core_kernel_classes_Resource $assembly)
 {
     $identifier = self::DELIVERY_EXECUTION_PREFIX . common_Utils::getNewUri();
     $de = new self($persistence, $identifier, array(RDFS_LABEL => $assembly->getLabel(), PROPERTY_DELVIERYEXECUTION_DELIVERY => $assembly->getUri(), PROPERTY_DELVIERYEXECUTION_SUBJECT => $userId, PROPERTY_DELVIERYEXECUTION_START => time(), PROPERTY_DELVIERYEXECUTION_STATUS => INSTANCE_DELIVERYEXEC_ACTIVE));
     $de->save();
     return $de;
 }
 /**
  * Short description of method remove
  *
  * @access public
  * @author Jehan Bihin, <*****@*****.**>
  * @param  string roleUri
  * @param  string accessUri
  * @return mixed
  */
 public function remove($roleUri, $accessUri)
 {
     $uri = explode('#', $accessUri);
     list($type, $ext, $mod, $act) = explode('_', $uri[1]);
     $role = new core_kernel_classes_Class($roleUri);
     $actionAccessProperty = new core_kernel_classes_Property(funcAcl_models_classes_AccessService::PROPERTY_ACL_GRANTACCESS);
     $module = new core_kernel_classes_Resource($this->makeEMAUri($ext, $mod));
     $controllerClassName = funcAcl_helpers_Map::getControllerFromUri($module->getUri());
     // access via controller?
     $controllerAccess = funcAcl_helpers_Cache::getControllerAccess($controllerClassName);
     if (in_array($roleUri, $controllerAccess['module'])) {
         // remove access to controller
         funcAcl_models_classes_ModuleAccessService::singleton()->remove($roleUri, $module->getUri());
         // add access to all other actions
         foreach (funcAcl_helpers_Model::getActions($module) as $action) {
             if ($action->getUri() != $accessUri) {
                 $this->add($roleUri, $action->getUri());
                 $this->getEventManager()->trigger(new AccessRightAddedEvent($roleUri, $action->getUri()));
             }
         }
     } elseif (isset($controllerAccess['actions'][$act]) && in_array($roleUri, $controllerAccess['actions'][$act])) {
         // remove action only
         $role->removePropertyValues($actionAccessProperty, array('pattern' => $accessUri));
         $this->getEventManager()->trigger(new AccessRightRemovedEvent($roleUri, $accessUri));
         funcAcl_helpers_Cache::flushControllerAccess($controllerClassName);
     }
 }
Example #15
0
 /**
  * Short description of method getValue
  *
  * @access public
  * @author Somsack Sipasseuth, <*****@*****.**>
  * @param  string rowId
  * @param  string columnId
  * @param  string data
  * @return mixed
  */
 public function getValue($rowId, $columnId, $data = null)
 {
     $returnValue = null;
     //@TODO : to be delegated to the LazyAdapter : columnNames, adapterOptions, excludedProperties
     if (isset($this->data[$rowId])) {
         //return values:
         if (isset($this->data[$rowId][$columnId])) {
             $returnValue = $this->data[$rowId][$columnId];
         }
     } else {
         if (common_Utils::isUri($rowId)) {
             $user = new core_kernel_classes_Resource($rowId);
             $this->data[$rowId] = array();
             $fastProperty = array(RDFS_LABEL, PROPERTY_USER_LOGIN, PROPERTY_USER_FIRSTNAME, PROPERTY_USER_LASTNAME, PROPERTY_USER_MAIL, PROPERTY_USER_UILG, PROPERTY_USER_DEFLG);
             $properties = array();
             $propertyUris = array_diff($fastProperty, $this->excludedProperties);
             foreach ($propertyUris as $activityExecutionPropertyUri) {
                 $properties[] = new core_kernel_classes_Property($activityExecutionPropertyUri);
             }
             $propertiesValues = $user->getPropertiesValues($properties);
             foreach ($propertyUris as $propertyUri) {
                 $value = null;
                 if (isset($propertiesValues[$propertyUri]) && count($propertiesValues[$propertyUri])) {
                     $value = reset($propertiesValues[$propertyUri]);
                 }
                 switch ($propertyUri) {
                     case RDFS_LABEL:
                     case PROPERTY_USER_LOGIN:
                     case PROPERTY_USER_FIRSTNAME:
                     case PROPERTY_USER_LASTNAME:
                     case PROPERTY_USER_MAIL:
                     case PROPERTY_USER_LOGIN:
                     case PROPERTY_USER_UILG:
                     case PROPERTY_USER_DEFLG:
                         $this->data[$rowId][$propertyUri] = $value instanceof core_kernel_classes_Resource ? $value->getLabel() : (string) $value;
                         break;
                 }
             }
             //get roles:
             if (!in_array('roles', $this->excludedProperties)) {
                 $i = 0;
                 foreach ($user->getTypes() as $role) {
                     if ($role instanceof core_kernel_classes_Resource) {
                         if ($i) {
                             $this->data[$rowId]['roles'] .= ', ';
                         } else {
                             $this->data[$rowId]['roles'] = '';
                         }
                         $this->data[$rowId]['roles'] .= $role->getLabel();
                     }
                     $i++;
                 }
             }
             if (isset($this->data[$rowId][$columnId])) {
                 $returnValue = $this->data[$rowId][$columnId];
             }
         }
     }
     return $returnValue;
 }
Example #16
0
 public function tearDown()
 {
     // removes the created user
     $user = new \core_kernel_classes_Resource($this->userUri);
     $success = $user->delete();
     $this->restoreCache();
 }
 /**
  * Get tokens as string[] extracted from a QTI file
  * XML inside qti.xml is parsed and all text is tokenized
  *
  * @param \core_kernel_classes_Resource $resource
  * @return array
  */
 public function getStrings(\core_kernel_classes_Resource $resource)
 {
     try {
         $ontologyFiles = $resource->getPropertyValues($this->getProperty(TAO_ITEM_CONTENT_PROPERTY));
         if (empty($ontologyFiles)) {
             return [];
         }
     } catch (\core_kernel_classes_EmptyProperty $e) {
         return [];
     }
     $file = $this->getFileReferenceSerializer()->unserializeDirectory(reset($ontologyFiles))->getFile(Service::QTI_ITEM_FILE);
     if (!$file->exists()) {
         return [];
     }
     $content = $file->read();
     if (empty($content)) {
         return [];
     }
     $dom = new \DOMDocument();
     $dom->loadXML($content);
     $xpath = new \DOMXPath($dom);
     $textNodes = $xpath->query('//text()');
     unset($xpath);
     $contentStrings = array();
     foreach ($textNodes as $textNode) {
         if (ctype_space($textNode->wholeText) === false) {
             $contentStrings[] = trim($textNode->wholeText);
         }
     }
     return $contentStrings;
 }
Example #18
0
 /**
  * Test the existence of language definition resources in the knowledge base
  * regarding what we found in the tao/locales directory.
  * 
  * @author Jerome Bogaerts, <*****@*****.**>
  */
 public function testLanguagesExistence()
 {
     // Check for lang.rdf in /tao locales and query the KB to see if it exists or not.
     $languageClass = new core_kernel_classes_Class(CLASS_LANGUAGES);
     $taoLocalesDir = ROOT_PATH . '/tao/locales';
     $expectedUriPrefix = 'http://www.tao.lu/Ontologies/TAO.rdf#Lang';
     if (false !== ($locales = scandir($taoLocalesDir))) {
         foreach ($locales as $l) {
             $localePath = $taoLocalesDir . '/' . $l;
             if ($l[0] !== '.' && is_dir($localePath) && is_readable($localePath)) {
                 $langPath = $localePath . '/lang.rdf';
                 if (file_exists($langPath)) {
                     $lgResource = new core_kernel_classes_Resource($expectedUriPrefix . $l);
                     $this->assertTrue($lgResource->exists(), '$lgResource Resource does not exist (' . $expectedUriPrefix . $l . ').');
                     // Check for this language in Ontology.
                     $kbLangs = $lgResource->getPropertyValues(new core_kernel_classes_Property(RDF_VALUE));
                     if (is_array($kbLangs)) {
                         $this->assertEquals(count($kbLangs), 1, "Number of languages retrieved for language '{$l}' is '" . count($kbLangs) . "'.");
                         // Check if the language has the correct URI.
                         if ($kbLangs[0] instanceof core_kernel_classes_Resource) {
                             $this->assertTrue($kbLangs[0]->getUri() == $expectedUriPrefix . $l, "Malformed URI scheme for language resource '{$l}'.");
                         }
                     } else {
                         $this->fail('the $kbLangs variable should be an array. "' . gettype($kbLangs) . '" found instead.');
                     }
                 }
             }
         }
     }
 }
 /**
  * 
  * @author Lionel Lecaque, lionel@taotesting.com
  */
 public function wizard()
 {
     $this->defaultData();
     try {
         $formContainer = new \taoSimpleDelivery_actions_form_WizardForm(array('class' => $this->getCurrentClass()));
         $myForm = $formContainer->getForm();
         if ($myForm->isValid() && $myForm->isSubmited()) {
             $label = $myForm->getValue('label');
             $test = new core_kernel_classes_Resource($myForm->getValue('test'));
             $label = __("Delivery of %s", $test->getLabel());
             $deliveryClass = new core_kernel_classes_Class($myForm->getValue('classUri'));
             $report = taoSimpleDelivery_models_classes_SimpleDeliveryService::singleton()->create($deliveryClass, $test, $label);
             if ($report->getType() == common_report_Report::TYPE_SUCCESS) {
                 $assembly = $report->getdata();
                 $this->setData("selectNode", tao_helpers_Uri::encode($assembly->getUri()));
                 $this->setData('reload', true);
                 $this->setData('message', __('Delivery created'));
                 $this->setData('formTitle', __('Create a new delivery'));
                 $this->setView('form.tpl', 'tao');
             } else {
                 $this->setData('report', $report);
                 $this->setData('title', __('Error'));
                 $this->setView('report.tpl', 'tao');
             }
         } else {
             $this->setData('myForm', $myForm->render());
             $this->setData('formTitle', __('Create a new delivery'));
             $this->setView('form.tpl', 'tao');
         }
     } catch (taoSimpleDelivery_actions_form_NoTestsException $e) {
         $this->setView('wizard_error.tpl');
     }
 }
 /**
  *
  * @param array callOptions an array of parameters sent to the results storage configuration
  * @param mixed $resultServer
  * @param string uri or resource
  */
 public function __construct($resultServer, $additionalStorages = array())
 {
     $this->implementations = array();
     if (is_object($resultServer) and get_class($resultServer) == 'core_kernel_classes_Resource') {
         $this->resultServer = $resultServer;
     } else {
         if (common_Utils::isUri($resultServer)) {
             $this->resultServer = new core_kernel_classes_Resource($resultServer);
         }
     }
     // the static storages
     if ($this->resultServer->getUri() != TAO_VOID_RESULT_SERVER) {
         $resultServerModels = $this->resultServer->getPropertyValues(new core_kernel_classes_Property(TAO_RESULTSERVER_MODEL_PROP));
         if (!isset($resultServerModels) or count($resultServerModels) == 0) {
             throw new common_Exception("The result server is not correctly configured (Resource definition)");
         }
         foreach ($resultServerModels as $resultServerModelUri) {
             $resultServerModel = new core_kernel_classes_Resource($resultServerModelUri);
             $this->addImplementation($resultServerModel->getUniquePropertyValue(new core_kernel_classes_Property(TAO_RESULTSERVER_MODEL_IMPL_PROP))->literal);
         }
     }
     if (!is_null($additionalStorages)) {
         // the dynamic storages
         foreach ($additionalStorages as $additionalStorage) {
             $this->addImplementation($additionalStorage["implementation"], $additionalStorage["parameters"]);
         }
     }
     common_Logger::i("Result Server Initialized using defintion:" . $this->resultServer->getUri());
     // sets the details required depending on the type of storage
 }
 /**
  * Will make the Global Manager include the Management Role of the extension
  * to install (if it exists).
  *
  * @access public
  * @author Jerome Bogaerts <*****@*****.**>
  * @return void
  * @since 2.4
  */
 public function installManagementRole()
 {
     // Try to get a Management Role described by the extension itself.
     // (this information comes actually from the Manifest of the extension)
     $roleUri = $this->extension->getManifest()->getManagementRoleUri();
     if (!empty($roleUri)) {
         $role = new core_kernel_classes_Resource($roleUri);
         $roleService = tao_models_classes_RoleService::singleton();
         if (!$role->exists()) {
             // Management role does not exist yet, so we create it
             $roleClass = new core_kernel_classes_Class(CLASS_MANAGEMENTROLE);
             $roleLabel = $this->extension->getId() . ' Manager';
             $role = $roleClass->createInstance($roleLabel, $roleLabel . ' Role', $role->getUri());
             $roleService->includeRole($role, new core_kernel_classes_Resource(INSTANCE_ROLE_BACKOFFICE));
         }
         // Take the Global Manager role and make it include
         // the Management role of the currently installed extension.
         if ($role->getUri() !== INSTANCE_ROLE_GLOBALMANAGER) {
             $globalManagerRole = new core_kernel_classes_Resource(INSTANCE_ROLE_GLOBALMANAGER);
             $roleService->includeRole($globalManagerRole, $role);
         }
         common_Logger::d("Management Role " . $role->getUri() . " created for extension '" . $this->extension->getId() . "'.");
     } else {
         // There is no Management role described by the Extension Manifest.
         common_Logger::i("No management role for extension '" . $this->extension->getId() . "'.");
     }
 }
 /**
  * Short description of method buildStatusImageURI
  *
  * @access public
  * @author Somsack Sipasseuth, <*****@*****.**>
  * @param  Resource status
  * @return string
  */
 public static function buildStatusImageURI(core_kernel_classes_Resource $status)
 {
     $returnValue = (string) '';
     $baseURI = 'img/status_';
     $statusName = '';
     switch ($status->getUri()) {
         case INSTANCE_PROCESSSTATUS_PAUSED:
             $statusName = 'paused';
             break;
         case INSTANCE_PROCESSSTATUS_RESUMED:
             $statusName = 'resumed';
             break;
         case INSTANCE_PROCESSSTATUS_FINISHED:
             $statusName = 'finished';
             break;
         case INSTANCE_PROCESSSTATUS_STARTED:
             $statusName = 'started';
             break;
         case INSTANCE_PROCESSSTATUS_CLOSED:
             $statusName = 'closed';
             break;
         case INSTANCE_PROCESSSTATUS_STOPPED:
             $statusName = 'stopped';
             break;
     }
     $returnValue = $baseURI . $statusName . '.png';
     return (string) $returnValue;
 }
 public static function deepDelete(\core_kernel_classes_Resource $resource)
 {
     foreach ($resource->getRdfTriples() as $triple) {
         self::deleteDependencies($triple);
     }
     $resource->delete();
 }
 /**
  * Initialise the form for the given importHandlers
  *
  * @param tao_models_classes_import_ImportHandler $importHandler
  * @param array $availableHandlers
  * @param core_kernel_classes_Resource $class
  * @internal param array $importHandlers
  * @internal param tao_helpers_form_Form $subForm
  */
 public function __construct($importHandler, $availableHandlers, $class)
 {
     $this->importHandlers = $availableHandlers;
     if (!is_null($importHandler)) {
         $this->subForm = $importHandler->getForm();
     }
     parent::__construct(array('importHandler' => get_class($importHandler), 'classUri' => $class->getUri(), 'id' => $class->getUri()));
 }
Example #25
0
 /**
  * @requiresRight id WRITE
  */
 public function commitResource()
 {
     $resource = new \core_kernel_classes_Resource($this->getRequestParameter('id'));
     // prevent escaping on input
     $message = isset($_POST['message']) ? $_POST['message'] : '';
     $revision = $this->getRevisionService()->commit($resource->getUri(), $message);
     $this->returnJson(array('success' => true, 'id' => $revision->getVersion(), 'modified' => \tao_helpers_Date::displayeDate($revision->getDateCreated()), 'author' => UserHelper::renderHtmlUser($revision->getAuthorId()), 'message' => $revision->getMessage(), 'commitMessage' => __('%s has been committed', $resource->getLabel())));
 }
Example #26
0
 protected function getProperties(\core_kernel_classes_Resource $resource)
 {
     $classProperties = array($this->getProperty(RDFS_LABEL));
     foreach ($resource->getTypes() as $type) {
         $classProperties = array_merge($classProperties, $this->getPropertiesByClass($type));
     }
     return $classProperties;
 }
 /**
  * Creates a new simple delivery
  * 
  * @param core_kernel_classes_Class $deliveryClass
  * @param core_kernel_classes_Resource $test
  * @param string $label
  * @return common_report_Report
  */
 public function create(core_kernel_classes_Class $deliveryClass, core_kernel_classes_Resource $test, $label)
 {
     common_Logger::i('Creating ' . $label . ' with ' . $test->getLabel() . ' under ' . $deliveryClass->getLabel());
     $contentClass = new core_kernel_classes_Class(CLASS_SIMPLE_DELIVERYCONTENT);
     $content = $contentClass->createInstanceWithProperties(array(PROPERTY_DELIVERYCONTENT_TEST => $test->getUri()));
     $report = TemplateAssemblyService::singleton()->createAssemblyByContent($deliveryClass, $content, array(RDFS_LABEL => $label));
     $content->delete();
     return $report;
 }
 /**
  *
  * @param common_persistence_KeyValuePersistence $persistence
  * @param unknown $userId
  * @param core_kernel_classes_Resource $assembly
  * @return DeliveryExecution
  */
 public static function spawn(common_persistence_KeyValuePersistence $persistence, $userId, core_kernel_classes_Resource $assembly)
 {
     $identifier = self::DELIVERY_EXECUTION_PREFIX . common_Utils::getNewUri();
     $params = array(RDFS_LABEL => $assembly->getLabel(), PROPERTY_DELVIERYEXECUTION_DELIVERY => $assembly->getUri(), PROPERTY_DELVIERYEXECUTION_SUBJECT => $userId, PROPERTY_DELVIERYEXECUTION_START => microtime(), PROPERTY_DELVIERYEXECUTION_STATUS => InterfaceDeliveryExecution::STATE_ACTIVE);
     $kvDe = new static($persistence, $identifier, $params);
     $kvDe->save();
     $de = new DeliveryExecution($kvDe);
     return $de;
 }
 /**
  * @deprecated
  * @see taoTests_models_classes_TestModel::getAuthoring()
  */
 public function getAuthoring(core_kernel_classes_Resource $test)
 {
     $process = $test->getUniquePropertyValue(new core_kernel_classes_Property(TEST_TESTCONTENT_PROP));
     $ext = common_ext_ExtensionsManager::singleton()->getExtensionById('taoWfAdvTest');
     $widget = new Renderer($ext->getConstant('DIR_VIEWS') . 'templates' . DIRECTORY_SEPARATOR . 'authoring.tpl');
     $widget->setData('processUri', $process->getUri());
     $widget->setData('label', __('Authoring %s', $test->getLabel()));
     return $widget->render();
 }
 /**
  * Short description of method getNextSteps
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Resource step
  * @return array
  */
 public function getNextSteps(core_kernel_classes_Resource $step)
 {
     $returnValue = array();
     $nextStepProp = new core_kernel_classes_Property(PROPERTY_STEP_NEXT);
     foreach ($step->getPropertyValues($nextStepProp) as $stepUri) {
         $returnValue[] = new core_kernel_classes_Resource($stepUri);
     }
     return (array) $returnValue;
 }