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