Merge pull request #23008 from eileenmcnaughton/temp_selected
[civicrm-core.git] / CRM / Contact / DAO / RelationshipCache.php
CommitLineData
e752bdac
TO
1<?php
2
3/**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
bcf70e08 7 * Generated from xml/schema/CRM/Contact/RelationshipCache.xml
e752bdac 8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
28979d65 9 * (GenCodeChecksum:1bc7c47a01326782645f1cfac11c6d14)
e752bdac
TO
10 */
11
12/**
bcf70e08 13 * Database access object for the RelationshipCache entity.
e752bdac 14 */
bcf70e08 15class CRM_Contact_DAO_RelationshipCache extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '5.29';
e752bdac
TO
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
bcf70e08 24 public static $_tableName = 'civicrm_relationship_cache';
e752bdac
TO
25
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-handshake-o';
32
33 /**
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
35 *
36 * @var bool
37 */
38 public static $_log = FALSE;
39
c5076889
CW
40 /**
41 * Paths for accessing this entity in the UI.
42 *
43 * @var string[]
44 */
45 protected static $_paths = [
46 'view' => 'civicrm/contact/view/rel?action=view&reset=1&cid=[near_contact_id]&id=[relationship_id]',
47 'update' => 'civicrm/contact/view/rel?action=update&reset=1&cid=[near_contact_id]&id=[relationship_id]&rtype=[orientation]',
48 'delete' => 'civicrm/contact/view/rel?action=delete&reset=1&cid=[near_contact_id]&id=[relationship_id]',
49 ];
50
e752bdac 51 /**
bcf70e08 52 * Relationship Cache ID
e752bdac 53 *
28979d65
CW
54 * @var int|string|null
55 * (SQL type: int unsigned)
56 * Note that values will be retrieved from the database as a string.
e752bdac
TO
57 */
58 public $id;
59
60 /**
61 * id of the relationship (FK to civicrm_relationship.id)
62 *
28979d65
CW
63 * @var int|string
64 * (SQL type: int unsigned)
65 * Note that values will be retrieved from the database as a string.
e752bdac
TO
66 */
67 public $relationship_id;
68
69 /**
70 * id of the relationship type
71 *
28979d65
CW
72 * @var int|string
73 * (SQL type: int unsigned)
74 * Note that values will be retrieved from the database as a string.
e752bdac
TO
75 */
76 public $relationship_type_id;
77
78 /**
bcf70e08 79 * The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.
e752bdac
TO
80 *
81 * @var string
28979d65
CW
82 * (SQL type: char(3))
83 * Note that values will be retrieved from the database as a string.
e752bdac
TO
84 */
85 public $orientation;
86
87 /**
88 * id of the first contact
89 *
28979d65
CW
90 * @var int|string
91 * (SQL type: int unsigned)
92 * Note that values will be retrieved from the database as a string.
e752bdac
TO
93 */
94 public $near_contact_id;
95
96 /**
97 * name for relationship of near_contact to far_contact.
98 *
28979d65
CW
99 * @var string|null
100 * (SQL type: varchar(64))
101 * Note that values will be retrieved from the database as a string.
e752bdac
TO
102 */
103 public $near_relation;
104
105 /**
106 * id of the second contact
107 *
28979d65
CW
108 * @var int|string
109 * (SQL type: int unsigned)
110 * Note that values will be retrieved from the database as a string.
e752bdac
TO
111 */
112 public $far_contact_id;
113
114 /**
115 * name for relationship of far_contact to near_contact.
116 *
28979d65
CW
117 * @var string|null
118 * (SQL type: varchar(64))
119 * Note that values will be retrieved from the database as a string.
e752bdac
TO
120 */
121 public $far_relation;
122
123 /**
124 * is the relationship active ?
125 *
28979d65
CW
126 * @var bool|string|null
127 * (SQL type: tinyint)
128 * Note that values will be retrieved from the database as a string.
e752bdac
TO
129 */
130 public $is_active;
131
132 /**
133 * date when the relationship started
134 *
28979d65
CW
135 * @var string|null
136 * (SQL type: date)
137 * Note that values will be retrieved from the database as a string.
e752bdac
TO
138 */
139 public $start_date;
140
141 /**
142 * date when the relationship ended
143 *
28979d65
CW
144 * @var string|null
145 * (SQL type: date)
146 * Note that values will be retrieved from the database as a string.
e752bdac
TO
147 */
148 public $end_date;
149
bcd7e8d9
CW
150 /**
151 * FK to civicrm_case
152 *
28979d65
CW
153 * @var int|string|null
154 * (SQL type: int unsigned)
155 * Note that values will be retrieved from the database as a string.
bcd7e8d9
CW
156 */
157 public $case_id;
158
e752bdac
TO
159 /**
160 * Class constructor.
161 */
162 public function __construct() {
bcf70e08 163 $this->__table = 'civicrm_relationship_cache';
e752bdac
TO
164 parent::__construct();
165 }
166
167 /**
168 * Returns localized title of this entity.
7b66c3b5
AH
169 *
170 * @param bool $plural
171 * Whether to return the plural version of the title.
e752bdac 172 */
7b66c3b5 173 public static function getEntityTitle($plural = FALSE) {
c5368b3b 174 return $plural ? ts('Related Contacts') : ts('Related Contact');
e752bdac
TO
175 }
176
177 /**
178 * Returns foreign keys and entity references.
179 *
180 * @return array
181 * [CRM_Core_Reference_Interface]
182 */
183 public static function getReferenceColumns() {
184 if (!isset(Civi::$statics[__CLASS__]['links'])) {
185 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
186 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
187 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
188 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'near_contact_id', 'civicrm_contact', 'id');
189 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'far_contact_id', 'civicrm_contact', 'id');
bcd7e8d9 190 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'case_id', 'civicrm_case', 'id');
e752bdac
TO
191 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
192 }
193 return Civi::$statics[__CLASS__]['links'];
194 }
195
196 /**
197 * Returns all the column names of this table
198 *
199 * @return array
200 */
201 public static function &fields() {
202 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
203 Civi::$statics[__CLASS__]['fields'] = [
204 'id' => [
205 'name' => 'id',
206 'type' => CRM_Utils_Type::T_INT,
bcf70e08
TO
207 'title' => ts('Relationship Cache ID'),
208 'description' => ts('Relationship Cache ID'),
e752bdac 209 'required' => TRUE,
bcf70e08
TO
210 'where' => 'civicrm_relationship_cache.id',
211 'table_name' => 'civicrm_relationship_cache',
212 'entity' => 'RelationshipCache',
213 'bao' => 'CRM_Contact_BAO_RelationshipCache',
e752bdac 214 'localizable' => 0,
2cbbebe8
A
215 'html' => [
216 'type' => 'Number',
217 ],
1fe423d6 218 'readonly' => TRUE,
e752bdac
TO
219 'add' => '5.29',
220 ],
221 'relationship_id' => [
222 'name' => 'relationship_id',
223 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 224 'title' => ts('Relationship ID'),
e752bdac
TO
225 'description' => ts('id of the relationship (FK to civicrm_relationship.id)'),
226 'required' => TRUE,
bcf70e08
TO
227 'where' => 'civicrm_relationship_cache.relationship_id',
228 'table_name' => 'civicrm_relationship_cache',
229 'entity' => 'RelationshipCache',
230 'bao' => 'CRM_Contact_BAO_RelationshipCache',
e752bdac
TO
231 'localizable' => 0,
232 'FKClassName' => 'CRM_Contact_DAO_Relationship',
2cbbebe8
A
233 'html' => [
234 'label' => ts("Relationship"),
235 ],
ce16fdaa 236 'readonly' => TRUE,
e752bdac
TO
237 'add' => '5.29',
238 ],
239 'relationship_type_id' => [
240 'name' => 'relationship_type_id',
241 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 242 'title' => ts('Relationship Type ID'),
e752bdac
TO
243 'description' => ts('id of the relationship type'),
244 'required' => TRUE,
bcf70e08
TO
245 'where' => 'civicrm_relationship_cache.relationship_type_id',
246 'table_name' => 'civicrm_relationship_cache',
247 'entity' => 'RelationshipCache',
248 'bao' => 'CRM_Contact_BAO_RelationshipCache',
e752bdac
TO
249 'localizable' => 0,
250 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
2cbbebe8
A
251 'html' => [
252 'label' => ts("Relationship Type"),
253 ],
ce16fdaa 254 'readonly' => TRUE,
e752bdac
TO
255 'add' => '5.29',
256 ],
257 'orientation' => [
258 'name' => 'orientation',
259 'type' => CRM_Utils_Type::T_STRING,
260 'title' => ts('Orientation (a_b or b_a)'),
bcf70e08 261 'description' => ts('The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.'),
e752bdac
TO
262 'required' => TRUE,
263 'maxlength' => 3,
264 'size' => CRM_Utils_Type::FOUR,
bcf70e08
TO
265 'where' => 'civicrm_relationship_cache.orientation',
266 'table_name' => 'civicrm_relationship_cache',
267 'entity' => 'RelationshipCache',
268 'bao' => 'CRM_Contact_BAO_RelationshipCache',
e752bdac 269 'localizable' => 0,
bf01b886
CW
270 'pseudoconstant' => [
271 'callback' => 'CRM_Core_SelectValues::relationshipOrientation',
272 ],
ce16fdaa 273 'readonly' => TRUE,
e752bdac
TO
274 'add' => '5.29',
275 ],
276 'near_contact_id' => [
277 'name' => 'near_contact_id',
278 'type' => CRM_Utils_Type::T_INT,
279 'title' => ts('Contact ID (Near side)'),
280 'description' => ts('id of the first contact'),
281 'required' => TRUE,
bcf70e08
TO
282 'where' => 'civicrm_relationship_cache.near_contact_id',
283 'table_name' => 'civicrm_relationship_cache',
284 'entity' => 'RelationshipCache',
285 'bao' => 'CRM_Contact_BAO_RelationshipCache',
e752bdac
TO
286 'localizable' => 0,
287 'FKClassName' => 'CRM_Contact_DAO_Contact',
bf01b886
CW
288 'html' => [
289 'type' => 'EntityRef',
2cbbebe8 290 'label' => ts("Contact (Near side)"),
bf01b886 291 ],
ce16fdaa 292 'readonly' => TRUE,
e752bdac
TO
293 'add' => '5.29',
294 ],
295 'near_relation' => [
296 'name' => 'near_relation',
297 'type' => CRM_Utils_Type::T_STRING,
c5368b3b 298 'title' => ts('Relationship Name (to related contact)'),
e752bdac
TO
299 'description' => ts('name for relationship of near_contact to far_contact.'),
300 'maxlength' => 64,
301 'size' => CRM_Utils_Type::BIG,
bcf70e08
TO
302 'where' => 'civicrm_relationship_cache.near_relation',
303 'table_name' => 'civicrm_relationship_cache',
304 'entity' => 'RelationshipCache',
305 'bao' => 'CRM_Contact_BAO_RelationshipCache',
e752bdac 306 'localizable' => 0,
344c48b1
CW
307 'html' => [
308 'label' => ts("Relationship to contact"),
309 ],
bf01b886
CW
310 'pseudoconstant' => [
311 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
312 ],
ce16fdaa 313 'readonly' => TRUE,
e752bdac
TO
314 'add' => '5.29',
315 ],
316 'far_contact_id' => [
317 'name' => 'far_contact_id',
318 'type' => CRM_Utils_Type::T_INT,
319 'title' => ts('Contact ID (Far side)'),
320 'description' => ts('id of the second contact'),
321 'required' => TRUE,
bcf70e08
TO
322 'where' => 'civicrm_relationship_cache.far_contact_id',
323 'table_name' => 'civicrm_relationship_cache',
324 'entity' => 'RelationshipCache',
325 'bao' => 'CRM_Contact_BAO_RelationshipCache',
e752bdac
TO
326 'localizable' => 0,
327 'FKClassName' => 'CRM_Contact_DAO_Contact',
328 'html' => [
329 'type' => 'EntityRef',
2cbbebe8 330 'label' => ts("Contact (Far side)"),
e752bdac 331 ],
ce16fdaa 332 'readonly' => TRUE,
e752bdac
TO
333 'add' => '5.29',
334 ],
335 'far_relation' => [
336 'name' => 'far_relation',
337 'type' => CRM_Utils_Type::T_STRING,
c5368b3b 338 'title' => ts('Relationship Name (from related contact)'),
e752bdac
TO
339 'description' => ts('name for relationship of far_contact to near_contact.'),
340 'maxlength' => 64,
341 'size' => CRM_Utils_Type::BIG,
bcf70e08
TO
342 'where' => 'civicrm_relationship_cache.far_relation',
343 'table_name' => 'civicrm_relationship_cache',
344 'entity' => 'RelationshipCache',
345 'bao' => 'CRM_Contact_BAO_RelationshipCache',
e752bdac 346 'localizable' => 0,
344c48b1
CW
347 'html' => [
348 'label' => ts("Relationship from contact"),
349 ],
bf01b886
CW
350 'pseudoconstant' => [
351 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
352 ],
ce16fdaa 353 'readonly' => TRUE,
e752bdac
TO
354 'add' => '5.29',
355 ],
356 'is_active' => [
357 'name' => 'is_active',
358 'type' => CRM_Utils_Type::T_BOOLEAN,
359 'title' => ts('Relationship Is Active'),
360 'description' => ts('is the relationship active ?'),
bcf70e08 361 'where' => 'civicrm_relationship_cache.is_active',
e752bdac 362 'default' => '1',
bcf70e08
TO
363 'table_name' => 'civicrm_relationship_cache',
364 'entity' => 'RelationshipCache',
365 'bao' => 'CRM_Contact_BAO_RelationshipCache',
e752bdac
TO
366 'localizable' => 0,
367 'html' => [
368 'type' => 'CheckBox',
369 ],
ce16fdaa 370 'readonly' => TRUE,
e752bdac
TO
371 'add' => '5.29',
372 ],
373 'relationship_start_date' => [
374 'name' => 'start_date',
375 'type' => CRM_Utils_Type::T_DATE,
376 'title' => ts('Relationship Start Date'),
377 'description' => ts('date when the relationship started'),
bcf70e08
TO
378 'where' => 'civicrm_relationship_cache.start_date',
379 'table_name' => 'civicrm_relationship_cache',
380 'entity' => 'RelationshipCache',
381 'bao' => 'CRM_Contact_BAO_RelationshipCache',
e752bdac
TO
382 'localizable' => 0,
383 'html' => [
384 'type' => 'Select Date',
385 'formatType' => 'activityDate',
386 ],
ce16fdaa 387 'readonly' => TRUE,
e752bdac
TO
388 'add' => '5.29',
389 ],
390 'relationship_end_date' => [
391 'name' => 'end_date',
392 'type' => CRM_Utils_Type::T_DATE,
393 'title' => ts('Relationship End Date'),
394 'description' => ts('date when the relationship ended'),
bcf70e08
TO
395 'where' => 'civicrm_relationship_cache.end_date',
396 'table_name' => 'civicrm_relationship_cache',
397 'entity' => 'RelationshipCache',
398 'bao' => 'CRM_Contact_BAO_RelationshipCache',
e752bdac
TO
399 'localizable' => 0,
400 'html' => [
401 'type' => 'Select Date',
402 'formatType' => 'activityDate',
403 ],
ce16fdaa 404 'readonly' => TRUE,
e752bdac
TO
405 'add' => '5.29',
406 ],
bcd7e8d9
CW
407 'case_id' => [
408 'name' => 'case_id',
409 'type' => CRM_Utils_Type::T_INT,
410 'title' => ts('Case ID'),
411 'description' => ts('FK to civicrm_case'),
412 'where' => 'civicrm_relationship_cache.case_id',
6c438271 413 'default' => NULL,
bcd7e8d9
CW
414 'table_name' => 'civicrm_relationship_cache',
415 'entity' => 'RelationshipCache',
416 'bao' => 'CRM_Contact_BAO_RelationshipCache',
417 'localizable' => 0,
418 'FKClassName' => 'CRM_Case_DAO_Case',
419 'component' => 'CiviCase',
420 'html' => [
421 'label' => ts("Case"),
422 ],
423 'readonly' => TRUE,
424 'add' => '5.44',
425 ],
e752bdac
TO
426 ];
427 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
428 }
429 return Civi::$statics[__CLASS__]['fields'];
430 }
431
432 /**
433 * Return a mapping from field-name to the corresponding key (as used in fields()).
434 *
435 * @return array
436 * Array(string $name => string $uniqueName).
437 */
438 public static function &fieldKeys() {
439 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
440 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
441 }
442 return Civi::$statics[__CLASS__]['fieldKeys'];
443 }
444
445 /**
446 * Returns the names of this table
447 *
448 * @return string
449 */
450 public static function getTableName() {
451 return self::$_tableName;
452 }
453
454 /**
455 * Returns if this table needs to be logged
456 *
457 * @return bool
458 */
459 public function getLog() {
460 return self::$_log;
461 }
462
463 /**
464 * Returns the list of fields that can be imported
465 *
466 * @param bool $prefix
467 *
468 * @return array
469 */
470 public static function &import($prefix = FALSE) {
bcf70e08 471 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship_cache', $prefix, []);
e752bdac
TO
472 return $r;
473 }
474
475 /**
476 * Returns the list of fields that can be exported
477 *
478 * @param bool $prefix
479 *
480 * @return array
481 */
482 public static function &export($prefix = FALSE) {
bcf70e08 483 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship_cache', $prefix, []);
e752bdac
TO
484 return $r;
485 }
486
487 /**
488 * Returns the list of indices
489 *
490 * @param bool $localize
491 *
492 * @return array
493 */
494 public static function indices($localize = TRUE) {
495 $indices = [
496 'UI_relationship' => [
497 'name' => 'UI_relationship',
498 'field' => [
499 0 => 'relationship_id',
500 1 => 'orientation',
501 ],
502 'localizable' => FALSE,
503 'unique' => TRUE,
bcf70e08 504 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation',
e752bdac
TO
505 ],
506 'index_nearid_nearrelation' => [
507 'name' => 'index_nearid_nearrelation',
508 'field' => [
509 0 => 'near_contact_id',
510 1 => 'near_relation',
511 ],
512 'localizable' => FALSE,
bcf70e08 513 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation',
e752bdac
TO
514 ],
515 'index_nearid_farrelation' => [
516 'name' => 'index_nearid_farrelation',
517 'field' => [
518 0 => 'near_contact_id',
519 1 => 'far_relation',
520 ],
521 'localizable' => FALSE,
bcf70e08 522 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation',
e752bdac
TO
523 ],
524 'index_near_relation' => [
525 'name' => 'index_near_relation',
526 'field' => [
527 0 => 'near_relation',
528 ],
529 'localizable' => FALSE,
bcf70e08 530 'sig' => 'civicrm_relationship_cache::0::near_relation',
e752bdac
TO
531 ],
532 ];
533 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
534 }
535
536}