Merge pull request #23144 from colemanw/noMoreSaveButtonInApiExplorer
[civicrm-core.git] / CRM / Contact / DAO / Relationship.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contact/Relationship.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:138d23f70bbc1e8c3b1ad2d247e9a8df)
10 */
11
12 /**
13 * Database access object for the Relationship entity.
14 */
15 class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_relationship';
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 = TRUE;
39
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=[contact_id_a]&id=[id]',
47 'delete' => 'civicrm/contact/view/rel?action=delete&reset=1&cid=[contact_id_a]&id=[id]',
48 ];
49
50 /**
51 * Relationship ID
52 *
53 * @var int|string|null
54 * (SQL type: int unsigned)
55 * Note that values will be retrieved from the database as a string.
56 */
57 public $id;
58
59 /**
60 * id of the first contact
61 *
62 * @var int|string
63 * (SQL type: int unsigned)
64 * Note that values will be retrieved from the database as a string.
65 */
66 public $contact_id_a;
67
68 /**
69 * id of the second contact
70 *
71 * @var int|string
72 * (SQL type: int unsigned)
73 * Note that values will be retrieved from the database as a string.
74 */
75 public $contact_id_b;
76
77 /**
78 * Type of relationship
79 *
80 * @var int|string
81 * (SQL type: int unsigned)
82 * Note that values will be retrieved from the database as a string.
83 */
84 public $relationship_type_id;
85
86 /**
87 * date when the relationship started
88 *
89 * @var string|null
90 * (SQL type: date)
91 * Note that values will be retrieved from the database as a string.
92 */
93 public $start_date;
94
95 /**
96 * date when the relationship ended
97 *
98 * @var string|null
99 * (SQL type: date)
100 * Note that values will be retrieved from the database as a string.
101 */
102 public $end_date;
103
104 /**
105 * is the relationship active ?
106 *
107 * @var bool|string
108 * (SQL type: tinyint)
109 * Note that values will be retrieved from the database as a string.
110 */
111 public $is_active;
112
113 /**
114 * Optional verbose description for the relationship.
115 *
116 * @var string|null
117 * (SQL type: varchar(255))
118 * Note that values will be retrieved from the database as a string.
119 */
120 public $description;
121
122 /**
123 * Permission that Contact A has to view/update Contact B
124 *
125 * @var int|string
126 * (SQL type: int unsigned)
127 * Note that values will be retrieved from the database as a string.
128 */
129 public $is_permission_a_b;
130
131 /**
132 * Permission that Contact B has to view/update Contact A
133 *
134 * @var int|string
135 * (SQL type: int unsigned)
136 * Note that values will be retrieved from the database as a string.
137 */
138 public $is_permission_b_a;
139
140 /**
141 * FK to civicrm_case
142 *
143 * @var int|string|null
144 * (SQL type: int unsigned)
145 * Note that values will be retrieved from the database as a string.
146 */
147 public $case_id;
148
149 /**
150 * Relationship created date.
151 *
152 * @var string
153 * (SQL type: timestamp)
154 * Note that values will be retrieved from the database as a string.
155 */
156 public $created_date;
157
158 /**
159 * Relationship last modified.
160 *
161 * @var string
162 * (SQL type: timestamp)
163 * Note that values will be retrieved from the database as a string.
164 */
165 public $modified_date;
166
167 /**
168 * Class constructor.
169 */
170 public function __construct() {
171 $this->__table = 'civicrm_relationship';
172 parent::__construct();
173 }
174
175 /**
176 * Returns localized title of this entity.
177 *
178 * @param bool $plural
179 * Whether to return the plural version of the title.
180 */
181 public static function getEntityTitle($plural = FALSE) {
182 return $plural ? ts('Relationships') : ts('Relationship');
183 }
184
185 /**
186 * Returns foreign keys and entity references.
187 *
188 * @return array
189 * [CRM_Core_Reference_Interface]
190 */
191 public static function getReferenceColumns() {
192 if (!isset(Civi::$statics[__CLASS__]['links'])) {
193 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
194 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id_a', 'civicrm_contact', 'id');
195 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id_b', 'civicrm_contact', 'id');
196 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
197 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'case_id', 'civicrm_case', 'id');
198 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
199 }
200 return Civi::$statics[__CLASS__]['links'];
201 }
202
203 /**
204 * Returns all the column names of this table
205 *
206 * @return array
207 */
208 public static function &fields() {
209 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
210 Civi::$statics[__CLASS__]['fields'] = [
211 'id' => [
212 'name' => 'id',
213 'type' => CRM_Utils_Type::T_INT,
214 'title' => ts('Relationship ID'),
215 'description' => ts('Relationship ID'),
216 'required' => TRUE,
217 'where' => 'civicrm_relationship.id',
218 'table_name' => 'civicrm_relationship',
219 'entity' => 'Relationship',
220 'bao' => 'CRM_Contact_BAO_Relationship',
221 'localizable' => 0,
222 'html' => [
223 'type' => 'Number',
224 ],
225 'readonly' => TRUE,
226 'add' => '1.1',
227 ],
228 'contact_id_a' => [
229 'name' => 'contact_id_a',
230 'type' => CRM_Utils_Type::T_INT,
231 'title' => ts('Contact A ID'),
232 'description' => ts('id of the first contact'),
233 'required' => TRUE,
234 'where' => 'civicrm_relationship.contact_id_a',
235 'table_name' => 'civicrm_relationship',
236 'entity' => 'Relationship',
237 'bao' => 'CRM_Contact_BAO_Relationship',
238 'localizable' => 0,
239 'FKClassName' => 'CRM_Contact_DAO_Contact',
240 'html' => [
241 'label' => ts("Contact A"),
242 ],
243 'add' => '1.1',
244 ],
245 'contact_id_b' => [
246 'name' => 'contact_id_b',
247 'type' => CRM_Utils_Type::T_INT,
248 'title' => ts('Contact B ID'),
249 'description' => ts('id of the second contact'),
250 'required' => TRUE,
251 'where' => 'civicrm_relationship.contact_id_b',
252 'table_name' => 'civicrm_relationship',
253 'entity' => 'Relationship',
254 'bao' => 'CRM_Contact_BAO_Relationship',
255 'localizable' => 0,
256 'FKClassName' => 'CRM_Contact_DAO_Contact',
257 'html' => [
258 'type' => 'EntityRef',
259 'label' => ts("Contact B"),
260 ],
261 'add' => '1.1',
262 ],
263 'relationship_type_id' => [
264 'name' => 'relationship_type_id',
265 'type' => CRM_Utils_Type::T_INT,
266 'title' => ts('Relationship Type ID'),
267 'description' => ts('Type of relationship'),
268 'required' => TRUE,
269 'where' => 'civicrm_relationship.relationship_type_id',
270 'table_name' => 'civicrm_relationship',
271 'entity' => 'Relationship',
272 'bao' => 'CRM_Contact_BAO_Relationship',
273 'localizable' => 0,
274 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
275 'html' => [
276 'type' => 'Select',
277 'label' => ts("Relationship Type"),
278 ],
279 'pseudoconstant' => [
280 'table' => 'civicrm_relationship_type',
281 'keyColumn' => 'id',
282 'labelColumn' => 'label_a_b',
283 'nameColumn' => 'name_a_b',
284 ],
285 'add' => '1.1',
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.start_date',
293 'table_name' => 'civicrm_relationship',
294 'entity' => 'Relationship',
295 'bao' => 'CRM_Contact_BAO_Relationship',
296 'localizable' => 0,
297 'html' => [
298 'type' => 'Select Date',
299 'formatType' => 'activityDate',
300 ],
301 'add' => '1.1',
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.end_date',
309 'table_name' => 'civicrm_relationship',
310 'entity' => 'Relationship',
311 'bao' => 'CRM_Contact_BAO_Relationship',
312 'localizable' => 0,
313 'html' => [
314 'type' => 'Select Date',
315 'formatType' => 'activityDate',
316 ],
317 'add' => '1.1',
318 ],
319 'is_active' => [
320 'name' => 'is_active',
321 'type' => CRM_Utils_Type::T_BOOLEAN,
322 'title' => ts('Relationship Is Active'),
323 'description' => ts('is the relationship active ?'),
324 'required' => TRUE,
325 'where' => 'civicrm_relationship.is_active',
326 'default' => '1',
327 'table_name' => 'civicrm_relationship',
328 'entity' => 'Relationship',
329 'bao' => 'CRM_Contact_BAO_Relationship',
330 'localizable' => 0,
331 'html' => [
332 'type' => 'CheckBox',
333 ],
334 'add' => '1.1',
335 ],
336 'description' => [
337 'name' => 'description',
338 'type' => CRM_Utils_Type::T_STRING,
339 'title' => ts('Relationship Description'),
340 'description' => ts('Optional verbose description for the relationship.'),
341 'maxlength' => 255,
342 'size' => CRM_Utils_Type::HUGE,
343 'where' => 'civicrm_relationship.description',
344 'table_name' => 'civicrm_relationship',
345 'entity' => 'Relationship',
346 'bao' => 'CRM_Contact_BAO_Relationship',
347 'localizable' => 0,
348 'html' => [
349 'type' => 'Text',
350 ],
351 'add' => '1.5',
352 ],
353 'is_permission_a_b' => [
354 'name' => 'is_permission_a_b',
355 'type' => CRM_Utils_Type::T_INT,
356 'title' => ts('Contact A has Permission Over Contact B'),
357 'description' => ts('Permission that Contact A has to view/update Contact B'),
358 'required' => TRUE,
359 'where' => 'civicrm_relationship.is_permission_a_b',
360 'default' => '0',
361 'table_name' => 'civicrm_relationship',
362 'entity' => 'Relationship',
363 'bao' => 'CRM_Contact_BAO_Relationship',
364 'localizable' => 0,
365 'html' => [
366 'type' => 'Radio',
367 ],
368 'pseudoconstant' => [
369 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
370 ],
371 'add' => '2.1',
372 ],
373 'is_permission_b_a' => [
374 'name' => 'is_permission_b_a',
375 'type' => CRM_Utils_Type::T_INT,
376 'title' => ts('Contact B has Permission Over Contact A'),
377 'description' => ts('Permission that Contact B has to view/update Contact A'),
378 'required' => TRUE,
379 'where' => 'civicrm_relationship.is_permission_b_a',
380 'default' => '0',
381 'table_name' => 'civicrm_relationship',
382 'entity' => 'Relationship',
383 'bao' => 'CRM_Contact_BAO_Relationship',
384 'localizable' => 0,
385 'html' => [
386 'type' => 'Radio',
387 ],
388 'pseudoconstant' => [
389 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
390 ],
391 'add' => '2.1',
392 ],
393 'case_id' => [
394 'name' => 'case_id',
395 'type' => CRM_Utils_Type::T_INT,
396 'title' => ts('Case ID'),
397 'description' => ts('FK to civicrm_case'),
398 'where' => 'civicrm_relationship.case_id',
399 'default' => NULL,
400 'table_name' => 'civicrm_relationship',
401 'entity' => 'Relationship',
402 'bao' => 'CRM_Contact_BAO_Relationship',
403 'localizable' => 0,
404 'FKClassName' => 'CRM_Case_DAO_Case',
405 'component' => 'CiviCase',
406 'html' => [
407 'label' => ts("Case"),
408 ],
409 'add' => '2.2',
410 ],
411 'created_date' => [
412 'name' => 'created_date',
413 'type' => CRM_Utils_Type::T_TIMESTAMP,
414 'title' => ts('Created Date'),
415 'description' => ts('Relationship created date.'),
416 'required' => TRUE,
417 'where' => 'civicrm_relationship.created_date',
418 'default' => 'CURRENT_TIMESTAMP',
419 'table_name' => 'civicrm_relationship',
420 'entity' => 'Relationship',
421 'bao' => 'CRM_Contact_BAO_Relationship',
422 'localizable' => 0,
423 'add' => '5.47',
424 ],
425 'modified_date' => [
426 'name' => 'modified_date',
427 'type' => CRM_Utils_Type::T_TIMESTAMP,
428 'title' => ts('Relationship Modified Date'),
429 'description' => ts('Relationship last modified.'),
430 'required' => TRUE,
431 'where' => 'civicrm_relationship.modified_date',
432 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
433 'table_name' => 'civicrm_relationship',
434 'entity' => 'Relationship',
435 'bao' => 'CRM_Contact_BAO_Relationship',
436 'localizable' => 0,
437 'readonly' => TRUE,
438 'add' => '5.47',
439 ],
440 ];
441 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
442 }
443 return Civi::$statics[__CLASS__]['fields'];
444 }
445
446 /**
447 * Return a mapping from field-name to the corresponding key (as used in fields()).
448 *
449 * @return array
450 * Array(string $name => string $uniqueName).
451 */
452 public static function &fieldKeys() {
453 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
454 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
455 }
456 return Civi::$statics[__CLASS__]['fieldKeys'];
457 }
458
459 /**
460 * Returns the names of this table
461 *
462 * @return string
463 */
464 public static function getTableName() {
465 return self::$_tableName;
466 }
467
468 /**
469 * Returns if this table needs to be logged
470 *
471 * @return bool
472 */
473 public function getLog() {
474 return self::$_log;
475 }
476
477 /**
478 * Returns the list of fields that can be imported
479 *
480 * @param bool $prefix
481 *
482 * @return array
483 */
484 public static function &import($prefix = FALSE) {
485 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, []);
486 return $r;
487 }
488
489 /**
490 * Returns the list of fields that can be exported
491 *
492 * @param bool $prefix
493 *
494 * @return array
495 */
496 public static function &export($prefix = FALSE) {
497 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, []);
498 return $r;
499 }
500
501 /**
502 * Returns the list of indices
503 *
504 * @param bool $localize
505 *
506 * @return array
507 */
508 public static function indices($localize = TRUE) {
509 $indices = [];
510 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
511 }
512
513 }