CRM-19925 Updated DAO files
[civicrm-core.git] / CRM / Core / DAO / CustomField.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/CustomField.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:9a71ccf425ce3ba8f5ad59f4fdb8ebf8)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Core_DAO_CustomField constructor.
39 */
40 class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_custom_field';
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 Field ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * FK to civicrm_custom_group.
61 *
62 * @var int unsigned
63 */
64 public $custom_group_id;
65 /**
66 * Variable name/programmatic handle for this group.
67 *
68 * @var string
69 */
70 public $name;
71 /**
72 * Text for form field label (also friendly name for administering this custom property).
73 *
74 * @var string
75 */
76 public $label;
77 /**
78 * Controls location of data storage in extended_data table.
79 *
80 * @var string
81 */
82 public $data_type;
83 /**
84 * HTML types plus several built-in extended types.
85 *
86 * @var string
87 */
88 public $html_type;
89 /**
90 * Use form_options.is_default for field_types which use options.
91 *
92 * @var string
93 */
94 public $default_value;
95 /**
96 * Is a value required for this property.
97 *
98 * @var boolean
99 */
100 public $is_required;
101 /**
102 * Is this property searchable.
103 *
104 * @var boolean
105 */
106 public $is_searchable;
107 /**
108 * Is this property range searchable.
109 *
110 * @var boolean
111 */
112 public $is_search_range;
113 /**
114 * Controls field display order within an extended property group.
115 *
116 * @var int
117 */
118 public $weight;
119 /**
120 * Description and/or help text to display before this field.
121 *
122 * @var text
123 */
124 public $help_pre;
125 /**
126 * Description and/or help text to display after this field.
127 *
128 * @var text
129 */
130 public $help_post;
131 /**
132 * Optional format instructions for specific field types, like date types.
133 *
134 * @var string
135 */
136 public $mask;
137 /**
138 * Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes
139 *
140 * @var string
141 */
142 public $attributes;
143 /**
144 * Optional scripting attributes for field.
145 *
146 * @var string
147 */
148 public $javascript;
149 /**
150 * Is this property active?
151 *
152 * @var boolean
153 */
154 public $is_active;
155 /**
156 * Is this property set by PHP Code? A code field is viewable but not editable
157 *
158 * @var boolean
159 */
160 public $is_view;
161 /**
162 * number of options per line for checkbox and radio
163 *
164 * @var int unsigned
165 */
166 public $options_per_line;
167 /**
168 * field length if alphanumeric
169 *
170 * @var int unsigned
171 */
172 public $text_length;
173 /**
174 * Date may be up to start_date_years years prior to the current date.
175 *
176 * @var int
177 */
178 public $start_date_years;
179 /**
180 * Date may be up to end_date_years years after the current date.
181 *
182 * @var int
183 */
184 public $end_date_years;
185 /**
186 * date format for custom date
187 *
188 * @var string
189 */
190 public $date_format;
191 /**
192 * time format for custom date
193 *
194 * @var int unsigned
195 */
196 public $time_format;
197 /**
198 * Number of columns in Note Field
199 *
200 * @var int unsigned
201 */
202 public $note_columns;
203 /**
204 * Number of rows in Note Field
205 *
206 * @var int unsigned
207 */
208 public $note_rows;
209 /**
210 * Name of the column that holds the values for this field.
211 *
212 * @var string
213 */
214 public $column_name;
215 /**
216 * For elements with options, the option group id that is used
217 *
218 * @var int unsigned
219 */
220 public $option_group_id;
221 /**
222 * Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.
223 *
224 * @var string
225 */
226 public $filter;
227 /**
228 * Should the multi-record custom field values be displayed in tab table listing
229 *
230 * @var boolean
231 */
232 public $in_selector;
233 /**
234 * Class constructor.
235 */
236 function __construct() {
237 $this->__table = 'civicrm_custom_field';
238 parent::__construct();
239 }
240 /**
241 * Returns foreign keys and entity references.
242 *
243 * @return array
244 * [CRM_Core_Reference_Interface]
245 */
246 static function getReferenceColumns() {
247 if (!isset(Civi::$statics[__CLASS__]['links'])) {
248 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
249 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'custom_group_id', 'civicrm_custom_group', 'id');
250 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
251 }
252 return Civi::$statics[__CLASS__]['links'];
253 }
254 /**
255 * Returns all the column names of this table
256 *
257 * @return array
258 */
259 static function &fields() {
260 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
261 Civi::$statics[__CLASS__]['fields'] = array(
262 'id' => array(
263 'name' => 'id',
264 'type' => CRM_Utils_Type::T_INT,
265 'title' => ts('Custom Field ID') ,
266 'description' => 'Unique Custom Field ID',
267 'required' => true,
268 'table_name' => 'civicrm_custom_field',
269 'entity' => 'CustomField',
270 'bao' => 'CRM_Core_BAO_CustomField',
271 ) ,
272 'custom_group_id' => array(
273 'name' => 'custom_group_id',
274 'type' => CRM_Utils_Type::T_INT,
275 'title' => ts('Custom Group') ,
276 'description' => 'FK to civicrm_custom_group.',
277 'required' => true,
278 'table_name' => 'civicrm_custom_field',
279 'entity' => 'CustomField',
280 'bao' => 'CRM_Core_BAO_CustomField',
281 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
282 'html' => array(
283 'type' => 'Select',
284 ) ,
285 'pseudoconstant' => array(
286 'table' => 'civicrm_custom_group',
287 'keyColumn' => 'id',
288 'labelColumn' => 'title',
289 )
290 ) ,
291 'name' => array(
292 'name' => 'name',
293 'type' => CRM_Utils_Type::T_STRING,
294 'title' => ts('Custom Field Name') ,
295 'description' => 'Variable name/programmatic handle for this group.',
296 'maxlength' => 64,
297 'size' => CRM_Utils_Type::BIG,
298 'table_name' => 'civicrm_custom_field',
299 'entity' => 'CustomField',
300 'bao' => 'CRM_Core_BAO_CustomField',
301 ) ,
302 'label' => array(
303 'name' => 'label',
304 'type' => CRM_Utils_Type::T_STRING,
305 'title' => ts('Custom Field Label') ,
306 'description' => 'Text for form field label (also friendly name for administering this custom property).',
307 'required' => true,
308 'maxlength' => 255,
309 'size' => CRM_Utils_Type::HUGE,
310 'table_name' => 'civicrm_custom_field',
311 'entity' => 'CustomField',
312 'bao' => 'CRM_Core_BAO_CustomField',
313 ) ,
314 'data_type' => array(
315 'name' => 'data_type',
316 'type' => CRM_Utils_Type::T_STRING,
317 'title' => ts('Custom Field Data Type') ,
318 'description' => 'Controls location of data storage in extended_data table.',
319 'required' => true,
320 'maxlength' => 16,
321 'size' => CRM_Utils_Type::TWELVE,
322 'table_name' => 'civicrm_custom_field',
323 'entity' => 'CustomField',
324 'bao' => 'CRM_Core_BAO_CustomField',
325 'html' => array(
326 'type' => 'Select',
327 ) ,
328 'pseudoconstant' => array(
329 'callback' => 'CRM_Core_BAO_CustomField::dataType',
330 )
331 ) ,
332 'html_type' => array(
333 'name' => 'html_type',
334 'type' => CRM_Utils_Type::T_STRING,
335 'title' => ts('Custom Field HTML Type') ,
336 'description' => 'HTML types plus several built-in extended types.',
337 'required' => true,
338 'maxlength' => 32,
339 'size' => CRM_Utils_Type::MEDIUM,
340 'table_name' => 'civicrm_custom_field',
341 'entity' => 'CustomField',
342 'bao' => 'CRM_Core_BAO_CustomField',
343 'pseudoconstant' => array(
344 'callback' => 'CRM_Core_SelectValues::customHtmlType',
345 )
346 ) ,
347 'default_value' => array(
348 'name' => 'default_value',
349 'type' => CRM_Utils_Type::T_STRING,
350 'title' => ts('Custom Field Default') ,
351 'description' => 'Use form_options.is_default for field_types which use options.',
352 'maxlength' => 255,
353 'size' => CRM_Utils_Type::HUGE,
354 'table_name' => 'civicrm_custom_field',
355 'entity' => 'CustomField',
356 'bao' => 'CRM_Core_BAO_CustomField',
357 ) ,
358 'is_required' => array(
359 'name' => 'is_required',
360 'type' => CRM_Utils_Type::T_BOOLEAN,
361 'title' => ts('Custom Field Is Required?') ,
362 'description' => 'Is a value required for this property.',
363 'table_name' => 'civicrm_custom_field',
364 'entity' => 'CustomField',
365 'bao' => 'CRM_Core_BAO_CustomField',
366 ) ,
367 'is_searchable' => array(
368 'name' => 'is_searchable',
369 'type' => CRM_Utils_Type::T_BOOLEAN,
370 'title' => ts('Allow Searching on Field?') ,
371 'description' => 'Is this property searchable.',
372 'table_name' => 'civicrm_custom_field',
373 'entity' => 'CustomField',
374 'bao' => 'CRM_Core_BAO_CustomField',
375 ) ,
376 'is_search_range' => array(
377 'name' => 'is_search_range',
378 'type' => CRM_Utils_Type::T_BOOLEAN,
379 'title' => ts('Search as a Range') ,
380 'description' => 'Is this property range searchable.',
381 'table_name' => 'civicrm_custom_field',
382 'entity' => 'CustomField',
383 'bao' => 'CRM_Core_BAO_CustomField',
384 ) ,
385 'weight' => array(
386 'name' => 'weight',
387 'type' => CRM_Utils_Type::T_INT,
388 'title' => ts('Order') ,
389 'description' => 'Controls field display order within an extended property group.',
390 'required' => true,
391 'default' => '1',
392 'table_name' => 'civicrm_custom_field',
393 'entity' => 'CustomField',
394 'bao' => 'CRM_Core_BAO_CustomField',
395 ) ,
396 'help_pre' => array(
397 'name' => 'help_pre',
398 'type' => CRM_Utils_Type::T_TEXT,
399 'title' => ts('Custom Field Pre Text') ,
400 'description' => 'Description and/or help text to display before this field.',
401 'table_name' => 'civicrm_custom_field',
402 'entity' => 'CustomField',
403 'bao' => 'CRM_Core_BAO_CustomField',
404 ) ,
405 'help_post' => array(
406 'name' => 'help_post',
407 'type' => CRM_Utils_Type::T_TEXT,
408 'title' => ts('Custom Field Post Text') ,
409 'description' => 'Description and/or help text to display after this field.',
410 'table_name' => 'civicrm_custom_field',
411 'entity' => 'CustomField',
412 'bao' => 'CRM_Core_BAO_CustomField',
413 ) ,
414 'mask' => array(
415 'name' => 'mask',
416 'type' => CRM_Utils_Type::T_STRING,
417 'title' => ts('Custom Field Formatting') ,
418 'description' => 'Optional format instructions for specific field types, like date types.',
419 'maxlength' => 64,
420 'size' => CRM_Utils_Type::BIG,
421 'table_name' => 'civicrm_custom_field',
422 'entity' => 'CustomField',
423 'bao' => 'CRM_Core_BAO_CustomField',
424 ) ,
425 'attributes' => array(
426 'name' => 'attributes',
427 'type' => CRM_Utils_Type::T_STRING,
428 'title' => ts('Custom Field Attributes') ,
429 'description' => 'Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes',
430 'maxlength' => 255,
431 'size' => CRM_Utils_Type::HUGE,
432 'table_name' => 'civicrm_custom_field',
433 'entity' => 'CustomField',
434 'bao' => 'CRM_Core_BAO_CustomField',
435 ) ,
436 'javascript' => array(
437 'name' => 'javascript',
438 'type' => CRM_Utils_Type::T_STRING,
439 'title' => ts('Custom Field Javascript') ,
440 'description' => 'Optional scripting attributes for field.',
441 'maxlength' => 255,
442 'size' => CRM_Utils_Type::HUGE,
443 'table_name' => 'civicrm_custom_field',
444 'entity' => 'CustomField',
445 'bao' => 'CRM_Core_BAO_CustomField',
446 ) ,
447 'is_active' => array(
448 'name' => 'is_active',
449 'type' => CRM_Utils_Type::T_BOOLEAN,
450 'title' => ts('Custom Field Is Active?') ,
451 'description' => 'Is this property active?',
452 'table_name' => 'civicrm_custom_field',
453 'entity' => 'CustomField',
454 'bao' => 'CRM_Core_BAO_CustomField',
455 ) ,
456 'is_view' => array(
457 'name' => 'is_view',
458 'type' => CRM_Utils_Type::T_BOOLEAN,
459 'title' => ts('Field is Viewable') ,
460 'description' => 'Is this property set by PHP Code? A code field is viewable but not editable',
461 'table_name' => 'civicrm_custom_field',
462 'entity' => 'CustomField',
463 'bao' => 'CRM_Core_BAO_CustomField',
464 ) ,
465 'options_per_line' => array(
466 'name' => 'options_per_line',
467 'type' => CRM_Utils_Type::T_INT,
468 'title' => ts('Field Options Per Line') ,
469 'description' => 'number of options per line for checkbox and radio',
470 'table_name' => 'civicrm_custom_field',
471 'entity' => 'CustomField',
472 'bao' => 'CRM_Core_BAO_CustomField',
473 ) ,
474 'text_length' => array(
475 'name' => 'text_length',
476 'type' => CRM_Utils_Type::T_INT,
477 'title' => ts('Field Length') ,
478 'description' => 'field length if alphanumeric',
479 'table_name' => 'civicrm_custom_field',
480 'entity' => 'CustomField',
481 'bao' => 'CRM_Core_BAO_CustomField',
482 ) ,
483 'start_date_years' => array(
484 'name' => 'start_date_years',
485 'type' => CRM_Utils_Type::T_INT,
486 'title' => ts('Field Start Date') ,
487 'description' => 'Date may be up to start_date_years years prior to the current date.',
488 'table_name' => 'civicrm_custom_field',
489 'entity' => 'CustomField',
490 'bao' => 'CRM_Core_BAO_CustomField',
491 ) ,
492 'end_date_years' => array(
493 'name' => 'end_date_years',
494 'type' => CRM_Utils_Type::T_INT,
495 'title' => ts('Field End Date') ,
496 'description' => 'Date may be up to end_date_years years after the current date.',
497 'table_name' => 'civicrm_custom_field',
498 'entity' => 'CustomField',
499 'bao' => 'CRM_Core_BAO_CustomField',
500 ) ,
501 'date_format' => array(
502 'name' => 'date_format',
503 'type' => CRM_Utils_Type::T_STRING,
504 'title' => ts('Field Data Format') ,
505 'description' => 'date format for custom date',
506 'maxlength' => 64,
507 'size' => CRM_Utils_Type::BIG,
508 'table_name' => 'civicrm_custom_field',
509 'entity' => 'CustomField',
510 'bao' => 'CRM_Core_BAO_CustomField',
511 ) ,
512 'time_format' => array(
513 'name' => 'time_format',
514 'type' => CRM_Utils_Type::T_INT,
515 'title' => ts('Field Time Format') ,
516 'description' => 'time format for custom date',
517 'table_name' => 'civicrm_custom_field',
518 'entity' => 'CustomField',
519 'bao' => 'CRM_Core_BAO_CustomField',
520 ) ,
521 'note_columns' => array(
522 'name' => 'note_columns',
523 'type' => CRM_Utils_Type::T_INT,
524 'title' => ts('Field Note Columns') ,
525 'description' => ' Number of columns in Note Field ',
526 'table_name' => 'civicrm_custom_field',
527 'entity' => 'CustomField',
528 'bao' => 'CRM_Core_BAO_CustomField',
529 ) ,
530 'note_rows' => array(
531 'name' => 'note_rows',
532 'type' => CRM_Utils_Type::T_INT,
533 'title' => ts('Field Note Rows') ,
534 'description' => ' Number of rows in Note Field ',
535 'table_name' => 'civicrm_custom_field',
536 'entity' => 'CustomField',
537 'bao' => 'CRM_Core_BAO_CustomField',
538 ) ,
539 'column_name' => array(
540 'name' => 'column_name',
541 'type' => CRM_Utils_Type::T_STRING,
542 'title' => ts('Field Column Name') ,
543 'description' => 'Name of the column that holds the values for this field.',
544 'maxlength' => 255,
545 'size' => CRM_Utils_Type::HUGE,
546 'table_name' => 'civicrm_custom_field',
547 'entity' => 'CustomField',
548 'bao' => 'CRM_Core_BAO_CustomField',
549 ) ,
550 'option_group_id' => array(
551 'name' => 'option_group_id',
552 'type' => CRM_Utils_Type::T_INT,
553 'title' => ts('Field Option Group') ,
554 'description' => 'For elements with options, the option group id that is used',
555 'table_name' => 'civicrm_custom_field',
556 'entity' => 'CustomField',
557 'bao' => 'CRM_Core_BAO_CustomField',
558 ) ,
559 'filter' => array(
560 'name' => 'filter',
561 'type' => CRM_Utils_Type::T_STRING,
562 'title' => ts('Field Filter') ,
563 'description' => 'Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.',
564 'maxlength' => 255,
565 'size' => CRM_Utils_Type::HUGE,
566 'table_name' => 'civicrm_custom_field',
567 'entity' => 'CustomField',
568 'bao' => 'CRM_Core_BAO_CustomField',
569 ) ,
570 'in_selector' => array(
571 'name' => 'in_selector',
572 'type' => CRM_Utils_Type::T_BOOLEAN,
573 'title' => ts('Field Display') ,
574 'description' => 'Should the multi-record custom field values be displayed in tab table listing',
575 'table_name' => 'civicrm_custom_field',
576 'entity' => 'CustomField',
577 'bao' => 'CRM_Core_BAO_CustomField',
578 ) ,
579 );
580 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
581 }
582 return Civi::$statics[__CLASS__]['fields'];
583 }
584 /**
585 * Return a mapping from field-name to the corresponding key (as used in fields()).
586 *
587 * @return array
588 * Array(string $name => string $uniqueName).
589 */
590 static function &fieldKeys() {
591 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
592 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
593 }
594 return Civi::$statics[__CLASS__]['fieldKeys'];
595 }
596 /**
597 * Returns the names of this table
598 *
599 * @return string
600 */
601 static function getTableName() {
602 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
603 }
604 /**
605 * Returns if this table needs to be logged
606 *
607 * @return boolean
608 */
609 function getLog() {
610 return self::$_log;
611 }
612 /**
613 * Returns the list of fields that can be imported
614 *
615 * @param bool $prefix
616 *
617 * @return array
618 */
619 static function &import($prefix = false) {
620 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'custom_field', $prefix, array());
621 return $r;
622 }
623 /**
624 * Returns the list of fields that can be exported
625 *
626 * @param bool $prefix
627 *
628 * @return array
629 */
630 static function &export($prefix = false) {
631 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'custom_field', $prefix, array());
632 return $r;
633 }
634 }