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