Merge pull request #8916 from cividesk/CRM-19256-4.7
[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:dc13acb1a31d4ed4837ebb0a167da9e9)
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 ) ,
269 'custom_group_id' => array(
270 'name' => 'custom_group_id',
271 'type' => CRM_Utils_Type::T_INT,
272 'title' => ts('Custom Group') ,
273 'description' => 'FK to civicrm_custom_group.',
274 'required' => true,
275 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
276 'html' => array(
277 'type' => 'Select',
278 ) ,
279 'pseudoconstant' => array(
280 'table' => 'civicrm_custom_group',
281 'keyColumn' => 'id',
282 'labelColumn' => 'title',
283 )
284 ) ,
285 'name' => array(
286 'name' => 'name',
287 'type' => CRM_Utils_Type::T_STRING,
288 'title' => ts('Custom Field Name') ,
289 'description' => 'Variable name/programmatic handle for this group.',
290 'maxlength' => 64,
291 'size' => CRM_Utils_Type::BIG,
292 ) ,
293 'label' => array(
294 'name' => 'label',
295 'type' => CRM_Utils_Type::T_STRING,
296 'title' => ts('Custom Field Label') ,
297 'description' => 'Text for form field label (also friendly name for administering this custom property).',
298 'required' => true,
299 'maxlength' => 255,
300 'size' => CRM_Utils_Type::HUGE,
301 ) ,
302 'data_type' => array(
303 'name' => 'data_type',
304 'type' => CRM_Utils_Type::T_STRING,
305 'title' => ts('Custom Field Data Type') ,
306 'description' => 'Controls location of data storage in extended_data table.',
307 'required' => true,
308 'maxlength' => 16,
309 'size' => CRM_Utils_Type::TWELVE,
310 'html' => array(
311 'type' => 'Select',
312 ) ,
313 'pseudoconstant' => array(
314 'callback' => 'CRM_Core_BAO_CustomField::dataType',
315 )
316 ) ,
317 'html_type' => array(
318 'name' => 'html_type',
319 'type' => CRM_Utils_Type::T_STRING,
320 'title' => ts('Custom Field HTML Type') ,
321 'description' => 'HTML types plus several built-in extended types.',
322 'required' => true,
323 'maxlength' => 32,
324 'size' => CRM_Utils_Type::MEDIUM,
325 'pseudoconstant' => array(
326 'callback' => 'CRM_Core_SelectValues::customHtmlType',
327 )
328 ) ,
329 'default_value' => array(
330 'name' => 'default_value',
331 'type' => CRM_Utils_Type::T_STRING,
332 'title' => ts('Custom Field Default') ,
333 'description' => 'Use form_options.is_default for field_types which use options.',
334 'maxlength' => 255,
335 'size' => CRM_Utils_Type::HUGE,
336 ) ,
337 'is_required' => array(
338 'name' => 'is_required',
339 'type' => CRM_Utils_Type::T_BOOLEAN,
340 'title' => ts('Custom Field Is Required?') ,
341 'description' => 'Is a value required for this property.',
342 ) ,
343 'is_searchable' => array(
344 'name' => 'is_searchable',
345 'type' => CRM_Utils_Type::T_BOOLEAN,
346 'title' => ts('Allow Searching on Field?') ,
347 'description' => 'Is this property searchable.',
348 ) ,
349 'is_search_range' => array(
350 'name' => 'is_search_range',
351 'type' => CRM_Utils_Type::T_BOOLEAN,
352 'title' => ts('Search as a Range') ,
353 'description' => 'Is this property range searchable.',
354 ) ,
355 'weight' => array(
356 'name' => 'weight',
357 'type' => CRM_Utils_Type::T_INT,
358 'title' => ts('Order') ,
359 'description' => 'Controls field display order within an extended property group.',
360 'required' => true,
361 'default' => '1',
362 ) ,
363 'help_pre' => array(
364 'name' => 'help_pre',
365 'type' => CRM_Utils_Type::T_TEXT,
366 'title' => ts('Custom Field Pre Text') ,
367 'description' => 'Description and/or help text to display before this field.',
368 ) ,
369 'help_post' => array(
370 'name' => 'help_post',
371 'type' => CRM_Utils_Type::T_TEXT,
372 'title' => ts('Custom Field Post Text') ,
373 'description' => 'Description and/or help text to display after this field.',
374 ) ,
375 'mask' => array(
376 'name' => 'mask',
377 'type' => CRM_Utils_Type::T_STRING,
378 'title' => ts('Custom Field Formatting') ,
379 'description' => 'Optional format instructions for specific field types, like date types.',
380 'maxlength' => 64,
381 'size' => CRM_Utils_Type::BIG,
382 ) ,
383 'attributes' => array(
384 'name' => 'attributes',
385 'type' => CRM_Utils_Type::T_STRING,
386 'title' => ts('Custom Field Attributes') ,
387 'description' => 'Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes',
388 'maxlength' => 255,
389 'size' => CRM_Utils_Type::HUGE,
390 ) ,
391 'javascript' => array(
392 'name' => 'javascript',
393 'type' => CRM_Utils_Type::T_STRING,
394 'title' => ts('Custom Field Javascript') ,
395 'description' => 'Optional scripting attributes for field.',
396 'maxlength' => 255,
397 'size' => CRM_Utils_Type::HUGE,
398 ) ,
399 'is_active' => array(
400 'name' => 'is_active',
401 'type' => CRM_Utils_Type::T_BOOLEAN,
402 'title' => ts('Custom Field Is Active?') ,
403 'description' => 'Is this property active?',
404 ) ,
405 'is_view' => array(
406 'name' => 'is_view',
407 'type' => CRM_Utils_Type::T_BOOLEAN,
408 'title' => ts('Field is Viewable') ,
409 'description' => 'Is this property set by PHP Code? A code field is viewable but not editable',
410 ) ,
411 'options_per_line' => array(
412 'name' => 'options_per_line',
413 'type' => CRM_Utils_Type::T_INT,
414 'title' => ts('Field Options Per Line') ,
415 'description' => 'number of options per line for checkbox and radio',
416 ) ,
417 'text_length' => array(
418 'name' => 'text_length',
419 'type' => CRM_Utils_Type::T_INT,
420 'title' => ts('Field Length') ,
421 'description' => 'field length if alphanumeric',
422 ) ,
423 'start_date_years' => array(
424 'name' => 'start_date_years',
425 'type' => CRM_Utils_Type::T_INT,
426 'title' => ts('Field Start Date') ,
427 'description' => 'Date may be up to start_date_years years prior to the current date.',
428 ) ,
429 'end_date_years' => array(
430 'name' => 'end_date_years',
431 'type' => CRM_Utils_Type::T_INT,
432 'title' => ts('Field End Date') ,
433 'description' => 'Date may be up to end_date_years years after the current date.',
434 ) ,
435 'date_format' => array(
436 'name' => 'date_format',
437 'type' => CRM_Utils_Type::T_STRING,
438 'title' => ts('Field Data Format') ,
439 'description' => 'date format for custom date',
440 'maxlength' => 64,
441 'size' => CRM_Utils_Type::BIG,
442 ) ,
443 'time_format' => array(
444 'name' => 'time_format',
445 'type' => CRM_Utils_Type::T_INT,
446 'title' => ts('Field Time Format') ,
447 'description' => 'time format for custom date',
448 ) ,
449 'note_columns' => array(
450 'name' => 'note_columns',
451 'type' => CRM_Utils_Type::T_INT,
452 'title' => ts('Field Note Columns') ,
453 'description' => ' Number of columns in Note Field ',
454 ) ,
455 'note_rows' => array(
456 'name' => 'note_rows',
457 'type' => CRM_Utils_Type::T_INT,
458 'title' => ts('Field Note Rows') ,
459 'description' => ' Number of rows in Note Field ',
460 ) ,
461 'column_name' => array(
462 'name' => 'column_name',
463 'type' => CRM_Utils_Type::T_STRING,
464 'title' => ts('Field Column Name') ,
465 'description' => 'Name of the column that holds the values for this field.',
466 'maxlength' => 255,
467 'size' => CRM_Utils_Type::HUGE,
468 ) ,
469 'option_group_id' => array(
470 'name' => 'option_group_id',
471 'type' => CRM_Utils_Type::T_INT,
472 'title' => ts('Field Option Group') ,
473 'description' => 'For elements with options, the option group id that is used',
474 ) ,
475 'filter' => array(
476 'name' => 'filter',
477 'type' => CRM_Utils_Type::T_STRING,
478 'title' => ts('Field Filter') ,
479 'description' => 'Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.',
480 'maxlength' => 255,
481 'size' => CRM_Utils_Type::HUGE,
482 ) ,
483 'in_selector' => array(
484 'name' => 'in_selector',
485 'type' => CRM_Utils_Type::T_BOOLEAN,
486 'title' => ts('Field Display') ,
487 'description' => 'Should the multi-record custom field values be displayed in tab table listing',
488 ) ,
489 );
490 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
491 }
492 return Civi::$statics[__CLASS__]['fields'];
493 }
494 /**
495 * Return a mapping from field-name to the corresponding key (as used in fields()).
496 *
497 * @return array
498 * Array(string $name => string $uniqueName).
499 */
500 static function &fieldKeys() {
501 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
502 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
503 }
504 return Civi::$statics[__CLASS__]['fieldKeys'];
505 }
506 /**
507 * Returns the names of this table
508 *
509 * @return string
510 */
511 static function getTableName() {
512 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
513 }
514 /**
515 * Returns if this table needs to be logged
516 *
517 * @return boolean
518 */
519 function getLog() {
520 return self::$_log;
521 }
522 /**
523 * Returns the list of fields that can be imported
524 *
525 * @param bool $prefix
526 *
527 * @return array
528 */
529 static function &import($prefix = false) {
530 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'custom_field', $prefix, array());
531 return $r;
532 }
533 /**
534 * Returns the list of fields that can be exported
535 *
536 * @param bool $prefix
537 *
538 * @return array
539 */
540 static function &export($prefix = false) {
541 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'custom_field', $prefix, array());
542 return $r;
543 }
544 }