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