Regenerate DAOs with readonly attribute for id fields
[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:8212489988aab524bb6353113ae01b66)
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 * @param bool $plural
129 * Whether to return the plural version of the title.
130 */
131 public static function getEntityTitle($plural = FALSE) {
132 return $plural ? ts('Relationship Types') : ts('Relationship Type');
133 }
134
135 /**
136 * Returns all the column names of this table
137 *
138 * @return array
139 */
140 public static function &fields() {
141 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
142 Civi::$statics[__CLASS__]['fields'] = [
143 'id' => [
144 'name' => 'id',
145 'type' => CRM_Utils_Type::T_INT,
146 'title' => ts('Relationship Type ID'),
147 'description' => ts('Primary key'),
148 'required' => TRUE,
149 'where' => 'civicrm_relationship_type.id',
150 'table_name' => 'civicrm_relationship_type',
151 'entity' => 'RelationshipType',
152 'bao' => 'CRM_Contact_BAO_RelationshipType',
153 'localizable' => 0,
154 'html' => [
155 'type' => 'Number',
156 ],
157 'readonly' => TRUE,
158 'add' => '1.1',
159 ],
160 'name_a_b' => [
161 'name' => 'name_a_b',
162 'type' => CRM_Utils_Type::T_STRING,
163 'title' => ts('Relationship Type Name A to B'),
164 'description' => ts('name for relationship of contact_a to contact_b.'),
165 'maxlength' => 64,
166 'size' => CRM_Utils_Type::BIG,
167 'where' => 'civicrm_relationship_type.name_a_b',
168 'table_name' => 'civicrm_relationship_type',
169 'entity' => 'RelationshipType',
170 'bao' => 'CRM_Contact_BAO_RelationshipType',
171 'localizable' => 0,
172 'add' => '1.1',
173 ],
174 'label_a_b' => [
175 'name' => 'label_a_b',
176 'type' => CRM_Utils_Type::T_STRING,
177 'title' => ts('Relationship Type Label A to B'),
178 'description' => ts('label for relationship of contact_a to contact_b.'),
179 'maxlength' => 64,
180 'size' => CRM_Utils_Type::BIG,
181 'where' => 'civicrm_relationship_type.label_a_b',
182 'table_name' => 'civicrm_relationship_type',
183 'entity' => 'RelationshipType',
184 'bao' => 'CRM_Contact_BAO_RelationshipType',
185 'localizable' => 1,
186 'html' => [
187 'type' => 'Text',
188 ],
189 'add' => '3.0',
190 ],
191 'name_b_a' => [
192 'name' => 'name_b_a',
193 'type' => CRM_Utils_Type::T_STRING,
194 'title' => ts('Relationship Type Name B to A'),
195 'description' => ts('Optional name for relationship of contact_b to contact_a.'),
196 'maxlength' => 64,
197 'size' => CRM_Utils_Type::BIG,
198 'where' => 'civicrm_relationship_type.name_b_a',
199 'table_name' => 'civicrm_relationship_type',
200 'entity' => 'RelationshipType',
201 'bao' => 'CRM_Contact_BAO_RelationshipType',
202 'localizable' => 0,
203 'add' => '1.1',
204 ],
205 'label_b_a' => [
206 'name' => 'label_b_a',
207 'type' => CRM_Utils_Type::T_STRING,
208 'title' => ts('Relationship Type Label B to A'),
209 'description' => ts('Optional label for relationship of contact_b to contact_a.'),
210 'maxlength' => 64,
211 'size' => CRM_Utils_Type::BIG,
212 'where' => 'civicrm_relationship_type.label_b_a',
213 'table_name' => 'civicrm_relationship_type',
214 'entity' => 'RelationshipType',
215 'bao' => 'CRM_Contact_BAO_RelationshipType',
216 'localizable' => 1,
217 'html' => [
218 'type' => 'Text',
219 ],
220 'add' => '3.0',
221 ],
222 'description' => [
223 'name' => 'description',
224 'type' => CRM_Utils_Type::T_STRING,
225 'title' => ts('Relationship Description'),
226 'description' => ts('Optional verbose description of the relationship type.'),
227 'maxlength' => 255,
228 'size' => CRM_Utils_Type::HUGE,
229 'where' => 'civicrm_relationship_type.description',
230 'table_name' => 'civicrm_relationship_type',
231 'entity' => 'RelationshipType',
232 'bao' => 'CRM_Contact_BAO_RelationshipType',
233 'localizable' => 1,
234 'html' => [
235 'type' => 'Text',
236 ],
237 'add' => '1.1',
238 ],
239 'contact_type_a' => [
240 'name' => 'contact_type_a',
241 'type' => CRM_Utils_Type::T_STRING,
242 'title' => ts('Contact Type for Contact A'),
243 'description' => ts('If defined, contact_a in a relationship of this type must be a specific contact_type.'),
244 'maxlength' => 12,
245 'size' => CRM_Utils_Type::TWELVE,
246 'where' => 'civicrm_relationship_type.contact_type_a',
247 'table_name' => 'civicrm_relationship_type',
248 'entity' => 'RelationshipType',
249 'bao' => 'CRM_Contact_BAO_RelationshipType',
250 'localizable' => 0,
251 'html' => [
252 'type' => 'Select',
253 ],
254 'pseudoconstant' => [
255 'table' => 'civicrm_contact_type',
256 'keyColumn' => 'name',
257 'labelColumn' => 'label',
258 'condition' => 'parent_id IS NULL',
259 ],
260 'add' => '1.1',
261 ],
262 'contact_type_b' => [
263 'name' => 'contact_type_b',
264 'type' => CRM_Utils_Type::T_STRING,
265 'title' => ts('Contact Type for Contact B'),
266 'description' => ts('If defined, contact_b in a relationship of this type must be a specific contact_type.'),
267 'maxlength' => 12,
268 'size' => CRM_Utils_Type::TWELVE,
269 'where' => 'civicrm_relationship_type.contact_type_b',
270 'table_name' => 'civicrm_relationship_type',
271 'entity' => 'RelationshipType',
272 'bao' => 'CRM_Contact_BAO_RelationshipType',
273 'localizable' => 0,
274 'html' => [
275 'type' => 'Select',
276 ],
277 'pseudoconstant' => [
278 'table' => 'civicrm_contact_type',
279 'keyColumn' => 'name',
280 'labelColumn' => 'label',
281 'condition' => 'parent_id IS NULL',
282 ],
283 'add' => '1.1',
284 ],
285 'contact_sub_type_a' => [
286 'name' => 'contact_sub_type_a',
287 'type' => CRM_Utils_Type::T_STRING,
288 'title' => ts('Contact Subtype A'),
289 'description' => ts('If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.'),
290 'maxlength' => 64,
291 'size' => CRM_Utils_Type::BIG,
292 'where' => 'civicrm_relationship_type.contact_sub_type_a',
293 'table_name' => 'civicrm_relationship_type',
294 'entity' => 'RelationshipType',
295 'bao' => 'CRM_Contact_BAO_RelationshipType',
296 'localizable' => 0,
297 'html' => [
298 'type' => 'Select',
299 ],
300 'pseudoconstant' => [
301 'table' => 'civicrm_contact_type',
302 'keyColumn' => 'name',
303 'labelColumn' => 'label',
304 'condition' => 'parent_id IS NOT NULL',
305 ],
306 'add' => '3.1',
307 ],
308 'contact_sub_type_b' => [
309 'name' => 'contact_sub_type_b',
310 'type' => CRM_Utils_Type::T_STRING,
311 'title' => ts('Contact Subtype B'),
312 'description' => ts('If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.'),
313 'maxlength' => 64,
314 'size' => CRM_Utils_Type::BIG,
315 'where' => 'civicrm_relationship_type.contact_sub_type_b',
316 'table_name' => 'civicrm_relationship_type',
317 'entity' => 'RelationshipType',
318 'bao' => 'CRM_Contact_BAO_RelationshipType',
319 'localizable' => 0,
320 'html' => [
321 'type' => 'Select',
322 ],
323 'pseudoconstant' => [
324 'table' => 'civicrm_contact_type',
325 'keyColumn' => 'name',
326 'labelColumn' => 'label',
327 'condition' => 'parent_id IS NOT NULL',
328 ],
329 'add' => '3.1',
330 ],
331 'is_reserved' => [
332 'name' => 'is_reserved',
333 'type' => CRM_Utils_Type::T_BOOLEAN,
334 'title' => ts('Relationship Type is Reserved'),
335 'description' => ts('Is this relationship type a predefined system type (can not be changed or de-activated)?'),
336 'where' => 'civicrm_relationship_type.is_reserved',
337 'table_name' => 'civicrm_relationship_type',
338 'entity' => 'RelationshipType',
339 'bao' => 'CRM_Contact_BAO_RelationshipType',
340 'localizable' => 0,
341 'html' => [
342 'type' => 'CheckBox',
343 ],
344 'add' => '1.1',
345 ],
346 'is_active' => [
347 'name' => 'is_active',
348 'type' => CRM_Utils_Type::T_BOOLEAN,
349 'title' => ts('Relationship Type is Active'),
350 'description' => ts('Is this relationship type currently active (i.e. can be used when creating or editing relationships)?'),
351 'where' => 'civicrm_relationship_type.is_active',
352 'default' => '1',
353 'table_name' => 'civicrm_relationship_type',
354 'entity' => 'RelationshipType',
355 'bao' => 'CRM_Contact_BAO_RelationshipType',
356 'localizable' => 0,
357 'html' => [
358 'type' => 'CheckBox',
359 ],
360 'add' => '1.1',
361 ],
362 ];
363 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
364 }
365 return Civi::$statics[__CLASS__]['fields'];
366 }
367
368 /**
369 * Return a mapping from field-name to the corresponding key (as used in fields()).
370 *
371 * @return array
372 * Array(string $name => string $uniqueName).
373 */
374 public static function &fieldKeys() {
375 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
376 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
377 }
378 return Civi::$statics[__CLASS__]['fieldKeys'];
379 }
380
381 /**
382 * Returns the names of this table
383 *
384 * @return string
385 */
386 public static function getTableName() {
387 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
388 }
389
390 /**
391 * Returns if this table needs to be logged
392 *
393 * @return bool
394 */
395 public function getLog() {
396 return self::$_log;
397 }
398
399 /**
400 * Returns the list of fields that can be imported
401 *
402 * @param bool $prefix
403 *
404 * @return array
405 */
406 public static function &import($prefix = FALSE) {
407 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship_type', $prefix, []);
408 return $r;
409 }
410
411 /**
412 * Returns the list of fields that can be exported
413 *
414 * @param bool $prefix
415 *
416 * @return array
417 */
418 public static function &export($prefix = FALSE) {
419 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship_type', $prefix, []);
420 return $r;
421 }
422
423 /**
424 * Returns the list of indices
425 *
426 * @param bool $localize
427 *
428 * @return array
429 */
430 public static function indices($localize = TRUE) {
431 $indices = [
432 'UI_name_a_b' => [
433 'name' => 'UI_name_a_b',
434 'field' => [
435 0 => 'name_a_b',
436 ],
437 'localizable' => FALSE,
438 'unique' => TRUE,
439 'sig' => 'civicrm_relationship_type::1::name_a_b',
440 ],
441 'UI_name_b_a' => [
442 'name' => 'UI_name_b_a',
443 'field' => [
444 0 => 'name_b_a',
445 ],
446 'localizable' => FALSE,
447 'unique' => TRUE,
448 'sig' => 'civicrm_relationship_type::1::name_b_a',
449 ],
450 ];
451 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
452 }
453
454 }