Merge pull request #10549 from jitendrapurohit/CRM-20761
[civicrm-core.git] / CRM / Core / DAO / CustomGroup.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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
29 * @copyright CiviCRM LLC (c) 2004-2017
30 *
31 * Generated from xml/schema/CRM/Core/CustomGroup.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:5b2dac3266e0184dc4eaa6de10c9d401)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Core_DAO_CustomGroup constructor.
39 */
40 class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_custom_group';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 * Unique Custom Group ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * Variable name/programmatic handle for this group.
61 *
62 * @var string
63 */
64 public $name;
65 /**
66 * Friendly Name.
67 *
68 * @var string
69 */
70 public $title;
71 /**
72 * Type of object this group extends (can add other options later e.g. contact_address, etc.).
73 *
74 * @var string
75 */
76 public $extends;
77 /**
78 * FK to civicrm_option_value.id (for option group custom_data_type.)
79 *
80 * @var int unsigned
81 */
82 public $extends_entity_column_id;
83 /**
84 * linking custom group for dynamic object
85 *
86 * @var string
87 */
88 public $extends_entity_column_value;
89 /**
90 * Visual relationship between this form and its parent.
91 *
92 * @var string
93 */
94 public $style;
95 /**
96 * Will this group be in collapsed or expanded mode on initial display ?
97 *
98 * @var int unsigned
99 */
100 public $collapse_display;
101 /**
102 * Description and/or help text to display before fields in form.
103 *
104 * @var text
105 */
106 public $help_pre;
107 /**
108 * Description and/or help text to display after fields in form.
109 *
110 * @var text
111 */
112 public $help_post;
113 /**
114 * Controls display order when multiple extended property groups are setup for the same class.
115 *
116 * @var int
117 */
118 public $weight;
119 /**
120 * Is this property active?
121 *
122 * @var boolean
123 */
124 public $is_active;
125 /**
126 * Name of the table that holds the values for this group.
127 *
128 * @var string
129 */
130 public $table_name;
131 /**
132 * Does this group hold multiple values?
133 *
134 * @var boolean
135 */
136 public $is_multiple;
137 /**
138 * minimum number of multiple records (typically 0?)
139 *
140 * @var int unsigned
141 */
142 public $min_multiple;
143 /**
144 * maximum number of multiple records, if 0 - no max
145 *
146 * @var int unsigned
147 */
148 public $max_multiple;
149 /**
150 * Will this group be in collapsed or expanded mode on advanced search display ?
151 *
152 * @var int unsigned
153 */
154 public $collapse_adv_display;
155 /**
156 * FK to civicrm_contact, who created this custom group
157 *
158 * @var int unsigned
159 */
160 public $created_id;
161 /**
162 * Date and time this custom group was created.
163 *
164 * @var datetime
165 */
166 public $created_date;
167 /**
168 * Is this a reserved Custom Group?
169 *
170 * @var boolean
171 */
172 public $is_reserved;
173 /**
174 * Is this property public?
175 *
176 * @var boolean
177 */
178 public $is_public;
179 /**
180 * Class constructor.
181 */
182 function __construct() {
183 $this->__table = 'civicrm_custom_group';
184 parent::__construct();
185 }
186 /**
187 * Returns foreign keys and entity references.
188 *
189 * @return array
190 * [CRM_Core_Reference_Interface]
191 */
192 static function getReferenceColumns() {
193 if (!isset(Civi::$statics[__CLASS__]['links'])) {
194 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
195 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'created_id', 'civicrm_contact', 'id');
196 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
197 }
198 return Civi::$statics[__CLASS__]['links'];
199 }
200 /**
201 * Returns all the column names of this table
202 *
203 * @return array
204 */
205 static function &fields() {
206 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
207 Civi::$statics[__CLASS__]['fields'] = array(
208 'id' => array(
209 'name' => 'id',
210 'type' => CRM_Utils_Type::T_INT,
211 'title' => ts('Custom Group ID') ,
212 'description' => 'Unique Custom Group ID',
213 'required' => true,
214 'table_name' => 'civicrm_custom_group',
215 'entity' => 'CustomGroup',
216 'bao' => 'CRM_Core_BAO_CustomGroup',
217 'localizable' => 0,
218 ) ,
219 'name' => array(
220 'name' => 'name',
221 'type' => CRM_Utils_Type::T_STRING,
222 'title' => ts('Custom Group Name') ,
223 'description' => 'Variable name/programmatic handle for this group.',
224 'maxlength' => 64,
225 'size' => CRM_Utils_Type::BIG,
226 'table_name' => 'civicrm_custom_group',
227 'entity' => 'CustomGroup',
228 'bao' => 'CRM_Core_BAO_CustomGroup',
229 'localizable' => 0,
230 ) ,
231 'title' => array(
232 'name' => 'title',
233 'type' => CRM_Utils_Type::T_STRING,
234 'title' => ts('Custom Group Title') ,
235 'description' => 'Friendly Name.',
236 'required' => true,
237 'maxlength' => 64,
238 'size' => CRM_Utils_Type::BIG,
239 'table_name' => 'civicrm_custom_group',
240 'entity' => 'CustomGroup',
241 'bao' => 'CRM_Core_BAO_CustomGroup',
242 'localizable' => 1,
243 ) ,
244 'extends' => array(
245 'name' => 'extends',
246 'type' => CRM_Utils_Type::T_STRING,
247 'title' => ts('Custom Group Extends') ,
248 'description' => 'Type of object this group extends (can add other options later e.g. contact_address, etc.).',
249 'maxlength' => 255,
250 'size' => CRM_Utils_Type::HUGE,
251 'default' => 'Contact',
252 'table_name' => 'civicrm_custom_group',
253 'entity' => 'CustomGroup',
254 'bao' => 'CRM_Core_BAO_CustomGroup',
255 'localizable' => 0,
256 ) ,
257 'extends_entity_column_id' => array(
258 'name' => 'extends_entity_column_id',
259 'type' => CRM_Utils_Type::T_INT,
260 'title' => ts('Custom Group Subtype List') ,
261 'description' => 'FK to civicrm_option_value.id (for option group custom_data_type.)',
262 'default' => 'NULL',
263 'table_name' => 'civicrm_custom_group',
264 'entity' => 'CustomGroup',
265 'bao' => 'CRM_Core_BAO_CustomGroup',
266 'localizable' => 0,
267 ) ,
268 'extends_entity_column_value' => array(
269 'name' => 'extends_entity_column_value',
270 'type' => CRM_Utils_Type::T_STRING,
271 'title' => ts('Custom Group Subtype') ,
272 'description' => 'linking custom group for dynamic object',
273 'maxlength' => 255,
274 'size' => CRM_Utils_Type::HUGE,
275 'table_name' => 'civicrm_custom_group',
276 'entity' => 'CustomGroup',
277 'bao' => 'CRM_Core_BAO_CustomGroup',
278 'localizable' => 0,
279 ) ,
280 'style' => array(
281 'name' => 'style',
282 'type' => CRM_Utils_Type::T_STRING,
283 'title' => ts('Custom Group Style') ,
284 'description' => 'Visual relationship between this form and its parent.',
285 'maxlength' => 15,
286 'size' => CRM_Utils_Type::TWELVE,
287 'table_name' => 'civicrm_custom_group',
288 'entity' => 'CustomGroup',
289 'bao' => 'CRM_Core_BAO_CustomGroup',
290 'localizable' => 0,
291 'html' => array(
292 'type' => 'Select',
293 ) ,
294 'pseudoconstant' => array(
295 'callback' => 'CRM_Core_SelectValues::customGroupStyle',
296 )
297 ) ,
298 'collapse_display' => array(
299 'name' => 'collapse_display',
300 'type' => CRM_Utils_Type::T_INT,
301 'title' => ts('Collapse Custom Group?') ,
302 'description' => 'Will this group be in collapsed or expanded mode on initial display ?',
303 'table_name' => 'civicrm_custom_group',
304 'entity' => 'CustomGroup',
305 'bao' => 'CRM_Core_BAO_CustomGroup',
306 'localizable' => 0,
307 ) ,
308 'help_pre' => array(
309 'name' => 'help_pre',
310 'type' => CRM_Utils_Type::T_TEXT,
311 'title' => ts('Custom Group Pre Text') ,
312 'description' => 'Description and/or help text to display before fields in form.',
313 'rows' => 4,
314 'cols' => 80,
315 'table_name' => 'civicrm_custom_group',
316 'entity' => 'CustomGroup',
317 'bao' => 'CRM_Core_BAO_CustomGroup',
318 'localizable' => 1,
319 'html' => array(
320 'type' => 'TextArea',
321 ) ,
322 ) ,
323 'help_post' => array(
324 'name' => 'help_post',
325 'type' => CRM_Utils_Type::T_TEXT,
326 'title' => ts('Custom Group Post Text') ,
327 'description' => 'Description and/or help text to display after fields in form.',
328 'rows' => 4,
329 'cols' => 80,
330 'table_name' => 'civicrm_custom_group',
331 'entity' => 'CustomGroup',
332 'bao' => 'CRM_Core_BAO_CustomGroup',
333 'localizable' => 1,
334 'html' => array(
335 'type' => 'TextArea',
336 ) ,
337 ) ,
338 'weight' => array(
339 'name' => 'weight',
340 'type' => CRM_Utils_Type::T_INT,
341 'title' => ts('Order') ,
342 'description' => 'Controls display order when multiple extended property groups are setup for the same class.',
343 'required' => true,
344 'default' => '1',
345 'table_name' => 'civicrm_custom_group',
346 'entity' => 'CustomGroup',
347 'bao' => 'CRM_Core_BAO_CustomGroup',
348 'localizable' => 0,
349 ) ,
350 'is_active' => array(
351 'name' => 'is_active',
352 'type' => CRM_Utils_Type::T_BOOLEAN,
353 'title' => ts('Custom Group Is Active?') ,
354 'description' => 'Is this property active?',
355 'table_name' => 'civicrm_custom_group',
356 'entity' => 'CustomGroup',
357 'bao' => 'CRM_Core_BAO_CustomGroup',
358 'localizable' => 0,
359 ) ,
360 'table_name' => array(
361 'name' => 'table_name',
362 'type' => CRM_Utils_Type::T_STRING,
363 'title' => ts('Table Name') ,
364 'description' => 'Name of the table that holds the values for this group.',
365 'maxlength' => 255,
366 'size' => CRM_Utils_Type::HUGE,
367 'table_name' => 'civicrm_custom_group',
368 'entity' => 'CustomGroup',
369 'bao' => 'CRM_Core_BAO_CustomGroup',
370 'localizable' => 0,
371 ) ,
372 'is_multiple' => array(
373 'name' => 'is_multiple',
374 'type' => CRM_Utils_Type::T_BOOLEAN,
375 'title' => ts('Supports Multiple Records') ,
376 'description' => 'Does this group hold multiple values?',
377 'table_name' => 'civicrm_custom_group',
378 'entity' => 'CustomGroup',
379 'bao' => 'CRM_Core_BAO_CustomGroup',
380 'localizable' => 0,
381 ) ,
382 'min_multiple' => array(
383 'name' => 'min_multiple',
384 'type' => CRM_Utils_Type::T_INT,
385 'title' => ts('Minimum Multiple Records') ,
386 'description' => 'minimum number of multiple records (typically 0?)',
387 'table_name' => 'civicrm_custom_group',
388 'entity' => 'CustomGroup',
389 'bao' => 'CRM_Core_BAO_CustomGroup',
390 'localizable' => 0,
391 ) ,
392 'max_multiple' => array(
393 'name' => 'max_multiple',
394 'type' => CRM_Utils_Type::T_INT,
395 'title' => ts('Maximum Multiple Records') ,
396 'description' => 'maximum number of multiple records, if 0 - no max',
397 'table_name' => 'civicrm_custom_group',
398 'entity' => 'CustomGroup',
399 'bao' => 'CRM_Core_BAO_CustomGroup',
400 'localizable' => 0,
401 ) ,
402 'collapse_adv_display' => array(
403 'name' => 'collapse_adv_display',
404 'type' => CRM_Utils_Type::T_INT,
405 'title' => ts('Collapse Group Display') ,
406 'description' => 'Will this group be in collapsed or expanded mode on advanced search display ?',
407 'table_name' => 'civicrm_custom_group',
408 'entity' => 'CustomGroup',
409 'bao' => 'CRM_Core_BAO_CustomGroup',
410 'localizable' => 0,
411 ) ,
412 'created_id' => array(
413 'name' => 'created_id',
414 'type' => CRM_Utils_Type::T_INT,
415 'title' => ts('Custom Group Created By') ,
416 'description' => 'FK to civicrm_contact, who created this custom group',
417 'table_name' => 'civicrm_custom_group',
418 'entity' => 'CustomGroup',
419 'bao' => 'CRM_Core_BAO_CustomGroup',
420 'localizable' => 0,
421 'FKClassName' => 'CRM_Contact_DAO_Contact',
422 ) ,
423 'created_date' => array(
424 'name' => 'created_date',
425 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
426 'title' => ts('Custom Group Created Date') ,
427 'description' => 'Date and time this custom group was created.',
428 'table_name' => 'civicrm_custom_group',
429 'entity' => 'CustomGroup',
430 'bao' => 'CRM_Core_BAO_CustomGroup',
431 'localizable' => 0,
432 ) ,
433 'is_reserved' => array(
434 'name' => 'is_reserved',
435 'type' => CRM_Utils_Type::T_BOOLEAN,
436 'title' => ts('Reserved Group?') ,
437 'description' => 'Is this a reserved Custom Group?',
438 'table_name' => 'civicrm_custom_group',
439 'entity' => 'CustomGroup',
440 'bao' => 'CRM_Core_BAO_CustomGroup',
441 'localizable' => 0,
442 ) ,
443 'is_public' => array(
444 'name' => 'is_public',
445 'type' => CRM_Utils_Type::T_BOOLEAN,
446 'title' => ts('Custom Group Is Public?') ,
447 'description' => 'Is this property public?',
448 'default' => '1',
449 'table_name' => 'civicrm_custom_group',
450 'entity' => 'CustomGroup',
451 'bao' => 'CRM_Core_BAO_CustomGroup',
452 'localizable' => 0,
453 ) ,
454 );
455 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
456 }
457 return Civi::$statics[__CLASS__]['fields'];
458 }
459 /**
460 * Return a mapping from field-name to the corresponding key (as used in fields()).
461 *
462 * @return array
463 * Array(string $name => string $uniqueName).
464 */
465 static function &fieldKeys() {
466 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
467 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
468 }
469 return Civi::$statics[__CLASS__]['fieldKeys'];
470 }
471 /**
472 * Returns the names of this table
473 *
474 * @return string
475 */
476 static function getTableName() {
477 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
478 }
479 /**
480 * Returns if this table needs to be logged
481 *
482 * @return boolean
483 */
484 function getLog() {
485 return self::$_log;
486 }
487 /**
488 * Returns the list of fields that can be imported
489 *
490 * @param bool $prefix
491 *
492 * @return array
493 */
494 static function &import($prefix = false) {
495 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'custom_group', $prefix, array());
496 return $r;
497 }
498 /**
499 * Returns the list of fields that can be exported
500 *
501 * @param bool $prefix
502 *
503 * @return array
504 */
505 static function &export($prefix = false) {
506 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'custom_group', $prefix, array());
507 return $r;
508 }
509 /**
510 * Returns the list of indices
511 */
512 public static function indices($localize = TRUE) {
513 $indices = array(
514 'UI_title_extends' => array(
515 'name' => 'UI_title_extends',
516 'field' => array(
517 0 => 'title',
518 1 => 'extends',
519 ) ,
520 'localizable' => true,
521 'unique' => true,
522 'sig' => 'civicrm_custom_group::1::title::extends',
523 ) ,
524 'UI_name_extends' => array(
525 'name' => 'UI_name_extends',
526 'field' => array(
527 0 => 'name',
528 1 => 'extends',
529 ) ,
530 'localizable' => false,
531 'unique' => true,
532 'sig' => 'civicrm_custom_group::1::name::extends',
533 ) ,
534 );
535 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
536 }
537 }