Merge pull request #17866 from colemanw/customFix
[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:6a586a5a5550a64db4c9907387c1411d)
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 'add' => '5.29',
211 ],
212 'near_contact_id' => [
213 'name' => 'near_contact_id',
214 'type' => CRM_Utils_Type::T_INT,
215 'title' => ts('Contact ID (Near side)'),
216 'description' => ts('id of the first contact'),
217 'required' => TRUE,
218 'where' => 'civicrm_relationship_cache.near_contact_id',
219 'table_name' => 'civicrm_relationship_cache',
220 'entity' => 'RelationshipCache',
221 'bao' => 'CRM_Contact_BAO_RelationshipCache',
222 'localizable' => 0,
223 'FKClassName' => 'CRM_Contact_DAO_Contact',
224 'add' => '5.29',
225 ],
226 'near_relation' => [
227 'name' => 'near_relation',
228 'type' => CRM_Utils_Type::T_STRING,
229 'title' => ts('Relationship Name (Near side)'),
230 'description' => ts('name for relationship of near_contact to far_contact.'),
231 'maxlength' => 64,
232 'size' => CRM_Utils_Type::BIG,
233 'where' => 'civicrm_relationship_cache.near_relation',
234 'table_name' => 'civicrm_relationship_cache',
235 'entity' => 'RelationshipCache',
236 'bao' => 'CRM_Contact_BAO_RelationshipCache',
237 'localizable' => 0,
238 'add' => '5.29',
239 ],
240 'far_contact_id' => [
241 'name' => 'far_contact_id',
242 'type' => CRM_Utils_Type::T_INT,
243 'title' => ts('Contact ID (Far side)'),
244 'description' => ts('id of the second contact'),
245 'required' => TRUE,
246 'where' => 'civicrm_relationship_cache.far_contact_id',
247 'table_name' => 'civicrm_relationship_cache',
248 'entity' => 'RelationshipCache',
249 'bao' => 'CRM_Contact_BAO_RelationshipCache',
250 'localizable' => 0,
251 'FKClassName' => 'CRM_Contact_DAO_Contact',
252 'html' => [
253 'type' => 'EntityRef',
254 ],
255 'add' => '5.29',
256 ],
257 'far_relation' => [
258 'name' => 'far_relation',
259 'type' => CRM_Utils_Type::T_STRING,
260 'title' => ts('Relationship Name (Near side)'),
261 'description' => ts('name for relationship of far_contact to near_contact.'),
262 'maxlength' => 64,
263 'size' => CRM_Utils_Type::BIG,
264 'where' => 'civicrm_relationship_cache.far_relation',
265 'table_name' => 'civicrm_relationship_cache',
266 'entity' => 'RelationshipCache',
267 'bao' => 'CRM_Contact_BAO_RelationshipCache',
268 'localizable' => 0,
269 'add' => '5.29',
270 ],
271 'is_active' => [
272 'name' => 'is_active',
273 'type' => CRM_Utils_Type::T_BOOLEAN,
274 'title' => ts('Relationship Is Active'),
275 'description' => ts('is the relationship active ?'),
276 'where' => 'civicrm_relationship_cache.is_active',
277 'default' => '1',
278 'table_name' => 'civicrm_relationship_cache',
279 'entity' => 'RelationshipCache',
280 'bao' => 'CRM_Contact_BAO_RelationshipCache',
281 'localizable' => 0,
282 'html' => [
283 'type' => 'CheckBox',
284 ],
285 'add' => '5.29',
286 ],
287 'relationship_start_date' => [
288 'name' => 'start_date',
289 'type' => CRM_Utils_Type::T_DATE,
290 'title' => ts('Relationship Start Date'),
291 'description' => ts('date when the relationship started'),
292 'where' => 'civicrm_relationship_cache.start_date',
293 'table_name' => 'civicrm_relationship_cache',
294 'entity' => 'RelationshipCache',
295 'bao' => 'CRM_Contact_BAO_RelationshipCache',
296 'localizable' => 0,
297 'html' => [
298 'type' => 'Select Date',
299 'formatType' => 'activityDate',
300 ],
301 'add' => '5.29',
302 ],
303 'relationship_end_date' => [
304 'name' => 'end_date',
305 'type' => CRM_Utils_Type::T_DATE,
306 'title' => ts('Relationship End Date'),
307 'description' => ts('date when the relationship ended'),
308 'where' => 'civicrm_relationship_cache.end_date',
309 'table_name' => 'civicrm_relationship_cache',
310 'entity' => 'RelationshipCache',
311 'bao' => 'CRM_Contact_BAO_RelationshipCache',
312 'localizable' => 0,
313 'html' => [
314 'type' => 'Select Date',
315 'formatType' => 'activityDate',
316 ],
317 'add' => '5.29',
318 ],
319 ];
320 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
321 }
322 return Civi::$statics[__CLASS__]['fields'];
323 }
324
325 /**
326 * Return a mapping from field-name to the corresponding key (as used in fields()).
327 *
328 * @return array
329 * Array(string $name => string $uniqueName).
330 */
331 public static function &fieldKeys() {
332 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
333 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
334 }
335 return Civi::$statics[__CLASS__]['fieldKeys'];
336 }
337
338 /**
339 * Returns the names of this table
340 *
341 * @return string
342 */
343 public static function getTableName() {
344 return self::$_tableName;
345 }
346
347 /**
348 * Returns if this table needs to be logged
349 *
350 * @return bool
351 */
352 public function getLog() {
353 return self::$_log;
354 }
355
356 /**
357 * Returns the list of fields that can be imported
358 *
359 * @param bool $prefix
360 *
361 * @return array
362 */
363 public static function &import($prefix = FALSE) {
364 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship_cache', $prefix, []);
365 return $r;
366 }
367
368 /**
369 * Returns the list of fields that can be exported
370 *
371 * @param bool $prefix
372 *
373 * @return array
374 */
375 public static function &export($prefix = FALSE) {
376 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship_cache', $prefix, []);
377 return $r;
378 }
379
380 /**
381 * Returns the list of indices
382 *
383 * @param bool $localize
384 *
385 * @return array
386 */
387 public static function indices($localize = TRUE) {
388 $indices = [
389 'UI_relationship' => [
390 'name' => 'UI_relationship',
391 'field' => [
392 0 => 'relationship_id',
393 1 => 'orientation',
394 ],
395 'localizable' => FALSE,
396 'unique' => TRUE,
397 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation',
398 ],
399 'index_nearid_nearrelation' => [
400 'name' => 'index_nearid_nearrelation',
401 'field' => [
402 0 => 'near_contact_id',
403 1 => 'near_relation',
404 ],
405 'localizable' => FALSE,
406 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation',
407 ],
408 'index_nearid_farrelation' => [
409 'name' => 'index_nearid_farrelation',
410 'field' => [
411 0 => 'near_contact_id',
412 1 => 'far_relation',
413 ],
414 'localizable' => FALSE,
415 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation',
416 ],
417 'index_near_relation' => [
418 'name' => 'index_near_relation',
419 'field' => [
420 0 => 'near_relation',
421 ],
422 'localizable' => FALSE,
423 'sig' => 'civicrm_relationship_cache::0::near_relation',
424 ],
425 ];
426 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
427 }
428
429 }