Merge pull request #13134 from agileware/CIVICRM-1006
[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 */
22 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 */
c3fc2621
CW
29 static $_log = TRUE;
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
TO
123 if (!isset(Civi::$statics[__CLASS__]['links'])) {
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,
522a26c9 148 'table_name' => 'civicrm_relationship',
149 'entity' => 'Relationship',
150 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 151 'localizable' => 0,
c3fc2621
CW
152 ],
153 'contact_id_a' => [
e501603b
TO
154 'name' => 'contact_id_a',
155 'type' => CRM_Utils_Type::T_INT,
c3fc2621 156 'title' => ts('Contact A'),
215b423e 157 'description' => ts('id of the first contact'),
c3fc2621 158 'required' => TRUE,
522a26c9 159 'table_name' => 'civicrm_relationship',
160 'entity' => 'Relationship',
161 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 162 'localizable' => 0,
e501603b 163 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
164 ],
165 'contact_id_b' => [
e501603b
TO
166 'name' => 'contact_id_b',
167 'type' => CRM_Utils_Type::T_INT,
c3fc2621 168 'title' => ts('Contact B'),
215b423e 169 'description' => ts('id of the second contact'),
c3fc2621 170 'required' => TRUE,
522a26c9 171 'table_name' => 'civicrm_relationship',
172 'entity' => 'Relationship',
173 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 174 'localizable' => 0,
e501603b 175 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621 176 'html' => [
e501603b 177 'type' => 'EntityRef',
c3fc2621
CW
178 ],
179 ],
180 'relationship_type_id' => [
e501603b
TO
181 'name' => 'relationship_type_id',
182 'type' => CRM_Utils_Type::T_INT,
c3fc2621 183 'title' => ts('Relationship Type'),
215b423e 184 'description' => ts('id of the relationship'),
c3fc2621 185 'required' => TRUE,
522a26c9 186 'table_name' => 'civicrm_relationship',
187 'entity' => 'Relationship',
188 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 189 'localizable' => 0,
e501603b 190 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
c3fc2621 191 'html' => [
e501603b 192 'type' => 'Select',
c3fc2621
CW
193 ],
194 ],
195 'start_date' => [
e501603b
TO
196 'name' => 'start_date',
197 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 198 'title' => ts('Relationship Start Date'),
215b423e 199 'description' => ts('date when the relationship started'),
522a26c9 200 'table_name' => 'civicrm_relationship',
201 'entity' => 'Relationship',
202 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 203 'localizable' => 0,
c3fc2621 204 'html' => [
e501603b 205 'type' => 'Select Date',
425d6064 206 'formatType' => 'activityDate',
c3fc2621
CW
207 ],
208 ],
209 'end_date' => [
e501603b
TO
210 'name' => 'end_date',
211 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 212 'title' => ts('Relationship End Date'),
215b423e 213 'description' => ts('date when the relationship ended'),
522a26c9 214 'table_name' => 'civicrm_relationship',
215 'entity' => 'Relationship',
216 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 217 'localizable' => 0,
c3fc2621 218 'html' => [
e501603b 219 'type' => 'Select Date',
425d6064 220 'formatType' => 'activityDate',
c3fc2621
CW
221 ],
222 ],
223 'is_active' => [
e501603b
TO
224 'name' => 'is_active',
225 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 226 'title' => ts('Relationship Is Active'),
215b423e 227 'description' => ts('is the relationship active ?'),
e501603b 228 'default' => '1',
522a26c9 229 'table_name' => 'civicrm_relationship',
230 'entity' => 'Relationship',
231 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 232 'localizable' => 0,
c3fc2621 233 'html' => [
e501603b 234 'type' => 'CheckBox',
c3fc2621
CW
235 ],
236 ],
237 'description' => [
e501603b
TO
238 'name' => 'description',
239 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 240 'title' => ts('Relationship Description'),
215b423e 241 'description' => ts('Optional verbose description for the relationship.'),
e501603b
TO
242 'maxlength' => 255,
243 'size' => CRM_Utils_Type::HUGE,
522a26c9 244 'table_name' => 'civicrm_relationship',
245 'entity' => 'Relationship',
246 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 247 'localizable' => 0,
c3fc2621 248 'html' => [
e501603b 249 'type' => 'Text',
c3fc2621
CW
250 ],
251 ],
252 'is_permission_a_b' => [
e501603b 253 'name' => 'is_permission_a_b',
f871c3a9 254 'type' => CRM_Utils_Type::T_INT,
c3fc2621 255 'title' => ts('Contact A has Permission Over Contact B'),
215b423e 256 'description' => ts('Permission that Contact A has to view/update Contact B'),
f871c3a9 257 'required' => TRUE,
45a83e42 258 'default' => '0',
522a26c9 259 'table_name' => 'civicrm_relationship',
260 'entity' => 'Relationship',
261 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 262 'localizable' => 0,
c3fc2621 263 'html' => [
f871c3a9 264 'type' => 'Radio',
c3fc2621 265 ],
f871c3a9
AS
266 'pseudoconstant' => [
267 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
268 ]
c3fc2621
CW
269 ],
270 'is_permission_b_a' => [
e501603b 271 'name' => 'is_permission_b_a',
f871c3a9 272 'type' => CRM_Utils_Type::T_INT,
c3fc2621 273 'title' => ts('Contact B has Permission Over Contact A'),
215b423e 274 'description' => ts('Permission that Contact B has to view/update Contact A'),
f871c3a9 275 'required' => TRUE,
45a83e42 276 'default' => '0',
522a26c9 277 'table_name' => 'civicrm_relationship',
278 'entity' => 'Relationship',
279 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 280 'localizable' => 0,
c3fc2621 281 'html' => [
f871c3a9 282 'type' => 'Radio',
c3fc2621 283 ],
f871c3a9
AS
284 'pseudoconstant' => [
285 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
286 ]
c3fc2621
CW
287 ],
288 'case_id' => [
e501603b
TO
289 'name' => 'case_id',
290 'type' => CRM_Utils_Type::T_INT,
c3fc2621 291 'title' => ts('Relationship Case'),
215b423e 292 'description' => ts('FK to civicrm_case'),
e501603b 293 'default' => 'NULL',
522a26c9 294 'table_name' => 'civicrm_relationship',
295 'entity' => 'Relationship',
296 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 297 'localizable' => 0,
e501603b 298 'FKClassName' => 'CRM_Case_DAO_Case',
c3fc2621
CW
299 ],
300 ];
346aaaba 301 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 302 }
346aaaba 303 return Civi::$statics[__CLASS__]['fields'];
e501603b 304 }
c3fc2621 305
e501603b 306 /**
bd8e0b14 307 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
308 *
309 * @return array
bd8e0b14 310 * Array(string $name => string $uniqueName).
e501603b 311 */
c3fc2621 312 public static function &fieldKeys() {
bd8e0b14
TO
313 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
314 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 315 }
bd8e0b14 316 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 317 }
c3fc2621 318
e501603b
TO
319 /**
320 * Returns the names of this table
321 *
322 * @return string
323 */
c3fc2621 324 public static function getTableName() {
e501603b
TO
325 return self::$_tableName;
326 }
c3fc2621 327
e501603b
TO
328 /**
329 * Returns if this table needs to be logged
330 *
c3fc2621 331 * @return bool
e501603b 332 */
c3fc2621 333 public function getLog() {
e501603b
TO
334 return self::$_log;
335 }
c3fc2621 336
e501603b
TO
337 /**
338 * Returns the list of fields that can be imported
339 *
340 * @param bool $prefix
341 *
342 * @return array
343 */
c3fc2621
CW
344 public static function &import($prefix = FALSE) {
345 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, []);
60808919 346 return $r;
e501603b 347 }
c3fc2621 348
e501603b
TO
349 /**
350 * Returns the list of fields that can be exported
351 *
352 * @param bool $prefix
353 *
354 * @return array
355 */
c3fc2621
CW
356 public static function &export($prefix = FALSE) {
357 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, []);
60808919 358 return $r;
e501603b 359 }
c3fc2621 360
e7a6b91a
AS
361 /**
362 * Returns the list of indices
c3fc2621
CW
363 *
364 * @param bool $localize
365 *
366 * @return array
e7a6b91a
AS
367 */
368 public static function indices($localize = TRUE) {
c3fc2621 369 $indices = [];
e7a6b91a
AS
370 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
371 }
c3fc2621 372
e501603b 373}