Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
19 | * | |
20 | */ | |
21 | class CRM_Core_Permission_UnitTests extends CRM_Core_Permission_Base { | |
22 | ||
518fa0ee SL |
23 | /** |
24 | * permission mapping to stub check() calls | |
25 | * @var array | |
26 | */ | |
6a488035 TO |
27 | public $permissions = NULL; |
28 | ||
b5c2afd0 | 29 | /** |
100fef9d | 30 | * Given a permission string, check for access requirements |
b5c2afd0 | 31 | * |
6a0b768e TO |
32 | * @param string $str |
33 | * The permission to check. | |
18be3201 | 34 | * @param int $userId |
b5c2afd0 | 35 | * |
608e6658 | 36 | * @return bool |
a6c01b45 | 37 | * true if yes, else false |
b5c2afd0 | 38 | */ |
18be3201 | 39 | public function check($str, $userId = NULL) { |
17b9f7be TO |
40 | if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) { |
41 | return FALSE; | |
42 | } | |
43 | if ($str == CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) { | |
44 | return TRUE; | |
45 | } | |
46 | ||
6a488035 TO |
47 | // return the stubbed permission (defaulting to true if the array is missing) |
48 | return is_array($this->permissions) ? in_array($str, $this->permissions) : TRUE; | |
49 | } | |
50 | ||
51 | /** | |
d09edf64 | 52 | * Get the permissioned where clause for the user. |
6a488035 | 53 | * |
6a0b768e TO |
54 | * @param int $type |
55 | * The type of permission needed. | |
56 | * @param array $tables | |
57 | * (reference ) add the tables that are needed for the select clause. | |
58 | * @param array $whereTables | |
59 | * (reference ) add the tables that are needed for the where clause. | |
6a488035 | 60 | * |
a6c01b45 CW |
61 | * @return string |
62 | * the group where clause for this user | |
6a488035 TO |
63 | */ |
64 | public function whereClause($type, &$tables, &$whereTables) { | |
65 | return '( 1 )'; | |
66 | } | |
96025800 | 67 | |
6a488035 | 68 | } |