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