Fix any title or label that contain name of own entity
[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
8ab43c93 9 * (GenCodeChecksum:3712a8e412a011a13e2898d0f151b264)
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,
a9d0587b 184 'add' => '1.2',
c3fc2621
CW
185 ],
186 'mapping_id' => [
e501603b
TO
187 'name' => 'mapping_id',
188 'type' => CRM_Utils_Type::T_INT,
c3fc2621 189 'title' => ts('Mapping ID'),
215b423e 190 'description' => ts('Mapping to which this field belongs'),
c3fc2621 191 'required' => TRUE,
a36434b9 192 'where' => 'civicrm_mapping_field.mapping_id',
522a26c9 193 'table_name' => 'civicrm_mapping_field',
194 'entity' => 'MappingField',
195 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 196 'localizable' => 0,
e501603b 197 'FKClassName' => 'CRM_Core_DAO_Mapping',
a9d0587b 198 'add' => '1.2',
c3fc2621
CW
199 ],
200 'name' => [
e501603b
TO
201 'name' => 'name',
202 'type' => CRM_Utils_Type::T_STRING,
110684e4 203 'title' => ts('Field Name (or unique reference)'),
215b423e 204 'description' => ts('Mapping field key'),
e501603b
TO
205 'maxlength' => 255,
206 'size' => CRM_Utils_Type::HUGE,
a36434b9 207 'where' => 'civicrm_mapping_field.name',
522a26c9 208 'table_name' => 'civicrm_mapping_field',
209 'entity' => 'MappingField',
210 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 211 'localizable' => 0,
a9d0587b 212 'add' => '1.2',
c3fc2621
CW
213 ],
214 'contact_type' => [
e501603b
TO
215 'name' => 'contact_type',
216 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 217 'title' => ts('Contact Type'),
215b423e 218 'description' => ts('Contact Type in mapping'),
e501603b
TO
219 'maxlength' => 64,
220 'size' => CRM_Utils_Type::BIG,
a36434b9 221 'where' => 'civicrm_mapping_field.contact_type',
522a26c9 222 'table_name' => 'civicrm_mapping_field',
223 'entity' => 'MappingField',
224 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 225 'localizable' => 0,
c3fc2621 226 'html' => [
e501603b 227 'type' => 'Select',
c3fc2621 228 ],
a9d0587b 229 'add' => '1.2',
c3fc2621
CW
230 ],
231 'column_number' => [
e501603b
TO
232 'name' => 'column_number',
233 'type' => CRM_Utils_Type::T_INT,
110684e4 234 'title' => ts('Column Number to map to'),
215b423e 235 'description' => ts('Column number for mapping set'),
c3fc2621 236 'required' => TRUE,
a36434b9 237 'where' => 'civicrm_mapping_field.column_number',
522a26c9 238 'table_name' => 'civicrm_mapping_field',
239 'entity' => 'MappingField',
240 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 241 'localizable' => 0,
a9d0587b 242 'add' => '1.2',
c3fc2621
CW
243 ],
244 'location_type_id' => [
e501603b
TO
245 'name' => 'location_type_id',
246 'type' => CRM_Utils_Type::T_INT,
c3fc2621 247 'title' => ts('Location type ID'),
215b423e 248 'description' => ts('Location type of this mapping, if required'),
a36434b9 249 'where' => 'civicrm_mapping_field.location_type_id',
522a26c9 250 'table_name' => 'civicrm_mapping_field',
251 'entity' => 'MappingField',
252 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 253 'localizable' => 0,
e501603b 254 'FKClassName' => 'CRM_Core_DAO_LocationType',
3c5a48c7 255 'pseudoconstant' => [
256 'table' => 'civicrm_location_type',
257 'keyColumn' => 'id',
258 'labelColumn' => 'display_name',
259 ],
a9d0587b 260 'add' => '1.2',
c3fc2621
CW
261 ],
262 'phone_type_id' => [
e501603b
TO
263 'name' => 'phone_type_id',
264 'type' => CRM_Utils_Type::T_INT,
110684e4 265 'title' => ts('Phone Type'),
215b423e 266 'description' => ts('Which type of phone does this number belongs.'),
a36434b9 267 'where' => 'civicrm_mapping_field.phone_type_id',
522a26c9 268 'table_name' => 'civicrm_mapping_field',
269 'entity' => 'MappingField',
270 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 271 'localizable' => 0,
a9d0587b 272 'add' => '2.2',
c3fc2621
CW
273 ],
274 'im_provider_id' => [
e501603b
TO
275 'name' => 'im_provider_id',
276 'type' => CRM_Utils_Type::T_INT,
c3fc2621 277 'title' => ts('IM provider ID'),
215b423e 278 'description' => ts('Which type of IM Provider does this name belong.'),
a36434b9 279 'where' => 'civicrm_mapping_field.im_provider_id',
522a26c9 280 'table_name' => 'civicrm_mapping_field',
281 'entity' => 'MappingField',
282 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 283 'localizable' => 0,
c3fc2621 284 'html' => [
e501603b 285 'type' => 'Select',
c3fc2621
CW
286 ],
287 'pseudoconstant' => [
e501603b
TO
288 'optionGroupName' => 'instant_messenger_service',
289 'optionEditPath' => 'civicrm/admin/options/instant_messenger_service',
e6ca0a57 290 ],
a9d0587b 291 'add' => '3.0',
c3fc2621
CW
292 ],
293 'website_type_id' => [
e501603b
TO
294 'name' => 'website_type_id',
295 'type' => CRM_Utils_Type::T_INT,
c3fc2621 296 'title' => ts('Website type ID'),
215b423e 297 'description' => ts('Which type of website does this site belong'),
a36434b9 298 'where' => 'civicrm_mapping_field.website_type_id',
522a26c9 299 'table_name' => 'civicrm_mapping_field',
300 'entity' => 'MappingField',
301 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 302 'localizable' => 0,
c3fc2621 303 'html' => [
e501603b 304 'type' => 'Select',
c3fc2621
CW
305 ],
306 'pseudoconstant' => [
e501603b
TO
307 'optionGroupName' => 'website_type',
308 'optionEditPath' => 'civicrm/admin/options/website_type',
e6ca0a57 309 ],
a9d0587b 310 'add' => '3.2',
c3fc2621
CW
311 ],
312 'relationship_type_id' => [
e501603b
TO
313 'name' => 'relationship_type_id',
314 'type' => CRM_Utils_Type::T_INT,
c3fc2621 315 'title' => ts('Relationship type ID'),
215b423e 316 'description' => ts('Relationship type, if required'),
a36434b9 317 'where' => 'civicrm_mapping_field.relationship_type_id',
522a26c9 318 'table_name' => 'civicrm_mapping_field',
319 'entity' => 'MappingField',
320 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 321 'localizable' => 0,
e501603b 322 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
a9d0587b 323 'add' => '1.2',
c3fc2621
CW
324 ],
325 'relationship_direction' => [
e501603b
TO
326 'name' => 'relationship_direction',
327 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 328 'title' => ts('Relationship Direction'),
e501603b
TO
329 'maxlength' => 6,
330 'size' => CRM_Utils_Type::SIX,
a36434b9 331 'where' => 'civicrm_mapping_field.relationship_direction',
522a26c9 332 'table_name' => 'civicrm_mapping_field',
333 'entity' => 'MappingField',
334 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 335 'localizable' => 0,
a9d0587b 336 'add' => '1.7',
c3fc2621
CW
337 ],
338 'grouping' => [
e501603b
TO
339 'name' => 'grouping',
340 'type' => CRM_Utils_Type::T_INT,
110684e4 341 'title' => ts('Field Grouping'),
215b423e 342 'description' => ts('Used to group mapping_field records into related sets (e.g. for criteria sets in search builder
fb607354 343 mappings).'),
a36434b9 344 'where' => 'civicrm_mapping_field.grouping',
e501603b 345 'default' => '1',
522a26c9 346 'table_name' => 'civicrm_mapping_field',
347 'entity' => 'MappingField',
348 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 349 'localizable' => 0,
a9d0587b 350 'add' => '1.5',
c3fc2621
CW
351 ],
352 'operator' => [
e501603b
TO
353 'name' => 'operator',
354 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 355 'title' => ts('Operator'),
215b423e 356 'description' => ts('SQL WHERE operator for search-builder mapping fields (search criteria).'),
e501603b
TO
357 'maxlength' => 16,
358 'size' => CRM_Utils_Type::TWELVE,
a36434b9 359 'where' => 'civicrm_mapping_field.operator',
522a26c9 360 'table_name' => 'civicrm_mapping_field',
361 'entity' => 'MappingField',
362 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 363 'localizable' => 0,
c3fc2621 364 'html' => [
e501603b 365 'type' => 'Select',
c3fc2621
CW
366 ],
367 'pseudoconstant' => [
e501603b 368 'callback' => 'CRM_Core_SelectValues::getSearchBuilderOperators',
e6ca0a57 369 ],
a9d0587b 370 'add' => '1.5',
c3fc2621
CW
371 ],
372 'value' => [
e501603b
TO
373 'name' => 'value',
374 'type' => CRM_Utils_Type::T_STRING,
110684e4 375 'title' => ts('Search builder where clause'),
215b423e 376 'description' => ts('SQL WHERE value for search-builder mapping fields.'),
e501603b
TO
377 'maxlength' => 255,
378 'size' => CRM_Utils_Type::HUGE,
a36434b9 379 'where' => 'civicrm_mapping_field.value',
522a26c9 380 'table_name' => 'civicrm_mapping_field',
381 'entity' => 'MappingField',
382 'bao' => 'CRM_Core_DAO_MappingField',
6a7e5e5d 383 'localizable' => 0,
a9d0587b 384 'add' => '1.5',
c3fc2621
CW
385 ],
386 ];
346aaaba 387 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 388 }
346aaaba 389 return Civi::$statics[__CLASS__]['fields'];
e501603b 390 }
c3fc2621 391
e501603b 392 /**
bd8e0b14 393 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
394 *
395 * @return array
bd8e0b14 396 * Array(string $name => string $uniqueName).
e501603b 397 */
c3fc2621 398 public static function &fieldKeys() {
bd8e0b14
TO
399 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
400 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 401 }
bd8e0b14 402 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 403 }
c3fc2621 404
e501603b
TO
405 /**
406 * Returns the names of this table
407 *
408 * @return string
409 */
c3fc2621 410 public static function getTableName() {
e501603b
TO
411 return self::$_tableName;
412 }
c3fc2621 413
e501603b
TO
414 /**
415 * Returns if this table needs to be logged
416 *
c3fc2621 417 * @return bool
e501603b 418 */
c3fc2621 419 public function getLog() {
e501603b
TO
420 return self::$_log;
421 }
c3fc2621 422
e501603b
TO
423 /**
424 * Returns the list of fields that can be imported
425 *
426 * @param bool $prefix
427 *
428 * @return array
429 */
c3fc2621
CW
430 public static function &import($prefix = FALSE) {
431 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mapping_field', $prefix, []);
60808919 432 return $r;
e501603b 433 }
c3fc2621 434
e501603b
TO
435 /**
436 * Returns the list of fields that can be exported
437 *
438 * @param bool $prefix
439 *
440 * @return array
441 */
c3fc2621
CW
442 public static function &export($prefix = FALSE) {
443 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mapping_field', $prefix, []);
60808919 444 return $r;
e501603b 445 }
c3fc2621 446
e7a6b91a
AS
447 /**
448 * Returns the list of indices
c3fc2621
CW
449 *
450 * @param bool $localize
451 *
452 * @return array
e7a6b91a
AS
453 */
454 public static function indices($localize = TRUE) {
c3fc2621 455 $indices = [];
e7a6b91a
AS
456 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
457 }
c3fc2621 458
e501603b 459}