Merge pull request #19087 from civicrm/5.32
[civicrm-core.git] / CRM / Contact / DAO / RelationshipCache.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contact/RelationshipCache.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:3bee16c8388728d3e391e9dd7c17abb8)
10 */
11
12 /**
13 * Database access object for the RelationshipCache entity.
14 */
15 class CRM_Contact_DAO_RelationshipCache extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '5.29';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_relationship_cache';
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 /**
41 * Relationship Cache ID
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 /**
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.
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
117 /**
118 * Class constructor.
119 */
120 public function __construct() {
121 $this->__table = 'civicrm_relationship_cache';
122 parent::__construct();
123 }
124
125 /**
126 * Returns localized title of this entity.
127 *
128 * @param bool $plural
129 * Whether to return the plural version of the title.
130 */
131 public static function getEntityTitle($plural = FALSE) {
132 return $plural ? ts('Relationship Caches') : ts('Relationship Cache');
133 }
134
135 /**
136 * Returns foreign keys and entity references.
137 *
138 * @return array
139 * [CRM_Core_Reference_Interface]
140 */
141 public static function getReferenceColumns() {
142 if (!isset(Civi::$statics[__CLASS__]['links'])) {
143 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
144 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
145 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
146 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'near_contact_id', 'civicrm_contact', 'id');
147 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'far_contact_id', 'civicrm_contact', 'id');
148 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
149 }
150 return Civi::$statics[__CLASS__]['links'];
151 }
152
153 /**
154 * Returns all the column names of this table
155 *
156 * @return array
157 */
158 public static function &fields() {
159 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
160 Civi::$statics[__CLASS__]['fields'] = [
161 'id' => [
162 'name' => 'id',
163 'type' => CRM_Utils_Type::T_INT,
164 'title' => ts('Relationship Cache ID'),
165 'description' => ts('Relationship Cache ID'),
166 'required' => TRUE,
167 'where' => 'civicrm_relationship_cache.id',
168 'table_name' => 'civicrm_relationship_cache',
169 'entity' => 'RelationshipCache',
170 'bao' => 'CRM_Contact_BAO_RelationshipCache',
171 'localizable' => 0,
172 'add' => '5.29',
173 ],
174 'relationship_id' => [
175 'name' => 'relationship_id',
176 'type' => CRM_Utils_Type::T_INT,
177 'title' => ts('Relationship'),
178 'description' => ts('id of the relationship (FK to civicrm_relationship.id)'),
179 'required' => TRUE,
180 'where' => 'civicrm_relationship_cache.relationship_id',
181 'table_name' => 'civicrm_relationship_cache',
182 'entity' => 'RelationshipCache',
183 'bao' => 'CRM_Contact_BAO_RelationshipCache',
184 'localizable' => 0,
185 'FKClassName' => 'CRM_Contact_DAO_Relationship',
186 'add' => '5.29',
187 ],
188 'relationship_type_id' => [
189 'name' => 'relationship_type_id',
190 'type' => CRM_Utils_Type::T_INT,
191 'title' => ts('Relationship Type'),
192 'description' => ts('id of the relationship type'),
193 'required' => TRUE,
194 'where' => 'civicrm_relationship_cache.relationship_type_id',
195 'table_name' => 'civicrm_relationship_cache',
196 'entity' => 'RelationshipCache',
197 'bao' => 'CRM_Contact_BAO_RelationshipCache',
198 'localizable' => 0,
199 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
200 'add' => '5.29',
201 ],
202 'orientation' => [
203 'name' => 'orientation',
204 'type' => CRM_Utils_Type::T_STRING,
205 'title' => ts('Orientation (a_b or b_a)'),
206 '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.'),
207 'required' => TRUE,
208 'maxlength' => 3,
209 'size' => CRM_Utils_Type::FOUR,
210 'where' => 'civicrm_relationship_cache.orientation',
211 'table_name' => 'civicrm_relationship_cache',
212 'entity' => 'RelationshipCache',
213 'bao' => 'CRM_Contact_BAO_RelationshipCache',
214 'localizable' => 0,
215 'pseudoconstant' => [
216 'callback' => 'CRM_Core_SelectValues::relationshipOrientation',
217 ],
218 'add' => '5.29',
219 ],
220 'near_contact_id' => [
221 'name' => 'near_contact_id',
222 'type' => CRM_Utils_Type::T_INT,
223 'title' => ts('Contact ID (Near side)'),
224 'description' => ts('id of the first contact'),
225 'required' => TRUE,
226 'where' => 'civicrm_relationship_cache.near_contact_id',
227 'table_name' => 'civicrm_relationship_cache',
228 'entity' => 'RelationshipCache',
229 'bao' => 'CRM_Contact_BAO_RelationshipCache',
230 'localizable' => 0,
231 'FKClassName' => 'CRM_Contact_DAO_Contact',
232 'html' => [
233 'type' => 'EntityRef',
234 ],
235 'add' => '5.29',
236 ],
237 'near_relation' => [
238 'name' => 'near_relation',
239 'type' => CRM_Utils_Type::T_STRING,
240 'title' => ts('Relationship Name (Near side)'),
241 'description' => ts('name for relationship of near_contact to far_contact.'),
242 'maxlength' => 64,
243 'size' => CRM_Utils_Type::BIG,
244 'where' => 'civicrm_relationship_cache.near_relation',
245 'table_name' => 'civicrm_relationship_cache',
246 'entity' => 'RelationshipCache',
247 'bao' => 'CRM_Contact_BAO_RelationshipCache',
248 'localizable' => 0,
249 'pseudoconstant' => [
250 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
251 ],
252 'add' => '5.29',
253 ],
254 'far_contact_id' => [
255 'name' => 'far_contact_id',
256 'type' => CRM_Utils_Type::T_INT,
257 'title' => ts('Contact ID (Far side)'),
258 'description' => ts('id of the second contact'),
259 'required' => TRUE,
260 'where' => 'civicrm_relationship_cache.far_contact_id',
261 'table_name' => 'civicrm_relationship_cache',
262 'entity' => 'RelationshipCache',
263 'bao' => 'CRM_Contact_BAO_RelationshipCache',
264 'localizable' => 0,
265 'FKClassName' => 'CRM_Contact_DAO_Contact',
266 'html' => [
267 'type' => 'EntityRef',
268 ],
269 'add' => '5.29',
270 ],
271 'far_relation' => [
272 'name' => 'far_relation',
273 'type' => CRM_Utils_Type::T_STRING,
274 'title' => ts('Relationship Name (Near side)'),
275 'description' => ts('name for relationship of far_contact to near_contact.'),
276 'maxlength' => 64,
277 'size' => CRM_Utils_Type::BIG,
278 'where' => 'civicrm_relationship_cache.far_relation',
279 'table_name' => 'civicrm_relationship_cache',
280 'entity' => 'RelationshipCache',
281 'bao' => 'CRM_Contact_BAO_RelationshipCache',
282 'localizable' => 0,
283 'pseudoconstant' => [
284 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
285 ],
286 'add' => '5.29',
287 ],
288 'is_active' => [
289 'name' => 'is_active',
290 'type' => CRM_Utils_Type::T_BOOLEAN,
291 'title' => ts('Relationship Is Active'),
292 'description' => ts('is the relationship active ?'),
293 'where' => 'civicrm_relationship_cache.is_active',
294 'default' => '1',
295 'table_name' => 'civicrm_relationship_cache',
296 'entity' => 'RelationshipCache',
297 'bao' => 'CRM_Contact_BAO_RelationshipCache',
298 'localizable' => 0,
299 'html' => [
300 'type' => 'CheckBox',
301 ],
302 'add' => '5.29',
303 ],
304 'relationship_start_date' => [
305 'name' => 'start_date',
306 'type' => CRM_Utils_Type::T_DATE,
307 'title' => ts('Relationship Start Date'),
308 'description' => ts('date when the relationship started'),
309 'where' => 'civicrm_relationship_cache.start_date',
310 'table_name' => 'civicrm_relationship_cache',
311 'entity' => 'RelationshipCache',
312 'bao' => 'CRM_Contact_BAO_RelationshipCache',
313 'localizable' => 0,
314 'html' => [
315 'type' => 'Select Date',
316 'formatType' => 'activityDate',
317 ],
318 'add' => '5.29',
319 ],
320 'relationship_end_date' => [
321 'name' => 'end_date',
322 'type' => CRM_Utils_Type::T_DATE,
323 'title' => ts('Relationship End Date'),
324 'description' => ts('date when the relationship ended'),
325 'where' => 'civicrm_relationship_cache.end_date',
326 'table_name' => 'civicrm_relationship_cache',
327 'entity' => 'RelationshipCache',
328 'bao' => 'CRM_Contact_BAO_RelationshipCache',
329 'localizable' => 0,
330 'html' => [
331 'type' => 'Select Date',
332 'formatType' => 'activityDate',
333 ],
334 'add' => '5.29',
335 ],
336 ];
337 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
338 }
339 return Civi::$statics[__CLASS__]['fields'];
340 }
341
342 /**
343 * Return a mapping from field-name to the corresponding key (as used in fields()).
344 *
345 * @return array
346 * Array(string $name => string $uniqueName).
347 */
348 public static function &fieldKeys() {
349 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
350 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
351 }
352 return Civi::$statics[__CLASS__]['fieldKeys'];
353 }
354
355 /**
356 * Returns the names of this table
357 *
358 * @return string
359 */
360 public static function getTableName() {
361 return self::$_tableName;
362 }
363
364 /**
365 * Returns if this table needs to be logged
366 *
367 * @return bool
368 */
369 public function getLog() {
370 return self::$_log;
371 }
372
373 /**
374 * Returns the list of fields that can be imported
375 *
376 * @param bool $prefix
377 *
378 * @return array
379 */
380 public static function &import($prefix = FALSE) {
381 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship_cache', $prefix, []);
382 return $r;
383 }
384
385 /**
386 * Returns the list of fields that can be exported
387 *
388 * @param bool $prefix
389 *
390 * @return array
391 */
392 public static function &export($prefix = FALSE) {
393 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship_cache', $prefix, []);
394 return $r;
395 }
396
397 /**
398 * Returns the list of indices
399 *
400 * @param bool $localize
401 *
402 * @return array
403 */
404 public static function indices($localize = TRUE) {
405 $indices = [
406 'UI_relationship' => [
407 'name' => 'UI_relationship',
408 'field' => [
409 0 => 'relationship_id',
410 1 => 'orientation',
411 ],
412 'localizable' => FALSE,
413 'unique' => TRUE,
414 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation',
415 ],
416 'index_nearid_nearrelation' => [
417 'name' => 'index_nearid_nearrelation',
418 'field' => [
419 0 => 'near_contact_id',
420 1 => 'near_relation',
421 ],
422 'localizable' => FALSE,
423 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation',
424 ],
425 'index_nearid_farrelation' => [
426 'name' => 'index_nearid_farrelation',
427 'field' => [
428 0 => 'near_contact_id',
429 1 => 'far_relation',
430 ],
431 'localizable' => FALSE,
432 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation',
433 ],
434 'index_near_relation' => [
435 'name' => 'index_near_relation',
436 'field' => [
437 0 => 'near_relation',
438 ],
439 'localizable' => FALSE,
440 'sig' => 'civicrm_relationship_cache::0::near_relation',
441 ],
442 ];
443 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
444 }
445
446 }