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