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