DAOs with singular/plural options for entity titles
[civicrm-core.git] / CRM / ACL / DAO / ACL.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/ACL/ACL.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:54e8c75c28c9dd74192f60bbcf1605f6)
10 */
11
12 /**
13 * Database access object for the ACL entity.
14 */
15 class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.6';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_acl';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = FALSE;
32
33 /**
34 * Unique table ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * ACL Name.
42 *
43 * @var string
44 */
45 public $name;
46
47 /**
48 * Is this ACL entry Allow (0) or Deny (1) ?
49 *
50 * @var bool
51 */
52 public $deny;
53
54 /**
55 * Table of the object possessing this ACL entry (Contact, Group, or ACL Group)
56 *
57 * @var string
58 */
59 public $entity_table;
60
61 /**
62 * ID of the object possessing this ACL
63 *
64 * @var int
65 */
66 public $entity_id;
67
68 /**
69 * What operation does this ACL entry control?
70 *
71 * @var string
72 */
73 public $operation;
74
75 /**
76 * The table of the object controlled by this ACL entry
77 *
78 * @var string
79 */
80 public $object_table;
81
82 /**
83 * The ID of the object controlled by this ACL entry
84 *
85 * @var int
86 */
87 public $object_id;
88
89 /**
90 * If this is a grant/revoke entry, what table are we granting?
91 *
92 * @var string
93 */
94 public $acl_table;
95
96 /**
97 * ID of the ACL or ACL group being granted/revoked
98 *
99 * @var int
100 */
101 public $acl_id;
102
103 /**
104 * Is this property active?
105 *
106 * @var bool
107 */
108 public $is_active;
109
110 /**
111 * Class constructor.
112 */
113 public function __construct() {
114 $this->__table = 'civicrm_acl';
115 parent::__construct();
116 }
117
118 /**
119 * Returns localized title of this entity.
120 *
121 * @param bool $plural
122 * Whether to return the plural version of the title.
123 */
124 public static function getEntityTitle($plural = FALSE) {
125 return $plural ? ts('ACLs') : ts('ACL');
126 }
127
128 /**
129 * Returns foreign keys and entity references.
130 *
131 * @return array
132 * [CRM_Core_Reference_Interface]
133 */
134 public static function getReferenceColumns() {
135 if (!isset(Civi::$statics[__CLASS__]['links'])) {
136 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
137 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
138 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
139 }
140 return Civi::$statics[__CLASS__]['links'];
141 }
142
143 /**
144 * Returns all the column names of this table
145 *
146 * @return array
147 */
148 public static function &fields() {
149 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
150 Civi::$statics[__CLASS__]['fields'] = [
151 'id' => [
152 'name' => 'id',
153 'type' => CRM_Utils_Type::T_INT,
154 'title' => ts('ACL ID'),
155 'description' => ts('Unique table ID'),
156 'required' => TRUE,
157 'where' => 'civicrm_acl.id',
158 'table_name' => 'civicrm_acl',
159 'entity' => 'ACL',
160 'bao' => 'CRM_ACL_BAO_ACL',
161 'localizable' => 0,
162 'add' => '1.6',
163 ],
164 'name' => [
165 'name' => 'name',
166 'type' => CRM_Utils_Type::T_STRING,
167 'title' => ts('ACL Name'),
168 'description' => ts('ACL Name.'),
169 'maxlength' => 64,
170 'size' => CRM_Utils_Type::BIG,
171 'where' => 'civicrm_acl.name',
172 'table_name' => 'civicrm_acl',
173 'entity' => 'ACL',
174 'bao' => 'CRM_ACL_BAO_ACL',
175 'localizable' => 0,
176 'html' => [
177 'type' => 'Text',
178 ],
179 'add' => '1.6',
180 ],
181 'deny' => [
182 'name' => 'deny',
183 'type' => CRM_Utils_Type::T_BOOLEAN,
184 'title' => ts('Deny ACL?'),
185 'description' => ts('Is this ACL entry Allow (0) or Deny (1) ?'),
186 'required' => TRUE,
187 'where' => 'civicrm_acl.deny',
188 'default' => '0',
189 'table_name' => 'civicrm_acl',
190 'entity' => 'ACL',
191 'bao' => 'CRM_ACL_BAO_ACL',
192 'localizable' => 0,
193 'html' => [
194 'type' => 'Radio',
195 ],
196 'add' => '1.6',
197 ],
198 'entity_table' => [
199 'name' => 'entity_table',
200 'type' => CRM_Utils_Type::T_STRING,
201 'title' => ts('ACL Entity'),
202 'description' => ts('Table of the object possessing this ACL entry (Contact, Group, or ACL Group)'),
203 'required' => TRUE,
204 'maxlength' => 64,
205 'size' => CRM_Utils_Type::BIG,
206 'where' => 'civicrm_acl.entity_table',
207 'table_name' => 'civicrm_acl',
208 'entity' => 'ACL',
209 'bao' => 'CRM_ACL_BAO_ACL',
210 'localizable' => 0,
211 'add' => '1.6',
212 ],
213 'entity_id' => [
214 'name' => 'entity_id',
215 'type' => CRM_Utils_Type::T_INT,
216 'title' => ts('Entity ID'),
217 'description' => ts('ID of the object possessing this ACL'),
218 'where' => 'civicrm_acl.entity_id',
219 'table_name' => 'civicrm_acl',
220 'entity' => 'ACL',
221 'bao' => 'CRM_ACL_BAO_ACL',
222 'localizable' => 0,
223 'add' => '1.6',
224 ],
225 'operation' => [
226 'name' => 'operation',
227 'type' => CRM_Utils_Type::T_STRING,
228 'title' => ts('ACL Operation'),
229 'description' => ts('What operation does this ACL entry control?'),
230 'required' => TRUE,
231 'maxlength' => 8,
232 'size' => CRM_Utils_Type::EIGHT,
233 'where' => 'civicrm_acl.operation',
234 'table_name' => 'civicrm_acl',
235 'entity' => 'ACL',
236 'bao' => 'CRM_ACL_BAO_ACL',
237 'localizable' => 0,
238 'html' => [
239 'type' => 'Select',
240 ],
241 'pseudoconstant' => [
242 'callback' => 'CRM_ACL_BAO_ACL::operation',
243 ],
244 'add' => '1.6',
245 ],
246 'object_table' => [
247 'name' => 'object_table',
248 'type' => CRM_Utils_Type::T_STRING,
249 'title' => ts('ACL Object'),
250 'description' => ts('The table of the object controlled by this ACL entry'),
251 'maxlength' => 64,
252 'size' => CRM_Utils_Type::BIG,
253 'where' => 'civicrm_acl.object_table',
254 'table_name' => 'civicrm_acl',
255 'entity' => 'ACL',
256 'bao' => 'CRM_ACL_BAO_ACL',
257 'localizable' => 0,
258 'add' => '1.6',
259 ],
260 'object_id' => [
261 'name' => 'object_id',
262 'type' => CRM_Utils_Type::T_INT,
263 'title' => ts('ACL Object ID'),
264 'description' => ts('The ID of the object controlled by this ACL entry'),
265 'where' => 'civicrm_acl.object_id',
266 'table_name' => 'civicrm_acl',
267 'entity' => 'ACL',
268 'bao' => 'CRM_ACL_BAO_ACL',
269 'localizable' => 0,
270 'add' => '1.6',
271 ],
272 'acl_table' => [
273 'name' => 'acl_table',
274 'type' => CRM_Utils_Type::T_STRING,
275 'title' => ts('ACL Table'),
276 'description' => ts('If this is a grant/revoke entry, what table are we granting?'),
277 'maxlength' => 64,
278 'size' => CRM_Utils_Type::BIG,
279 'where' => 'civicrm_acl.acl_table',
280 'table_name' => 'civicrm_acl',
281 'entity' => 'ACL',
282 'bao' => 'CRM_ACL_BAO_ACL',
283 'localizable' => 0,
284 'add' => '1.6',
285 ],
286 'acl_id' => [
287 'name' => 'acl_id',
288 'type' => CRM_Utils_Type::T_INT,
289 'title' => ts('ACL Group ID'),
290 'description' => ts('ID of the ACL or ACL group being granted/revoked'),
291 'where' => 'civicrm_acl.acl_id',
292 'table_name' => 'civicrm_acl',
293 'entity' => 'ACL',
294 'bao' => 'CRM_ACL_BAO_ACL',
295 'localizable' => 0,
296 'add' => '1.6',
297 ],
298 'is_active' => [
299 'name' => 'is_active',
300 'type' => CRM_Utils_Type::T_BOOLEAN,
301 'title' => ts('ACL Is Active?'),
302 'description' => ts('Is this property active?'),
303 'where' => 'civicrm_acl.is_active',
304 'table_name' => 'civicrm_acl',
305 'entity' => 'ACL',
306 'bao' => 'CRM_ACL_BAO_ACL',
307 'localizable' => 0,
308 'html' => [
309 'type' => 'CheckBox',
310 ],
311 'add' => '1.6',
312 ],
313 ];
314 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
315 }
316 return Civi::$statics[__CLASS__]['fields'];
317 }
318
319 /**
320 * Return a mapping from field-name to the corresponding key (as used in fields()).
321 *
322 * @return array
323 * Array(string $name => string $uniqueName).
324 */
325 public static function &fieldKeys() {
326 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
327 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
328 }
329 return Civi::$statics[__CLASS__]['fieldKeys'];
330 }
331
332 /**
333 * Returns the names of this table
334 *
335 * @return string
336 */
337 public static function getTableName() {
338 return self::$_tableName;
339 }
340
341 /**
342 * Returns if this table needs to be logged
343 *
344 * @return bool
345 */
346 public function getLog() {
347 return self::$_log;
348 }
349
350 /**
351 * Returns the list of fields that can be imported
352 *
353 * @param bool $prefix
354 *
355 * @return array
356 */
357 public static function &import($prefix = FALSE) {
358 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'acl', $prefix, []);
359 return $r;
360 }
361
362 /**
363 * Returns the list of fields that can be exported
364 *
365 * @param bool $prefix
366 *
367 * @return array
368 */
369 public static function &export($prefix = FALSE) {
370 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'acl', $prefix, []);
371 return $r;
372 }
373
374 /**
375 * Returns the list of indices
376 *
377 * @param bool $localize
378 *
379 * @return array
380 */
381 public static function indices($localize = TRUE) {
382 $indices = [
383 'index_acl_id' => [
384 'name' => 'index_acl_id',
385 'field' => [
386 0 => 'acl_id',
387 ],
388 'localizable' => FALSE,
389 'sig' => 'civicrm_acl::0::acl_id',
390 ],
391 ];
392 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
393 }
394
395 }