Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| common_user_User | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| getIdentifier | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getPropertyValues | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| refresh | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getRoles | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
20 | |||
| 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) 2017 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | use oat\generis\model\GenerisRdf; |
| 24 | use oat\oatbox\user\User; |
| 25 | use oat\oatbox\Refreshable; |
| 26 | |
| 27 | /** |
| 28 | * Abstract User |
| 29 | * |
| 30 | * @access public |
| 31 | * @author Joel Bout, <joel@taotesting.com> |
| 32 | * @package generis |
| 33 | */ |
| 34 | abstract class common_user_User implements User, Refreshable |
| 35 | { |
| 36 | /** |
| 37 | * Store roles to prevent recalculation in runtime |
| 38 | * @var array |
| 39 | */ |
| 40 | protected $roles = []; |
| 41 | |
| 42 | abstract public function getIdentifier(); |
| 43 | |
| 44 | abstract public function getPropertyValues($property); |
| 45 | |
| 46 | abstract public function refresh(); |
| 47 | |
| 48 | /** |
| 49 | * Extends the users explizit roles with the implizit rules |
| 50 | * of the local system |
| 51 | * |
| 52 | * @return array the identifiers of the roles: |
| 53 | */ |
| 54 | public function getRoles() |
| 55 | { |
| 56 | $returnValue = []; |
| 57 | if (! $this->roles) { |
| 58 | // We use a Depth First Search approach to flatten the Roles Graph. |
| 59 | foreach ($this->getPropertyValues(GenerisRdf::PROPERTY_USER_ROLES) as $roleUri) { |
| 60 | $returnValue[] = $roleUri; |
| 61 | $includedRoles = core_kernel_users_Service::singleton()->getIncludedRoles( |
| 62 | new core_kernel_classes_Resource($roleUri) |
| 63 | ); |
| 64 | |
| 65 | foreach ($includedRoles as $role) { |
| 66 | $returnValue[] = $role->getUri(); |
| 67 | } |
| 68 | } |
| 69 | $returnValue = array_unique($returnValue); |
| 70 | $this->roles = $returnValue; |
| 71 | } |
| 72 | return $this->roles; |
| 73 | } |
| 74 | } |