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