Commit | Line | Data |
---|---|---|
e501603b TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.7 | | |
5 | +--------------------------------------------------------------------+ | |
0f03f337 | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
e501603b TO |
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 | * @package CRM | |
0f03f337 | 29 | * @copyright CiviCRM LLC (c) 2004-2017 |
e501603b TO |
30 | * |
31 | * Generated from xml/schema/CRM/Contact/Group.xml | |
32 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
2a5c9b4d | 33 | * (GenCodeChecksum:848664fcd390bd178325b0d991c8e947) |
e501603b TO |
34 | */ |
35 | require_once 'CRM/Core/DAO.php'; | |
36 | require_once 'CRM/Utils/Type.php'; | |
f41f0342 | 37 | /** |
38 | * CRM_Contact_DAO_Group constructor. | |
39 | */ | |
e501603b TO |
40 | class CRM_Contact_DAO_Group extends CRM_Core_DAO { |
41 | /** | |
f41f0342 | 42 | * Static instance to hold the table name. |
e501603b TO |
43 | * |
44 | * @var string | |
45 | */ | |
46 | static $_tableName = 'civicrm_group'; | |
e501603b | 47 | /** |
f41f0342 | 48 | * Should CiviCRM log any modifications to this table in the civicrm_log table. |
e501603b TO |
49 | * |
50 | * @var boolean | |
51 | */ | |
52 | static $_log = true; | |
53 | /** | |
54 | * Group ID | |
55 | * | |
56 | * @var int unsigned | |
57 | */ | |
58 | public $id; | |
59 | /** | |
60 | * Internal name of Group. | |
61 | * | |
62 | * @var string | |
63 | */ | |
64 | public $name; | |
65 | /** | |
66 | * Name of Group. | |
67 | * | |
68 | * @var string | |
69 | */ | |
70 | public $title; | |
71 | /** | |
72 | * Optional verbose description of the group. | |
73 | * | |
74 | * @var text | |
75 | */ | |
76 | public $description; | |
77 | /** | |
78 | * Module or process which created this group. | |
79 | * | |
80 | * @var string | |
81 | */ | |
82 | public $source; | |
83 | /** | |
84 | * FK to saved search table. | |
85 | * | |
86 | * @var int unsigned | |
87 | */ | |
88 | public $saved_search_id; | |
89 | /** | |
90 | * Is this entry active? | |
91 | * | |
92 | * @var boolean | |
93 | */ | |
94 | public $is_active; | |
95 | /** | |
96 | * In what context(s) is this field visible. | |
97 | * | |
98 | * @var string | |
99 | */ | |
100 | public $visibility; | |
101 | /** | |
102 | * the sql where clause if a saved search acl | |
103 | * | |
104 | * @var text | |
105 | */ | |
106 | public $where_clause; | |
107 | /** | |
108 | * the tables to be included in a select data | |
109 | * | |
110 | * @var text | |
111 | */ | |
112 | public $select_tables; | |
113 | /** | |
114 | * the tables to be included in the count statement | |
115 | * | |
116 | * @var text | |
117 | */ | |
118 | public $where_tables; | |
119 | /** | |
120 | * FK to group type | |
121 | * | |
122 | * @var string | |
123 | */ | |
124 | public $group_type; | |
125 | /** | |
126 | * Date when we created the cache for a smart group | |
127 | * | |
128 | * @var timestamp | |
129 | */ | |
130 | public $cache_date; | |
131 | /** | |
132 | * Date and time when we need to refresh the cache next. | |
133 | * | |
134 | * @var timestamp | |
135 | */ | |
136 | public $refresh_date; | |
137 | /** | |
138 | * IDs of the parent(s) | |
139 | * | |
140 | * @var text | |
141 | */ | |
142 | public $parents; | |
143 | /** | |
144 | * IDs of the child(ren) | |
145 | * | |
146 | * @var text | |
147 | */ | |
148 | public $children; | |
149 | /** | |
150 | * Is this group hidden? | |
151 | * | |
152 | * @var boolean | |
153 | */ | |
154 | public $is_hidden; | |
155 | /** | |
156 | * | |
157 | * @var boolean | |
158 | */ | |
159 | public $is_reserved; | |
160 | /** | |
161 | * FK to contact table. | |
162 | * | |
163 | * @var int unsigned | |
164 | */ | |
165 | public $created_id; | |
166 | /** | |
167 | * FK to contact table. | |
168 | * | |
169 | * @var int unsigned | |
170 | */ | |
171 | public $modified_id; | |
172 | /** | |
f41f0342 | 173 | * Class constructor. |
e501603b TO |
174 | */ |
175 | function __construct() { | |
176 | $this->__table = 'civicrm_group'; | |
177 | parent::__construct(); | |
178 | } | |
179 | /** | |
f41f0342 | 180 | * Returns foreign keys and entity references. |
e501603b TO |
181 | * |
182 | * @return array | |
183 | * [CRM_Core_Reference_Interface] | |
184 | */ | |
185 | static function getReferenceColumns() { | |
346aaaba TO |
186 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
187 | Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); | |
188 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'saved_search_id', 'civicrm_saved_search', 'id'); | |
189 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'created_id', 'civicrm_contact', 'id'); | |
190 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'modified_id', 'civicrm_contact', 'id'); | |
191 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); | |
e501603b | 192 | } |
346aaaba | 193 | return Civi::$statics[__CLASS__]['links']; |
e501603b TO |
194 | } |
195 | /** | |
196 | * Returns all the column names of this table | |
197 | * | |
198 | * @return array | |
199 | */ | |
200 | static function &fields() { | |
346aaaba TO |
201 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
202 | Civi::$statics[__CLASS__]['fields'] = array( | |
e501603b TO |
203 | 'id' => array( |
204 | 'name' => 'id', | |
205 | 'type' => CRM_Utils_Type::T_INT, | |
206 | 'title' => ts('Group ID') , | |
207 | 'description' => 'Group ID', | |
208 | 'required' => true, | |
522a26c9 | 209 | 'table_name' => 'civicrm_group', |
210 | 'entity' => 'Group', | |
211 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 212 | 'localizable' => 0, |
e501603b TO |
213 | ) , |
214 | 'name' => array( | |
215 | 'name' => 'name', | |
216 | 'type' => CRM_Utils_Type::T_STRING, | |
217 | 'title' => ts('Group Name') , | |
218 | 'description' => 'Internal name of Group.', | |
219 | 'maxlength' => 64, | |
220 | 'size' => CRM_Utils_Type::BIG, | |
522a26c9 | 221 | 'table_name' => 'civicrm_group', |
222 | 'entity' => 'Group', | |
223 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 224 | 'localizable' => 0, |
e501603b TO |
225 | ) , |
226 | 'title' => array( | |
227 | 'name' => 'title', | |
228 | 'type' => CRM_Utils_Type::T_STRING, | |
229 | 'title' => ts('Group Title') , | |
230 | 'description' => 'Name of Group.', | |
231 | 'maxlength' => 64, | |
232 | 'size' => CRM_Utils_Type::BIG, | |
522a26c9 | 233 | 'table_name' => 'civicrm_group', |
234 | 'entity' => 'Group', | |
235 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 236 | 'localizable' => 1, |
e501603b TO |
237 | ) , |
238 | 'description' => array( | |
239 | 'name' => 'description', | |
240 | 'type' => CRM_Utils_Type::T_TEXT, | |
241 | 'title' => ts('Group Description') , | |
242 | 'description' => 'Optional verbose description of the group.', | |
243 | 'rows' => 2, | |
244 | 'cols' => 60, | |
522a26c9 | 245 | 'table_name' => 'civicrm_group', |
246 | 'entity' => 'Group', | |
247 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 248 | 'localizable' => 0, |
e501603b TO |
249 | 'html' => array( |
250 | 'type' => 'TextArea', | |
251 | ) , | |
252 | ) , | |
253 | 'source' => array( | |
254 | 'name' => 'source', | |
255 | 'type' => CRM_Utils_Type::T_STRING, | |
256 | 'title' => ts('Group Source') , | |
257 | 'description' => 'Module or process which created this group.', | |
258 | 'maxlength' => 64, | |
259 | 'size' => CRM_Utils_Type::BIG, | |
522a26c9 | 260 | 'table_name' => 'civicrm_group', |
261 | 'entity' => 'Group', | |
262 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 263 | 'localizable' => 0, |
e501603b TO |
264 | ) , |
265 | 'saved_search_id' => array( | |
266 | 'name' => 'saved_search_id', | |
267 | 'type' => CRM_Utils_Type::T_INT, | |
268 | 'title' => ts('Saved Search ID') , | |
269 | 'description' => 'FK to saved search table.', | |
522a26c9 | 270 | 'table_name' => 'civicrm_group', |
271 | 'entity' => 'Group', | |
272 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 273 | 'localizable' => 0, |
e501603b TO |
274 | 'FKClassName' => 'CRM_Contact_DAO_SavedSearch', |
275 | ) , | |
276 | 'is_active' => array( | |
277 | 'name' => 'is_active', | |
278 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
279 | 'title' => ts('Group Enabled') , | |
280 | 'description' => 'Is this entry active?', | |
522a26c9 | 281 | 'table_name' => 'civicrm_group', |
282 | 'entity' => 'Group', | |
283 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 284 | 'localizable' => 0, |
e501603b TO |
285 | ) , |
286 | 'visibility' => array( | |
287 | 'name' => 'visibility', | |
288 | 'type' => CRM_Utils_Type::T_STRING, | |
289 | 'title' => ts('Group Visibility Setting') , | |
290 | 'description' => 'In what context(s) is this field visible.', | |
291 | 'maxlength' => 24, | |
292 | 'size' => CRM_Utils_Type::MEDIUM, | |
293 | 'default' => 'User and User Admin Only', | |
522a26c9 | 294 | 'table_name' => 'civicrm_group', |
295 | 'entity' => 'Group', | |
296 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 297 | 'localizable' => 0, |
e501603b TO |
298 | 'html' => array( |
299 | 'type' => 'Select', | |
300 | ) , | |
301 | 'pseudoconstant' => array( | |
302 | 'callback' => 'CRM_Core_SelectValues::groupVisibility', | |
303 | ) | |
304 | ) , | |
305 | 'where_clause' => array( | |
306 | 'name' => 'where_clause', | |
307 | 'type' => CRM_Utils_Type::T_TEXT, | |
308 | 'title' => ts('Group Where Clause') , | |
309 | 'description' => 'the sql where clause if a saved search acl', | |
522a26c9 | 310 | 'table_name' => 'civicrm_group', |
311 | 'entity' => 'Group', | |
312 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 313 | 'localizable' => 0, |
e501603b TO |
314 | ) , |
315 | 'select_tables' => array( | |
316 | 'name' => 'select_tables', | |
317 | 'type' => CRM_Utils_Type::T_TEXT, | |
318 | 'title' => ts('Tables For Select Clause') , | |
319 | 'description' => 'the tables to be included in a select data', | |
522a26c9 | 320 | 'table_name' => 'civicrm_group', |
321 | 'entity' => 'Group', | |
322 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 323 | 'localizable' => 0, |
2a5c9b4d | 324 | 'serialize' => self::SERIALIZE_PHP, |
e501603b TO |
325 | ) , |
326 | 'where_tables' => array( | |
327 | 'name' => 'where_tables', | |
328 | 'type' => CRM_Utils_Type::T_TEXT, | |
329 | 'title' => ts('Tables For Where Clause') , | |
330 | 'description' => 'the tables to be included in the count statement', | |
522a26c9 | 331 | 'table_name' => 'civicrm_group', |
332 | 'entity' => 'Group', | |
333 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 334 | 'localizable' => 0, |
2a5c9b4d | 335 | 'serialize' => self::SERIALIZE_PHP, |
e501603b TO |
336 | ) , |
337 | 'group_type' => array( | |
338 | 'name' => 'group_type', | |
339 | 'type' => CRM_Utils_Type::T_STRING, | |
340 | 'title' => ts('Group Type') , | |
341 | 'description' => 'FK to group type', | |
342 | 'maxlength' => 128, | |
343 | 'size' => CRM_Utils_Type::HUGE, | |
522a26c9 | 344 | 'table_name' => 'civicrm_group', |
345 | 'entity' => 'Group', | |
346 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 347 | 'localizable' => 0, |
2a5c9b4d | 348 | 'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND, |
e501603b TO |
349 | 'pseudoconstant' => array( |
350 | 'optionGroupName' => 'group_type', | |
351 | 'optionEditPath' => 'civicrm/admin/options/group_type', | |
352 | ) | |
353 | ) , | |
354 | 'cache_date' => array( | |
355 | 'name' => 'cache_date', | |
356 | 'type' => CRM_Utils_Type::T_TIMESTAMP, | |
357 | 'title' => ts('Group Cache Date') , | |
358 | 'description' => 'Date when we created the cache for a smart group', | |
359 | 'required' => false, | |
522a26c9 | 360 | 'table_name' => 'civicrm_group', |
361 | 'entity' => 'Group', | |
362 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 363 | 'localizable' => 0, |
e501603b TO |
364 | ) , |
365 | 'refresh_date' => array( | |
366 | 'name' => 'refresh_date', | |
367 | 'type' => CRM_Utils_Type::T_TIMESTAMP, | |
368 | 'title' => ts('Next Group Refresh Time') , | |
369 | 'description' => 'Date and time when we need to refresh the cache next.', | |
370 | 'required' => false, | |
522a26c9 | 371 | 'table_name' => 'civicrm_group', |
372 | 'entity' => 'Group', | |
373 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 374 | 'localizable' => 0, |
e501603b TO |
375 | ) , |
376 | 'parents' => array( | |
377 | 'name' => 'parents', | |
378 | 'type' => CRM_Utils_Type::T_TEXT, | |
379 | 'title' => ts('Group Parents') , | |
380 | 'description' => 'IDs of the parent(s)', | |
522a26c9 | 381 | 'table_name' => 'civicrm_group', |
382 | 'entity' => 'Group', | |
383 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 384 | 'localizable' => 0, |
e501603b TO |
385 | ) , |
386 | 'children' => array( | |
387 | 'name' => 'children', | |
388 | 'type' => CRM_Utils_Type::T_TEXT, | |
389 | 'title' => ts('Group Children') , | |
390 | 'description' => 'IDs of the child(ren)', | |
522a26c9 | 391 | 'table_name' => 'civicrm_group', |
392 | 'entity' => 'Group', | |
393 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 394 | 'localizable' => 0, |
e501603b TO |
395 | ) , |
396 | 'is_hidden' => array( | |
397 | 'name' => 'is_hidden', | |
398 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
399 | 'title' => ts('Group is Hidden') , | |
400 | 'description' => 'Is this group hidden?', | |
522a26c9 | 401 | 'table_name' => 'civicrm_group', |
402 | 'entity' => 'Group', | |
403 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 404 | 'localizable' => 0, |
e501603b TO |
405 | ) , |
406 | 'is_reserved' => array( | |
407 | 'name' => 'is_reserved', | |
408 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
409 | 'title' => ts('Group is Reserved') , | |
522a26c9 | 410 | 'table_name' => 'civicrm_group', |
411 | 'entity' => 'Group', | |
412 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 413 | 'localizable' => 0, |
e501603b TO |
414 | ) , |
415 | 'created_id' => array( | |
416 | 'name' => 'created_id', | |
417 | 'type' => CRM_Utils_Type::T_INT, | |
418 | 'title' => ts('Group Created By') , | |
419 | 'description' => 'FK to contact table.', | |
522a26c9 | 420 | 'table_name' => 'civicrm_group', |
421 | 'entity' => 'Group', | |
422 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 423 | 'localizable' => 0, |
e501603b TO |
424 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
425 | ) , | |
426 | 'modified_id' => array( | |
427 | 'name' => 'modified_id', | |
428 | 'type' => CRM_Utils_Type::T_INT, | |
429 | 'title' => ts('Group Modified By') , | |
430 | 'description' => 'FK to contact table.', | |
522a26c9 | 431 | 'table_name' => 'civicrm_group', |
432 | 'entity' => 'Group', | |
433 | 'bao' => 'CRM_Contact_BAO_Group', | |
6a7e5e5d | 434 | 'localizable' => 0, |
e501603b TO |
435 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
436 | ) , | |
437 | ); | |
346aaaba | 438 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 439 | } |
346aaaba | 440 | return Civi::$statics[__CLASS__]['fields']; |
e501603b TO |
441 | } |
442 | /** | |
bd8e0b14 | 443 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
444 | * |
445 | * @return array | |
bd8e0b14 | 446 | * Array(string $name => string $uniqueName). |
e501603b TO |
447 | */ |
448 | static function &fieldKeys() { | |
bd8e0b14 TO |
449 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
450 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 451 | } |
bd8e0b14 | 452 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b TO |
453 | } |
454 | /** | |
455 | * Returns the names of this table | |
456 | * | |
457 | * @return string | |
458 | */ | |
459 | static function getTableName() { | |
460 | return CRM_Core_DAO::getLocaleTableName(self::$_tableName); | |
461 | } | |
462 | /** | |
463 | * Returns if this table needs to be logged | |
464 | * | |
465 | * @return boolean | |
466 | */ | |
467 | function getLog() { | |
468 | return self::$_log; | |
469 | } | |
470 | /** | |
471 | * Returns the list of fields that can be imported | |
472 | * | |
473 | * @param bool $prefix | |
474 | * | |
475 | * @return array | |
476 | */ | |
477 | static function &import($prefix = false) { | |
60808919 TO |
478 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group', $prefix, array()); |
479 | return $r; | |
e501603b TO |
480 | } |
481 | /** | |
482 | * Returns the list of fields that can be exported | |
483 | * | |
484 | * @param bool $prefix | |
485 | * | |
486 | * @return array | |
487 | */ | |
488 | static function &export($prefix = false) { | |
60808919 TO |
489 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group', $prefix, array()); |
490 | return $r; | |
e501603b | 491 | } |
e7a6b91a AS |
492 | /** |
493 | * Returns the list of indices | |
494 | */ | |
495 | public static function indices($localize = TRUE) { | |
496 | $indices = array( | |
497 | 'index_group_type' => array( | |
498 | 'name' => 'index_group_type', | |
499 | 'field' => array( | |
500 | 0 => 'group_type', | |
501 | ) , | |
502 | 'localizable' => false, | |
503 | 'sig' => 'civicrm_group::0::group_type', | |
504 | ) , | |
505 | 'UI_title' => array( | |
506 | 'name' => 'UI_title', | |
507 | 'field' => array( | |
508 | 0 => 'title', | |
509 | ) , | |
510 | 'localizable' => true, | |
511 | 'unique' => true, | |
512 | 'sig' => 'civicrm_group::1::title', | |
513 | ) , | |
514 | 'UI_name' => array( | |
515 | 'name' => 'UI_name', | |
516 | 'field' => array( | |
517 | 0 => 'name', | |
518 | ) , | |
519 | 'localizable' => false, | |
520 | 'unique' => true, | |
521 | 'sig' => 'civicrm_group::1::name', | |
522 | ) , | |
523 | ); | |
524 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; | |
525 | } | |
e501603b | 526 | } |