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