Esempio n. 1
0
 public function getData()
 {
     if (!tao_helpers_Request::isAjax()) {
         throw new common_exception_IsAjaxAction(__FUNCTION__);
     }
     if ($this->hasRequestParameter('classUri')) {
         $classUri = tao_helpers_Uri::decode($this->getRequestParameter('classUri'));
         $class = new core_kernel_classes_Class($classUri);
         $hideNode = true;
     } elseif ($this->hasRequestParameter('rootNode')) {
         $class = new core_kernel_classes_Class($this->getRequestParameter('rootNode'));
         $hideNode = false;
     } else {
         throw new common_Exception('Missing node information for ' . __FUNCTION__);
     }
     $openNodes = array($class->getUri());
     if ($this->hasRequestParameter('openNodes') && is_array($this->getRequestParameter('openNodes'))) {
         $openNodes = array_merge($openNodes, $this->getRequestParameter('openNodes'));
     }
     $limit = $this->hasRequestParameter('limit') ? $this->getRequestParameter('limit') : self::DEFAULT_LIMIT;
     $offset = $this->hasRequestParameter('offset') ? $this->getRequestParameter('offset') : 0;
     $showInst = $this->hasRequestParameter('hideInstances') ? !$this->getRequestParameter('hideInstances') : true;
     $factory = new tao_models_classes_GenerisTreeFactory();
     $array = $factory->buildTree($class, $showInst, $openNodes, $limit, $offset);
     if ($hideNode) {
         $array = isset($array['children']) ? $array['children'] : array();
     }
     echo json_encode($array);
 }
 /**
  * Short description of method __construct
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Class clazz
  * @param  Resource user
  * @param  boolean forceAdd
  * @return mixed
  */
 public function __construct(core_kernel_classes_Class $clazz, core_kernel_classes_Resource $user = null, $forceAdd = false)
 {
     if (empty($clazz)) {
         throw new Exception('Set the user class in the parameters');
     }
     $this->formName = 'user_form';
     $options = array();
     $service = tao_models_classes_UserService::singleton();
     if (!empty($user)) {
         $this->user = $user;
         $options['mode'] = 'edit';
     } else {
         if (isset($_POST[$this->formName . '_sent']) && isset($_POST['uri'])) {
             $this->user = new core_kernel_classes_Resource(tao_helpers_Uri::decode($_POST['uri']));
         } else {
             $this->user = $service->createInstance($clazz, $service->createUniqueLabel($clazz));
         }
         $options['mode'] = 'add';
     }
     if ($forceAdd) {
         $options['mode'] = 'add';
     }
     $options['topClazz'] = CLASS_GENERIS_USER;
     parent::__construct($clazz, $this->user, $options);
 }
 /**
  * 
  * @author Lionel Lecaque, lionel@taotesting.com
  */
 public function save()
 {
     $saved = false;
     $instance = $this->getCurrentInstance();
     $testUri = tao_helpers_Uri::decode($this->getRequestParameter(tao_helpers_Uri::encode(PROPERTY_DELIVERYCONTENT_TEST)));
     $saved = $this->contentModel->addTest($instance, new core_kernel_classes_Resource($testUri));
     //$saved = $instance->editPropertyValues(new core_kernel_classes_Property(PROPERTY_DELIVERYCONTENT_TEST ), $testUri);
     echo json_encode(array('saved' => $saved));
 }
 /**
  * Short description of method feed
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @return mixed
  */
 public function feed()
 {
     $expression = "/^" . preg_quote($this->name, "/") . "(.)*[0-9]+\$/";
     $this->setValues(array());
     foreach ($_POST as $key => $value) {
         if (preg_match($expression, $key)) {
             $this->addValue(tao_helpers_Uri::decode($value));
         }
     }
 }
 public function initDeliveryExecution()
 {
     $compiledDelivery = new core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('uri')));
     $user = common_session_SessionManager::getSession()->getUser();
     if ($this->service->isDeliveryExecutionAllowed($compiledDelivery, $user)) {
         $deliveryExecution = $this->executionService->initDeliveryExecution($compiledDelivery, $user->getIdentifier());
     } else {
         common_Logger::i('Testtaker ' . $user->getIdentifier() . ' not authorised to initialise delivery ' . $compiledDelivery->getUri());
         return $this->returnError(__('You are no longer allowed to take the test %s', $compiledDelivery->getLabel()), true);
     }
     $this->redirect(_url('runDeliveryExecution', null, null, array('deliveryExecution' => $deliveryExecution->getIdentifier())));
 }
Esempio n. 6
0
 /**
  * Short description of method getValues
  *
  * @access public
  * @author Bertrand Chevrier, <*****@*****.**>
  * @param  string groupName
  * @return array
  */
 public function getValues($groupName = '')
 {
     $returnValue = array();
     foreach ($this->elements as $element) {
         if (empty($groupName) || !isset($this->groups[$groupName]) || in_array($element->getName(), $this->groups[$groupName]['elements'])) {
             $returnValue[tao_helpers_Uri::decode($element->getName())] = $element->getEvaluatedValue();
         }
     }
     unset($returnValue['uri']);
     unset($returnValue['classUri']);
     return (array) $returnValue;
 }
Esempio n. 7
0
 /**
  * get the selected group from the current context (from the uri and classUri parameter in the request)
  * @return core_kernel_classes_Resource $group
  */
 protected function getCurrentInstance()
 {
     $uri = tao_helpers_Uri::decode($this->getRequestParameter('uri'));
     if (is_null($uri) || empty($uri) || !common_Utils::isUri($uri)) {
         throw new Exception("No valid uri found");
     }
     $clazz = $this->getCurrentClass();
     $role = $this->service->getRole($uri);
     if (is_null($role)) {
         throw new Exception("No role found for the uri {$uri}");
     }
     return $role;
 }
Esempio n. 8
0
 /**
  * Initialize the form elements
  *
  * @access protected
  * @author Bertrand Chevrier, <*****@*****.**>
  * @return mixed
  */
 protected function initElements()
 {
     parent::initElements();
     $elements = $this->form->getElements();
     $this->form->setElements(array());
     $currentLangElt = tao_helpers_form_FormFactory::getElement('current_lang', 'Textbox');
     $currentLangElt->setDescription(__('Current language'));
     $currentLangElt->setAttributes(array('readonly' => 'true'));
     $currentLangElt->setValue(\common_session_SessionManager::getSession()->getDataLanguage());
     //API lang /data lang
     $this->form->addElement($currentLangElt);
     $dataLangElement = tao_helpers_form_FormFactory::getElement('translate_lang', 'Combobox');
     $dataLangElement->setDescription(__('Translate to'));
     $dataLangElement->setOptions(tao_helpers_I18n::getAvailableLangsByUsage(new core_kernel_classes_Resource(INSTANCE_LANGUAGE_USAGE_DATA)));
     $dataLangElement->setEmptyOption(__('Select a language'));
     $dataLangElement->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
     $this->form->addElement($dataLangElement);
     $this->form->createGroup('translation_info', __('Translation parameters'), array('current_lang', 'translate_lang'));
     $dataGroup = array();
     foreach ($elements as $element) {
         if ($element instanceof tao_helpers_form_elements_Hidden || $element->getName() == 'uri' || $element->getName() == 'classUri') {
             $this->form->addElement($element);
         } else {
             $propertyUri = tao_helpers_Uri::decode($element->getName());
             $property = new core_kernel_classes_Property($propertyUri);
             //translate only language dependent properties or Labels
             //supported widget are: Textbox, TextArea, HtmlArea
             //@todo support other widgets
             if ($property->isLgDependent() && ($element instanceof tao_helpers_form_elements_Textbox || $element instanceof tao_helpers_form_elements_TextArea || $element instanceof tao_helpers_form_elements_HtmlArea) || $propertyUri == RDFS_LABEL) {
                 $translatedElt = clone $element;
                 $viewElt = tao_helpers_form_FormFactory::getElement('view_' . $element->getName(), 'Label');
                 $viewElt->setDescription($element->getDescription());
                 $viewElt->setValue($element->getValue());
                 $viewElt->setAttribute('no-format', true);
                 if ($element instanceof tao_helpers_form_elements_HtmlArea) {
                     $viewElt->setAttribute('htmlentities', false);
                 }
                 $this->form->addElement($viewElt);
                 $dataGroup[] = $viewElt->getName();
                 $translatedElt->setDescription(' ');
                 $translatedElt->setValue('');
                 if ($propertyUri == RDFS_LABEL) {
                     $translatedElt->setForcedValid();
                 }
                 $this->form->addElement($translatedElt);
                 $dataGroup[] = $translatedElt->getName();
             }
         }
     }
     $this->form->createGroup('translation_form', __('Translate'), $dataGroup);
 }
 /**
  * Return the currently viewing resource
  * 
  * @return \core_kernel_classes_Resource
  */
 private function getCurrentResource()
 {
     if ($this->hasRequestParameter('uri')) {
         $uri = $this->getRequestParameter('uri');
         if (preg_match('/^i[0-9]+$/', $uri)) {
             $uri = LOCAL_NAMESPACE . '#' . $uri;
         } elseif (substr($uri, 0, 7) == 'http_2_') {
             $uri = \tao_helpers_Uri::decode($uri);
         }
     } else {
         $uri = TAO_OBJECT_CLASS;
     }
     return new \core_kernel_classes_Resource($uri);
 }
 /**
  * render the main layout
  */
 public function index()
 {
     $uri = tao_helpers_Uri::decode($this->getRequestParameter('uri'));
     $links = array();
     $class = new core_kernel_classes_Class(CLASS_LTI_CONSUMER);
     foreach ($class->getInstances() as $consumer) {
         $links[] = array('key' => $consumer->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_OAUTH_KEY)), 'secret' => $consumer->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_OAUTH_SECRET)), 'url' => $this->service->getLaunchUrl(array('delivery' => $uri)));
     }
     $this->setData('links', $links);
     $this->setData('launchUrl', $this->service->getLaunchUrl(array('delivery' => $uri)));
     $this->setData('consumers', $class->getInstances());
     $this->setData('delivery', $uri);
     $this->setView('linkManagement.tpl', 'taoLti');
 }
 /**
  * @requiresRight uri READ
  */
 public function index()
 {
     $item = new core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('uri')));
     $itemService = taoItems_models_classes_ItemsService::singleton();
     if ($itemService->hasItemContent($item) && $itemService->isItemModelDefined($item)) {
         //this is this url that will contains the preview
         //@see taoItems_actions_LegacyPreviewApi
         $previewUrl = $this->getPreviewUrl($item);
         $this->setData('previewUrl', $previewUrl);
         $this->setData('client_config_url', $this->getClientConfigUrl());
         $this->setData('resultServer', $this->getResultServer());
     }
     $this->setView('ItemPreview/index.tpl', 'taoItems');
 }
 /**
  * save the related items from the checkbox tree or from the sequence box
  * @return void
  */
 public function save()
 {
     $saved = false;
     $instance = $this->getCurrentInstance();
     $launchUrl = $this->getRequestParameter(tao_helpers_Uri::encode(PROPERTY_LTI_LINK_LAUNCHURL));
     $consumerUrl = $this->getRequestParameter(tao_helpers_Uri::encode(PROPERTY_LTI_LINK_CONSUMER));
     if (empty($launchUrl)) {
         return $this->returnError('Launch URL is required');
     }
     if (empty($consumerUrl)) {
         return $this->returnError('Consumer is required');
     }
     $consumer = new core_kernel_classes_Resource(tao_helpers_Uri::decode($consumerUrl));
     $saved = $instance->setPropertiesValues(array(PROPERTY_LTI_LINK_LAUNCHURL => $launchUrl, PROPERTY_LTI_LINK_CONSUMER => $consumer));
     echo json_encode(array('saved' => $saved));
 }
 /**
  * @param \core_kernel_classes_Resource $instance
  * @param \tao_helpers_form_Form $form
  * @return \common_report_Report
  */
 public function edit($instance, $form)
 {
     \helpers_TimeOutHelper::setTimeOutLimit(\helpers_TimeOutHelper::LONG);
     try {
         $fileInfo = $form->getValue('source');
         $xmlFile = $this->getSharedStimulusFile($fileInfo['uploaded_file']);
         // throws an exception of invalid
         SharedStimulusImporter::isValidSharedStimulus($xmlFile);
         $embeddedFile = $this->embedAssets($xmlFile);
         $report = $this->replaceSharedStimulus($instance, \tao_helpers_Uri::decode($form->getValue('lang')), $embeddedFile);
     } catch (\Exception $e) {
         $report = \common_report_Report::createFailure($e->getMessage());
     }
     \helpers_TimeOutHelper::reset();
     return $report;
 }
 public function setServiceDefinition()
 {
     $serviceCallUri = tao_helpers_Uri::decode($this->getRequestParameter('callOfServiceUri'));
     $serviceDefinitionUri = tao_helpers_Uri::decode($this->getRequestParameter(tao_helpers_Uri::encode(PROPERTY_CALLOFSERVICES_SERVICEDEFINITION)));
     if (empty($serviceCallUri)) {
         throw new tao_models_classes_MissingRequestParameterException('callOfServiceUri');
     }
     if (empty($serviceDefinitionUri)) {
         throw new tao_models_classes_MissingRequestParameterException(tao_helpers_Uri::encode(PROPERTY_CALLOFSERVICES_SERVICEDEFINITION));
     }
     $serviceCall = new core_kernel_classes_Resource($serviceCallUri);
     $serviceDefinition = new core_kernel_classes_Resource($serviceDefinitionUri);
     $service = tao_models_classes_InteractiveServiceService::singleton();
     $service->setCallOfServiceDefinition($serviceCall, $serviceDefinition);
     $service->setDefaultParameters($serviceCall);
     echo json_encode(array('saved' => 'true'));
 }
Esempio n. 15
0
 /**
  * Short description of method feed
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @return mixed
  */
 public function feed()
 {
     $expression = "/^" . preg_quote($this->name, "/") . "(.)*[0-9]+\$/";
     $foundIndexes = array();
     foreach ($_POST as $key => $value) {
         if (preg_match($expression, $key)) {
             $foundIndexes[] = $key;
         }
     }
     if (count($foundIndexes) > 0 && $_POST[$foundIndexes[0]] !== self::NO_TREEVIEW_INTERACTION_IDENTIFIER || count($foundIndexes) === 0) {
         $this->setValues(array());
     } elseif (count($foundIndexes) > 0 && $_POST[$foundIndexes[0]] === self::NO_TREEVIEW_INTERACTION_IDENTIFIER) {
         array_shift($foundIndexes);
     }
     foreach ($foundIndexes as $index) {
         $this->addValue(tao_helpers_Uri::decode($_POST[$index]));
     }
 }
Esempio n. 16
0
 /**
  * Get filter options of the tree form the HTTP paramters
  *  - itemModel: filter by item model (or at least ensure a model is defined)
  * @return $propertyFilter
  */
 private function getTreeFilter()
 {
     $propertyFilter = array();
     if ($this->hasRequestParameter('itemModel')) {
         $propertyFilter = array(TAO_ITEM_MODEL_PROPERTY => tao_helpers_Uri::decode($this->getRequestParameter('itemModel')));
     } else {
         //Get all item model values so we ensure the item has a model.
         //I know it would be better to be able to filter instances that don't have a model,
         //but the API is incomplete
         $itemModels = array();
         $itemModelClass = new core_kernel_classes_Class(TAO_ITEM_MODEL_CLASS);
         foreach ($itemModelClass->getInstances() as $itemModel) {
             $itemModels[] = $itemModel->getUri();
         }
         if (!empty($itemModels)) {
             $propertyFilter = array(TAO_ITEM_MODEL_PROPERTY => $itemModels);
         }
     }
     return $propertyFilter;
 }
 public function deleteProcessesExecutions()
 {
     $processExecutionUri = '';
     if (isset($_GET['processExecutionUri'])) {
         $processExecutionUri = tao_helpers_Uri::decode($_GET['processExecutionUri']);
     }
     $finishedOnly = false;
     if (isset($_GET['finishedOnly'])) {
         if ($_GET['finishedOnly'] != 'false') {
             $finishedOnly = (bool) $_GET['finishedOnly'];
         }
     }
     $deleteDeliveryHistory = false;
     if (isset($_GET['deliveryHistory'])) {
         if ($_GET['deliveryHistory'] != 'false') {
             $deleteDeliveryHistory = (bool) $_GET['deliveryHistory'];
         }
     }
     $processExecutionService = wfEngine_models_classes_ProcessExecutionService::singleton();
     $result = false;
     if (!empty($processExecutionUri)) {
         if ($processExecutionUri == 'all' || ($processExecutionUri = '*')) {
             $result = $processExecutionService->deleteProcessExecutions(array(), $finishedOnly);
             if ($deleteDeliveryHistory) {
                 //delete all delivery history:
                 $deliveryHistoryClass = new core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAODelivery.rdf#History');
                 foreach ($deliveryHistoryClass->getInstances() as $history) {
                     $history->delete();
                 }
             }
         } else {
             $processExecution = new core_kernel_classes_Resource($processExecutionUri);
             $result = $processExecutionService->deleteProcessExecution($processExecution, $finishedOnly);
         }
     }
     if ($result === true) {
         echo 'deletion completed';
     } else {
         echo 'deletion failed';
     }
 }
 public function exportIrregularities()
 {
     if (!$this->hasRequestParameter('uri')) {
         $response = array('success' => false, 'message' => __('You must select a delivery in order to export its irregularities'));
         $this->returnJson($response, 200);
         return;
     }
     $delivery = new \core_kernel_classes_Resource(\tao_helpers_Uri::decode($this->getRequestParameter('uri')));
     $from = $this->hasRequestParameter('from') ? strtotime($this->getRequestParameter('from')) : '';
     $to = $this->hasRequestParameter('to') ? strtotime($this->getRequestParameter('to')) : '';
     try {
         $export = $this->getIrregularities($delivery, $from, $to);
     } catch (\common_Exception $e) {
         $response = array('success' => false, 'message' => __('Something went wrong during the export'));
         $this->returnJson($response, 200);
         return;
     }
     setcookie('fileDownload', 'true', 0, '/');
     $exporter = new CsvExporter($export);
     $exporter->export(false, true);
 }
Esempio n. 19
0
 /**
  * Constructs the Import form container
  * In need of a major refactoring, which will
  * probably involve refactoring the Form engine as well
  */
 private function createImportFormContainer()
 {
     $sourceContainer = new tao_models_classes_import_CsvUploadForm();
     $sourceForm = $sourceContainer->getForm();
     foreach ($sourceForm->getElements() as $element) {
         $element->feed();
     }
     if (isset($_POST['importFile'])) {
         $file = $_POST['importFile'];
     } else {
         $sourceForm->getElement('source')->feed();
         $fileInfo = $sourceForm->getValue('source');
         $file = $fileInfo['uploaded_file'];
     }
     $properties = array(tao_helpers_Uri::encode(RDFS_LABEL) => __('Label'));
     $rangedProperties = array();
     $classUri = \tao_helpers_Uri::decode($_POST['classUri']);
     $class = new core_kernel_classes_Class($classUri);
     $classProperties = $this->getClassProperties($class);
     foreach ($classProperties as $property) {
         if (!in_array($property->getUri(), $this->getExludedProperties())) {
             //@todo manage the properties with range
             $range = $property->getRange();
             $properties[tao_helpers_Uri::encode($property->getUri())] = $property->getLabel();
             if ($range instanceof core_kernel_classes_Resource && $range->getUri() != RDFS_LITERAL) {
                 $rangedProperties[tao_helpers_Uri::encode($property->getUri())] = $property->getLabel();
             }
         }
     }
     //load the csv data from the file (uploaded in the upload form) to get the columns
     $csv_data = new tao_helpers_data_CsvFile($sourceForm->getValues());
     $csv_data->load($file);
     $values = $sourceForm->getValues();
     $values[tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES] = !empty($values[tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES]);
     $values['importFile'] = $file;
     $myFormContainer = new tao_models_classes_import_CSVMappingForm($values, array('class_properties' => $properties, 'ranged_properties' => $rangedProperties, 'csv_column' => $this->getColumnMapping($csv_data, $sourceForm->getValue(tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES)), tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES => $sourceForm->getValue(tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES)));
     return $myFormContainer;
 }
Esempio n. 20
0
 /**
  * (non-PHPdoc)
  * @see \oat\tao\model\accessControl\AccessControl::hasAccess()
  */
 public function hasAccess(User $user, $controller, $action, $parameters)
 {
     $required = array();
     try {
         foreach (ControllerHelper::getRequiredRights($controller, $action) as $paramName => $privileges) {
             if (isset($parameters[$paramName])) {
                 if (preg_match('/^[a-z]*_2_/', $parameters[$paramName]) != 0) {
                     common_Logger::w('url encoded parameter detected for ' . $paramName);
                     $cleanName = \tao_helpers_Uri::decode($parameters[$paramName]);
                 } else {
                     $cleanName = $parameters[$paramName];
                 }
                 $required[$cleanName] = $privileges;
             } else {
                 throw new \Exception('Missing parameter ' . $paramName . ' for ' . $controller . '/' . $action);
             }
         }
     } catch (ActionNotFoundException $e) {
         // action not found, no access
         return false;
     }
     return empty($required) ? true : self::hasPrivileges($user, $required);
 }
Esempio n. 21
0
 /**
  * (non-PHPdoc)
  * @see tao_actions_form_Instance::initElements()
  */
 protected function initElements()
 {
     parent::initElements();
     $elementId = tao_helpers_Uri::encode(TAO_ITEM_MODEL_PROPERTY);
     $ele = $this->form->getElement($elementId);
     $ele->feed();
     $modelUri = $ele->getEvaluatedValue();
     if (empty($modelUri)) {
         // remove deprecated models
         $statusProperty = new core_kernel_classes_Property(TAO_ITEM_MODEL_STATUS_PROPERTY);
         $options = array();
         foreach ($ele->getOptions() as $optUri => $optLabel) {
             $model = new core_kernel_classes_Resource(tao_helpers_Uri::decode($optUri));
             $status = $model->getOnePropertyValue($statusProperty);
             if (!is_null($status) && $status->getUri() != TAO_ITEM_MODEL_STATUS_DEPRECATED) {
                 $options[$optUri] = $optLabel;
             }
         }
         $ele->setOptions($options);
         if (count($options) === 1) {
             reset($options);
             $ele->setValue(key($options));
         }
     } else {
         // replace radio with hidden element
         $this->form->removeElement($elementId);
         $itemModelElt = tao_helpers_form_FormFactory::getElement($elementId, 'Hidden');
         $itemModelElt->setValue($modelUri);
         $this->form->addElement($itemModelElt);
         // display model label
         $model = new core_kernel_classes_Resource($modelUri);
         $itemModelLabelElt = tao_helpers_form_FormFactory::getElement('itemModelLabel', 'Label');
         $itemModelLabelElt->setDescription(__('Item Model'));
         $itemModelLabelElt->setValue($model->getLabel());
         $this->form->addElement($itemModelLabelElt);
     }
 }
 protected function get()
 {
     $requestParams = $this->getRequestParameters();
     $delivery = $this->getCurrentInstance();
     $deliveryUsers = $this->testTakersService->getDeliveryTestTakers($delivery);
     $result = array('ttexcluded' => array(), 'ttassigned' => array());
     $excludedUsersUri = array_map(function ($val) {
         return $val['uri'];
     }, $deliveryUsers['ttexcluded']);
     if (isset($requestParams['groups'])) {
         $groupsService = GroupsService::singleton();
         foreach ($requestParams['groups'] as $group) {
             $users = $groupsService->getUsers(\tao_helpers_Uri::decode($group));
             foreach ($users as $user) {
                 if (!in_array($user->getUri(), $excludedUsersUri)) {
                     $result['ttassigned'][] = $this->testTakersService->getTestTakerData($user);
                 } else {
                     $result['ttexcluded'][] = $this->testTakersService->getTestTakerData($user);
                 }
             }
         }
     }
     $this->sendData($result);
 }
 /**
  * Data provider for the table, returns json encoded data according to the parameter
  * @author Bertrand Chevrier, <*****@*****.**>,
  */
 public function data()
 {
     $filterData = $this->hasRequestParameter('filter') ? $this->getRequestParameter('filter') : array();
     $deliveryUri = \tao_helpers_Uri::decode($this->getRequestParameter('classUri'));
     $columns = $this->hasRequestParameter('columns') ? $this->getColumns('columns') : array();
     $page = $this->getRequestParameter('page');
     $limit = $this->getRequestParameter('rows');
     $sidx = $this->getRequestParameter('sidx');
     $sord = $this->getRequestParameter('sord');
     $start = $limit * $page - $limit;
     $options = array('recursive' => true, 'like' => false, 'offset' => $start, 'limit' => $limit, 'order' => $sidx, 'orderdir' => $sord);
     $response = new \stdClass();
     $delivery = new \core_kernel_classes_Resource($deliveryUri);
     $implementation = $this->service->getReadableImplementation($delivery);
     $this->service->setImplementation($implementation);
     $deliveryResults = $this->service->getImplementation()->getResultByDelivery(array($deliveryUri), $options);
     $counti = $this->service->getImplementation()->countResultByDelivery(array($deliveryUri));
     foreach ($deliveryResults as $deliveryResult) {
         $results[] = new core_kernel_classes_Resource($deliveryResult['deliveryResultIdentifier']);
     }
     $dpmap = array();
     foreach ($columns as $column) {
         $dataprovider = $column->getDataProvider();
         $found = false;
         foreach ($dpmap as $k => $dp) {
             if ($dp['instance'] == $dataprovider) {
                 $found = true;
                 $dpmap[$k]['columns'][] = $column;
             }
         }
         if (!$found) {
             $dpmap[] = array('instance' => $dataprovider, 'columns' => array($column));
         }
     }
     foreach ($dpmap as $arr) {
         $arr['instance']->prepare($results, $arr['columns']);
     }
     foreach ($results as $result) {
         $data = array('id' => $result->getUri());
         foreach ($columns as $column) {
             $key = null;
             if ($column instanceof tao_models_classes_table_PropertyColumn) {
                 $key = $column->getProperty()->getUri();
             } else {
                 if ($column instanceof VariableColumn) {
                     $key = $column->getContextIdentifier() . '_' . $column->getIdentifier();
                 }
             }
             if (!is_null($key)) {
                 if (count($column->getDataProvider()->cache) > 0) {
                     $data[$key] = self::filterCellData($column->getDataProvider()->getValue($result, $column), $filterData);
                 } else {
                     $data[$key] = self::filterCellData((string) $this->service->getTestTaker($result)->getOnePropertyValue(new \core_kernel_classes_Property(PROPERTY_USER_LOGIN)), $filterData);
                 }
             } else {
                 \common_Logger::w('KEY IS NULL');
             }
         }
         $response->data[] = $data;
     }
     $response->page = (int) $page;
     if ($limit != 0) {
         $response->total = ceil($counti / $limit);
     } else {
         $response->total = 1;
     }
     $response->records = count($results);
     $this->returnJSON($response);
 }
 /**
  * Get JSON monitoring data
  */
 public function monitorProcess()
 {
     $returnValue = array();
     $filters = null;
     //get the filter
     if ($this->hasRequestParameter('filter')) {
         $filter = $this->getRequestParameter('filter');
         $filter = $filter == 'null' || empty($filter) ? null : $filter;
         if (is_array($filter)) {
             foreach ($filter as $propertyUri => $propertyValues) {
                 foreach ($propertyValues as $i => $propertyValue) {
                     $propertyDecoded = tao_helpers_Uri::decode($propertyValue);
                     if (common_Utils::isUri($propertyDecoded)) {
                         $filters[tao_helpers_Uri::decode($propertyUri)][$i] = $propertyDecoded;
                     }
                 }
             }
         }
     }
     //get the processes uris
     $processesUri = $this->hasRequestParameter('processesUri') ? $this->getRequestParameter('processesUri') : null;
     $processInstancesClass = new core_kernel_classes_Class(CLASS_PROCESSINSTANCES);
     if (!is_null($filters)) {
         $processExecutions = $processInstancesClass->searchInstances($filters, array('recursive' => true));
     } else {
         if (!is_null($processesUri)) {
             foreach ($processesUri as $processUri) {
                 $processExecutions[$processUri] = new core_kernel_classes_resource($processUri);
             }
         } else {
             $processExecutions = $processInstancesClass->getInstances();
         }
     }
     $processMonitoringGrid = new wfEngine_helpers_Monitoring_ProcessMonitoringGrid(array_keys($processExecutions), $this->processMonitoringGridOptions);
     $data = $processMonitoringGrid->toArray();
     echo json_encode($data);
 }
Esempio n. 25
0
 public function getPropertyFileInfo()
 {
     $data = array('name' => __('(empty)'));
     if ($this->hasRequestParameter('uri') && $this->hasRequestParameter('propertyUri')) {
         $uri = tao_helpers_Uri::decode($this->getRequestParameter('uri'));
         $propertyUri = tao_helpers_Uri::decode($this->getRequestParameter('propertyUri'));
         $instance = new core_kernel_classes_Resource($uri);
         $file = $instance->getOnePropertyValue(new core_kernel_classes_Property($propertyUri));
         if (!is_null($file) && $file instanceof core_kernel_classes_Resource && core_kernel_file_File::isFile($file)) {
             $data = $this->getFileInfo($file->getUri());
         }
     }
     echo json_encode($data);
 }
 /**
  * @return array
  */
 private function getClassProperties()
 {
     $classUri = tao_helpers_Uri::decode($_POST['classUri']);
     $clazz = new core_kernel_classes_Class($classUri);
     $topLevelClass = new core_kernel_classes_Class(CLASS_GENERIS_RESOURCE);
     $classProperties = tao_models_classes_TaoService::singleton()->getClazzProperties($clazz, $topLevelClass);
     return $classProperties;
 }
 /**
  * Init a delivery execution from the current delivery.
  *
  * @throws \common_exception_Unauthorized
  * @return DeliveryExecution the selected execution
  */
 protected function _initDeliveryExecution()
 {
     $compiledDelivery = new \core_kernel_classes_Resource(\tao_helpers_Uri::decode($this->getRequestParameter('uri')));
     $user = common_session_SessionManager::getSession()->getUser();
     $assignmentService = $this->getServiceManager()->get(AssignmentService::CONFIG_ID);
     $this->verifyDeliveryStartAuthorized($compiledDelivery->getUri());
     //check if the assignment allows the user to start the delivery and the authorization provider
     if (!$assignmentService->isDeliveryExecutionAllowed($compiledDelivery->getUri(), $user)) {
         throw new \common_exception_Unauthorized();
     }
     $deliveryExecution = $this->executionService->initDeliveryExecution($compiledDelivery, $user->getIdentifier());
     return $deliveryExecution;
 }
 protected function savePropertyIndex($indexValues)
 {
     $values = array();
     foreach ($indexValues as $key => $value) {
         $values[tao_helpers_Uri::decode($key)] = tao_helpers_Uri::decode($value);
     }
     $validator = new tao_helpers_form_validators_IndexIdentifier();
     // if the identifier is valid
     $values[INDEX_PROPERTY_IDENTIFIER] = strtolower($values[INDEX_PROPERTY_IDENTIFIER]);
     if (!$validator->evaluate($values[INDEX_PROPERTY_IDENTIFIER])) {
         throw new Exception($validator->getMessage());
     }
     //if the property exists edit it, else create one
     $existingIndex = \oat\tao\model\search\IndexService::getIndexById($values[INDEX_PROPERTY_IDENTIFIER]);
     $indexProperty = new core_kernel_classes_Property($values['uri']);
     if (!is_null($existingIndex) && !$existingIndex->equals($indexProperty)) {
         throw new Exception("The index identifier should be unique");
     }
     unset($values['uri']);
     $this->bindProperties($indexProperty, $values);
 }
 /**
  * Get delivery by request params.
  * @throws \tao_models_classes_MissingRequestParameterException
  * @returns \core_kernel_classes_Class Delivery instance.
  */
 private function getDelivery()
 {
     $params = $this->getRequestParams();
     if (empty($params['uri'])) {
         throw new \tao_models_classes_MissingRequestParameterException("uri or parentDeliveryUri");
     }
     $delivery = new \core_kernel_classes_Class(\tao_helpers_Uri::decode($params['uri']));
     return $delivery;
 }
Esempio n. 30
0
 /**
  * get the current item class regarding the classUri' request parameter
  * prevent exception by returning the root class if no class is selected
  *  
  * @return core_kernel_classes_Class the item class
  */
 protected function getCurrentClass()
 {
     $classUri = tao_helpers_Uri::decode($this->getRequestParameter('classUri'));
     if ($this->isStandAlone && (is_null($classUri) || empty($classUri))) {
         return $this->getRootClass();
     } else {
         return parent::getCurrentClass();
     }
 }