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