Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
31 | * @copyright CiviCRM LLC (c) 2004-2013 | |
32 | * $Id$ | |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * | |
38 | */ | |
39 | class CRM_Core_Permission_Base { | |
40 | ||
41 | /** | |
42 | * get the current permission of this user | |
43 | * | |
44 | * @return string the permission of the user (edit or view or null) | |
45 | */ | |
46 | public function getPermission() { | |
47 | return CRM_Core_Permission::EDIT; | |
48 | } | |
49 | ||
50 | /** | |
51 | * Get the permissioned where clause for the user | |
52 | * | |
53 | * @param int $type the type of permission needed | |
54 | * @param array $tables (reference ) add the tables that are needed for the select clause | |
55 | * @param array $whereTables (reference ) add the tables that are needed for the where clause | |
56 | * | |
57 | * @return string the group where clause for this user | |
58 | * @access public | |
59 | */ | |
60 | public function whereClause($type, &$tables, &$whereTables) { | |
61 | return '( 1 )'; | |
62 | } | |
63 | /** | |
64 | * Get the permissioned where clause for the user when trying to see groups | |
65 | * | |
66 | * @param int $type the type of permission needed | |
67 | * @param array $tables (reference ) add the tables that are needed for the select clause | |
68 | * @param array $whereTables (reference ) add the tables that are needed for the where clause | |
69 | * | |
70 | * @return string the group where clause for this user | |
71 | * @access public | |
72 | */ | |
73 | public function getPermissionedStaticGroupClause($type, &$tables, &$whereTables) { | |
74 | $this->group(); | |
75 | return $this->groupClause($type, $tables, $whereTables); | |
76 | } | |
77 | /** | |
78 | * Get all groups from database, filtered by permissions | |
79 | * for this user | |
80 | * | |
81 | * @param string $groupType type of group(Access/Mailing) | |
82 | * @param boolen $excludeHidden exclude hidden groups. | |
83 | * | |
84 | * @access public | |
85 | * | |
86 | * @return array - array reference of all groups. | |
87 | * | |
88 | */ | |
89 | public function group($groupType = NULL, $excludeHidden = TRUE) { | |
90 | return CRM_Core_PseudoConstant::allGroup($groupType, $excludeHidden); | |
91 | } | |
92 | ||
93 | /** | |
94 | * Get group clause for this user | |
95 | * | |
96 | * @param int $type the type of permission needed | |
97 | * @param array $tables (reference ) add the tables that are needed for the select clause | |
98 | * @param array $whereTables (reference ) add the tables that are needed for the where clause | |
99 | * | |
100 | * @return string the group where clause for this user | |
101 | * @access public | |
102 | */ | |
103 | public function groupClause($type, &$tables, &$whereTables) { | |
104 | return ' (1) '; | |
105 | } | |
106 | ||
107 | /** | |
108 | * given a permission string, check for access requirements | |
109 | * | |
110 | * @param string $str the permission to check | |
111 | * | |
112 | * @return boolean true if yes, else false | |
113 | * @access public | |
114 | */ | |
115 | ||
116 | function check($str) { | |
117 | //no default behaviour | |
118 | } | |
119 | ||
120 | /** | |
121 | * Given a roles array, check for access requirements | |
122 | * | |
123 | * @param array $array the roles to check | |
124 | * | |
125 | * @return boolean true if yes, else false | |
126 | * @access public | |
127 | */ | |
128 | ||
129 | function checkGroupRole($array) { | |
130 | return FALSE; | |
131 | } | |
132 | ||
133 | /** | |
134 | * Get all the contact emails for users that have a specific permission | |
135 | * | |
136 | * @param string $permissionName name of the permission we are interested in | |
137 | * | |
138 | * @return string a comma separated list of email addresses | |
139 | */ | |
140 | public function permissionEmails($permissionName) { | |
141 | CRM_Core_Error::fatal("this function only works in Drupal 6 at the moment"); | |
142 | } | |
143 | ||
144 | /** | |
145 | * Get all the contact emails for users that have a specific role | |
146 | * | |
147 | * @param string $roleName name of the role we are interested in | |
148 | * | |
149 | * @return string a comma separated list of email addresses | |
150 | */ | |
151 | public function roleEmails($roleName) { | |
152 | CRM_Core_Error::fatal("this function only works in Drupal 6 at the moment"); | |
153 | } | |
154 | ||
155 | /** | |
156 | * Remove all vestiges of permissions for the given module. | |
157 | */ | |
158 | function uninstallPermissions($module) { | |
159 | } | |
160 | ||
161 | /** | |
162 | * Ensure that all cached permissions associated with the given module are | |
163 | * actually defined by that module. This is useful during module upgrade | |
164 | * when the newer module version has removed permission that were defined | |
165 | * in the older version. | |
166 | */ | |
167 | function upgradePermissions($module) { | |
168 | } | |
169 | ||
170 | /** | |
171 | * Get the permissions defined in the hook_civicrm_permission implementation | |
172 | * of the given module. | |
173 | * | |
174 | * @return Array of permissions, in the same format as CRM_Core_Permission::getCorePermissions(). | |
175 | */ | |
176 | static function getModulePermissions($module) { | |
177 | return array(); | |
178 | } | |
179 | ||
180 | /** | |
181 | * Get the permissions defined in the hook_civicrm_permission implementation | |
182 | * in all enabled CiviCRM module extensions. | |
183 | * | |
184 | * @return Array of permissions, in the same format as CRM_Core_Permission::getCorePermissions(). | |
185 | */ | |
186 | function getAllModulePermissions() { | |
187 | $permissions = array(); | |
188 | CRM_Utils_Hook::permission($permissions); | |
189 | return $permissions; | |
190 | } | |
191 | } | |
192 |