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