Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Updater | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
72 | |
0.00% |
0 / 1 |
| update | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
72 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg |
| 19 | * (under the project TAO & TAO2); |
| 20 | * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung |
| 21 | * (under the project TAO-TRANSFER); |
| 22 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 23 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 24 | * 2013-2014 (update and modification) Open Assessment Technologies SA |
| 25 | */ |
| 26 | |
| 27 | namespace oat\taoGroups\models\update; |
| 28 | |
| 29 | use common_ext_ExtensionUpdater; |
| 30 | use core_kernel_classes_Property; |
| 31 | use core_kernel_classes_ResourceIterator; |
| 32 | use oat\tao\model\accessControl\func\AccessRule; |
| 33 | use oat\tao\model\accessControl\func\AclProxy; |
| 34 | use oat\tao\model\user\TaoRoles; |
| 35 | use oat\tao\scripts\update\OntologyUpdater; |
| 36 | use oat\taoGroups\controller\Api; |
| 37 | use oat\taoGroups\models\GroupsService; |
| 38 | |
| 39 | /** |
| 40 | * Service methods to manage the Groups business models using the RDF API. |
| 41 | * |
| 42 | * @access public |
| 43 | * |
| 44 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 45 | * |
| 46 | * @package taoGroups |
| 47 | * |
| 48 | * @deprecated use migrations instead. See https://github.com/oat-sa/generis/wiki/Tao-Update-Process |
| 49 | */ |
| 50 | class Updater extends common_ext_ExtensionUpdater |
| 51 | { |
| 52 | public const OLD_MEMBER_PROPERTY = 'http://www.tao.lu/Ontologies/TAOGroup.rdf#Members'; |
| 53 | |
| 54 | /** |
| 55 | * (non-PHPdoc) |
| 56 | * |
| 57 | * @see common_ext_ExtensionUpdater::update() |
| 58 | * |
| 59 | * @param mixed $initialVersion |
| 60 | */ |
| 61 | public function update($initialVersion) |
| 62 | { |
| 63 | if ($this->isVersion('2.6')) { |
| 64 | OntologyUpdater::syncModels(); |
| 65 | |
| 66 | $iterator = new core_kernel_classes_ResourceIterator([GroupsService::singleton()->getRootClass()]); |
| 67 | |
| 68 | foreach ($iterator as $group) { |
| 69 | $users = $group->getPropertyValues(new core_kernel_classes_Property(self::OLD_MEMBER_PROPERTY)); |
| 70 | |
| 71 | foreach ($users as $userUri) { |
| 72 | if (GroupsService::singleton()->addUser($userUri, $group)) { |
| 73 | // $group->removePropertyValue( |
| 74 | // new \core_kernel_classes_Property(self::OLD_MEMBER_PROPERTY), |
| 75 | // $userUri |
| 76 | // ); |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | $this->setVersion('2.6.1'); |
| 81 | } |
| 82 | |
| 83 | if ($this->isBetween('2.6.1', '2.7')) { |
| 84 | $this->setVersion('2.7'); |
| 85 | } |
| 86 | |
| 87 | if ($this->isVersion('2.7')) { |
| 88 | OntologyUpdater::syncModels(); |
| 89 | $this->setVersion('2.7.1'); |
| 90 | } |
| 91 | |
| 92 | $this->skip('2.7.1', '3.0.0'); |
| 93 | // fix anonymous access |
| 94 | if ($this->isVersion('3.0.0')) { |
| 95 | AclProxy::revokeRule(new AccessRule(AccessRule::GRANT, TaoRoles::ANONYMOUS, Api::class)); |
| 96 | $this->setVersion('3.0.1'); |
| 97 | } |
| 98 | |
| 99 | $this->skip('3.0.1', '6.5.1'); |
| 100 | |
| 101 | //Updater files are deprecated. Please use migrations. |
| 102 | //See: https://github.com/oat-sa/generis/wiki/Tao-Update-Process |
| 103 | |
| 104 | $this->setVersion($this->getExtension()->getManifest()->getVersion()); |
| 105 | } |
| 106 | } |