Declare API Key as a protected field for future use
[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:473d5c38633f0dfbc4b459efe556b8d6)
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 unsigned
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 boolean
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 boolean
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 '),
267 'maxlength' => 64,
268 'size' => CRM_Utils_Type::BIG,
269 'where' => 'civicrm_relationship_type.contact_sub_type_a',
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 NOT NULL',
282 ]
283 ],
284 'contact_sub_type_b' => [
285 'name' => 'contact_sub_type_b',
286 'type' => CRM_Utils_Type::T_STRING,
287 'title' => ts('Contact Subtype B'),
288 'description' => ts('If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.
289 '),
290 'maxlength' => 64,
291 'size' => CRM_Utils_Type::BIG,
292 'where' => 'civicrm_relationship_type.contact_sub_type_b',
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 ],
307 'is_reserved' => [
308 'name' => 'is_reserved',
309 'type' => CRM_Utils_Type::T_BOOLEAN,
310 'title' => ts('Relationship Type is Reserved'),
311 'description' => ts('Is this relationship type a predefined system type (can not be changed or de-activated)?'),
312 'where' => 'civicrm_relationship_type.is_reserved',
313 'table_name' => 'civicrm_relationship_type',
314 'entity' => 'RelationshipType',
315 'bao' => 'CRM_Contact_BAO_RelationshipType',
316 'localizable' => 0,
317 'html' => [
318 'type' => 'CheckBox',
319 ],
320 ],
321 'is_active' => [
322 'name' => 'is_active',
323 'type' => CRM_Utils_Type::T_BOOLEAN,
324 'title' => ts('Relationship Type is Active'),
325 'description' => ts('Is this relationship type currently active (i.e. can be used when creating or editing relationships)?
326 '),
327 'where' => 'civicrm_relationship_type.is_active',
328 'default' => '1',
329 'table_name' => 'civicrm_relationship_type',
330 'entity' => 'RelationshipType',
331 'bao' => 'CRM_Contact_BAO_RelationshipType',
332 'localizable' => 0,
333 'html' => [
334 'type' => 'CheckBox',
335 ],
336 ],
337 ];
338 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
339 }
340 return Civi::$statics[__CLASS__]['fields'];
341 }
342
343 /**
344 * Return a mapping from field-name to the corresponding key (as used in fields()).
345 *
346 * @return array
347 * Array(string $name => string $uniqueName).
348 */
349 public static function &fieldKeys() {
350 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
351 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
352 }
353 return Civi::$statics[__CLASS__]['fieldKeys'];
354 }
355
356 /**
357 * Returns the names of this table
358 *
359 * @return string
360 */
361 public static function getTableName() {
362 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
363 }
364
365 /**
366 * Returns if this table needs to be logged
367 *
368 * @return bool
369 */
370 public function getLog() {
371 return self::$_log;
372 }
373
374 /**
375 * Returns the list of fields that can be imported
376 *
377 * @param bool $prefix
378 *
379 * @return array
380 */
381 public static function &import($prefix = FALSE) {
382 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship_type', $prefix, []);
383 return $r;
384 }
385
386 /**
387 * Returns the list of fields that can be exported
388 *
389 * @param bool $prefix
390 *
391 * @return array
392 */
393 public static function &export($prefix = FALSE) {
394 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship_type', $prefix, []);
395 return $r;
396 }
397
398 /**
399 * Returns the list of indices
400 *
401 * @param bool $localize
402 *
403 * @return array
404 */
405 public static function indices($localize = TRUE) {
406 $indices = [
407 'UI_name_a_b' => [
408 'name' => 'UI_name_a_b',
409 'field' => [
410 0 => 'name_a_b',
411 ],
412 'localizable' => FALSE,
413 'unique' => TRUE,
414 'sig' => 'civicrm_relationship_type::1::name_a_b',
415 ],
416 'UI_name_b_a' => [
417 'name' => 'UI_name_b_a',
418 'field' => [
419 0 => 'name_b_a',
420 ],
421 'localizable' => FALSE,
422 'unique' => TRUE,
423 'sig' => 'civicrm_relationship_type::1::name_b_a',
424 ],
425 ];
426 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
427 }
428
429 }