コード例 #1
0
 /**
  * 
  * @param string $currentVersion
  * @return string $versionUpdatedTo
  */
 public function update($initialVersion)
 {
     $currentVersion = $initialVersion;
     //migrate from 2.6 to 2.6.1
     if ($currentVersion == '2.6') {
         //data upgrade
         OntologyUpdater::syncModels();
         $currentVersion = '2.6.1';
     }
     if ($currentVersion == '2.6.1') {
         $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
         $className = $ext->getConfig(\taoDelivery_models_classes_execution_ServiceProxy::CONFIG_KEY);
         if (is_string($className)) {
             $impl = null;
             switch ($className) {
                 case 'taoDelivery_models_classes_execution_OntologyService':
                     $impl = new \taoDelivery_models_classes_execution_OntologyService();
                     break;
                 case 'taoDelivery_models_classes_execution_KeyValueService':
                     $impl = new \taoDelivery_models_classes_execution_KeyValueService(array(\taoDelivery_models_classes_execution_KeyValueService::OPTION_PERSISTENCE => 'deliveryExecution'));
                     break;
                 default:
                     \common_Logger::w('Unable to migrate custom execution service');
             }
             if (!is_null($impl)) {
                 $proxy = \taoDelivery_models_classes_execution_ServiceProxy::singleton();
                 $proxy->setImplementation($impl);
                 $currentVersion = '2.6.2';
             }
         }
     }
     if ($currentVersion == '2.6.2') {
         $currentVersion = '2.6.3';
     }
     if ($currentVersion == '2.6.3') {
         //data upgrade
         OntologyUpdater::syncModels();
         $currentVersion = '2.7.0';
     }
     if ($currentVersion == '2.7.0') {
         EntryPointService::getRegistry()->registerEntryPoint(new \taoDelivery_models_classes_entrypoint_FrontOfficeEntryPoint());
         $currentVersion = '2.7.1';
     }
     if ($currentVersion == '2.7.1' || $currentVersion == '2.8') {
         $currentVersion = '2.9';
     }
     return $currentVersion;
 }
コード例 #2
0
ファイル: class.Main.php プロジェクト: oat-sa/tao-core
 /**
  * First page, when arriving on a system
  * to choose front or back office
  */
 public function entry()
 {
     $entries = array();
     foreach (EntryPointService::getRegistry()->getEntryPoints() as $entry) {
         if (tao_models_classes_accessControl_AclProxy::hasAccessUrl($entry->getUrl())) {
             $entries[] = $entry;
         }
     }
     if (empty($entries)) {
         // no access -> error
         if (common_session_SessionManager::isAnonymous()) {
             /* @var $urlRouteService DefaultUrlService */
             $urlRouteService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
             $this->redirect($urlRouteService->getLoginUrl());
         } else {
             common_session_SessionManager::endSession();
             return $this->returnError(__('You currently have no access to the platform'));
         }
     } elseif (count($entries) == 1 && !common_session_SessionManager::isAnonymous()) {
         // single entrypoint -> redirect
         $entry = current($entries);
         return $this->redirect($entry->getUrl());
     } else {
         // multiple entries -> choice
         if (!common_session_SessionManager::isAnonymous()) {
             $this->setData('user', common_session_SessionManager::getSession()->getUserLabel());
         }
         $this->setData('entries', $entries);
         $naviElements = $this->getNavigationElementsByGroup('settings');
         foreach ($naviElements as $key => $naviElement) {
             if ($naviElement['perspective']->getId() !== 'user_settings') {
                 unset($naviElements[$key]);
                 continue;
             }
         }
         $this->setData('userLabel', \common_session_SessionManager::getSession()->getUserLabel());
         $this->setData('settings-menu', $naviElements);
         $this->setData('current-section', $this->getRequestParameter('section'));
         $this->setData('content-template', array('blocks/entry-points.tpl', 'tao'));
         $this->setView('layout.tpl', 'tao');
     }
 }
コード例 #3
0
 /**
  * Perform update from $currentVersion to $versionUpdatedTo.
  * 
  * @param string $currentVersion
  * @return string $versionUpdatedTo
  */
 public function update($initialVersion)
 {
     $currentVersion = $initialVersion;
     // migrate from 1.0.0 to 1.1.0
     // old taoResults extension gets uninistalled and taoOutcomeRds becomes
     // the new default result storage mechanism.
     if ($currentVersion == '1.0.0') {
         self::migrateFrom100To110();
         $currentVersion = '1.1.0';
     }
     // migrate from 1.1.0 to 1.1.1
     // RDF based result server removal and assignment of deliveries
     // to RDS implementation.
     if ($currentVersion == '1.1.0') {
         self::migrateFrom110to111();
         $currentVersion = '1.1.1';
     }
     if ($currentVersion == '1.1.1') {
         $currentVersion = '1.1.2';
     }
     if ($currentVersion == '1.1.2') {
         EntryPointService::getRegistry()->registerEntryPoint(new TaoCeEntrypoint());
         $currentVersion = '1.1.3';
     }
     return $currentVersion;
 }
コード例 #4
0
<?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);
 *               
 * 
 */
use oat\tao\model\entryPoint\EntryPointService;
use oat\taoProctoring\model\entrypoint\ProctoringEntryPoint;
EntryPointService::getRegistry()->registerEntryPoint(new ProctoringEntryPoint());
コード例 #5
0
 /**
  * 
  * @param string $currentVersion
  * @return string $versionUpdatedTo
  */
 public function update($initialVersion)
 {
     $currentVersion = $initialVersion;
     //migrate from 2.6 to 2.6.1
     if ($currentVersion == '2.6') {
         //data upgrade
         OntologyUpdater::syncModels();
         $currentVersion = '2.6.1';
     }
     if ($currentVersion == '2.6.1') {
         $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
         $className = $ext->getConfig(\taoDelivery_models_classes_execution_ServiceProxy::CONFIG_KEY);
         if (is_string($className)) {
             $impl = null;
             switch ($className) {
                 case 'taoDelivery_models_classes_execution_OntologyService':
                     $impl = new \taoDelivery_models_classes_execution_OntologyService();
                     break;
                 case 'taoDelivery_models_classes_execution_KeyValueService':
                     $impl = new \taoDelivery_models_classes_execution_KeyValueService(array(\taoDelivery_models_classes_execution_KeyValueService::OPTION_PERSISTENCE => 'deliveryExecution'));
                     break;
                 default:
                     \common_Logger::w('Unable to migrate custom execution service');
             }
             if (!is_null($impl)) {
                 $proxy = \taoDelivery_models_classes_execution_ServiceProxy::singleton();
                 $proxy->setImplementation($impl);
                 $currentVersion = '2.6.2';
             }
         }
     }
     if ($currentVersion == '2.6.2') {
         $currentVersion = '2.6.3';
     }
     if ($currentVersion == '2.6.3') {
         //data upgrade
         OntologyUpdater::syncModels();
         $currentVersion = '2.7.0';
     }
     if ($currentVersion == '2.7.0') {
         EntryPointService::getRegistry()->registerEntryPoint(new \taoDelivery_models_classes_entrypoint_FrontOfficeEntryPoint());
         $currentVersion = '2.7.1';
     }
     if ($currentVersion == '2.7.1' || $currentVersion == '2.8') {
         $currentVersion = '2.9';
     }
     if ($currentVersion == '2.9') {
         OntologyUpdater::syncModels();
         //grant access to anonymous user
         $anonymousRole = new \core_kernel_classes_Resource(INSTANCE_ROLE_ANONYMOUS);
         $accessService = \funcAcl_models_classes_AccessService::singleton();
         $accessService->grantActionAccess($anonymousRole, 'taoDelivery', 'DeliveryServer', 'guest');
         $currentVersion = '2.9.1';
     }
     if ($currentVersion == '2.9.1') {
         OntologyUpdater::syncModels();
         $currentVersion = '2.9.2';
     }
     if ($currentVersion == '2.9.2') {
         //$assignmentService = new \taoDelivery_models_classes_AssignmentService();
         //$this->getServiceManager()->register('taoDelivery/assignment', $assignmentService);
         $currentVersion = '2.9.3';
     }
     if ($currentVersion == '2.9.3') {
         try {
             $currentConfig = $this->getServiceManager()->get(\taoDelivery_models_classes_DeliveryServerService::CONFIG_ID);
             if (is_array($currentConfig)) {
                 $deliveryServerService = new \taoDelivery_models_classes_DeliveryServerService($currentConfig);
             } else {
                 $deliveryServerService = new \taoDelivery_models_classes_DeliveryServerService();
             }
         } catch (ServiceNotFoundException $e) {
             $deliveryServerService = new \taoDelivery_models_classes_DeliveryServerService();
         }
         $this->getServiceManager()->register(\taoDelivery_models_classes_DeliveryServerService::CONFIG_ID, $deliveryServerService);
         $currentVersion = '2.9.4';
     }
     $this->setVersion($currentVersion);
     if ($this->isVersion('2.9.4')) {
         OntologyUpdater::syncModels();
         $this->setVersion('3.0.0');
     }
     if ($this->isBetween('3.0.0', '3.1.0')) {
         $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
         $config = $extension->getConfig('deliveryServer');
         $config->setOption('deliveryContainer', 'oat\\taoDelivery\\helper\\container\\DeliveryServiceContainer');
         $extension->setConfig('deliveryServer', $config);
         $this->setVersion('3.1.0');
     }
     $this->skip('3.1.0', '3.2.0');
     if ($this->isVersion('3.2.0')) {
         // set the test runner controller
         $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
         $config = $extension->getConfig('testRunner');
         $config['serviceController'] = 'Runner';
         $config['serviceExtension'] = 'taoQtiTest';
         $extension->setConfig('testRunner', $config);
         $this->setVersion('3.3.0');
     }
     $this->skip('3.3.0', '3.5.0');
 }
コード例 #6
0
<?php

use oat\tao\model\entryPoint\EntryPointService;
/**
 * 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) 2014 (original work) Open Assessment Technologies SA;
 *
 *
 */
EntryPointService::getRegistry()->registerEntryPoint(new taoDelivery_models_classes_entrypoint_FrontOfficeEntryPoint());
コード例 #7
0
ファイル: Updater.php プロジェクト: nagyist/tao-core
 /**
  * 
  * @param string $currentVersion
  * @return string $versionUpdatedTo
  */
 public function update($initialVersion)
 {
     $currentVersion = $initialVersion;
     $extensionManager = common_ext_ExtensionsManager::singleton();
     //migrate from 2.6 to 2.7.0
     if ($currentVersion == '2.6') {
         //create Js config
         $ext = $extensionManager->getExtensionById('tao');
         $config = array('timeout' => 30);
         $ext->setConfig('js', $config);
         $currentVersion = '2.7.0';
     }
     //migrate from 2.7.0 to 2.7.1
     if ($currentVersion == '2.7.0') {
         $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_7_1.rdf';
         $adapter = new tao_helpers_data_GenerisAdapterRdf();
         if ($adapter->import($file)) {
             $currentVersion = '2.7.1';
         } else {
             common_Logger::w('Import failed for ' . $file);
         }
     }
     if ($currentVersion === '2.7.1') {
         SearchService::setSearchImplementation(ZendSearch::createSearch());
         $currentVersion = '2.7.2';
     }
     if ($currentVersion == '2.7.2') {
         foreach ($extensionManager->getInstalledExtensions() as $extension) {
             $extManifestConsts = $extension->getConstants();
             if (isset($extManifestConsts['BASE_WWW'])) {
                 ClientLibRegistry::getRegistry()->register($extension->getId(), $extManifestConsts['BASE_WWW'] . 'js');
                 ClientLibRegistry::getRegistry()->register($extension->getId() . 'Css', $extManifestConsts['BASE_WWW'] . 'css');
             }
         }
         $currentVersion = '2.7.3';
     }
     if ($currentVersion == '2.7.3') {
         $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_7_4.rdf';
         $adapter = new tao_helpers_data_GenerisAdapterRdf();
         if ($adapter->import($file)) {
             $currentVersion = '2.7.4';
         } else {
             common_Logger::w('Import failed for ' . $file);
         }
     }
     if ($currentVersion == '2.7.4') {
         $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'model_2_7_5.rdf';
         $adapter = new tao_helpers_data_GenerisAdapterRdf();
         if ($adapter->import($file)) {
             $currentVersion = '2.7.5';
         } else {
             common_Logger::w('Import failed for ' . $file);
         }
     }
     if ($currentVersion == '2.7.5') {
         $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'index_type_2_7_6.rdf';
         $adapter = new tao_helpers_data_GenerisAdapterRdf();
         if ($adapter->import($file)) {
             $currentVersion = '2.7.6';
         } else {
             common_Logger::w('Import failed for ' . $file);
         }
     }
     if ($currentVersion == '2.7.6') {
         $dir = FILES_PATH . 'updates' . DIRECTORY_SEPARATOR . 'pre_' . $currentVersion;
         if (!mkdir($dir, 0700, true)) {
             throw new \common_exception_Error('Unable to log update to ' . $dir);
         }
         FileModel::toFile($dir . DIRECTORY_SEPARATOR . 'backup.rdf', ModelManager::getModel()->getRdfInterface());
         OntologyUpdater::correctModelId(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_7_1.rdf');
         OntologyUpdater::correctModelId(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_7_4.rdf');
         OntologyUpdater::correctModelId(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'model_2_7_5.rdf');
         OntologyUpdater::correctModelId(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'index_type_2_7_6.rdf');
         // syncronise also adds translations to correct modelid
         OntologyUpdater::syncModels();
         // remove translations from model 1
         $persistence = \common_persistence_SqlPersistence::getPersistence('default');
         $result = $persistence->query("SELECT DISTINCT subject FROM statements WHERE NOT modelId = 1");
         $toCleanup = array();
         while ($row = $result->fetch()) {
             $toCleanup[] = $row['subject'];
         }
         $query = "DELETE from statements WHERE modelId = 1 AND subject = ? " . "AND predicate IN ('" . RDFS_LABEL . "','" . RDFS_COMMENT . "') ";
         foreach ($toCleanup as $subject) {
             $persistence->exec($query, array($subject));
         }
         $currentVersion = '2.7.7';
     }
     if ($currentVersion == '2.7.7') {
         $lockImpl = defined('ENABLE_LOCK') && ENABLE_LOCK ? new OntoLock() : new NoLock();
         LockManager::setImplementation($lockImpl);
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole', array('ext' => 'tao', 'mod' => 'Lock')));
         $currentVersion = '2.7.8';
     }
     if ($currentVersion == '2.7.8') {
         if ($this->migrateFsAccess()) {
             $currentVersion = '2.7.9';
         }
     }
     if ($currentVersion == '2.7.9') {
         // update role classes
         OntologyUpdater::syncModels();
         $currentVersion = '2.7.10';
     }
     if ($currentVersion == '2.7.10') {
         // correct access roles
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole', array('act' => 'tao_actions_Lists@getListElements')));
         AclProxy::revokeRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole', array('ext' => 'tao', 'mod' => 'Lock')));
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole', array('act' => 'tao_actions_Lock@release')));
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole', array('act' => 'tao_actions_Lock@locked')));
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#LockManagerRole', array('act' => 'tao_actions_Lock@forceRelease')));
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole', array('ext' => 'tao', 'mod' => 'Search')));
         $currentVersion = '2.7.11';
     }
     if ($currentVersion == '2.7.11') {
         // move session abstraction
         if (defined("PHP_SESSION_HANDLER") && class_exists(PHP_SESSION_HANDLER)) {
             if (PHP_SESSION_HANDLER == 'common_session_php_KeyValueSessionHandler') {
                 $sessionHandler = new \common_session_php_KeyValueSessionHandler(array(\common_session_php_KeyValueSessionHandler::OPTION_PERSISTENCE => 'session'));
             } else {
                 $sessionHandler = new PHP_SESSION_HANDLER();
             }
             $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao');
             $ext->setConfig(\Bootstrap::CONFIG_SESSION_HANDLER, $sessionHandler);
         }
         $currentVersion = '2.7.12';
     }
     if ($currentVersion == '2.7.12') {
         // add the property manager
         OntologyUpdater::syncModels();
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#PropertyManagerRole', array('controller' => 'tao_actions_Lists')));
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#PropertyManagerRole', array('controller' => 'tao_actions_PropertiesAuthoring')));
         $currentVersion = '2.7.13';
     }
     if ($currentVersion == '2.7.13') {
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/generis.rdf#AnonymousRole', array('ext' => 'tao', 'mod' => 'PasswordRecovery', 'act' => 'index')));
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/generis.rdf#AnonymousRole', array('ext' => 'tao', 'mod' => 'PasswordRecovery', 'act' => 'resetPassword')));
         $currentVersion = '2.7.14';
     }
     if ($currentVersion == '2.7.14') {
         // index user logins
         OntologyUpdater::syncModels();
         $currentVersion = '2.7.15';
     }
     // reset the search impl for machines that missed 2.7.1 update due to merge
     if ($currentVersion === '2.7.15' || $currentVersion === '2.7.16') {
         try {
             SearchService::getSearchImplementation();
             // all good
         } catch (\common_exception_Error $error) {
             SearchService::setSearchImplementation(new GenerisSearch());
         }
         $currentVersion = '2.7.17';
     }
     if ($currentVersion === '2.7.16') {
         $registry = ClientLibRegistry::getRegistry();
         $map = $registry->getLibAliasMap();
         foreach ($map as $id => $fqp) {
             $registry->remove($id);
             $registry->register($id, $fqp);
         }
         $currentVersion = '2.7.17';
     }
     // semantic versioning
     if ($currentVersion === '2.7.17') {
         $currentVersion = '2.8.0';
     }
     if ($currentVersion === '2.8.0') {
         EntryPointService::getRegistry()->registerEntryPoint(new BackOfficeEntrypoint());
         $currentVersion = '2.8.1';
     }
     // semantic versioning
     if ($currentVersion === '2.8.1') {
         $currentVersion = '2.9';
     }
     // remove id properties
     if ($currentVersion === '2.9') {
         $rdf = ModelManager::getModel()->getRdfInterface();
         foreach ($rdf as $triple) {
             if ($triple->predicate == 'id') {
                 $rdf->remove($triple);
             }
         }
         $currentVersion = '2.9.1';
     }
     // tao object split
     if ($currentVersion === '2.9.1') {
         OntologyUpdater::syncModels();
         $currentVersion = '2.10.0';
     }
     return $currentVersion;
 }
コード例 #8
0
<?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;
 * 
 */
use oat\tao\model\entryPoint\EntryPointService;
use oat\taoCe\model\entryPoint\TaoCeEntrypoint;
EntryPointService::getRegistry()->registerEntryPoint(new TaoCeEntrypoint());
コード例 #9
0
<?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) 2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
 *               
 * 
 */
use oat\oatbox\service\ServiceManager;
use oat\tao\model\entryPoint\BackOfficeEntrypoint;
use oat\tao\model\entryPoint\EntryPointService;
EntryPointService::getRegistry()->registerEntryPoint(new BackOfficeEntrypoint());
//ServiceManager::getServiceManager()->register('tao/entrypoint', $entryPointManager);
コード例 #10
0
 /**
  * Perform update from $currentVersion to $versionUpdatedTo.
  *
  * @param string $currentVersion
  * @return string $versionUpdatedTo
  */
 public function update($initialVersion)
 {
     // migrate from 1.0.0 to 1.1.0
     // old taoResults extension gets uninistalled and taoOutcomeRds becomes
     // the new default result storage mechanism.
     if ($this->isVersion('1.0.0')) {
         self::migrateFrom100To110();
         $this->setVersion('1.1.0');
     }
     // migrate from 1.1.0 to 1.1.1
     // RDF based result server removal and assignment of deliveries
     // to RDS implementation.
     if ($this->isVersion('1.1.0')) {
         self::migrateFrom110to111();
         $this->setVersion('1.1.1');
     }
     if ($this->isBetween('1.1.1', '1.1.3')) {
         EntryPointService::getRegistry()->registerEntryPoint(new TaoCeEntrypoint());
         $this->setVersion('1.1.3');
     }
     if ($this->isBetween('1.1.3', '1.2.1')) {
         $this->setVersion('1.2.2');
     }
     $this->skip('1.2.2', '1.6.2');
     if ($this->isVersion('1.6.2')) {
         AclProxy::applyRule(new AccessRule('grant', INSTANCE_ROLE_ANONYMOUS, ['ext' => 'taoCe', 'mod' => 'Main', 'act' => 'rootEntry']));
         $this->setVersion('1.7.0');
     }
     $this->skip('1.7.0', '1.7.1');
     // add guest login
     if ($this->isVersion('1.7.1')) {
         $entryPointService = $this->getServiceManager()->get(EntryPointService::SERVICE_ID);
         $entryPointService->addEntryPoint(new GuestAccess(), EntryPointService::OPTION_PRELOGIN);
         $this->getServiceManager()->register(EntryPointService::SERVICE_ID, $entryPointService);
         $this->setVersion('1.8.0');
     }
     $this->skip('1.8.0', '1.9.0');
 }
コード例 #11
0
ファイル: Updater.php プロジェクト: oat-sa/tao-core
 /**
  *
  * @param $initialVersion
  * @return string $initialVersion
  * @throws \common_exception_Error
  * @throws \common_exception_InconsistentData
  * @throws \common_ext_ExtensionException
  * @throws common_Exception
  */
 public function update($initialVersion)
 {
     $extensionManager = common_ext_ExtensionsManager::singleton();
     //migrate from 2.6 to 2.7.0
     if ($this->isVersion('2.6')) {
         //create Js config
         $ext = $extensionManager->getExtensionById('tao');
         $config = array('timeout' => 30);
         $ext->setConfig('js', $config);
         $this->setVersion('2.7.0');
     }
     //migrate from 2.7.0 to 2.7.1
     if ($this->isVersion('2.7.0')) {
         $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_7_1.rdf';
         $adapter = new tao_helpers_data_GenerisAdapterRdf();
         if ($adapter->import($file)) {
             $this->setVersion('2.7.1');
         } else {
             common_Logger::w('Import failed for ' . $file);
         }
     }
     if ($this->isVersion('2.7.1')) {
         SearchService::setSearchImplementation(ZendSearch::createSearch());
         $this->setVersion('2.7.2');
     }
     // upgrade is requied for asset service to continue working
     if ($this->isBetween('2.7.2', '2.13.2')) {
         if (!$this->getServiceManager()->has(AssetService::SERVICE_ID)) {
             $this->getServiceManager()->register(AssetService::SERVICE_ID, new AssetService());
         }
     }
     if ($this->isVersion('2.7.2')) {
         foreach ($extensionManager->getInstalledExtensions() as $extension) {
             $extManifestConsts = $extension->getConstants();
             if (isset($extManifestConsts['BASE_WWW'])) {
                 ClientLibRegistry::getRegistry()->register($extension->getId(), $extManifestConsts['BASE_WWW'] . 'js');
                 ClientLibRegistry::getRegistry()->register($extension->getId() . 'Css', $extManifestConsts['BASE_WWW'] . 'css');
             }
         }
         $this->setVersion('2.7.3');
     }
     if ($this->isVersion('2.7.3')) {
         $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_7_4.rdf';
         $adapter = new tao_helpers_data_GenerisAdapterRdf();
         if ($adapter->import($file)) {
             $this->setVersion('2.7.4');
         } else {
             common_Logger::w('Import failed for ' . $file);
         }
     }
     if ($this->isVersion('2.7.4')) {
         $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'model_2_7_5.rdf';
         $adapter = new tao_helpers_data_GenerisAdapterRdf();
         if ($adapter->import($file)) {
             $this->setVersion('2.7.5');
         } else {
             common_Logger::w('Import failed for ' . $file);
         }
     }
     if ($this->isVersion('2.7.5')) {
         $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'index_type_2_7_6.rdf';
         $adapter = new tao_helpers_data_GenerisAdapterRdf();
         if ($adapter->import($file)) {
             $this->setVersion('2.7.6');
         } else {
             common_Logger::w('Import failed for ' . $file);
         }
     }
     if ($this->isVersion('2.7.6')) {
         $dir = FILES_PATH . 'updates' . DIRECTORY_SEPARATOR . 'pre_2.7.6';
         if (!mkdir($dir, 0700, true)) {
             throw new \common_exception_Error('Unable to log update to ' . $dir);
         }
         FileModel::toFile($dir . DIRECTORY_SEPARATOR . 'backup.rdf', ModelManager::getModel()->getRdfInterface());
         OntologyUpdater::correctModelId(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_7_1.rdf');
         OntologyUpdater::correctModelId(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_7_4.rdf');
         OntologyUpdater::correctModelId(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'model_2_7_5.rdf');
         OntologyUpdater::correctModelId(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'index_type_2_7_6.rdf');
         // syncronise also adds translations to correct modelid
         OntologyUpdater::syncModels();
         // remove translations from model 1
         $persistence = \common_persistence_SqlPersistence::getPersistence('default');
         $result = $persistence->query("SELECT DISTINCT subject FROM statements WHERE NOT modelId = 1");
         $toCleanup = array();
         while ($row = $result->fetch()) {
             $toCleanup[] = $row['subject'];
         }
         $query = "DELETE from statements WHERE modelId = 1 AND subject = ? " . "AND predicate IN ('" . RDFS_LABEL . "','" . RDFS_COMMENT . "') ";
         foreach ($toCleanup as $subject) {
             $persistence->exec($query, array($subject));
         }
         $this->setVersion('2.7.7');
     }
     // update FuncAccessControl early to support access changes
     if ($this->isBetween('2.7.7', '2.17.4')) {
         $implClass = common_ext_ExtensionsManager::singleton()->getExtensionById('tao')->getConfig('FuncAccessControl');
         if (is_string($implClass)) {
             $impl = new $implClass();
             $this->getServiceManager()->register(AclProxy::SERVICE_ID, $impl);
         }
     }
     if ($this->isVersion('2.7.7')) {
         $lockImpl = defined('ENABLE_LOCK') && ENABLE_LOCK ? new OntoLock() : new NoLock();
         LockManager::setImplementation($lockImpl);
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole', array('ext' => 'tao', 'mod' => 'Lock')));
         $this->setVersion('2.7.8');
     }
     if ($this->isVersion('2.7.8')) {
         if ($this->migrateFsAccess()) {
             $this->setVersion('2.7.9');
         }
     }
     if ($this->isVersion('2.7.9')) {
         // update role classes
         OntologyUpdater::syncModels();
         $this->setVersion('2.7.10');
     }
     if ($this->isVersion('2.7.10')) {
         // correct access roles
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole', array('act' => 'tao_actions_Lists@getListElements')));
         AclProxy::revokeRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole', array('ext' => 'tao', 'mod' => 'Lock')));
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole', array('act' => 'tao_actions_Lock@release')));
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole', array('act' => 'tao_actions_Lock@locked')));
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#LockManagerRole', array('act' => 'tao_actions_Lock@forceRelease')));
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole', array('ext' => 'tao', 'mod' => 'Search')));
         $this->setVersion('2.7.11');
     }
     if ($this->isVersion('2.7.11')) {
         // move session abstraction
         if (defined("PHP_SESSION_HANDLER") && class_exists(PHP_SESSION_HANDLER)) {
             if (PHP_SESSION_HANDLER == 'common_session_php_KeyValueSessionHandler') {
                 $sessionHandler = new \common_session_php_KeyValueSessionHandler(array(\common_session_php_KeyValueSessionHandler::OPTION_PERSISTENCE => 'session'));
             } else {
                 $sessionHandler = new PHP_SESSION_HANDLER();
             }
             $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao');
             $ext->setConfig(\Bootstrap::CONFIG_SESSION_HANDLER, $sessionHandler);
         }
         $this->setVersion('2.7.12');
     }
     if ($this->isVersion('2.7.12')) {
         // add the property manager
         OntologyUpdater::syncModels();
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#PropertyManagerRole', array('controller' => 'tao_actions_Lists')));
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#PropertyManagerRole', array('controller' => 'tao_actions_PropertiesAuthoring')));
         $this->setVersion('2.7.13');
     }
     if ($this->isVersion('2.7.13')) {
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/generis.rdf#AnonymousRole', array('ext' => 'tao', 'mod' => 'PasswordRecovery', 'act' => 'index')));
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/generis.rdf#AnonymousRole', array('ext' => 'tao', 'mod' => 'PasswordRecovery', 'act' => 'resetPassword')));
         $this->setVersion('2.7.14');
     }
     if ($this->isVersion('2.7.14')) {
         // index user logins
         OntologyUpdater::syncModels();
         $this->setVersion('2.7.15');
     }
     // reset the search impl for machines that missed 2.7.1 update due to merge
     if ($this->isVersion('2.7.15') || $this->isVersion('2.7.16')) {
         try {
             SearchService::getSearchImplementation();
             // all good
         } catch (\common_exception_Error $error) {
             SearchService::setSearchImplementation(new GenerisSearch());
         }
         $this->setVersion('2.7.16');
     }
     if ($this->isVersion('2.7.16')) {
         $registry = ClientLibRegistry::getRegistry();
         $map = $registry->getLibAliasMap();
         foreach ($map as $id => $fqp) {
             $registry->remove($id);
             $registry->register($id, $fqp);
         }
         $this->setVersion('2.7.17');
     }
     // semantic versioning
     $this->skip('2.7.17', '2.8.0');
     if ($this->isBetween('2.8.0', '2.13.0')) {
         $tao = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao');
         $entryPoints = $tao->getConfig('entrypoint');
         if (is_array($entryPoints) || $entryPoints == false) {
             $service = new EntryPointService();
             if (is_array($entryPoints)) {
                 foreach ($entryPoints as $id => $entryPoint) {
                     $service->overrideEntryPoint($id, $entryPoint);
                     $service->activateEntryPoint($id, EntryPointService::OPTION_POSTLOGIN);
                 }
             }
             // register, don't activate
             $passwordResetEntry = new PasswordReset();
             $service->overrideEntryPoint($passwordResetEntry->getId(), $passwordResetEntry);
             $this->getServiceManager()->register(EntryPointService::SERVICE_ID, $service);
         }
     }
     if ($this->isVersion('2.8.0')) {
         $service = $this->getServiceManager()->get(EntryPointService::SERVICE_ID);
         $service->registerEntryPoint(new BackOfficeEntrypoint());
         $this->getServiceManager()->register(EntryPointService::SERVICE_ID, $service);
         $this->setVersion('2.8.1');
     }
     // semantic versioning
     $this->skip('2.8.1', '2.9');
     // remove id properties
     if ($this->isVersion('2.9')) {
         $rdf = ModelManager::getModel()->getRdfInterface();
         foreach ($rdf as $triple) {
             if ($triple->predicate == 'id') {
                 $rdf->remove($triple);
             }
         }
         $this->setVersion('2.9.1');
     }
     // tao object split
     if ($this->isVersion('2.9.1')) {
         OntologyUpdater::syncModels();
         $this->setVersion('2.10.0');
     }
     // widget definitions
     if ($this->isVersion('2.10.0')) {
         OntologyUpdater::syncModels();
         $this->setVersion('2.10.1');
     }
     // add login form config
     if ($this->isVersion('2.10.1')) {
         $loginFormSettings = array('elements' => array());
         $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao');
         $ext->setConfig('loginForm', $loginFormSettings);
         $this->setVersion('2.10.2');
     }
     if ($this->isVersion('2.10.2')) {
         $s = DIRECTORY_SEPARATOR;
         ThemeRegistry::getRegistry()->createTarget('frontOffice', array('css' => 'tao' . $s . 'views' . $s . 'css' . $s . 'tao-3.css', 'templates' => array('header-logo' => 'taoDelivery' . $s . 'views' . $s . 'templates' . $s . 'DeliveryServer' . $s . 'blocks' . $s . 'header-logo.tpl', 'footer' => 'taoDelivery' . $s . 'views' . $s . 'templates' . $s . 'DeliveryServer' . $s . 'blocks' . $s . 'footer.tpl')));
         ThemeRegistry::getRegistry()->createTarget('backOffice', array('css' => 'tao' . $s . 'views' . $s . 'css' . $s . 'tao-3.css', 'templates' => array('header-logo' => 'tao' . $s . 'views' . $s . 'templates' . $s . 'blocks' . $s . 'header-logo.tpl', 'footer' => 'tao' . $s . 'views' . $s . 'templates' . $s . 'blocks' . $s . 'footer.tpl')));
         $this->setVersion('2.11.0');
     }
     if ($this->isVersion('2.11.0')) {
         $service = new \tao_models_classes_service_StateStorage(array('persistence' => 'serviceState'));
         $this->getServiceManager()->register('tao/stateStorage', $service);
         $this->setVersion('2.12.0');
     }
     $this->skip('2.12.0', '2.13.0');
     // moved to 2.8.0
     $this->skip('2.13.0', '2.13.1');
     // moved to 2.7.2
     $this->skip('2.13.1', '2.13.2');
     if ($this->isVersion('2.13.2')) {
         //add the new customizable template "login-message" to backOffice target
         $themeService = new ThemeService();
         //test for overrides
         $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao');
         $oldConfig = $ext->getConfig('themes');
         $compatibilityConfig = array();
         foreach ($oldConfig['frontOffice']['available'] as $arr) {
             if ($arr['id'] == $oldConfig['frontOffice']['default']) {
                 $compatibilityConfig[Theme::CONTEXT_FRONTOFFICE] = $arr;
             }
         }
         foreach ($oldConfig['backOffice']['available'] as $arr) {
             if ($arr['id'] == $oldConfig['backOffice']['default']) {
                 $compatibilityConfig[Theme::CONTEXT_BACKOFFICE] = $arr;
             }
         }
         if (empty($compatibilityConfig)) {
             $themeService->setTheme(new DefaultTheme());
         } else {
             $themeService->setTheme(new CompatibilityTheme($compatibilityConfig));
         }
         unset($oldConfig['backOffice']);
         unset($oldConfig['frontOffice']);
         $ext->setConfig('themes', $oldConfig);
         $this->getServiceManager()->register(ThemeService::SERVICE_ID, $themeService);
         $this->setVersion('2.14.0');
     }
     $this->skip('2.14.0', '2.15.0');
     if ($this->isVersion('2.15.0')) {
         (new SimpleAccess())->revokeRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/generis.rdf#AnonymousRole', ['ext' => 'tao', 'mod' => 'AuthApi']));
         $this->setVersion('2.15.1');
     }
     $this->skip('2.15.1', '2.15.2');
     if ($this->isVersion('2.15.2')) {
         ClientLibConfigRegistry::getRegistry()->register('util/locale', ['decimalSeparator' => '.', 'thousandsSeparator' => '']);
         $this->setVersion('2.15.3');
     }
     $this->skip('2.15.3', '2.16.0');
     if ($this->isVersion('2.16.0')) {
         try {
             $this->getServiceManager()->get(RequiredActionService::CONFIG_ID);
             // all good, already configured
         } catch (ServiceNotFoundException $error) {
             $requiredActionService = new RequiredActionService();
             $this->getServiceManager()->register(RequiredActionService::CONFIG_ID, $requiredActionService);
         }
         OntologyUpdater::syncModels();
         $this->setVersion('2.17.0');
     }
     if ($this->isBetween('2.17.0', '2.17.4')) {
         ClientLibConfigRegistry::getRegistry()->register('util/locale', ['decimalSeparator' => '.', 'thousandsSeparator' => '']);
         $this->setVersion('2.17.4');
     }
     // skiped registering of func ACL proxy as done before 2.7.7
     $this->skip('2.17.4', '2.18.2');
     if ($this->isVersion('2.18.2')) {
         $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao');
         $config = $extension->getConfig('login');
         if (!is_array($config)) {
             $config = [];
         }
         if (!array_key_exists('disableAutocomplete', $config)) {
             $config['disableAutocomplete'] = false;
         }
         $extension->setConfig('login', $config);
         $this->setVersion('2.19.0');
     }
     $this->skip('2.19.0', '2.21.0');
     if ($this->isVersion('2.21.0')) {
         $config = common_ext_ExtensionsManager::singleton()->getExtensionById('tao')->getConfig('ServiceFileStorage');
         $service = new \tao_models_classes_service_FileStorage($config);
         $this->getServiceManager()->register(\tao_models_classes_service_FileStorage::SERVICE_ID, $service);
         $this->setVersion('2.22.0');
     }
     $this->skip('2.22.0', '5.5.0');
     if ($this->isVersion('5.5.0')) {
         $clientConfig = new ClientConfigService();
         $clientConfig->setClientConfig('themesAvailable', new ThemeConfig());
         $this->getServiceManager()->register(ClientConfigService::SERVICE_ID, $clientConfig);
         $this->setVersion('5.6.0');
     }
     $this->skip('5.6.0', '5.6.2');
     if ($this->isVersion('5.6.2')) {
         if (!$this->getServiceManager()->has(UpdateLogger::SERVICE_ID)) {
             // setup log fs
             $fsm = $this->getServiceManager()->get(FileSystemService::SERVICE_ID);
             $fsm->createFileSystem('log', 'tao/log');
             $this->getServiceManager()->register(FileSystemService::SERVICE_ID, $fsm);
             $this->getServiceManager()->register(UpdateLogger::SERVICE_ID, new UpdateLogger(array(UpdateLogger::OPTION_FILESYSTEM => 'log')));
         }
         $this->setVersion('5.6.3');
     }
     $this->skip('5.6.3', '5.9.1');
     if ($this->isVersion('5.9.1')) {
         /** @var EventManager $eventManager */
         $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID);
         $eventManager->detach(RoleRemovedEvent::class, ['oat\\tao\\scripts\\update\\LoggerService', 'logEvent']);
         $eventManager->detach(RoleCreatedEvent::class, ['oat\\tao\\scripts\\update\\LoggerService', 'logEvent']);
         $eventManager->detach(RoleChangedEvent::class, ['oat\\tao\\scripts\\update\\LoggerService', 'logEvent']);
         $eventManager->detach(UserCreatedEvent::class, ['oat\\tao\\scripts\\update\\LoggerService', 'logEvent']);
         $eventManager->detach(UserUpdatedEvent::class, ['oat\\tao\\scripts\\update\\LoggerService', 'logEvent']);
         $eventManager->detach(UserRemovedEvent::class, ['oat\\tao\\scripts\\update\\LoggerService', 'logEvent']);
         $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager);
         $this->setVersion('5.9.2');
     }
     $this->skip('5.9.2', '6.0.1');
     if ($this->isVersion('6.0.1')) {
         OntologyUpdater::syncModels();
         $this->setVersion('6.1.0');
     }
     $this->skip('6.1.0', '7.16.2');
     if ($this->isVersion('7.16.2')) {
         OntologyUpdater::syncModels();
         ValidationRuleRegistry::getRegistry()->set('notEmpty', new \tao_helpers_form_validators_NotEmpty());
         $this->setVersion('7.17.0');
     }
     $this->skip('7.17.0', '7.23.0');
     if ($this->isVersion('7.23.0')) {
         $service = new \oat\tao\model\mvc\DefaultUrlService(['default' => ['ext' => 'tao', 'controller' => 'Main', 'action' => 'index'], 'login' => ['ext' => 'tao', 'controller' => 'Main', 'action' => 'login']]);
         $this->getServiceManager()->register(\oat\tao\model\mvc\DefaultUrlService::SERVICE_ID, $service);
         $this->setVersion('7.24.0');
     }
     $this->skip('7.24.0', '7.27.0');
     if ($this->isVersion('7.27.0')) {
         OntologyUpdater::syncModels();
         $this->setVersion('7.28.0');
     }
     $this->skip('7.28.0', '7.30.1');
 }
コード例 #12
0
 /**
  * @param string $initialVersion
  * @return string string
  */
 public function update($initialVersion)
 {
     $currentVersion = $initialVersion;
     $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoProctoring');
     if ($currentVersion == '0.1') {
         $service = new DeliveryService();
         $ext->setConfig('delivery', $service);
         $currentVersion = '0.2';
     }
     if ($currentVersion == '0.2') {
         //            $service = new TestCenterService();
         //            $ext->setConfig('testCenter', $service);
         $currentVersion = '0.3';
     }
     if ($currentVersion == '0.3') {
         //grant access to test taker
         $testTakerRole = new \core_kernel_classes_Resource(INSTANCE_ROLE_DELIVERY);
         $accessService = \funcAcl_models_classes_AccessService::singleton();
         $accessService->grantModuleAccess($testTakerRole, 'taoProctoring', 'DeliveryServer');
         $mpManagerRole = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOProctor.rdf#ProctorRole');
         $accessService->revokeModuleAccess($mpManagerRole, 'taoProctoring', 'DeliveryServer');
         //replace delivery server
         $entryPointService = EntryPointService::getRegistry();
         $entryPointService->overrideEntryPoint('deliveryServer', new ProctoringDeliveryServer());
         $this->getServiceManager()->register(EntryPointService::SERVICE_ID, $entryPointService);
         $currentVersion = '0.4';
     }
     if ($currentVersion == '0.4') {
         OntologyUpdater::syncModels();
         $ext->unsetConfig('testCenter');
         $accessService = \funcAcl_models_classes_AccessService::singleton();
         $roleService = \tao_models_classes_RoleService::singleton();
         //grant access right to proctoring manager
         $testCenterManager = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOProctor.rdf#TestCenterManager');
         $globalManager = new \core_kernel_Classes_Resource('http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole');
         $roleService->includeRole($globalManager, $testCenterManager);
         $accessService->grantModuleAccess($testCenterManager, 'taoProctoring', 'TestCenterManager');
         //revoke access to legacy delivery server
         $testTakerRole = new \core_kernel_classes_Resource(INSTANCE_ROLE_DELIVERY);
         $accessService->revokeModuleAccess($testTakerRole, 'taoDelivery', 'DeliveryServer');
         //grant access to proctor role
         $proctorRole = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOProctor.rdf#ProctorRole');
         $accessService->grantModuleAccess($proctorRole, 'taoProctoring', 'Delivery');
         $accessService->grantModuleAccess($proctorRole, 'taoProctoring', 'Diagnostic');
         $accessService->grantModuleAccess($proctorRole, 'taoProctoring', 'Reporting');
         $accessService->grantModuleAccess($proctorRole, 'taoProctoring', 'TestCenter');
         $currentVersion = '0.5';
     }
     if ($currentVersion == '0.5') {
         try {
             $this->getServiceManager()->get(AssessmentResultsService::CONFIG_ID);
         } catch (ServiceNotFoundException $e) {
             $service = new AssessmentResultsService([AssessmentResultsService::OPTION_PRINTABLE_RUBRIC_TAG => 'x-tao-scorereport', AssessmentResultsService::OPTION_PRINT_REPORT_BUTTON => false]);
             $service->setServiceManager($this->getServiceManager());
             $this->getServiceManager()->register(AssessmentResultsService::CONFIG_ID, $service);
         }
         $currentVersion = '0.6';
     }
     $this->setVersion($currentVersion);
     if ($this->isVersion('0.6')) {
         OntologyUpdater::syncModels();
         //grant access to test site admin role
         $proctorRole = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOProctor.rdf#TestCenterAdministratorRole');
         $accessService = \funcAcl_models_classes_AccessService::singleton();
         $accessService->grantModuleAccess($proctorRole, 'taoProctoring', 'ProctorManager');
         $this->setVersion('0.7');
     }
     if ($this->isVersion('0.7')) {
         try {
             $this->getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID);
         } catch (ServiceNotFoundException $e) {
             $service = new DeliveryMonitoringService(array(DeliveryMonitoringService::OPTION_PERSISTENCE => 'default'));
             $service->setServiceManager($this->getServiceManager());
             $this->getServiceManager()->register(DeliveryMonitoringService::CONFIG_ID, $service);
         }
         include __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . 'createDeliveryMonitoringTables.php';
         $this->setVersion('0.8.0');
     }
     if ($this->isVersion('0.8.0')) {
         $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID);
         $eventManager->attach(TestChangedEvent::EVENT_NAME, array('oat\\taoProctoring\\model\\monitorCache\\update\\TestUpdate', 'testStateChange'));
         $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager);
         $this->setVersion('0.9.0');
     }
     // nothign to do
     if ($this->isVersion('0.9.0')) {
         $this->setVersion('1.0.0');
     }
     if ($this->isVersion('1.0.0')) {
         try {
             $this->getServiceManager()->get(DeliveryAuthorizationService::SERVICE_ID);
         } catch (ServiceNotFoundException $e) {
             $service = new DeliveryAuthorizationService();
             $service->setServiceManager($this->getServiceManager());
             $this->getServiceManager()->register(DeliveryAuthorizationService::SERVICE_ID, $service);
         }
         $this->setVersion('1.1.0');
     }
     if ($this->isVersion('1.1.0')) {
         OntologyUpdater::syncModels();
         $this->setVersion('1.2.0');
     }
     if ($this->isVersion('1.2.0')) {
         try {
             $this->getServiceManager()->get(DeliveryExecutionStateService::SERVICE_ID);
         } catch (ServiceNotFoundException $e) {
             $service = new DeliveryExecutionStateService();
             $service->setServiceManager($this->getServiceManager());
             $this->getServiceManager()->register(DeliveryExecutionStateService::SERVICE_ID, $service);
         }
         $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID);
         $eventManager->attach('oat\\taoTests\\models\\event\\TestChangedEvent', array('\\oat\\taoProctoring\\helpers\\DeliveryHelper', 'testStateChanged'));
         $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager);
         $this->setVersion('1.3.0');
     }
     if ($this->isVersion('1.3.0')) {
         $proctoringExtension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoProctoring');
         $proctoringExtension->setConfig('monitoringUserExtraFields', array());
         $this->setVersion('1.4.0');
     }
     $this->skip('1.4.0', '1.4.1');
     $this->skip('1.4.1', '1.5.0');
     if ($this->isVersion('1.5.0')) {
         try {
             $this->getServiceManager()->get(RdsDeliveryLogService::SERVICE_ID);
         } catch (ServiceNotFoundException $e) {
             $action = new RegisterProctoringLog();
             $action->setServiceLocator($this->getServiceManager());
             $action->__invoke(array('default'));
         }
         $this->setVersion('1.6.0');
     }
     if ($this->isVersion('1.6.0')) {
         $settingsScript = new addDiagnosticSettings();
         $settingsScript([]);
         $sqlScript = new createDiagnosticTable();
         $sqlScript([]);
         //Grant access to the overridden controller
         $accessService = \funcAcl_models_classes_AccessService::singleton();
         $taoClientDiagnosticManager = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/generis.rdf#taoClientDiagnosticManager');
         $accessService->grantModuleAccess($taoClientDiagnosticManager, 'taoProctoring', 'DiagnosticChecker');
         $anonymousRole = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/generis.rdf#AnonymousRole');
         $accessService->grantModuleAccess($anonymousRole, 'taoProctoring', 'DiagnosticChecker');
         $this->setVersion('1.7.0');
     }
     $this->skip('1.7.0', '1.7.1');
     if ($this->isVersion('1.7.1')) {
         $deliveryExecutionStateService = $this->getServiceManager()->get(DeliveryExecutionStateService::SERVICE_ID);
         $deliveryExecutionStateService->setOption(DeliveryExecutionStateService::OPTION_TERMINATION_DELAY_AFTER_PAUSE, 'PT1H');
         $this->getServiceManager()->register(DeliveryExecutionStateService::SERVICE_ID, $deliveryExecutionStateService);
         $this->setVersion('1.8.0');
     }
     $this->skip('1.8.0', '1.9.0');
     if ($this->isVersion('1.9.0')) {
         $persistence = $this->getServiceManager()->get(PaginatedStorage::SERVICE_ID)->getPersistence();
         $schemaManager = $persistence->getDriver()->getSchemaManager();
         $schema = $schemaManager->createSchema();
         $fromSchema = clone $schema;
         /** @var \Doctrine\DBAL\Schema\Table $tableResults */
         $tableResults = $schema->getTable(DiagnosticStorage::DIAGNOSTIC_TABLE);
         $tableResults->changeColumn(DiagnosticStorage::DIAGNOSTIC_TEST_CENTER, ['notnull' => false]);
         $tableResults->changeColumn(DiagnosticStorage::DIAGNOSTIC_WORKSTATION, ['notnull' => false]);
         $queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema);
         foreach ($queries as $query) {
             $persistence->exec($query);
         }
         $this->setVersion('1.9.1');
     }
     if ($this->isVersion('1.9.1')) {
         $assignmentService = new ProctoringAssignmentService();
         $assignmentService->setServiceManager($this->getServiceManager());
         $this->getServiceManager()->register(ProctoringAssignmentService::CONFIG_ID, $assignmentService);
         $deliveryExt = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
         $deliveryServerConfig = $deliveryExt->getConfig('deliveryServer');
         $deliveryServerOptions = $deliveryServerConfig->getOptions();
         $deliveryServerService = new DeliveryServerService($deliveryServerOptions);
         $deliveryServerService->setServiceManager($this->getServiceManager());
         $this->getServiceManager()->register(DeliveryServerService::CONFIG_ID, $deliveryServerService);
         $this->setVersion('1.9.2');
     }
     $this->skip('1.9.2', '1.12.2');
     if ($this->isVersion('1.12.2')) {
         $persistenceId = $this->getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID)->getOption(DeliveryMonitoringService::OPTION_PERSISTENCE);
         $persistence = \common_persistence_Manager::getPersistence($persistenceId);
         $schemaManager = $persistence->getDriver()->getSchemaManager();
         $schema = $schemaManager->createSchema();
         $fromSchema = clone $schema;
         try {
             $tableData = $schema->getTable(DeliveryMonitoringService::TABLE_NAME);
             $tableData->changeColumn(DeliveryMonitoringService::COLUMN_START_TIME, array('type' => \Doctrine\DBAL\Types\Type::getType('string'), 'notnull' => false, 'length' => 255));
             $tableData->changeColumn(DeliveryMonitoringService::COLUMN_END_TIME, array('type' => \Doctrine\DBAL\Types\Type::getType('string'), 'notnull' => false, 'length' => 255));
         } catch (SchemaException $e) {
             \common_Logger::i('Database Schema already up to date.');
         }
         $queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema);
         foreach ($queries as $query) {
             $persistence->exec($query);
         }
         $this->setVersion('1.12.3');
     }
     if ($this->isVersion('1.12.3')) {
         try {
             $this->getServiceManager()->get(TestSessionConnectivityStatusService::SERVICE_ID);
         } catch (ServiceNotFoundException $e) {
             $service = new TestSessionConnectivityStatusService();
             $service->setServiceManager($this->getServiceManager());
             $this->getServiceManager()->register(TestSessionConnectivityStatusService::SERVICE_ID, $service);
         }
         $this->setVersion('1.13.0');
     }
     if ($this->isVersion('1.13.0')) {
         $this->refreshMonitoringData();
         $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID);
         $eventManager->attach('oat\\taoDelivery\\models\\classes\\execution\\event\\DeliveryExecutionState', ['oat\\taoProctoring\\model\\monitorCache\\update\\DeliveryExecutionStateUpdate', 'stateChange']);
         $eventManager->attach(EligiblityChanged::EVENT_NAME, ['oat\\taoProctoring\\model\\monitorCache\\update\\EligiblityUpdate', 'eligiblityChange']);
         $eventManager->attach(MetadataModified::class, ['oat\\taoProctoring\\model\\monitorCache\\update\\DeliveryUpdate', 'labelChange']);
         $eventManager->attach(MetadataModified::class, ['oat\\taoProctoring\\model\\monitorCache\\update\\TestTakerUpdate', 'propertyChange']);
         $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager);
         $this->setVersion('1.14.0');
     }
     $this->skip('1.14.0', '1.14.1');
     if ($this->isVersion('1.14.1')) {
         $this->refreshMonitoringData();
         $this->setVersion('1.14.2');
     }
     if ($this->isVersion('1.14.2') || $this->isVersion('1.14.3')) {
         $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
         $config = $ext->getConfig('execution_service');
         $config = new \oat\taoProctoring\model\execution\DeliveryExecutionService(['implementation' => $config]);
         $ext->setConfig('execution_service', $config);
         $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID);
         $eventManager->attach('oat\\taoDelivery\\models\\classes\\execution\\event\\DeliveryExecutionState', ['oat\\taoProctoring\\model\\monitorCache\\update\\DeliveryExecutionStateUpdate', 'stateChange']);
         $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager);
         OntologyUpdater::syncModels();
         $this->refreshMonitoringData();
         $this->setVersion('1.15.0');
     }
     if ($this->isVersion('1.15.0')) {
         $this->refreshMonitoringData();
         $this->setVersion('1.15.1');
     }
     $this->skip('1.15.1', '1.16.2');
     if ($this->isVersion('1.16.2')) {
         OntologyUpdater::syncModels();
         $this->setVersion('1.17.0');
     }
     $this->skip('1.17.0', '2.1.0');
     if ($this->isVersion('2.1.0')) {
         $authService = $this->getServiceManager()->get(AuthorizationService::SERVICE_ID);
         if ($authService instanceof AuthorizationAggregator) {
             $authService->unregister(StateValidation::class);
             $authService->addProvider(new ProctorAuthorizationProvider());
             $this->getServiceManager()->register(AuthorizationService::SERVICE_ID, $authService);
         } else {
             throw new \common_exception_Error('Incompatible AuthorizationService "' . get_class($authService) . '" found.');
         }
         $this->setVersion('3.0.0');
     }
     $this->skip('3.0.0', '3.0.6');
     if ($this->isVersion('3.0.6')) {
         //grant access to test taker
         $globalManagerRole = new \core_kernel_classes_Resource(INSTANCE_ROLE_GLOBALMANAGER);
         $accessService = \funcAcl_models_classes_AccessService::singleton();
         $accessService->grantModuleAccess($globalManagerRole, 'taoProctoring', 'Irregularity');
         $this->setVersion('3.1.0');
     }
     if ($this->isVersion('3.1.0')) {
         $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID);
         $eventManager->attach('oat\\taoTests\\models\\event\\TestExecutionPausedEvent', ['oat\\taoProctoring\\model\\implementation\\DeliveryExecutionStateService', 'catchSessionPause']);
         $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager);
         $this->setVersion('3.1.1');
     }
     $this->skip('3.1.1', '3.3.1');
     if ($this->isVersion('3.3.1')) {
         $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
         $config = $ext->getConfig('execution_service');
         $implementation = $config->getImplementation();
         $ext->setConfig('execution_service', $implementation);
         $this->setVersion('3.4.0');
     }
     if ($this->isVersion('3.4.0')) {
         try {
             $this->getServiceManager()->get(TestSessionService::SERVICE_ID);
         } catch (ServiceNotFoundException $e) {
             $service = new TestSessionService();
             $service->setServiceManager($this->getServiceManager());
             $this->getServiceManager()->register(TestSessionService::SERVICE_ID, $service);
         }
         $this->setVersion('3.4.1');
     }
     $this->skip('3.4.1', '3.6.3');
     if ($this->isVersion('3.6.3')) {
         $deliveryMonitoringService = $this->getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID);
         $deliveryMonitoringService->setOption(DeliveryMonitoringService::OPTION_PRIMARY_COLUMNS, [DeliveryMonitoringService::COLUMN_DELIVERY_EXECUTION_ID, DeliveryMonitoringService::COLUMN_STATUS, DeliveryMonitoringService::COLUMN_CURRENT_ASSESSMENT_ITEM, DeliveryMonitoringService::COLUMN_TEST_TAKER, DeliveryMonitoringService::COLUMN_AUTHORIZED_BY, DeliveryMonitoringService::COLUMN_START_TIME, DeliveryMonitoringService::COLUMN_END_TIME]);
         $this->getServiceManager()->register(DeliveryMonitoringService::CONFIG_ID, $deliveryMonitoringService);
         $this->setVersion('3.6.5');
     }
     $this->skip('3.6.4', '3.6.5');
     if ($this->isVersion('3.6.5')) {
         $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID);
         $eventManager->detach('oat\\taoTests\\models\\event\\TestChangedEvent', array('\\oat\\taoProctoring\\helpers\\DeliveryHelper', 'testStateChanged'));
         $eventManager->attach('oat\\taoQtiTest\\models\\event\\QtiTestStateChangeEvent', array('\\oat\\taoProctoring\\helpers\\DeliveryHelper', 'testStateChanged'));
         $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager);
         $this->setVersion('3.6.6');
     }
     $this->skip('3.6.6', '3.6.18');
     if ($this->isVersion('3.6.18')) {
         $this->getServiceManager()->register(ProctoringTextConverter::SERVICE_ID, new ProctoringTextConverter());
         $proctorRole = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOProctor.rdf#ProctorRole');
         $accessService = \funcAcl_models_classes_AccessService::singleton();
         $accessService->grantModuleAccess($proctorRole, 'taoProctoring', 'TextConverter');
         $this->setVersion('3.7.0');
     }
     $this->skip('3.7.0', '3.10.1');
     if ($this->isVersion('3.10.1')) {
         try {
             $this->getServiceManager()->get(TestSessionHistoryService::SERVICE_ID);
         } catch (ServiceNotFoundException $e) {
             $service = new TestSessionHistoryService();
             $service->setServiceManager($this->getServiceManager());
             $this->getServiceManager()->register(TestSessionHistoryService::SERVICE_ID, $service);
         }
         $this->setVersion('3.11.0');
     }
     if ($this->isVersion('3.11.0')) {
         // register timeHandling option
         try {
             $service = $this->getServiceManager()->get(DeliveryExecutionStateService::SERVICE_ID);
         } catch (ServiceNotFoundException $e) {
             $service = new DeliveryExecutionStateService([DeliveryExecutionStateService::OPTION_TERMINATION_DELAY_AFTER_PAUSE => 'PT1H', DeliveryExecutionStateService::OPTION_TIME_HANDLING => false]);
         }
         $service->setOption(DeliveryExecutionStateService::OPTION_TIME_HANDLING, false);
         $service->setServiceManager($this->getServiceManager());
         $this->getServiceManager()->register(DeliveryExecutionStateService::SERVICE_ID, $service);
         // extend the data table
         $persistenceId = $this->getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID)->getOption(DeliveryMonitoringService::OPTION_PERSISTENCE);
         $persistence = \common_persistence_Manager::getPersistence($persistenceId);
         $schemaManager = $persistence->getDriver()->getSchemaManager();
         $schema = $schemaManager->createSchema();
         $fromSchema = clone $schema;
         try {
             $tableData = $schema->getTable(DeliveryMonitoringService::TABLE_NAME);
             $tableData->addColumn(DeliveryMonitoringService::COLUMN_REMAINING_TIME, "string", array("notnull" => false, "length" => 255));
             $tableData->addColumn(DeliveryMonitoringService::COLUMN_EXTRA_TIME, "string", array("notnull" => false, "length" => 255));
             $tableData->addColumn(DeliveryMonitoringService::COLUMN_CONSUMED_EXTRA_TIME, "string", array("notnull" => false, "length" => 255));
         } catch (SchemaException $e) {
             \common_Logger::i('Database Schema already up to date.');
         }
         $queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema);
         foreach ($queries as $query) {
             $persistence->exec($query);
         }
         $this->setVersion('3.12.0');
     }
     $this->skip('3.12.0', '3.12.1');
     if ($this->isVersion('3.12.1')) {
         OntologyUpdater::syncModels();
         $this->setVersion('3.13.0');
     }
     $this->skip('3.13.0', '3.13.5');
 }