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