Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| AclProxy | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
| getImplementations | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| hasAccess | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| 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 | namespace oat\tao\model\accessControl; |
| 23 | |
| 24 | use oat\tao\model\accessControl\func\AclProxy as FuncProxy; |
| 25 | use oat\tao\model\accessControl\data\DataAccessControl; |
| 26 | use oat\oatbox\user\User; |
| 27 | |
| 28 | /** |
| 29 | * Proxy for the Acl Implementation |
| 30 | * |
| 31 | * @access public |
| 32 | * @author Joel Bout, <joel@taotesting.com> |
| 33 | * @package tao |
| 34 | |
| 35 | */ |
| 36 | class AclProxy |
| 37 | { |
| 38 | /** |
| 39 | * @var array |
| 40 | */ |
| 41 | private static $implementations; |
| 42 | |
| 43 | /** |
| 44 | * get the current access control implementations |
| 45 | * |
| 46 | * @return array |
| 47 | */ |
| 48 | protected static function getImplementations() |
| 49 | { |
| 50 | if (is_null(self::$implementations)) { |
| 51 | self::$implementations = [ |
| 52 | new FuncProxy(), |
| 53 | new DataAccessControl() |
| 54 | ]; |
| 55 | } |
| 56 | return self::$implementations; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Returns whenever or not a user has access to a specified link |
| 61 | * |
| 62 | * @param string $action |
| 63 | * @param string $controller |
| 64 | * @param string $extension |
| 65 | * @param array $parameters |
| 66 | * @return boolean |
| 67 | */ |
| 68 | public static function hasAccess(User $user, $controller, $action, $parameters) |
| 69 | { |
| 70 | $access = true; |
| 71 | foreach (self::getImplementations() as $impl) { |
| 72 | $access = $access && $impl->hasAccess($user, $controller, $action, $parameters); |
| 73 | } |
| 74 | return $access; |
| 75 | } |
| 76 | } |