DAOs with singular/plural options for entity titles
[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
7b66c3b5 9 * (GenCodeChecksum:7fed0ad7c2ed2b072582b55afdb6469f)
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
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
TO
61 /**
62 * id of the relationship
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,
a9d0587b 172 'add' => '1.1',
c3fc2621
CW
173 ],
174 'contact_id_a' => [
e501603b
TO
175 'name' => 'contact_id_a',
176 'type' => CRM_Utils_Type::T_INT,
c3fc2621 177 'title' => ts('Contact A'),
215b423e 178 'description' => ts('id of the first contact'),
c3fc2621 179 'required' => TRUE,
a36434b9 180 'where' => 'civicrm_relationship.contact_id_a',
522a26c9 181 'table_name' => 'civicrm_relationship',
182 'entity' => 'Relationship',
183 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 184 'localizable' => 0,
e501603b 185 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 186 'add' => '1.1',
c3fc2621
CW
187 ],
188 'contact_id_b' => [
e501603b
TO
189 'name' => 'contact_id_b',
190 'type' => CRM_Utils_Type::T_INT,
c3fc2621 191 'title' => ts('Contact B'),
215b423e 192 'description' => ts('id of the second contact'),
c3fc2621 193 'required' => TRUE,
a36434b9 194 'where' => 'civicrm_relationship.contact_id_b',
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',
c3fc2621 200 'html' => [
e501603b 201 'type' => 'EntityRef',
c3fc2621 202 ],
a9d0587b 203 'add' => '1.1',
c3fc2621
CW
204 ],
205 'relationship_type_id' => [
e501603b
TO
206 'name' => 'relationship_type_id',
207 'type' => CRM_Utils_Type::T_INT,
c3fc2621 208 'title' => ts('Relationship Type'),
215b423e 209 'description' => ts('id of the relationship'),
c3fc2621 210 'required' => TRUE,
a36434b9 211 'where' => 'civicrm_relationship.relationship_type_id',
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_RelationshipType',
c3fc2621 217 'html' => [
e501603b 218 'type' => 'Select',
c3fc2621 219 ],
a9d0587b 220 'add' => '1.1',
c3fc2621 221 ],
cc1b27ee 222 'relationship_start_date' => [
e501603b
TO
223 'name' => 'start_date',
224 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 225 'title' => ts('Relationship Start Date'),
215b423e 226 'description' => ts('date when the relationship started'),
a36434b9 227 'where' => 'civicrm_relationship.start_date',
522a26c9 228 'table_name' => 'civicrm_relationship',
229 'entity' => 'Relationship',
230 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 231 'localizable' => 0,
c3fc2621 232 'html' => [
e501603b 233 'type' => 'Select Date',
425d6064 234 'formatType' => 'activityDate',
c3fc2621 235 ],
a9d0587b 236 'add' => '1.1',
c3fc2621 237 ],
cc1b27ee 238 'relationship_end_date' => [
e501603b
TO
239 'name' => 'end_date',
240 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 241 'title' => ts('Relationship End Date'),
215b423e 242 'description' => ts('date when the relationship ended'),
a36434b9 243 'where' => 'civicrm_relationship.end_date',
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' => 'Select Date',
425d6064 250 'formatType' => 'activityDate',
c3fc2621 251 ],
a9d0587b 252 'add' => '1.1',
c3fc2621
CW
253 ],
254 'is_active' => [
e501603b
TO
255 'name' => 'is_active',
256 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 257 'title' => ts('Relationship Is Active'),
215b423e 258 'description' => ts('is the relationship active ?'),
a36434b9 259 'where' => 'civicrm_relationship.is_active',
e501603b 260 'default' => '1',
522a26c9 261 'table_name' => 'civicrm_relationship',
262 'entity' => 'Relationship',
263 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 264 'localizable' => 0,
c3fc2621 265 'html' => [
e501603b 266 'type' => 'CheckBox',
c3fc2621 267 ],
a9d0587b 268 'add' => '1.1',
c3fc2621
CW
269 ],
270 'description' => [
e501603b
TO
271 'name' => 'description',
272 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 273 'title' => ts('Relationship Description'),
215b423e 274 'description' => ts('Optional verbose description for the relationship.'),
e501603b
TO
275 'maxlength' => 255,
276 'size' => CRM_Utils_Type::HUGE,
a36434b9 277 'where' => 'civicrm_relationship.description',
522a26c9 278 'table_name' => 'civicrm_relationship',
279 'entity' => 'Relationship',
280 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 281 'localizable' => 0,
c3fc2621 282 'html' => [
e501603b 283 'type' => 'Text',
c3fc2621 284 ],
a9d0587b 285 'add' => '1.5',
c3fc2621
CW
286 ],
287 'is_permission_a_b' => [
e501603b 288 'name' => 'is_permission_a_b',
f871c3a9 289 'type' => CRM_Utils_Type::T_INT,
c3fc2621 290 'title' => ts('Contact A has Permission Over Contact B'),
215b423e 291 'description' => ts('Permission that Contact A has to view/update Contact B'),
f871c3a9 292 'required' => TRUE,
a36434b9 293 'where' => 'civicrm_relationship.is_permission_a_b',
45a83e42 294 'default' => '0',
522a26c9 295 'table_name' => 'civicrm_relationship',
296 'entity' => 'Relationship',
297 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 298 'localizable' => 0,
c3fc2621 299 'html' => [
f871c3a9 300 'type' => 'Radio',
c3fc2621 301 ],
f871c3a9
AS
302 'pseudoconstant' => [
303 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
e6ca0a57 304 ],
a9d0587b 305 'add' => '2.1',
c3fc2621
CW
306 ],
307 'is_permission_b_a' => [
e501603b 308 'name' => 'is_permission_b_a',
f871c3a9 309 'type' => CRM_Utils_Type::T_INT,
c3fc2621 310 'title' => ts('Contact B has Permission Over Contact A'),
215b423e 311 'description' => ts('Permission that Contact B has to view/update Contact A'),
f871c3a9 312 'required' => TRUE,
a36434b9 313 'where' => 'civicrm_relationship.is_permission_b_a',
45a83e42 314 'default' => '0',
522a26c9 315 'table_name' => 'civicrm_relationship',
316 'entity' => 'Relationship',
317 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 318 'localizable' => 0,
c3fc2621 319 'html' => [
f871c3a9 320 'type' => 'Radio',
c3fc2621 321 ],
f871c3a9
AS
322 'pseudoconstant' => [
323 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
e6ca0a57 324 ],
a9d0587b 325 'add' => '2.1',
c3fc2621
CW
326 ],
327 'case_id' => [
e501603b
TO
328 'name' => 'case_id',
329 'type' => CRM_Utils_Type::T_INT,
c3fc2621 330 'title' => ts('Relationship Case'),
215b423e 331 'description' => ts('FK to civicrm_case'),
a36434b9 332 'where' => 'civicrm_relationship.case_id',
e501603b 333 'default' => 'NULL',
522a26c9 334 'table_name' => 'civicrm_relationship',
335 'entity' => 'Relationship',
336 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 337 'localizable' => 0,
e501603b 338 'FKClassName' => 'CRM_Case_DAO_Case',
a9d0587b 339 'add' => '2.2',
c3fc2621
CW
340 ],
341 ];
346aaaba 342 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 343 }
346aaaba 344 return Civi::$statics[__CLASS__]['fields'];
e501603b 345 }
c3fc2621 346
e501603b 347 /**
bd8e0b14 348 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
349 *
350 * @return array
bd8e0b14 351 * Array(string $name => string $uniqueName).
e501603b 352 */
c3fc2621 353 public static function &fieldKeys() {
bd8e0b14
TO
354 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
355 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 356 }
bd8e0b14 357 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 358 }
c3fc2621 359
e501603b
TO
360 /**
361 * Returns the names of this table
362 *
363 * @return string
364 */
c3fc2621 365 public static function getTableName() {
e501603b
TO
366 return self::$_tableName;
367 }
c3fc2621 368
e501603b
TO
369 /**
370 * Returns if this table needs to be logged
371 *
c3fc2621 372 * @return bool
e501603b 373 */
c3fc2621 374 public function getLog() {
e501603b
TO
375 return self::$_log;
376 }
c3fc2621 377
e501603b
TO
378 /**
379 * Returns the list of fields that can be imported
380 *
381 * @param bool $prefix
382 *
383 * @return array
384 */
c3fc2621
CW
385 public static function &import($prefix = FALSE) {
386 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, []);
60808919 387 return $r;
e501603b 388 }
c3fc2621 389
e501603b
TO
390 /**
391 * Returns the list of fields that can be exported
392 *
393 * @param bool $prefix
394 *
395 * @return array
396 */
c3fc2621
CW
397 public static function &export($prefix = FALSE) {
398 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, []);
60808919 399 return $r;
e501603b 400 }
c3fc2621 401
e7a6b91a
AS
402 /**
403 * Returns the list of indices
c3fc2621
CW
404 *
405 * @param bool $localize
406 *
407 * @return array
e7a6b91a
AS
408 */
409 public static function indices($localize = TRUE) {
c3fc2621 410 $indices = [];
e7a6b91a
AS
411 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
412 }
c3fc2621 413
e501603b 414}