Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| AccessService | |
0.00% |
0 / 25 |
|
0.00% |
0 / 7 |
132 | |
0.00% |
0 / 1 |
| grantExtensionAccess | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| grantModuleAccess | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| grantActionAccess | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| revokeExtensionAccess | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| revokeModuleAccess | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| revokeActionAccess | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| makeEMAUri | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
30 | |||
| 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) 2009-2012 (original work) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV); |
| 19 | */ |
| 20 | |
| 21 | namespace oat\funcAcl\models; |
| 22 | |
| 23 | use core_kernel_classes_Resource; |
| 24 | use oat\oatbox\event\EventManagerAwareTrait; |
| 25 | use tao_models_classes_GenerisService; |
| 26 | |
| 27 | /** |
| 28 | * mother class for access operations |
| 29 | * |
| 30 | * @author Jehan Bihin |
| 31 | * |
| 32 | * @package tao |
| 33 | * |
| 34 | * @since 2.2 |
| 35 | */ |
| 36 | class AccessService extends tao_models_classes_GenerisService |
| 37 | { |
| 38 | use EventManagerAwareTrait; |
| 39 | |
| 40 | public const FUNCACL_NS = 'http://www.tao.lu/Ontologies/taoFuncACL.rdf'; |
| 41 | |
| 42 | public const PROPERTY_ACL_GRANTACCESS = 'http://www.tao.lu/Ontologies/taoFuncACL.rdf#GrantAccess'; |
| 43 | |
| 44 | public function grantExtensionAccess(core_kernel_classes_Resource $role, $ext) |
| 45 | { |
| 46 | $accessUri = $this->makeEMAUri($ext); |
| 47 | ExtensionAccessService::singleton()->add($role->getUri(), $accessUri); |
| 48 | } |
| 49 | |
| 50 | public function grantModuleAccess(core_kernel_classes_Resource $role, $ext, $mod) |
| 51 | { |
| 52 | $accessUri = $this->makeEMAUri($ext, $mod); |
| 53 | ModuleAccessService::singleton()->add($role->getUri(), $accessUri); |
| 54 | } |
| 55 | |
| 56 | public function grantActionAccess(core_kernel_classes_Resource $role, $ext, $mod, $act) |
| 57 | { |
| 58 | $accessUri = $this->makeEMAUri($ext, $mod, $act); |
| 59 | ActionAccessService::singleton()->add($role->getUri(), $accessUri); |
| 60 | } |
| 61 | |
| 62 | public function revokeExtensionAccess(core_kernel_classes_Resource $role, $ext) |
| 63 | { |
| 64 | $accessUri = $this->makeEMAUri($ext); |
| 65 | ExtensionAccessService::singleton()->remove($role->getUri(), $accessUri); |
| 66 | } |
| 67 | |
| 68 | public function revokeModuleAccess(core_kernel_classes_Resource $role, $ext, $mod) |
| 69 | { |
| 70 | $accessUri = $this->makeEMAUri($ext, $mod); |
| 71 | ModuleAccessService::singleton()->remove($role->getUri(), $accessUri); |
| 72 | } |
| 73 | |
| 74 | public function revokeActionAccess(core_kernel_classes_Resource $role, $ext, $mod, $act) |
| 75 | { |
| 76 | $accessUri = $this->makeEMAUri($ext, $mod, $act); |
| 77 | ActionAccessService::singleton()->remove($role->getUri(), $accessUri); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Short description of method makeEMAUri |
| 82 | * |
| 83 | * @access public |
| 84 | * |
| 85 | * @author Jehan Bihin, <jehan.bihin@tudor.lu> |
| 86 | * |
| 87 | * @param string $ext |
| 88 | * @param string $mod |
| 89 | * @param string $act |
| 90 | * |
| 91 | * @return string |
| 92 | */ |
| 93 | public function makeEMAUri($ext, $mod = null, $act = null) |
| 94 | { |
| 95 | $returnValue = (string) ''; |
| 96 | |
| 97 | $returnValue = self::FUNCACL_NS . '#'; |
| 98 | |
| 99 | if (! is_null($act)) { |
| 100 | $type = 'a'; |
| 101 | } else { |
| 102 | if (! is_null($mod)) { |
| 103 | $type = 'm'; |
| 104 | } else { |
| 105 | $type = 'e'; |
| 106 | } |
| 107 | } |
| 108 | $returnValue .= $type . '_' . $ext; |
| 109 | |
| 110 | if (! is_null($mod)) { |
| 111 | $returnValue .= '_' . $mod; |
| 112 | } |
| 113 | |
| 114 | if (! is_null($act)) { |
| 115 | $returnValue .= '_' . $act; |
| 116 | } |
| 117 | |
| 118 | return (string) $returnValue; |
| 119 | } |
| 120 | } |