Merge pull request #23192 from eileenmcnaughton/549
[civicrm-core.git] / CRM / Core / DAO / MappingField.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/MappingField.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:43e4b1c405dfce18840eca9d73aa70e7)
10 */
11
12 /**
13 * Database access object for the MappingField entity.
14 */
15 class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.2';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_mapping_field';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = FALSE;
32
33 /**
34 * Mapping Field ID
35 *
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
39 */
40 public $id;
41
42 /**
43 * Mapping to which this field belongs
44 *
45 * @var int|string
46 * (SQL type: int unsigned)
47 * Note that values will be retrieved from the database as a string.
48 */
49 public $mapping_id;
50
51 /**
52 * Mapping field key
53 *
54 * @var string|null
55 * (SQL type: varchar(255))
56 * Note that values will be retrieved from the database as a string.
57 */
58 public $name;
59
60 /**
61 * Contact Type in mapping
62 *
63 * @var string|null
64 * (SQL type: varchar(64))
65 * Note that values will be retrieved from the database as a string.
66 */
67 public $contact_type;
68
69 /**
70 * Column number for mapping set
71 *
72 * @var int|string
73 * (SQL type: int unsigned)
74 * Note that values will be retrieved from the database as a string.
75 */
76 public $column_number;
77
78 /**
79 * Location type of this mapping, if required
80 *
81 * @var int|string|null
82 * (SQL type: int unsigned)
83 * Note that values will be retrieved from the database as a string.
84 */
85 public $location_type_id;
86
87 /**
88 * Which type of phone does this number belongs.
89 *
90 * @var int|string|null
91 * (SQL type: int unsigned)
92 * Note that values will be retrieved from the database as a string.
93 */
94 public $phone_type_id;
95
96 /**
97 * Which type of IM Provider does this name belong.
98 *
99 * @var int|string|null
100 * (SQL type: int unsigned)
101 * Note that values will be retrieved from the database as a string.
102 */
103 public $im_provider_id;
104
105 /**
106 * Which type of website does this site belong
107 *
108 * @var int|string|null
109 * (SQL type: int unsigned)
110 * Note that values will be retrieved from the database as a string.
111 */
112 public $website_type_id;
113
114 /**
115 * Relationship type, if required
116 *
117 * @var int|string|null
118 * (SQL type: int unsigned)
119 * Note that values will be retrieved from the database as a string.
120 */
121 public $relationship_type_id;
122
123 /**
124 * @var string|null
125 * (SQL type: varchar(6))
126 * Note that values will be retrieved from the database as a string.
127 */
128 public $relationship_direction;
129
130 /**
131 * Used to group mapping_field records into related sets (e.g. for criteria sets in search builder
132 * mappings).
133 *
134 * @var int|string|null
135 * (SQL type: int unsigned)
136 * Note that values will be retrieved from the database as a string.
137 */
138 public $grouping;
139
140 /**
141 * SQL WHERE operator for search-builder mapping fields (search criteria).
142 *
143 * @var string|null
144 * (SQL type: varchar(16))
145 * Note that values will be retrieved from the database as a string.
146 */
147 public $operator;
148
149 /**
150 * SQL WHERE value for search-builder mapping fields.
151 *
152 * @var string|null
153 * (SQL type: varchar(255))
154 * Note that values will be retrieved from the database as a string.
155 */
156 public $value;
157
158 /**
159 * Class constructor.
160 */
161 public function __construct() {
162 $this->__table = 'civicrm_mapping_field';
163 parent::__construct();
164 }
165
166 /**
167 * Returns localized title of this entity.
168 *
169 * @param bool $plural
170 * Whether to return the plural version of the title.
171 */
172 public static function getEntityTitle($plural = FALSE) {
173 return $plural ? ts('Mapping Fields') : ts('Mapping Field');
174 }
175
176 /**
177 * Returns foreign keys and entity references.
178 *
179 * @return array
180 * [CRM_Core_Reference_Interface]
181 */
182 public static function getReferenceColumns() {
183 if (!isset(Civi::$statics[__CLASS__]['links'])) {
184 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
185 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mapping_id', 'civicrm_mapping', 'id');
186 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'location_type_id', 'civicrm_location_type', 'id');
187 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
188 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
189 }
190 return Civi::$statics[__CLASS__]['links'];
191 }
192
193 /**
194 * Returns all the column names of this table
195 *
196 * @return array
197 */
198 public static function &fields() {
199 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
200 Civi::$statics[__CLASS__]['fields'] = [
201 'id' => [
202 'name' => 'id',
203 'type' => CRM_Utils_Type::T_INT,
204 'title' => ts('Mapping Field ID'),
205 'description' => ts('Mapping Field ID'),
206 'required' => TRUE,
207 'where' => 'civicrm_mapping_field.id',
208 'table_name' => 'civicrm_mapping_field',
209 'entity' => 'MappingField',
210 'bao' => 'CRM_Core_DAO_MappingField',
211 'localizable' => 0,
212 'html' => [
213 'type' => 'Number',
214 ],
215 'readonly' => TRUE,
216 'add' => '1.2',
217 ],
218 'mapping_id' => [
219 'name' => 'mapping_id',
220 'type' => CRM_Utils_Type::T_INT,
221 'title' => ts('Mapping ID'),
222 'description' => ts('Mapping to which this field belongs'),
223 'required' => TRUE,
224 'where' => 'civicrm_mapping_field.mapping_id',
225 'table_name' => 'civicrm_mapping_field',
226 'entity' => 'MappingField',
227 'bao' => 'CRM_Core_DAO_MappingField',
228 'localizable' => 0,
229 'FKClassName' => 'CRM_Core_DAO_Mapping',
230 'html' => [
231 'label' => ts("Mapping"),
232 ],
233 'add' => '1.2',
234 ],
235 'name' => [
236 'name' => 'name',
237 'type' => CRM_Utils_Type::T_STRING,
238 'title' => ts('Field Name (or unique reference)'),
239 'description' => ts('Mapping field key'),
240 'maxlength' => 255,
241 'size' => CRM_Utils_Type::HUGE,
242 'where' => 'civicrm_mapping_field.name',
243 'table_name' => 'civicrm_mapping_field',
244 'entity' => 'MappingField',
245 'bao' => 'CRM_Core_DAO_MappingField',
246 'localizable' => 0,
247 'add' => '1.2',
248 ],
249 'contact_type' => [
250 'name' => 'contact_type',
251 'type' => CRM_Utils_Type::T_STRING,
252 'title' => ts('Contact Type'),
253 'description' => ts('Contact Type in mapping'),
254 'maxlength' => 64,
255 'size' => CRM_Utils_Type::BIG,
256 'where' => 'civicrm_mapping_field.contact_type',
257 'table_name' => 'civicrm_mapping_field',
258 'entity' => 'MappingField',
259 'bao' => 'CRM_Core_DAO_MappingField',
260 'localizable' => 0,
261 'html' => [
262 'type' => 'Select',
263 ],
264 'add' => '1.2',
265 ],
266 'column_number' => [
267 'name' => 'column_number',
268 'type' => CRM_Utils_Type::T_INT,
269 'title' => ts('Column Number to map to'),
270 'description' => ts('Column number for mapping set'),
271 'required' => TRUE,
272 'where' => 'civicrm_mapping_field.column_number',
273 'table_name' => 'civicrm_mapping_field',
274 'entity' => 'MappingField',
275 'bao' => 'CRM_Core_DAO_MappingField',
276 'localizable' => 0,
277 'add' => '1.2',
278 ],
279 'location_type_id' => [
280 'name' => 'location_type_id',
281 'type' => CRM_Utils_Type::T_INT,
282 'title' => ts('Location type ID'),
283 'description' => ts('Location type of this mapping, if required'),
284 'where' => 'civicrm_mapping_field.location_type_id',
285 'table_name' => 'civicrm_mapping_field',
286 'entity' => 'MappingField',
287 'bao' => 'CRM_Core_DAO_MappingField',
288 'localizable' => 0,
289 'FKClassName' => 'CRM_Core_DAO_LocationType',
290 'html' => [
291 'label' => ts("Location type"),
292 ],
293 'pseudoconstant' => [
294 'table' => 'civicrm_location_type',
295 'keyColumn' => 'id',
296 'labelColumn' => 'display_name',
297 ],
298 'add' => '1.2',
299 ],
300 'phone_type_id' => [
301 'name' => 'phone_type_id',
302 'type' => CRM_Utils_Type::T_INT,
303 'title' => ts('Phone type ID'),
304 'description' => ts('Which type of phone does this number belongs.'),
305 'where' => 'civicrm_mapping_field.phone_type_id',
306 'table_name' => 'civicrm_mapping_field',
307 'entity' => 'MappingField',
308 'bao' => 'CRM_Core_DAO_MappingField',
309 'localizable' => 0,
310 'add' => '2.2',
311 ],
312 'im_provider_id' => [
313 'name' => 'im_provider_id',
314 'type' => CRM_Utils_Type::T_INT,
315 'title' => ts('IM provider ID'),
316 'description' => ts('Which type of IM Provider does this name belong.'),
317 'where' => 'civicrm_mapping_field.im_provider_id',
318 'table_name' => 'civicrm_mapping_field',
319 'entity' => 'MappingField',
320 'bao' => 'CRM_Core_DAO_MappingField',
321 'localizable' => 0,
322 'html' => [
323 'type' => 'Select',
324 ],
325 'pseudoconstant' => [
326 'optionGroupName' => 'instant_messenger_service',
327 'optionEditPath' => 'civicrm/admin/options/instant_messenger_service',
328 ],
329 'add' => '3.0',
330 ],
331 'website_type_id' => [
332 'name' => 'website_type_id',
333 'type' => CRM_Utils_Type::T_INT,
334 'title' => ts('Website type ID'),
335 'description' => ts('Which type of website does this site belong'),
336 'where' => 'civicrm_mapping_field.website_type_id',
337 'table_name' => 'civicrm_mapping_field',
338 'entity' => 'MappingField',
339 'bao' => 'CRM_Core_DAO_MappingField',
340 'localizable' => 0,
341 'html' => [
342 'type' => 'Select',
343 ],
344 'pseudoconstant' => [
345 'optionGroupName' => 'website_type',
346 'optionEditPath' => 'civicrm/admin/options/website_type',
347 ],
348 'add' => '3.2',
349 ],
350 'relationship_type_id' => [
351 'name' => 'relationship_type_id',
352 'type' => CRM_Utils_Type::T_INT,
353 'title' => ts('Relationship type ID'),
354 'description' => ts('Relationship type, if required'),
355 'where' => 'civicrm_mapping_field.relationship_type_id',
356 'table_name' => 'civicrm_mapping_field',
357 'entity' => 'MappingField',
358 'bao' => 'CRM_Core_DAO_MappingField',
359 'localizable' => 0,
360 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
361 'html' => [
362 'label' => ts("Relationship type"),
363 ],
364 'add' => '1.2',
365 ],
366 'relationship_direction' => [
367 'name' => 'relationship_direction',
368 'type' => CRM_Utils_Type::T_STRING,
369 'title' => ts('Relationship Direction'),
370 'maxlength' => 6,
371 'size' => CRM_Utils_Type::SIX,
372 'where' => 'civicrm_mapping_field.relationship_direction',
373 'table_name' => 'civicrm_mapping_field',
374 'entity' => 'MappingField',
375 'bao' => 'CRM_Core_DAO_MappingField',
376 'localizable' => 0,
377 'add' => '1.7',
378 ],
379 'grouping' => [
380 'name' => 'grouping',
381 'type' => CRM_Utils_Type::T_INT,
382 'title' => ts('Field Grouping'),
383 'description' => ts('Used to group mapping_field records into related sets (e.g. for criteria sets in search builder
384 mappings).'),
385 'where' => 'civicrm_mapping_field.grouping',
386 'default' => '1',
387 'table_name' => 'civicrm_mapping_field',
388 'entity' => 'MappingField',
389 'bao' => 'CRM_Core_DAO_MappingField',
390 'localizable' => 0,
391 'add' => '1.5',
392 ],
393 'operator' => [
394 'name' => 'operator',
395 'type' => CRM_Utils_Type::T_STRING,
396 'title' => ts('Operator'),
397 'description' => ts('SQL WHERE operator for search-builder mapping fields (search criteria).'),
398 'maxlength' => 16,
399 'size' => CRM_Utils_Type::TWELVE,
400 'where' => 'civicrm_mapping_field.operator',
401 'table_name' => 'civicrm_mapping_field',
402 'entity' => 'MappingField',
403 'bao' => 'CRM_Core_DAO_MappingField',
404 'localizable' => 0,
405 'html' => [
406 'type' => 'Select',
407 ],
408 'pseudoconstant' => [
409 'callback' => 'CRM_Core_SelectValues::getSearchBuilderOperators',
410 ],
411 'add' => '1.5',
412 ],
413 'value' => [
414 'name' => 'value',
415 'type' => CRM_Utils_Type::T_STRING,
416 'title' => ts('Search builder where clause'),
417 'description' => ts('SQL WHERE value for search-builder mapping fields.'),
418 'maxlength' => 255,
419 'size' => CRM_Utils_Type::HUGE,
420 'where' => 'civicrm_mapping_field.value',
421 'table_name' => 'civicrm_mapping_field',
422 'entity' => 'MappingField',
423 'bao' => 'CRM_Core_DAO_MappingField',
424 'localizable' => 0,
425 'add' => '1.5',
426 ],
427 ];
428 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
429 }
430 return Civi::$statics[__CLASS__]['fields'];
431 }
432
433 /**
434 * Return a mapping from field-name to the corresponding key (as used in fields()).
435 *
436 * @return array
437 * Array(string $name => string $uniqueName).
438 */
439 public static function &fieldKeys() {
440 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
441 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
442 }
443 return Civi::$statics[__CLASS__]['fieldKeys'];
444 }
445
446 /**
447 * Returns the names of this table
448 *
449 * @return string
450 */
451 public static function getTableName() {
452 return self::$_tableName;
453 }
454
455 /**
456 * Returns if this table needs to be logged
457 *
458 * @return bool
459 */
460 public function getLog() {
461 return self::$_log;
462 }
463
464 /**
465 * Returns the list of fields that can be imported
466 *
467 * @param bool $prefix
468 *
469 * @return array
470 */
471 public static function &import($prefix = FALSE) {
472 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mapping_field', $prefix, []);
473 return $r;
474 }
475
476 /**
477 * Returns the list of fields that can be exported
478 *
479 * @param bool $prefix
480 *
481 * @return array
482 */
483 public static function &export($prefix = FALSE) {
484 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mapping_field', $prefix, []);
485 return $r;
486 }
487
488 /**
489 * Returns the list of indices
490 *
491 * @param bool $localize
492 *
493 * @return array
494 */
495 public static function indices($localize = TRUE) {
496 $indices = [];
497 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
498 }
499
500 }