Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| UserService | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
| getUserById | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |||
| addUser | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| 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) 2018 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | namespace oat\taoLti\models\classes\user; |
| 24 | |
| 25 | use core_kernel_classes_Class as TypeClass; |
| 26 | use core_kernel_classes_Resource as Resource; |
| 27 | use oat\oatbox\user\User; |
| 28 | |
| 29 | /** |
| 30 | * Class UserService |
| 31 | * @package oat\taoLti\models\classes\user |
| 32 | */ |
| 33 | class UserService extends \tao_models_classes_UserService |
| 34 | { |
| 35 | public const PASSWORD_LENGTH = 255; |
| 36 | |
| 37 | /** |
| 38 | * @param $userId |
| 39 | * @return User|array |
| 40 | * @throws \common_exception_Error |
| 41 | */ |
| 42 | public function getUserById($userId) |
| 43 | { |
| 44 | $user = parent::getUserById($userId); |
| 45 | if (!$user || !$this->getResource($user->getIdentifier())->exists()) { |
| 46 | /** @var LtiUserService $ltiUserService */ |
| 47 | $ltiUserService = $this->getServiceLocator()->get(LtiUserService::SERVICE_ID); |
| 48 | $userData = $ltiUserService->getUserDataFromId($userId); |
| 49 | if ($userData) { |
| 50 | $user = new KvLtiUser($userData); |
| 51 | } |
| 52 | } |
| 53 | return $user; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @inheritDoc |
| 58 | */ |
| 59 | public function addUser( |
| 60 | $login, |
| 61 | $password, |
| 62 | Resource $role = null, |
| 63 | TypeClass $class = null |
| 64 | ) { |
| 65 | $user = $this->getOneUser($login); |
| 66 | if ($user !== null) { |
| 67 | return $user; |
| 68 | } |
| 69 | return parent::addUser($login, $password, $role); |
| 70 | } |
| 71 | } |