curious
[civicrm-core.git] / CRM / Contact / DAO / Relationship.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
ca5cec67 5 * @copyright CiviCRM LLC https://civicrm.org/licensing
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Contact/Relationship.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
2562d09a 9 * (GenCodeChecksum:402d6e2cc8ffa3be531d291a20f59560)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Relationship entity.
f41f0342 14 */
e501603b 15class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
c3fc2621 18
e501603b 19 /**
f41f0342 20 * Static instance to hold the table name.
e501603b
TO
21 *
22 * @var string
23 */
fa45b5b9 24 public static $_tableName = 'civicrm_relationship';
c3fc2621 25
449c4e6b
CW
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-handshake-o';
32
e501603b 33 /**
f41f0342 34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 35 *
c3fc2621 36 * @var bool
e501603b 37 */
fa45b5b9 38 public static $_log = TRUE;
c3fc2621 39
c5076889
CW
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
e501603b
TO
50 /**
51 * Relationship ID
52 *
e6ca0a57 53 * @var int
e501603b
TO
54 */
55 public $id;
c3fc2621 56
e501603b
TO
57 /**
58 * id of the first contact
59 *
e6ca0a57 60 * @var int
e501603b
TO
61 */
62 public $contact_id_a;
c3fc2621 63
e501603b
TO
64 /**
65 * id of the second contact
66 *
e6ca0a57 67 * @var int
e501603b
TO
68 */
69 public $contact_id_b;
c3fc2621 70
e501603b 71 /**
1ac9bb56 72 * Type of relationship
e501603b 73 *
e6ca0a57 74 * @var int
e501603b
TO
75 */
76 public $relationship_type_id;
c3fc2621 77
e501603b
TO
78 /**
79 * date when the relationship started
80 *
81 * @var date
82 */
83 public $start_date;
c3fc2621 84
e501603b
TO
85 /**
86 * date when the relationship ended
87 *
88 * @var date
89 */
90 public $end_date;
c3fc2621 91
e501603b
TO
92 /**
93 * is the relationship active ?
94 *
e6ca0a57 95 * @var bool
e501603b
TO
96 */
97 public $is_active;
c3fc2621 98
e501603b
TO
99 /**
100 * Optional verbose description for the relationship.
101 *
102 * @var string
103 */
104 public $description;
c3fc2621 105
e501603b 106 /**
f871c3a9 107 * Permission that Contact A has to view/update Contact B
e501603b 108 *
e6ca0a57 109 * @var int
e501603b
TO
110 */
111 public $is_permission_a_b;
c3fc2621 112
e501603b 113 /**
f871c3a9 114 * Permission that Contact B has to view/update Contact A
e501603b 115 *
e6ca0a57 116 * @var int
e501603b
TO
117 */
118 public $is_permission_b_a;
c3fc2621 119
e501603b
TO
120 /**
121 * FK to civicrm_case
122 *
e6ca0a57 123 * @var int
e501603b
TO
124 */
125 public $case_id;
c3fc2621 126
e501603b 127 /**
f41f0342 128 * Class constructor.
e501603b 129 */
c3fc2621 130 public function __construct() {
e501603b
TO
131 $this->__table = 'civicrm_relationship';
132 parent::__construct();
133 }
c3fc2621 134
449c4e6b
CW
135 /**
136 * Returns localized title of this entity.
7b66c3b5
AH
137 *
138 * @param bool $plural
139 * Whether to return the plural version of the title.
449c4e6b 140 */
7b66c3b5
AH
141 public static function getEntityTitle($plural = FALSE) {
142 return $plural ? ts('Relationships') : ts('Relationship');
449c4e6b
CW
143 }
144
e501603b 145 /**
f41f0342 146 * Returns foreign keys and entity references.
e501603b
TO
147 *
148 * @return array
149 * [CRM_Core_Reference_Interface]
150 */
c3fc2621 151 public static function getReferenceColumns() {
346aaaba 152 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 153 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
154 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id_a', 'civicrm_contact', 'id');
155 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id_b', 'civicrm_contact', 'id');
156 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
157 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'case_id', 'civicrm_case', 'id');
346aaaba 158 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 159 }
346aaaba 160 return Civi::$statics[__CLASS__]['links'];
e501603b 161 }
c3fc2621 162
e501603b
TO
163 /**
164 * Returns all the column names of this table
165 *
166 * @return array
167 */
c3fc2621 168 public static function &fields() {
346aaaba 169 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
170 Civi::$statics[__CLASS__]['fields'] = [
171 'id' => [
e501603b
TO
172 'name' => 'id',
173 'type' => CRM_Utils_Type::T_INT,
c3fc2621 174 'title' => ts('Relationship ID'),
215b423e 175 'description' => ts('Relationship ID'),
c3fc2621 176 'required' => TRUE,
a36434b9 177 'where' => 'civicrm_relationship.id',
522a26c9 178 'table_name' => 'civicrm_relationship',
179 'entity' => 'Relationship',
180 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 181 'localizable' => 0,
2cbbebe8
A
182 'html' => [
183 'type' => 'Number',
184 ],
1fe423d6 185 'readonly' => TRUE,
a9d0587b 186 'add' => '1.1',
c3fc2621
CW
187 ],
188 'contact_id_a' => [
e501603b
TO
189 'name' => 'contact_id_a',
190 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 191 'title' => ts('Contact A ID'),
215b423e 192 'description' => ts('id of the first contact'),
c3fc2621 193 'required' => TRUE,
a36434b9 194 'where' => 'civicrm_relationship.contact_id_a',
522a26c9 195 'table_name' => 'civicrm_relationship',
196 'entity' => 'Relationship',
197 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 198 'localizable' => 0,
e501603b 199 'FKClassName' => 'CRM_Contact_DAO_Contact',
2cbbebe8
A
200 'html' => [
201 'label' => ts("Contact A"),
202 ],
a9d0587b 203 'add' => '1.1',
c3fc2621
CW
204 ],
205 'contact_id_b' => [
e501603b
TO
206 'name' => 'contact_id_b',
207 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 208 'title' => ts('Contact B ID'),
215b423e 209 'description' => ts('id of the second contact'),
c3fc2621 210 'required' => TRUE,
a36434b9 211 'where' => 'civicrm_relationship.contact_id_b',
522a26c9 212 'table_name' => 'civicrm_relationship',
213 'entity' => 'Relationship',
214 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 215 'localizable' => 0,
e501603b 216 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621 217 'html' => [
e501603b 218 'type' => 'EntityRef',
2cbbebe8 219 'label' => ts("Contact B"),
c3fc2621 220 ],
a9d0587b 221 'add' => '1.1',
c3fc2621
CW
222 ],
223 'relationship_type_id' => [
e501603b
TO
224 'name' => 'relationship_type_id',
225 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 226 'title' => ts('Relationship Type ID'),
1ac9bb56 227 'description' => ts('Type of relationship'),
c3fc2621 228 'required' => TRUE,
a36434b9 229 'where' => 'civicrm_relationship.relationship_type_id',
522a26c9 230 'table_name' => 'civicrm_relationship',
231 'entity' => 'Relationship',
232 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 233 'localizable' => 0,
e501603b 234 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
c3fc2621 235 'html' => [
e501603b 236 'type' => 'Select',
2cbbebe8 237 'label' => ts("Relationship Type"),
c3fc2621 238 ],
1ac9bb56
CW
239 'pseudoconstant' => [
240 'table' => 'civicrm_relationship_type',
241 'keyColumn' => 'id',
242 'labelColumn' => 'label_a_b',
243 'nameColumn' => 'name_a_b',
244 ],
a9d0587b 245 'add' => '1.1',
c3fc2621 246 ],
cc1b27ee 247 'relationship_start_date' => [
e501603b
TO
248 'name' => 'start_date',
249 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 250 'title' => ts('Relationship Start Date'),
215b423e 251 'description' => ts('date when the relationship started'),
a36434b9 252 'where' => 'civicrm_relationship.start_date',
522a26c9 253 'table_name' => 'civicrm_relationship',
254 'entity' => 'Relationship',
255 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 256 'localizable' => 0,
c3fc2621 257 'html' => [
e501603b 258 'type' => 'Select Date',
425d6064 259 'formatType' => 'activityDate',
c3fc2621 260 ],
a9d0587b 261 'add' => '1.1',
c3fc2621 262 ],
cc1b27ee 263 'relationship_end_date' => [
e501603b
TO
264 'name' => 'end_date',
265 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 266 'title' => ts('Relationship End Date'),
215b423e 267 'description' => ts('date when the relationship ended'),
a36434b9 268 'where' => 'civicrm_relationship.end_date',
522a26c9 269 'table_name' => 'civicrm_relationship',
270 'entity' => 'Relationship',
271 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 272 'localizable' => 0,
c3fc2621 273 'html' => [
e501603b 274 'type' => 'Select Date',
425d6064 275 'formatType' => 'activityDate',
c3fc2621 276 ],
a9d0587b 277 'add' => '1.1',
c3fc2621
CW
278 ],
279 'is_active' => [
e501603b
TO
280 'name' => 'is_active',
281 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 282 'title' => ts('Relationship Is Active'),
215b423e 283 'description' => ts('is the relationship active ?'),
a36434b9 284 'where' => 'civicrm_relationship.is_active',
e501603b 285 'default' => '1',
522a26c9 286 'table_name' => 'civicrm_relationship',
287 'entity' => 'Relationship',
288 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 289 'localizable' => 0,
c3fc2621 290 'html' => [
e501603b 291 'type' => 'CheckBox',
c3fc2621 292 ],
a9d0587b 293 'add' => '1.1',
c3fc2621
CW
294 ],
295 'description' => [
e501603b
TO
296 'name' => 'description',
297 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 298 'title' => ts('Relationship Description'),
215b423e 299 'description' => ts('Optional verbose description for the relationship.'),
e501603b
TO
300 'maxlength' => 255,
301 'size' => CRM_Utils_Type::HUGE,
a36434b9 302 'where' => 'civicrm_relationship.description',
522a26c9 303 'table_name' => 'civicrm_relationship',
304 'entity' => 'Relationship',
305 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 306 'localizable' => 0,
c3fc2621 307 'html' => [
e501603b 308 'type' => 'Text',
c3fc2621 309 ],
a9d0587b 310 'add' => '1.5',
c3fc2621
CW
311 ],
312 'is_permission_a_b' => [
e501603b 313 'name' => 'is_permission_a_b',
f871c3a9 314 'type' => CRM_Utils_Type::T_INT,
c3fc2621 315 'title' => ts('Contact A has Permission Over Contact B'),
215b423e 316 'description' => ts('Permission that Contact A has to view/update Contact B'),
f871c3a9 317 'required' => TRUE,
a36434b9 318 'where' => 'civicrm_relationship.is_permission_a_b',
45a83e42 319 'default' => '0',
522a26c9 320 'table_name' => 'civicrm_relationship',
321 'entity' => 'Relationship',
322 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 323 'localizable' => 0,
c3fc2621 324 'html' => [
f871c3a9 325 'type' => 'Radio',
c3fc2621 326 ],
f871c3a9
AS
327 'pseudoconstant' => [
328 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
e6ca0a57 329 ],
a9d0587b 330 'add' => '2.1',
c3fc2621
CW
331 ],
332 'is_permission_b_a' => [
e501603b 333 'name' => 'is_permission_b_a',
f871c3a9 334 'type' => CRM_Utils_Type::T_INT,
c3fc2621 335 'title' => ts('Contact B has Permission Over Contact A'),
215b423e 336 'description' => ts('Permission that Contact B has to view/update Contact A'),
f871c3a9 337 'required' => TRUE,
a36434b9 338 'where' => 'civicrm_relationship.is_permission_b_a',
45a83e42 339 'default' => '0',
522a26c9 340 'table_name' => 'civicrm_relationship',
341 'entity' => 'Relationship',
342 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 343 'localizable' => 0,
c3fc2621 344 'html' => [
f871c3a9 345 'type' => 'Radio',
c3fc2621 346 ],
f871c3a9
AS
347 'pseudoconstant' => [
348 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
e6ca0a57 349 ],
a9d0587b 350 'add' => '2.1',
c3fc2621
CW
351 ],
352 'case_id' => [
e501603b
TO
353 'name' => 'case_id',
354 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 355 'title' => ts('Case ID'),
215b423e 356 'description' => ts('FK to civicrm_case'),
a36434b9 357 'where' => 'civicrm_relationship.case_id',
5fb0de1f 358 'default' => NULL,
522a26c9 359 'table_name' => 'civicrm_relationship',
360 'entity' => 'Relationship',
361 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 362 'localizable' => 0,
e501603b 363 'FKClassName' => 'CRM_Case_DAO_Case',
2cbbebe8
A
364 'html' => [
365 'label' => ts("Case"),
366 ],
a9d0587b 367 'add' => '2.2',
c3fc2621
CW
368 ],
369 ];
346aaaba 370 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 371 }
346aaaba 372 return Civi::$statics[__CLASS__]['fields'];
e501603b 373 }
c3fc2621 374
e501603b 375 /**
bd8e0b14 376 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
377 *
378 * @return array
bd8e0b14 379 * Array(string $name => string $uniqueName).
e501603b 380 */
c3fc2621 381 public static function &fieldKeys() {
bd8e0b14
TO
382 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
383 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 384 }
bd8e0b14 385 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 386 }
c3fc2621 387
e501603b
TO
388 /**
389 * Returns the names of this table
390 *
391 * @return string
392 */
c3fc2621 393 public static function getTableName() {
e501603b
TO
394 return self::$_tableName;
395 }
c3fc2621 396
e501603b
TO
397 /**
398 * Returns if this table needs to be logged
399 *
c3fc2621 400 * @return bool
e501603b 401 */
c3fc2621 402 public function getLog() {
e501603b
TO
403 return self::$_log;
404 }
c3fc2621 405
e501603b
TO
406 /**
407 * Returns the list of fields that can be imported
408 *
409 * @param bool $prefix
410 *
411 * @return array
412 */
c3fc2621
CW
413 public static function &import($prefix = FALSE) {
414 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, []);
60808919 415 return $r;
e501603b 416 }
c3fc2621 417
e501603b
TO
418 /**
419 * Returns the list of fields that can be exported
420 *
421 * @param bool $prefix
422 *
423 * @return array
424 */
c3fc2621
CW
425 public static function &export($prefix = FALSE) {
426 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, []);
60808919 427 return $r;
e501603b 428 }
c3fc2621 429
e7a6b91a
AS
430 /**
431 * Returns the list of indices
c3fc2621
CW
432 *
433 * @param bool $localize
434 *
435 * @return array
e7a6b91a
AS
436 */
437 public static function indices($localize = TRUE) {
c3fc2621 438 $indices = [];
e7a6b91a
AS
439 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
440 }
c3fc2621 441
e501603b 442}