Skip to content

Commit

Permalink
Merge pull request #1093 from oat-sa/release-7.36.2
Browse files Browse the repository at this point in the history
Release 7.36.2
  • Loading branch information
krampstudio authored Dec 2, 2016
2 parents 67ed385 + 7ac8605 commit d6ebf1e
Show file tree
Hide file tree
Showing 56 changed files with 2,249 additions and 1,205 deletions.
9 changes: 8 additions & 1 deletion actions/class.Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,11 @@ public function login()
*/
public function logout()
{

common_session_SessionManager::endSession();
$this->redirect(_url('entry', 'Main', 'tao'));
/* @var $urlRouteService DefaultUrlService */
$urlRouteService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
$this->redirect($urlRouteService->getRedirectUrl('logout'));
}

/**
Expand Down Expand Up @@ -272,6 +275,10 @@ public function index()
$this->setData($perspectiveType . '-menu', $this->getNavigationElementsByGroup($perspectiveType));
}

/* @var $urlRouteService DefaultUrlService */
$urlRouteService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
$this->setData('logout', $urlRouteService->getLogoutUrl());

$this->setData('user_lang', \common_session_SessionManager::getSession()->getDataLanguage());
$this->setData('userLabel', \common_session_SessionManager::getSession()->getUserLabel());
// re-added to highlight selected extension in menu
Expand Down
23 changes: 13 additions & 10 deletions actions/class.PropertiesAuthoring.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
use oat\tao\model\search\Index;
use oat\tao\helpers\form\ValidationRuleRegistry;
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -349,35 +350,37 @@ public function getClassForm(core_kernel_classes_Class $clazz)
protected function saveSimpleProperty($propertyValues)
{
$propertyMap = tao_helpers_form_GenerisFormFactory::getPropertyMap();
$property = new core_kernel_classes_Property(tao_helpers_Uri::decode($propertyValues['uri']));
$type = $propertyValues['type'];
$range = (isset($propertyValues['range']) ? tao_helpers_Uri::decode(trim($propertyValues['range'])) : null);
unset($propertyValues['uri']);
unset($propertyValues['type']);
unset($propertyValues['range']);
$rangeNotEmpty = false;
$values = array(
ValidationRuleRegistry::PROPERTY_VALIDATION_RULE => array()
);

if (isset($propertyMap[$type])) {
$values[PROPERTY_WIDGET] = $propertyMap[$type]['widget'];
$rangeNotEmpty = ($propertyMap[$type]['range'] === RDFS_RESOURCE);
}

foreach($propertyValues as $key => $value){
$values[tao_helpers_Uri::decode($key)] = tao_helpers_Uri::decode($value);

}

// if the label is empty
$validator = new tao_helpers_form_validators_NotEmpty(array('message' => __('Property\'s label field is required')));
if(!$validator->evaluate($values[RDFS_LABEL])){
throw new Exception($validator->getMessage());
if (is_string($value)) {
$values[tao_helpers_Uri::decode($key)] = tao_helpers_Uri::decode($value);
} elseif (is_array($value)) {
$values[tao_helpers_Uri::decode($key)] = $value;
} else {
common_Logger::w('Unsuported value type '.gettype($value));
}
}

$rangeValidator = new tao_helpers_form_validators_NotEmpty(array('message' => __('Range field is required')));
if($rangeNotEmpty && !$rangeValidator->evaluate($range)){
throw new Exception($rangeValidator->getMessage());
}

$property = new core_kernel_classes_Property($values['uri']);
unset($values['uri']);
$this->bindProperties($property, $values);

// set the range
Expand Down
110 changes: 110 additions & 0 deletions actions/class.TaskQueue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

use oat\oatbox\task\Queue;
use oat\oatbox\task\Task;

/**
* Rest API controller for task queue
*
* Class tao_actions_TaskQueue
* @package oat\tao\controller\api
* @author Aleh Hutnikau, <[email protected]>
*/
class tao_actions_TaskQueue extends \tao_actions_RestController
{
const TASK_ID_PARAM = 'id';

/**
* Get task data by identifier
*/
public function get()
{
try {
if (!$this->hasRequestParameter(self::TASK_ID_PARAM)) {
throw new \common_exception_MissingParameter(self::TASK_ID_PARAM, $this->getRequestURI());
}
$data = $this->getTaskData($this->getRequestParameter(self::TASK_ID_PARAM));
$this->returnSuccess($data);
} catch (\Exception $e) {
$this->returnFailure($e);
}
}

/**
* Template method to generate task data to be returned to the end user.
* @param string $taskId
* @return array
*/
protected function getTaskData($taskId)
{
$task = $this->getTask($taskId);
$result['id'] = $this->getTaskId($task);
$result['status'] = $this->getTaskStatus($task);
$result['report'] = $this->getTaskReport($task);

return $result;
}

/**
* Get task instance from queue by identifier
* @param $taskId task identifier
* @throws \common_exception_NotFound
* @return Task
*/
protected function getTask($taskId)
{
/** @var Queue $taskQueue */
$taskQueue = $this->getServiceManager()->get(Queue::CONFIG_ID);
$task = $taskQueue->getTask($taskId);
if ($task === null) {
throw new \common_exception_NotFound(__('Task not found'));
}
return $task;
}

/**
* Return task report. Method may be overridden to comply special format of report
* @param Task $task
* @return null
*/
protected function getTaskReport(Task $task)
{
return $task->getReport();
}

/**
* Return task status
* @param Task $task
* @return null
*/
protected function getTaskStatus(Task $task)
{
return $task->getStatus();
}

/**
* Return task identifier
* @param Task $task
* @return null
*/
protected function getTaskId(Task $task)
{
return $task->getId();
}
}
5 changes: 4 additions & 1 deletion actions/form/class.SimpleProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*
*/
use oat\taoBackOffice\model\tree\TreeService;
use oat\tao\helpers\form\ValidationRuleRegistry;

/**
* Enable you to edit a property
Expand Down Expand Up @@ -47,7 +48,9 @@ protected function initElements()
$propertyProperties = array_merge(
tao_helpers_form_GenerisFormFactory::getDefaultProperties(),
array(new core_kernel_classes_Property(PROPERTY_IS_LG_DEPENDENT),
new core_kernel_classes_Property(TAO_GUIORDER_PROP))
new core_kernel_classes_Property(TAO_GUIORDER_PROP),
$this->getProperty(ValidationRuleRegistry::PROPERTY_VALIDATION_RULE)
)
);
$values = $property->getPropertiesValues($propertyProperties);

Expand Down
7 changes: 7 additions & 0 deletions config/default/urlroute.conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
'ext' => 'tao',
'controller' => 'Main',
'action' => 'login',
],
'logout' =>
[
'ext' => 'tao',
'controller' => 'Main',
'action' => 'logout',
'redirect' => _url('entry', 'Main', 'tao'),
]
]
);
Expand Down
12 changes: 11 additions & 1 deletion helpers/class.Icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*
* @access public
* @author Dieter Raber, <[email protected]>
* @date 2016-09-27 08:43:02
* @date 2016-12-02 07:57:18
* @package tao
* @subpackage helpers
*/
Expand Down Expand Up @@ -75,6 +75,8 @@ protected static function buildIcon($icon, $options=array()){
/**
* List of all icons as constant
*/
const CLASS_COMPRESS = 'icon-compress';
const CLASS_MAP_O = 'icon-map-o';
const CLASS_TEXT_MARKER = 'icon-text-marker';
const CLASS_UNSHIELD = 'icon-unshield';
const CLASS_SHIELD = 'icon-shield';
Expand Down Expand Up @@ -273,6 +275,14 @@ protected static function buildIcon($icon, $options=array()){
* List of all icons as function
*/

public static function iconCompress($options=array()){
return self::buildIcon(self::CLASS_COMPRESS, $options);
}

public static function iconMapO($options=array()){
return self::buildIcon(self::CLASS_MAP_O, $options);
}

public static function iconTextMarker($options=array()){
return self::buildIcon(self::CLASS_TEXT_MARKER, $options);
}
Expand Down
73 changes: 73 additions & 0 deletions helpers/form/elements/Validators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2015 (original work) Open Assessment Technologies SA;
*
*/

namespace oat\tao\helpers\form\elements;

use tao_helpers_form_elements_MultipleElement;
use core_kernel_classes_Property;
use core_kernel_classes_Resource;
use tao_helpers_Uri;
use oat\tao\helpers\form\ValidationRuleRegistry;

/**
* Implementation model selector
*
* @abstract
* @package tao
*/
abstract class Validators
extends tao_helpers_form_elements_MultipleElement
{

/**
* @todo should be a constant
* @var string
*/
protected $widget = 'http://www.tao.lu/datatypes/WidgetDefinitions.rdf#ValidationSelector';

/**
* (non-PHPdoc)
* @see tao_helpers_form_elements_MultipleElement::getOptions()
*/
public function getOptions() {
$options = parent::getOptions();

$statusProperty = new core_kernel_classes_Property(PROPERTY_ABSTRACTMODEL_STATUS);
$current = $this->getEvaluatedValue();

$options = array();
$map = ValidationRuleRegistry::getRegistry()->getMap();
foreach (ValidationRuleRegistry::getRegistry()->getMap() as $id => $validator) {
$options[$id] = $id;
}

return $options;
}

/**
* (non-PHPdoc)
* @see tao_helpers_form_elements_MultipleElement::setValue()
*/
public function setValue($value)
{
$this->addValue($value);
}

}
56 changes: 56 additions & 0 deletions helpers/form/elements/xhtml/Validators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2015 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
*
*/
namespace oat\tao\helpers\form\elements\xhtml;

use oat\tao\helpers\form\elements\Validators as AbstractValidators;

/**
* Based on tao_helpers_form_elements_xhtml_Radiobox
*/
class Validators extends AbstractValidators
{
use XhtmlRenderingTrait;

/**
*
* @see tao_helpers_form_FormElement::render
*/
public function render()
{
$returnValue = $this->renderLabel();

$i = 0;
$returnValue .= '<div class="form_radlst form_checklst">';
foreach ($this->getOptions() as $optionId => $optionLabel) {
$returnValue .= "<input type='checkbox' value='{$optionId}' name='{$this->name}[]' id='{$this->name}_{$i}' ";
$returnValue .= $this->renderAttributes();

if (in_array($optionId, $this->values)) {
$returnValue .= " checked='checked' ";
}
$returnValue .= " />&nbsp;<label class='elt_desc' for='{$this->name}_{$i}'>" . _dh($optionLabel) . "</label><br />";
$i ++;
}
$returnValue .= "</div>";

return (string) $returnValue;
}
}
2 changes: 1 addition & 1 deletion includes/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
*/
#TAO version number
define('TAO_VERSION', '3.2.0-sprint39');
define('TAO_VERSION', '3.2.0-sprint40');

$version = TAO_VERSION;

Expand Down
Loading

0 comments on commit d6ebf1e

Please sign in to comment.