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