Commit | Line | Data |
---|---|---|
e501603b TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.7 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2016 | | |
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-2016 | |
30 | * | |
31 | * Generated from xml/schema/CRM/Core/CustomField.xml | |
32 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
437fafcf | 33 | * (GenCodeChecksum:dc13acb1a31d4ed4837ebb0a167da9e9) |
e501603b TO |
34 | */ |
35 | require_once 'CRM/Core/DAO.php'; | |
36 | require_once 'CRM/Utils/Type.php'; | |
37 | class CRM_Core_DAO_CustomField extends CRM_Core_DAO { | |
38 | /** | |
39 | * static instance to hold the table name | |
40 | * | |
41 | * @var string | |
42 | */ | |
43 | static $_tableName = 'civicrm_custom_field'; | |
e501603b TO |
44 | /** |
45 | * static value to see if we should log any modifications to | |
46 | * this table in the civicrm_log table | |
47 | * | |
48 | * @var boolean | |
49 | */ | |
50 | static $_log = true; | |
51 | /** | |
52 | * Unique Custom Field ID | |
53 | * | |
54 | * @var int unsigned | |
55 | */ | |
56 | public $id; | |
57 | /** | |
58 | * FK to civicrm_custom_group. | |
59 | * | |
60 | * @var int unsigned | |
61 | */ | |
62 | public $custom_group_id; | |
63 | /** | |
64 | * Variable name/programmatic handle for this group. | |
65 | * | |
66 | * @var string | |
67 | */ | |
68 | public $name; | |
69 | /** | |
70 | * Text for form field label (also friendly name for administering this custom property). | |
71 | * | |
72 | * @var string | |
73 | */ | |
74 | public $label; | |
75 | /** | |
76 | * Controls location of data storage in extended_data table. | |
77 | * | |
78 | * @var string | |
79 | */ | |
80 | public $data_type; | |
81 | /** | |
82 | * HTML types plus several built-in extended types. | |
83 | * | |
84 | * @var string | |
85 | */ | |
86 | public $html_type; | |
87 | /** | |
88 | * Use form_options.is_default for field_types which use options. | |
89 | * | |
90 | * @var string | |
91 | */ | |
92 | public $default_value; | |
93 | /** | |
94 | * Is a value required for this property. | |
95 | * | |
96 | * @var boolean | |
97 | */ | |
98 | public $is_required; | |
99 | /** | |
100 | * Is this property searchable. | |
101 | * | |
102 | * @var boolean | |
103 | */ | |
104 | public $is_searchable; | |
105 | /** | |
106 | * Is this property range searchable. | |
107 | * | |
108 | * @var boolean | |
109 | */ | |
110 | public $is_search_range; | |
111 | /** | |
112 | * Controls field display order within an extended property group. | |
113 | * | |
114 | * @var int | |
115 | */ | |
116 | public $weight; | |
117 | /** | |
118 | * Description and/or help text to display before this field. | |
119 | * | |
120 | * @var text | |
121 | */ | |
122 | public $help_pre; | |
123 | /** | |
124 | * Description and/or help text to display after this field. | |
125 | * | |
126 | * @var text | |
127 | */ | |
128 | public $help_post; | |
129 | /** | |
130 | * Optional format instructions for specific field types, like date types. | |
131 | * | |
132 | * @var string | |
133 | */ | |
134 | public $mask; | |
135 | /** | |
136 | * Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes | |
137 | * | |
138 | * @var string | |
139 | */ | |
140 | public $attributes; | |
141 | /** | |
142 | * Optional scripting attributes for field. | |
143 | * | |
144 | * @var string | |
145 | */ | |
146 | public $javascript; | |
147 | /** | |
148 | * Is this property active? | |
149 | * | |
150 | * @var boolean | |
151 | */ | |
152 | public $is_active; | |
153 | /** | |
154 | * Is this property set by PHP Code? A code field is viewable but not editable | |
155 | * | |
156 | * @var boolean | |
157 | */ | |
158 | public $is_view; | |
159 | /** | |
160 | * number of options per line for checkbox and radio | |
161 | * | |
162 | * @var int unsigned | |
163 | */ | |
164 | public $options_per_line; | |
165 | /** | |
166 | * field length if alphanumeric | |
167 | * | |
168 | * @var int unsigned | |
169 | */ | |
170 | public $text_length; | |
171 | /** | |
172 | * Date may be up to start_date_years years prior to the current date. | |
173 | * | |
174 | * @var int | |
175 | */ | |
176 | public $start_date_years; | |
177 | /** | |
178 | * Date may be up to end_date_years years after the current date. | |
179 | * | |
180 | * @var int | |
181 | */ | |
182 | public $end_date_years; | |
183 | /** | |
184 | * date format for custom date | |
185 | * | |
186 | * @var string | |
187 | */ | |
188 | public $date_format; | |
189 | /** | |
190 | * time format for custom date | |
191 | * | |
192 | * @var int unsigned | |
193 | */ | |
194 | public $time_format; | |
195 | /** | |
196 | * Number of columns in Note Field | |
197 | * | |
198 | * @var int unsigned | |
199 | */ | |
200 | public $note_columns; | |
201 | /** | |
202 | * Number of rows in Note Field | |
203 | * | |
204 | * @var int unsigned | |
205 | */ | |
206 | public $note_rows; | |
207 | /** | |
208 | * Name of the column that holds the values for this field. | |
209 | * | |
210 | * @var string | |
211 | */ | |
212 | public $column_name; | |
213 | /** | |
214 | * For elements with options, the option group id that is used | |
215 | * | |
216 | * @var int unsigned | |
217 | */ | |
218 | public $option_group_id; | |
219 | /** | |
220 | * Stores Contact Get API params contact reference custom fields. May be used for other filters in the future. | |
221 | * | |
222 | * @var string | |
223 | */ | |
224 | public $filter; | |
225 | /** | |
226 | * Should the multi-record custom field values be displayed in tab table listing | |
227 | * | |
228 | * @var boolean | |
229 | */ | |
230 | public $in_selector; | |
231 | /** | |
232 | * class constructor | |
233 | * | |
234 | * @return civicrm_custom_field | |
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() { | |
346aaaba TO |
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']); | |
e501603b | 251 | } |
346aaaba | 252 | return Civi::$statics[__CLASS__]['links']; |
e501603b TO |
253 | } |
254 | /** | |
255 | * Returns all the column names of this table | |
256 | * | |
257 | * @return array | |
258 | */ | |
259 | static function &fields() { | |
346aaaba TO |
260 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
261 | Civi::$statics[__CLASS__]['fields'] = array( | |
e501603b TO |
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 | ); | |
346aaaba | 490 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 491 | } |
346aaaba | 492 | return Civi::$statics[__CLASS__]['fields']; |
e501603b TO |
493 | } |
494 | /** | |
bd8e0b14 | 495 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
496 | * |
497 | * @return array | |
bd8e0b14 | 498 | * Array(string $name => string $uniqueName). |
e501603b TO |
499 | */ |
500 | static function &fieldKeys() { | |
bd8e0b14 TO |
501 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
502 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 503 | } |
bd8e0b14 | 504 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b TO |
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) { | |
60808919 TO |
530 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'custom_field', $prefix, array()); |
531 | return $r; | |
e501603b TO |
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) { | |
60808919 TO |
541 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'custom_field', $prefix, array()); |
542 | return $r; | |
e501603b TO |
543 | } |
544 | } |