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