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