Merge pull request #23144 from colemanw/noMoreSaveButtonInApiExplorer
[civicrm-core.git] / CRM / Contact / DAO / RelationshipType.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/RelationshipType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
c1e814c7 9 * (GenCodeChecksum:f420b1007ffa4e74cd3e23e34133f170)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the RelationshipType entity.
f41f0342 14 */
e501603b 15class CRM_Contact_DAO_RelationshipType 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_type';
c3fc2621 25
e501603b 26 /**
f41f0342 27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 28 *
c3fc2621 29 * @var bool
e501603b 30 */
fa45b5b9 31 public static $_log = TRUE;
c3fc2621 32
e501603b
TO
33 /**
34 * Primary key
35 *
28979d65
CW
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
e501603b
TO
39 */
40 public $id;
c3fc2621 41
e501603b
TO
42 /**
43 * name for relationship of contact_a to contact_b.
44 *
28979d65
CW
45 * @var string|null
46 * (SQL type: varchar(64))
47 * Note that values will be retrieved from the database as a string.
e501603b
TO
48 */
49 public $name_a_b;
c3fc2621 50
e501603b
TO
51 /**
52 * label for relationship of contact_a to contact_b.
53 *
28979d65
CW
54 * @var string|null
55 * (SQL type: varchar(64))
56 * Note that values will be retrieved from the database as a string.
e501603b
TO
57 */
58 public $label_a_b;
c3fc2621 59
e501603b
TO
60 /**
61 * Optional name for relationship of contact_b to contact_a.
62 *
28979d65
CW
63 * @var string|null
64 * (SQL type: varchar(64))
65 * Note that values will be retrieved from the database as a string.
e501603b
TO
66 */
67 public $name_b_a;
c3fc2621 68
e501603b
TO
69 /**
70 * Optional label for relationship of contact_b to contact_a.
71 *
28979d65
CW
72 * @var string|null
73 * (SQL type: varchar(64))
74 * Note that values will be retrieved from the database as a string.
e501603b
TO
75 */
76 public $label_b_a;
c3fc2621 77
e501603b
TO
78 /**
79 * Optional verbose description of the relationship type.
80 *
28979d65
CW
81 * @var string|null
82 * (SQL type: varchar(255))
83 * Note that values will be retrieved from the database as a string.
e501603b
TO
84 */
85 public $description;
c3fc2621 86
e501603b
TO
87 /**
88 * If defined, contact_a in a relationship of this type must be a specific contact_type.
89 *
28979d65
CW
90 * @var string|null
91 * (SQL type: varchar(12))
92 * Note that values will be retrieved from the database as a string.
e501603b
TO
93 */
94 public $contact_type_a;
c3fc2621 95
e501603b
TO
96 /**
97 * If defined, contact_b in a relationship of this type must be a specific contact_type.
98 *
28979d65
CW
99 * @var string|null
100 * (SQL type: varchar(12))
101 * Note that values will be retrieved from the database as a string.
e501603b
TO
102 */
103 public $contact_type_b;
c3fc2621 104
e501603b
TO
105 /**
106 * If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.
107 *
28979d65
CW
108 * @var string|null
109 * (SQL type: varchar(64))
110 * Note that values will be retrieved from the database as a string.
e501603b
TO
111 */
112 public $contact_sub_type_a;
c3fc2621 113
e501603b
TO
114 /**
115 * If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.
116 *
28979d65
CW
117 * @var string|null
118 * (SQL type: varchar(64))
119 * Note that values will be retrieved from the database as a string.
e501603b
TO
120 */
121 public $contact_sub_type_b;
c3fc2621 122
e501603b
TO
123 /**
124 * Is this relationship type a predefined system type (can not be changed or de-activated)?
125 *
c1e814c7 126 * @var bool|string
28979d65
CW
127 * (SQL type: tinyint)
128 * Note that values will be retrieved from the database as a string.
e501603b
TO
129 */
130 public $is_reserved;
c3fc2621 131
e501603b
TO
132 /**
133 * Is this relationship type currently active (i.e. can be used when creating or editing relationships)?
134 *
c1e814c7 135 * @var bool|string
28979d65
CW
136 * (SQL type: tinyint)
137 * Note that values will be retrieved from the database as a string.
e501603b
TO
138 */
139 public $is_active;
c3fc2621 140
e501603b 141 /**
f41f0342 142 * Class constructor.
e501603b 143 */
c3fc2621 144 public function __construct() {
e501603b
TO
145 $this->__table = 'civicrm_relationship_type';
146 parent::__construct();
147 }
c3fc2621 148
449c4e6b
CW
149 /**
150 * Returns localized title of this entity.
7b66c3b5
AH
151 *
152 * @param bool $plural
153 * Whether to return the plural version of the title.
449c4e6b 154 */
7b66c3b5
AH
155 public static function getEntityTitle($plural = FALSE) {
156 return $plural ? ts('Relationship Types') : ts('Relationship Type');
449c4e6b
CW
157 }
158
e501603b
TO
159 /**
160 * Returns all the column names of this table
161 *
162 * @return array
163 */
c3fc2621 164 public static function &fields() {
346aaaba 165 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
166 Civi::$statics[__CLASS__]['fields'] = [
167 'id' => [
e501603b
TO
168 'name' => 'id',
169 'type' => CRM_Utils_Type::T_INT,
c3fc2621 170 'title' => ts('Relationship Type ID'),
215b423e 171 'description' => ts('Primary key'),
c3fc2621 172 'required' => TRUE,
a36434b9 173 'where' => 'civicrm_relationship_type.id',
522a26c9 174 'table_name' => 'civicrm_relationship_type',
175 'entity' => 'RelationshipType',
176 'bao' => 'CRM_Contact_BAO_RelationshipType',
6a7e5e5d 177 'localizable' => 0,
2cbbebe8
A
178 'html' => [
179 'type' => 'Number',
180 ],
1fe423d6 181 'readonly' => TRUE,
a9d0587b 182 'add' => '1.1',
c3fc2621
CW
183 ],
184 'name_a_b' => [
e501603b
TO
185 'name' => 'name_a_b',
186 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 187 'title' => ts('Relationship Type Name A to B'),
215b423e 188 'description' => ts('name for relationship of contact_a to contact_b.'),
e501603b
TO
189 'maxlength' => 64,
190 'size' => CRM_Utils_Type::BIG,
a36434b9 191 'where' => 'civicrm_relationship_type.name_a_b',
522a26c9 192 'table_name' => 'civicrm_relationship_type',
193 'entity' => 'RelationshipType',
194 'bao' => 'CRM_Contact_BAO_RelationshipType',
6a7e5e5d 195 'localizable' => 0,
a9d0587b 196 'add' => '1.1',
c3fc2621
CW
197 ],
198 'label_a_b' => [
e501603b
TO
199 'name' => 'label_a_b',
200 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 201 'title' => ts('Relationship Type Label A to B'),
215b423e 202 'description' => ts('label for relationship of contact_a to contact_b.'),
e501603b
TO
203 'maxlength' => 64,
204 'size' => CRM_Utils_Type::BIG,
a36434b9 205 'where' => 'civicrm_relationship_type.label_a_b',
522a26c9 206 'table_name' => 'civicrm_relationship_type',
207 'entity' => 'RelationshipType',
208 'bao' => 'CRM_Contact_BAO_RelationshipType',
6a7e5e5d 209 'localizable' => 1,
a9999eb6 210 'html' => [
211 'type' => 'Text',
212 ],
a9d0587b 213 'add' => '3.0',
c3fc2621
CW
214 ],
215 'name_b_a' => [
e501603b
TO
216 'name' => 'name_b_a',
217 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 218 'title' => ts('Relationship Type Name B to A'),
215b423e 219 'description' => ts('Optional name for relationship of contact_b to contact_a.'),
e501603b
TO
220 'maxlength' => 64,
221 'size' => CRM_Utils_Type::BIG,
a36434b9 222 'where' => 'civicrm_relationship_type.name_b_a',
522a26c9 223 'table_name' => 'civicrm_relationship_type',
224 'entity' => 'RelationshipType',
225 'bao' => 'CRM_Contact_BAO_RelationshipType',
6a7e5e5d 226 'localizable' => 0,
a9d0587b 227 'add' => '1.1',
c3fc2621
CW
228 ],
229 'label_b_a' => [
e501603b
TO
230 'name' => 'label_b_a',
231 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 232 'title' => ts('Relationship Type Label B to A'),
215b423e 233 'description' => ts('Optional label for relationship of contact_b to contact_a.'),
e501603b
TO
234 'maxlength' => 64,
235 'size' => CRM_Utils_Type::BIG,
a36434b9 236 'where' => 'civicrm_relationship_type.label_b_a',
522a26c9 237 'table_name' => 'civicrm_relationship_type',
238 'entity' => 'RelationshipType',
239 'bao' => 'CRM_Contact_BAO_RelationshipType',
6a7e5e5d 240 'localizable' => 1,
a9999eb6 241 'html' => [
242 'type' => 'Text',
243 ],
a9d0587b 244 'add' => '3.0',
c3fc2621
CW
245 ],
246 'description' => [
e501603b
TO
247 'name' => 'description',
248 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 249 'title' => ts('Relationship Description'),
215b423e 250 'description' => ts('Optional verbose description of the relationship type.'),
e501603b
TO
251 'maxlength' => 255,
252 'size' => CRM_Utils_Type::HUGE,
a36434b9 253 'where' => 'civicrm_relationship_type.description',
522a26c9 254 'table_name' => 'civicrm_relationship_type',
255 'entity' => 'RelationshipType',
256 'bao' => 'CRM_Contact_BAO_RelationshipType',
6a7e5e5d 257 'localizable' => 1,
a9999eb6 258 'html' => [
259 'type' => 'Text',
260 ],
a9d0587b 261 'add' => '1.1',
c3fc2621
CW
262 ],
263 'contact_type_a' => [
e501603b
TO
264 'name' => 'contact_type_a',
265 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 266 'title' => ts('Contact Type for Contact A'),
215b423e 267 'description' => ts('If defined, contact_a in a relationship of this type must be a specific contact_type.'),
e501603b
TO
268 'maxlength' => 12,
269 'size' => CRM_Utils_Type::TWELVE,
a36434b9 270 'where' => 'civicrm_relationship_type.contact_type_a',
522a26c9 271 'table_name' => 'civicrm_relationship_type',
272 'entity' => 'RelationshipType',
273 'bao' => 'CRM_Contact_BAO_RelationshipType',
6a7e5e5d 274 'localizable' => 0,
c3fc2621 275 'html' => [
e501603b 276 'type' => 'Select',
c3fc2621
CW
277 ],
278 'pseudoconstant' => [
e501603b
TO
279 'table' => 'civicrm_contact_type',
280 'keyColumn' => 'name',
281 'labelColumn' => 'label',
282 'condition' => 'parent_id IS NULL',
e6ca0a57 283 ],
a9d0587b 284 'add' => '1.1',
c3fc2621
CW
285 ],
286 'contact_type_b' => [
e501603b
TO
287 'name' => 'contact_type_b',
288 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 289 'title' => ts('Contact Type for Contact B'),
215b423e 290 'description' => ts('If defined, contact_b in a relationship of this type must be a specific contact_type.'),
e501603b
TO
291 'maxlength' => 12,
292 'size' => CRM_Utils_Type::TWELVE,
a36434b9 293 'where' => 'civicrm_relationship_type.contact_type_b',
522a26c9 294 'table_name' => 'civicrm_relationship_type',
295 'entity' => 'RelationshipType',
296 'bao' => 'CRM_Contact_BAO_RelationshipType',
6a7e5e5d 297 'localizable' => 0,
c3fc2621 298 'html' => [
e501603b 299 'type' => 'Select',
c3fc2621
CW
300 ],
301 'pseudoconstant' => [
e501603b
TO
302 'table' => 'civicrm_contact_type',
303 'keyColumn' => 'name',
304 'labelColumn' => 'label',
305 'condition' => 'parent_id IS NULL',
e6ca0a57 306 ],
a9d0587b 307 'add' => '1.1',
c3fc2621
CW
308 ],
309 'contact_sub_type_a' => [
e501603b
TO
310 'name' => 'contact_sub_type_a',
311 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 312 'title' => ts('Contact Subtype A'),
fb607354 313 'description' => ts('If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.'),
e501603b
TO
314 'maxlength' => 64,
315 'size' => CRM_Utils_Type::BIG,
a36434b9 316 'where' => 'civicrm_relationship_type.contact_sub_type_a',
522a26c9 317 'table_name' => 'civicrm_relationship_type',
318 'entity' => 'RelationshipType',
319 'bao' => 'CRM_Contact_BAO_RelationshipType',
6a7e5e5d 320 'localizable' => 0,
c3fc2621 321 'html' => [
e501603b 322 'type' => 'Select',
c3fc2621
CW
323 ],
324 'pseudoconstant' => [
e501603b
TO
325 'table' => 'civicrm_contact_type',
326 'keyColumn' => 'name',
327 'labelColumn' => 'label',
328 'condition' => 'parent_id IS NOT NULL',
e6ca0a57 329 ],
a9d0587b 330 'add' => '3.1',
c3fc2621
CW
331 ],
332 'contact_sub_type_b' => [
e501603b
TO
333 'name' => 'contact_sub_type_b',
334 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 335 'title' => ts('Contact Subtype B'),
fb607354 336 'description' => ts('If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.'),
e501603b
TO
337 'maxlength' => 64,
338 'size' => CRM_Utils_Type::BIG,
a36434b9 339 'where' => 'civicrm_relationship_type.contact_sub_type_b',
522a26c9 340 'table_name' => 'civicrm_relationship_type',
341 'entity' => 'RelationshipType',
342 'bao' => 'CRM_Contact_BAO_RelationshipType',
6a7e5e5d 343 'localizable' => 0,
c3fc2621 344 'html' => [
e501603b 345 'type' => 'Select',
c3fc2621
CW
346 ],
347 'pseudoconstant' => [
e501603b
TO
348 'table' => 'civicrm_contact_type',
349 'keyColumn' => 'name',
350 'labelColumn' => 'label',
351 'condition' => 'parent_id IS NOT NULL',
e6ca0a57 352 ],
a9d0587b 353 'add' => '3.1',
c3fc2621
CW
354 ],
355 'is_reserved' => [
e501603b
TO
356 'name' => 'is_reserved',
357 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 358 'title' => ts('Relationship Type is Reserved'),
215b423e 359 'description' => ts('Is this relationship type a predefined system type (can not be changed or de-activated)?'),
c1e814c7 360 'required' => TRUE,
a36434b9 361 'where' => 'civicrm_relationship_type.is_reserved',
c1e814c7 362 'default' => '0',
522a26c9 363 'table_name' => 'civicrm_relationship_type',
364 'entity' => 'RelationshipType',
365 'bao' => 'CRM_Contact_BAO_RelationshipType',
6a7e5e5d 366 'localizable' => 0,
a9999eb6 367 'html' => [
368 'type' => 'CheckBox',
369 ],
a9d0587b 370 'add' => '1.1',
c3fc2621
CW
371 ],
372 'is_active' => [
e501603b
TO
373 'name' => 'is_active',
374 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 375 'title' => ts('Relationship Type is Active'),
fb607354 376 'description' => ts('Is this relationship type currently active (i.e. can be used when creating or editing relationships)?'),
c1e814c7 377 'required' => TRUE,
a36434b9 378 'where' => 'civicrm_relationship_type.is_active',
e501603b 379 'default' => '1',
522a26c9 380 'table_name' => 'civicrm_relationship_type',
381 'entity' => 'RelationshipType',
382 'bao' => 'CRM_Contact_BAO_RelationshipType',
6a7e5e5d 383 'localizable' => 0,
a9999eb6 384 'html' => [
385 'type' => 'CheckBox',
386 ],
a9d0587b 387 'add' => '1.1',
c3fc2621
CW
388 ],
389 ];
346aaaba 390 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 391 }
346aaaba 392 return Civi::$statics[__CLASS__]['fields'];
e501603b 393 }
c3fc2621 394
e501603b 395 /**
bd8e0b14 396 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
397 *
398 * @return array
bd8e0b14 399 * Array(string $name => string $uniqueName).
e501603b 400 */
c3fc2621 401 public static function &fieldKeys() {
bd8e0b14
TO
402 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
403 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 404 }
bd8e0b14 405 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 406 }
c3fc2621 407
e501603b
TO
408 /**
409 * Returns the names of this table
410 *
411 * @return string
412 */
c3fc2621 413 public static function getTableName() {
e501603b
TO
414 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
415 }
c3fc2621 416
e501603b
TO
417 /**
418 * Returns if this table needs to be logged
419 *
c3fc2621 420 * @return bool
e501603b 421 */
c3fc2621 422 public function getLog() {
e501603b
TO
423 return self::$_log;
424 }
c3fc2621 425
e501603b
TO
426 /**
427 * Returns the list of fields that can be imported
428 *
429 * @param bool $prefix
430 *
431 * @return array
432 */
c3fc2621
CW
433 public static function &import($prefix = FALSE) {
434 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship_type', $prefix, []);
60808919 435 return $r;
e501603b 436 }
c3fc2621 437
e501603b
TO
438 /**
439 * Returns the list of fields that can be exported
440 *
441 * @param bool $prefix
442 *
443 * @return array
444 */
c3fc2621
CW
445 public static function &export($prefix = FALSE) {
446 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship_type', $prefix, []);
60808919 447 return $r;
e501603b 448 }
c3fc2621 449
e7a6b91a
AS
450 /**
451 * Returns the list of indices
c3fc2621
CW
452 *
453 * @param bool $localize
454 *
455 * @return array
e7a6b91a
AS
456 */
457 public static function indices($localize = TRUE) {
c3fc2621
CW
458 $indices = [
459 'UI_name_a_b' => [
e7a6b91a 460 'name' => 'UI_name_a_b',
c3fc2621 461 'field' => [
e7a6b91a 462 0 => 'name_a_b',
c3fc2621
CW
463 ],
464 'localizable' => FALSE,
465 'unique' => TRUE,
e7a6b91a 466 'sig' => 'civicrm_relationship_type::1::name_a_b',
c3fc2621
CW
467 ],
468 'UI_name_b_a' => [
e7a6b91a 469 'name' => 'UI_name_b_a',
c3fc2621 470 'field' => [
e7a6b91a 471 0 => 'name_b_a',
c3fc2621
CW
472 ],
473 'localizable' => FALSE,
474 'unique' => TRUE,
e7a6b91a 475 'sig' => 'civicrm_relationship_type::1::name_b_a',
c3fc2621
CW
476 ],
477 ];
e7a6b91a
AS
478 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
479 }
c3fc2621 480
e501603b 481}