Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| tao_models_classes_accessControl_AclProxy | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| hasAccess | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
| hasAccessUrl | |
0.00% |
0 / 6 |
|
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) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | use oat\tao\model\accessControl\func\AclProxy as FuncProxy; |
| 23 | use oat\tao\model\accessControl\AclProxy; |
| 24 | use oat\tao\model\accessControl\ActionResolver; |
| 25 | use oat\tao\model\routing\Resolver; |
| 26 | |
| 27 | /** |
| 28 | * Proxy for the Acl Implementation |
| 29 | * |
| 30 | * @access public |
| 31 | * @author Joel Bout, <joel@taotesting.com> |
| 32 | * @package tao |
| 33 | * @deprecated |
| 34 | */ |
| 35 | class tao_models_classes_accessControl_AclProxy |
| 36 | { |
| 37 | /** |
| 38 | * Returns whenever or not the current user has access to a specified link |
| 39 | * |
| 40 | * @param string $action |
| 41 | * @param string $controller |
| 42 | * @param string $extension |
| 43 | * @param array $parameters |
| 44 | * @return boolean |
| 45 | * @deprecated |
| 46 | */ |
| 47 | public static function hasAccess($action, $controller, $extension, $parameters = []) |
| 48 | { |
| 49 | $user = common_session_SessionManager::getSession()->getUser(); |
| 50 | try { |
| 51 | $resolver = ActionResolver::getByControllerName($controller, $extension); |
| 52 | $className = $resolver->getController(); |
| 53 | } catch (ResolverException $e) { |
| 54 | return false; |
| 55 | } |
| 56 | return AclProxy::hasAccess($user, $className, $action, $parameters); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Does not respect params |
| 61 | * |
| 62 | * @param string $url |
| 63 | * @return boolean |
| 64 | */ |
| 65 | public static function hasAccessUrl($url) |
| 66 | { |
| 67 | $user = common_session_SessionManager::getSession()->getUser(); |
| 68 | try { |
| 69 | $resolver = new ActionResolver($url); |
| 70 | return AclProxy::hasAccess($user, $resolver->getController(), $resolver->getAction(), []); |
| 71 | $className = $resolver->getController(); |
| 72 | } catch (ResolverException $e) { |
| 73 | return false; |
| 74 | } |
| 75 | } |
| 76 | } |