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