Skip to content

Commit

Permalink
Merge pull request #117 from oat-sa/release-1.15.2
Browse files Browse the repository at this point in the history
Release 1.15.2
  • Loading branch information
siwane authored Feb 24, 2017
2 parents 6b1d579 + e397d6a commit 0b57490
Show file tree
Hide file tree
Showing 14 changed files with 147 additions and 28 deletions.
13 changes: 9 additions & 4 deletions controller/CompatibilityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
*/
class CompatibilityChecker extends \tao_actions_CommonModule
{

const COOKIE_ID = 'compatibility_checker_id';

/**
* If logged in, display index view with config data
* If not, forward to login
Expand Down Expand Up @@ -240,11 +243,11 @@ protected function getParameters()
*/
protected function getId()
{
if (! isset($_COOKIE['id'])) {
if (! isset($_COOKIE[self::COOKIE_ID])) {
$id = uniqid();
setcookie('id', $id);
setcookie(self::COOKIE_ID, $id);
} else {
$id = $_COOKIE['id'];
$id = $_COOKIE[self::COOKIE_ID];
}
return $id;
}
Expand All @@ -257,6 +260,8 @@ protected function getId()
*/
protected function loadConfig()
{
return \common_ext_ExtensionsManager::singleton()->getExtensionById('taoClientDiagnostic')->getConfig('clientDiag');
$config = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoClientDiagnostic')->getConfig('clientDiag');
$config['controller'] = 'CompatibilityChecker';
return $config;
}
}
6 changes: 3 additions & 3 deletions controller/Diagnostic.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function index()

$data = array(
'title' => __('Readiness diagnostics'),
'set' => $diagnostics,
'config' => $this->loadConfig(),
'set' => json_encode($diagnostics),
'config' => json_encode($this->loadConfig()),
);

$userLabel = SessionManager::getSession()->getUserLabel();
Expand All @@ -78,7 +78,7 @@ public function diagnostic()
{
$data = array(
'title' => __('Readiness Check'),
'config' => $this->loadConfig(),
'config' => json_encode($this->loadConfig()),
);

$this->defaultData();
Expand Down
13 changes: 13 additions & 0 deletions controller/DiagnosticChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,17 @@ protected function getDiagnosticDataTable()
}
return $this->dataTable;
}

/**
* Get config parameters for compatibility check
*
* @return mixed
* @throws \common_ext_ExtensionException
*/
protected function loadConfig()
{
$config = parent::loadConfig();
$config['controller'] = 'DiagnosticChecker';
return $config;
}
}
17 changes: 17 additions & 0 deletions install/ontology/roles.rdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:generis="http://www.tao.lu/Ontologies/generis.rdf#"
xml:base="http://www.tao.lu/Ontologies/TAO.rdf#"
>
<!-- Create ReadinessCheckerRole -->
<rdf:Description rdf:about="http://www.taotesting.com/ontologies/TAOClientDiagnostic.rdf#ReadinessCheckerRole">
<rdf:type rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#UserRole"/>
<rdfs:label xml:lang="en-US"><![CDATA[Readiness checker]]></rdfs:label>
<rdfs:comment xml:lang="en-US"><![CDATA[Role to check readiness]]></rdfs:comment>
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/TAO.rdf#BaseUserRole"/>
</rdf:Description>

</rdf:RDF>

18 changes: 14 additions & 4 deletions manifest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2015 (original work) Open Assessment Technologies SA;
*
*
*
*/

use oat\taoClientDiagnostic\model\ClientDiagnosticRoles;
use oat\taoClientDiagnostic\controller\DiagnosticChecker;
use oat\taoClientDiagnostic\controller\Diagnostic;
use oat\taoClientDiagnostic\scripts\install\createDiagnosticTable;
use oat\tao\model\accessControl\func\AccessRule;

return array(
'name' => 'taoClientDiagnostic',
'label' => 'Browser and OS diagnostic tool',
'description' => 'Check compatibility of the os and browser of a client',
'license' => 'GPL-2.0',
'version' => '1.14.0',
'version' => '1.15.2',
'author' => 'Open Assessment Technologies SA',
'requires' => array(
'tao' => '>=4.0.0',
Expand All @@ -37,10 +42,15 @@
array('grant', 'http://www.tao.lu/Ontologies/generis.rdf#taoClientDiagnosticManager', array('ext'=>'taoClientDiagnostic')),
array('grant', 'http://www.tao.lu/Ontologies/generis.rdf#AnonymousRole', array('ext'=>'taoClientDiagnostic','mod' => 'CompatibilityChecker')),
array('grant', 'http://www.tao.lu/Ontologies/generis.rdf#AnonymousRole', array('ext'=>'taoClientDiagnostic','mod' => 'Authenticator')),
array(AccessRule::GRANT, ClientDiagnosticRoles::READINESS_CHECKER_ROLE, Diagnostic::class),
array(AccessRule::GRANT, ClientDiagnosticRoles::READINESS_CHECKER_ROLE, DiagnosticChecker::class),
),
'install' => array(
'rdf' => array(
__DIR__ . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . 'ontology' . DIRECTORY_SEPARATOR . 'roles.rdf',
),
'php' => array(
'oat\taoClientDiagnostic\scripts\install\createDiagnosticTable',
createDiagnosticTable::class
)
),
'uninstall' => array(
Expand Down
25 changes: 25 additions & 0 deletions model/ClientDiagnosticRoles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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) 2017 (original work) Open Assessment Technologies SA;
*/

namespace oat\taoClientDiagnostic\model;

interface ClientDiagnosticRoles
{
const READINESS_CHECKER_ROLE = 'http://www.taotesting.com/ontologies/TAOClientDiagnostic.rdf#ReadinessCheckerRole';
}
1 change: 1 addition & 0 deletions model/storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface Storage
* All columns of diagnostic storage
*/
const DIAGNOSTIC_ID = 'id';
const DIAGNOSTIC_CONTEXT_ID = 'context_id';
const DIAGNOSTIC_LOGIN = 'login';
const DIAGNOSTIC_IP = 'ip';
const DIAGNOSTIC_BROWSER = 'browser';
Expand Down
1 change: 1 addition & 0 deletions scripts/install/createDiagnosticTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function __invoke($params)
$tableResults->addOption('engine', 'MyISAM');

$tableResults->addColumn(Sql::DIAGNOSTIC_ID, 'string', ['length' => 16]);
$tableResults->addColumn(Sql::DIAGNOSTIC_CONTEXT_ID, 'string', ['length' => 256, 'notnull' => false]);
$tableResults->addColumn(Sql::DIAGNOSTIC_LOGIN, 'string', ['length' => 32]);
$tableResults->addColumn(Sql::DIAGNOSTIC_IP, 'string', ['length' => 32]);
$tableResults->addColumn(PaginatedSqlStorage::DIAGNOSTIC_WORKSTATION, 'string', ['length' => 64, 'notnull' => false]);
Expand Down
58 changes: 52 additions & 6 deletions scripts/update/Updater.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@
namespace oat\taoClientDiagnostic\scripts\update;

use Doctrine\DBAL\Types\Type;
use oat\tao\model\accessControl\func\AccessRule;
use oat\tao\model\accessControl\func\AclProxy;
use oat\tao\scripts\update\OntologyUpdater;
use oat\taoClientDiagnostic\controller\Diagnostic;
use oat\taoClientDiagnostic\controller\DiagnosticChecker;
use oat\taoClientDiagnostic\model\authorization\Authorization;
use oat\taoClientDiagnostic\model\authorization\RequireUsername;
use oat\taoClientDiagnostic\model\ClientDiagnosticRoles;
use oat\taoClientDiagnostic\model\storage\Csv;
use oat\taoClientDiagnostic\model\storage\PaginatedSqlStorage;
use oat\taoClientDiagnostic\model\storage\PaginatedStorage;
Expand Down Expand Up @@ -327,6 +333,14 @@ public function update($initialVersion)

$this->skip('1.10.2', '1.13.2');

if ($this->isBetween('1.11.0', '1.15.1')) {
$service = $this->safeLoadService(Storage::SERVICE_ID);
if (!$service instanceof Storage) {
// invalid Service, replace with default
$this->getServiceManager()->register(Storage::SERVICE_ID, new PaginatedSqlStorage($service->getOptions()));
}
}

if ($this->isVersion('1.13.2')) {

$storageService = $this->getServiceManager()->get(Storage::SERVICE_ID);
Expand All @@ -344,17 +358,49 @@ public function update($initialVersion)
$fromSchema = clone $schema;
$tableResults = $schema->getTable(Sql::DIAGNOSTIC_TABLE);

$tableResults->addColumn(PaginatedSqlStorage::DIAGNOSTIC_WORKSTATION, 'string', ['length' => 64, 'notnull' => false]);

$queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema);
foreach ($queries as $query) {
$persistence->exec($query);
if (! $tableResults->hasColumn(PaginatedSqlStorage::DIAGNOSTIC_WORKSTATION)) {
$tableResults->addColumn(PaginatedSqlStorage::DIAGNOSTIC_WORKSTATION, 'string', ['length' => 64, 'notnull' => false]);
$queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema);
foreach ($queries as $query) {
$persistence->exec($query);
}
}
}

$this->setVersion('1.14.0');
}

return null;
$this->skip('1.14.0', '1.14.1');

if ($this->isVersion('1.14.1')) {
OntologyUpdater::syncModels();
AclProxy::applyRule(new AccessRule(AccessRule::GRANT, ClientDiagnosticRoles::READINESS_CHECKER_ROLE, Diagnostic::class));
AclProxy::applyRule(new AccessRule(AccessRule::GRANT, ClientDiagnosticRoles::READINESS_CHECKER_ROLE, DiagnosticChecker::class));
$this->setVersion('1.14.2');
}

$this->skip('1.14.2', '1.14.3');

if ($this->isVersion('1.14.3')) {
$storageService = $this->getServiceManager()->get(Storage::SERVICE_ID);
if ($storageService instanceof Sql) {
$persistence = $storageService->getPersistence();
$schema = $persistence->getDriver()->getSchemaManager()->createSchema();
$fromSchema = clone $schema;
$tableResults = $schema->getTable(Sql::DIAGNOSTIC_TABLE);

if (! $tableResults->hasColumn(PaginatedSqlStorage::DIAGNOSTIC_CONTEXT_ID)) {
$tableResults->addColumn(PaginatedSqlStorage::DIAGNOSTIC_CONTEXT_ID, 'string', ['length' => 256, 'notnull' => false]);
$queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema);
foreach ($queries as $query) {
$persistence->exec($query);
}
}
}

$this->setVersion('1.15.0');
}

$this->skip('1.15.0', '1.15.2');
}
}
6 changes: 3 additions & 3 deletions views/js/controller/Diagnostic/diagnostic.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ define([
*/
start : function start() {
var $container = $(cssScope);
var extension = $container.data('extension') || 'taoClientDiagnostic';
var $list = $container.find('.list');
var $panel = $('.panel');
var config = $container.data('config');
var indexUrl = helpers._url('index', 'Diagnostic', 'taoClientDiagnostic');
var workstationUrl = helpers._url('workstation', 'DiagnosticChecker', 'taoClientDiagnostic');

var indexUrl = helpers._url('index', 'Diagnostic', extension);
var workstationUrl = helpers._url('workstation', 'DiagnosticChecker', extension);
/**
* Installs the diagnostic tool GUI
* @param {String} workstation
Expand Down
7 changes: 4 additions & 3 deletions views/js/controller/Diagnostic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ define([
*/
start : function start() {
var $container = $(cssScope);
var extension = $container.data('extension') || 'taoClientDiagnostic';
var $list = $container.find('.list');
var dataset = $container.data('set');
var config = $container.data('config') || {};
var installedExtension = $container.data('installedextension') || false;
var diagnosticUrl = helpers._url('diagnostic', 'Diagnostic', 'taoClientDiagnostic');
var removeUrl = helpers._url('remove', 'Diagnostic', 'taoClientDiagnostic');
var serviceUrl = helpers._url('diagnosticData', 'Diagnostic', 'taoClientDiagnostic');
var diagnosticUrl = helpers._url('diagnostic', 'Diagnostic', extension);
var removeUrl = helpers._url('remove', 'Diagnostic', extension);
var serviceUrl = helpers._url('diagnosticData', 'Diagnostic', extension);

var performancesConfig = config.performances || {};
var performancesOptimal = performancesConfig.optimal;
Expand Down
Loading

0 comments on commit 0b57490

Please sign in to comment.