Commit | Line | Data |
---|---|---|
e501603b | 1 | <?php |
c3fc2621 | 2 | |
e501603b TO |
3 | /** |
4 | * @package CRM | |
ca5cec67 | 5 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
e501603b TO |
6 | * |
7 | * Generated from xml/schema/CRM/Contact/RelationshipType.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
929a1c14 | 9 | * (GenCodeChecksum:6e9767fcd0fc6eba8fcd408588fe0755) |
e501603b | 10 | */ |
c3fc2621 | 11 | |
f41f0342 | 12 | /** |
c3fc2621 | 13 | * Database access object for the RelationshipType entity. |
f41f0342 | 14 | */ |
e501603b | 15 | class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO { |
929a1c14 CW |
16 | const EXT = 'civicrm'; |
17 | const TABLE_ADDED = '1.1'; | |
c3fc2621 | 18 | |
e501603b | 19 | /** |
f41f0342 | 20 | * Static instance to hold the table name. |
e501603b TO |
21 | * |
22 | * @var string | |
23 | */ | |
fa45b5b9 | 24 | public static $_tableName = 'civicrm_relationship_type'; |
c3fc2621 | 25 | |
e501603b | 26 | /** |
f41f0342 | 27 | * Should CiviCRM log any modifications to this table in the civicrm_log table. |
e501603b | 28 | * |
c3fc2621 | 29 | * @var bool |
e501603b | 30 | */ |
fa45b5b9 | 31 | public static $_log = TRUE; |
c3fc2621 | 32 | |
e501603b TO |
33 | /** |
34 | * Primary key | |
35 | * | |
e6ca0a57 | 36 | * @var int |
e501603b TO |
37 | */ |
38 | public $id; | |
c3fc2621 | 39 | |
e501603b TO |
40 | /** |
41 | * name for relationship of contact_a to contact_b. | |
42 | * | |
43 | * @var string | |
44 | */ | |
45 | public $name_a_b; | |
c3fc2621 | 46 | |
e501603b TO |
47 | /** |
48 | * label for relationship of contact_a to contact_b. | |
49 | * | |
50 | * @var string | |
51 | */ | |
52 | public $label_a_b; | |
c3fc2621 | 53 | |
e501603b TO |
54 | /** |
55 | * Optional name for relationship of contact_b to contact_a. | |
56 | * | |
57 | * @var string | |
58 | */ | |
59 | public $name_b_a; | |
c3fc2621 | 60 | |
e501603b TO |
61 | /** |
62 | * Optional label for relationship of contact_b to contact_a. | |
63 | * | |
64 | * @var string | |
65 | */ | |
66 | public $label_b_a; | |
c3fc2621 | 67 | |
e501603b TO |
68 | /** |
69 | * Optional verbose description of the relationship type. | |
70 | * | |
71 | * @var string | |
72 | */ | |
73 | public $description; | |
c3fc2621 | 74 | |
e501603b TO |
75 | /** |
76 | * If defined, contact_a in a relationship of this type must be a specific contact_type. | |
77 | * | |
78 | * @var string | |
79 | */ | |
80 | public $contact_type_a; | |
c3fc2621 | 81 | |
e501603b TO |
82 | /** |
83 | * If defined, contact_b in a relationship of this type must be a specific contact_type. | |
84 | * | |
85 | * @var string | |
86 | */ | |
87 | public $contact_type_b; | |
c3fc2621 | 88 | |
e501603b TO |
89 | /** |
90 | * If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type. | |
91 | * | |
92 | * @var string | |
93 | */ | |
94 | public $contact_sub_type_a; | |
c3fc2621 | 95 | |
e501603b TO |
96 | /** |
97 | * If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type. | |
98 | * | |
99 | * @var string | |
100 | */ | |
101 | public $contact_sub_type_b; | |
c3fc2621 | 102 | |
e501603b TO |
103 | /** |
104 | * Is this relationship type a predefined system type (can not be changed or de-activated)? | |
105 | * | |
e6ca0a57 | 106 | * @var bool |
e501603b TO |
107 | */ |
108 | public $is_reserved; | |
c3fc2621 | 109 | |
e501603b TO |
110 | /** |
111 | * Is this relationship type currently active (i.e. can be used when creating or editing relationships)? | |
112 | * | |
e6ca0a57 | 113 | * @var bool |
e501603b TO |
114 | */ |
115 | public $is_active; | |
c3fc2621 | 116 | |
e501603b | 117 | /** |
f41f0342 | 118 | * Class constructor. |
e501603b | 119 | */ |
c3fc2621 | 120 | public function __construct() { |
e501603b TO |
121 | $this->__table = 'civicrm_relationship_type'; |
122 | parent::__construct(); | |
123 | } | |
c3fc2621 | 124 | |
449c4e6b CW |
125 | /** |
126 | * Returns localized title of this entity. | |
127 | */ | |
128 | public static function getEntityTitle() { | |
129 | return ts('Relationship Types'); | |
130 | } | |
131 | ||
e501603b TO |
132 | /** |
133 | * Returns all the column names of this table | |
134 | * | |
135 | * @return array | |
136 | */ | |
c3fc2621 | 137 | public static function &fields() { |
346aaaba | 138 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
c3fc2621 CW |
139 | Civi::$statics[__CLASS__]['fields'] = [ |
140 | 'id' => [ | |
e501603b TO |
141 | 'name' => 'id', |
142 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 143 | 'title' => ts('Relationship Type ID'), |
215b423e | 144 | 'description' => ts('Primary key'), |
c3fc2621 | 145 | 'required' => TRUE, |
a36434b9 | 146 | 'where' => 'civicrm_relationship_type.id', |
522a26c9 | 147 | 'table_name' => 'civicrm_relationship_type', |
148 | 'entity' => 'RelationshipType', | |
149 | 'bao' => 'CRM_Contact_BAO_RelationshipType', | |
6a7e5e5d | 150 | 'localizable' => 0, |
a9d0587b | 151 | 'add' => '1.1', |
c3fc2621 CW |
152 | ], |
153 | 'name_a_b' => [ | |
e501603b TO |
154 | 'name' => 'name_a_b', |
155 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 156 | 'title' => ts('Relationship Type Name A to B'), |
215b423e | 157 | 'description' => ts('name for relationship of contact_a to contact_b.'), |
e501603b TO |
158 | 'maxlength' => 64, |
159 | 'size' => CRM_Utils_Type::BIG, | |
a36434b9 | 160 | 'where' => 'civicrm_relationship_type.name_a_b', |
522a26c9 | 161 | 'table_name' => 'civicrm_relationship_type', |
162 | 'entity' => 'RelationshipType', | |
163 | 'bao' => 'CRM_Contact_BAO_RelationshipType', | |
6a7e5e5d | 164 | 'localizable' => 0, |
a9d0587b | 165 | 'add' => '1.1', |
c3fc2621 CW |
166 | ], |
167 | 'label_a_b' => [ | |
e501603b TO |
168 | 'name' => 'label_a_b', |
169 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 170 | 'title' => ts('Relationship Type Label A to B'), |
215b423e | 171 | 'description' => ts('label for relationship of contact_a to contact_b.'), |
e501603b TO |
172 | 'maxlength' => 64, |
173 | 'size' => CRM_Utils_Type::BIG, | |
a36434b9 | 174 | 'where' => 'civicrm_relationship_type.label_a_b', |
522a26c9 | 175 | 'table_name' => 'civicrm_relationship_type', |
176 | 'entity' => 'RelationshipType', | |
177 | 'bao' => 'CRM_Contact_BAO_RelationshipType', | |
6a7e5e5d | 178 | 'localizable' => 1, |
a9999eb6 | 179 | 'html' => [ |
180 | 'type' => 'Text', | |
181 | ], | |
a9d0587b | 182 | 'add' => '3.0', |
c3fc2621 CW |
183 | ], |
184 | 'name_b_a' => [ | |
e501603b TO |
185 | 'name' => 'name_b_a', |
186 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 187 | 'title' => ts('Relationship Type Name B to A'), |
215b423e | 188 | 'description' => ts('Optional name for relationship of contact_b to contact_a.'), |
e501603b TO |
189 | 'maxlength' => 64, |
190 | 'size' => CRM_Utils_Type::BIG, | |
a36434b9 | 191 | 'where' => 'civicrm_relationship_type.name_b_a', |
522a26c9 | 192 | 'table_name' => 'civicrm_relationship_type', |
193 | 'entity' => 'RelationshipType', | |
194 | 'bao' => 'CRM_Contact_BAO_RelationshipType', | |
6a7e5e5d | 195 | 'localizable' => 0, |
a9d0587b | 196 | 'add' => '1.1', |
c3fc2621 CW |
197 | ], |
198 | 'label_b_a' => [ | |
e501603b TO |
199 | 'name' => 'label_b_a', |
200 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 201 | 'title' => ts('Relationship Type Label B to A'), |
215b423e | 202 | 'description' => ts('Optional label for relationship of contact_b to contact_a.'), |
e501603b TO |
203 | 'maxlength' => 64, |
204 | 'size' => CRM_Utils_Type::BIG, | |
a36434b9 | 205 | 'where' => 'civicrm_relationship_type.label_b_a', |
522a26c9 | 206 | 'table_name' => 'civicrm_relationship_type', |
207 | 'entity' => 'RelationshipType', | |
208 | 'bao' => 'CRM_Contact_BAO_RelationshipType', | |
6a7e5e5d | 209 | 'localizable' => 1, |
a9999eb6 | 210 | 'html' => [ |
211 | 'type' => 'Text', | |
212 | ], | |
a9d0587b | 213 | 'add' => '3.0', |
c3fc2621 CW |
214 | ], |
215 | 'description' => [ | |
e501603b TO |
216 | 'name' => 'description', |
217 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 218 | 'title' => ts('Relationship Description'), |
215b423e | 219 | 'description' => ts('Optional verbose description of the relationship type.'), |
e501603b TO |
220 | 'maxlength' => 255, |
221 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 222 | 'where' => 'civicrm_relationship_type.description', |
522a26c9 | 223 | 'table_name' => 'civicrm_relationship_type', |
224 | 'entity' => 'RelationshipType', | |
225 | 'bao' => 'CRM_Contact_BAO_RelationshipType', | |
6a7e5e5d | 226 | 'localizable' => 1, |
a9999eb6 | 227 | 'html' => [ |
228 | 'type' => 'Text', | |
229 | ], | |
a9d0587b | 230 | 'add' => '1.1', |
c3fc2621 CW |
231 | ], |
232 | 'contact_type_a' => [ | |
e501603b TO |
233 | 'name' => 'contact_type_a', |
234 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 235 | 'title' => ts('Contact Type for Contact A'), |
215b423e | 236 | 'description' => ts('If defined, contact_a in a relationship of this type must be a specific contact_type.'), |
e501603b TO |
237 | 'maxlength' => 12, |
238 | 'size' => CRM_Utils_Type::TWELVE, | |
a36434b9 | 239 | 'where' => 'civicrm_relationship_type.contact_type_a', |
522a26c9 | 240 | 'table_name' => 'civicrm_relationship_type', |
241 | 'entity' => 'RelationshipType', | |
242 | 'bao' => 'CRM_Contact_BAO_RelationshipType', | |
6a7e5e5d | 243 | 'localizable' => 0, |
c3fc2621 | 244 | 'html' => [ |
e501603b | 245 | 'type' => 'Select', |
c3fc2621 CW |
246 | ], |
247 | 'pseudoconstant' => [ | |
e501603b TO |
248 | 'table' => 'civicrm_contact_type', |
249 | 'keyColumn' => 'name', | |
250 | 'labelColumn' => 'label', | |
251 | 'condition' => 'parent_id IS NULL', | |
e6ca0a57 | 252 | ], |
a9d0587b | 253 | 'add' => '1.1', |
c3fc2621 CW |
254 | ], |
255 | 'contact_type_b' => [ | |
e501603b TO |
256 | 'name' => 'contact_type_b', |
257 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 258 | 'title' => ts('Contact Type for Contact B'), |
215b423e | 259 | 'description' => ts('If defined, contact_b in a relationship of this type must be a specific contact_type.'), |
e501603b TO |
260 | 'maxlength' => 12, |
261 | 'size' => CRM_Utils_Type::TWELVE, | |
a36434b9 | 262 | 'where' => 'civicrm_relationship_type.contact_type_b', |
522a26c9 | 263 | 'table_name' => 'civicrm_relationship_type', |
264 | 'entity' => 'RelationshipType', | |
265 | 'bao' => 'CRM_Contact_BAO_RelationshipType', | |
6a7e5e5d | 266 | 'localizable' => 0, |
c3fc2621 | 267 | 'html' => [ |
e501603b | 268 | 'type' => 'Select', |
c3fc2621 CW |
269 | ], |
270 | 'pseudoconstant' => [ | |
e501603b TO |
271 | 'table' => 'civicrm_contact_type', |
272 | 'keyColumn' => 'name', | |
273 | 'labelColumn' => 'label', | |
274 | 'condition' => 'parent_id IS NULL', | |
e6ca0a57 | 275 | ], |
a9d0587b | 276 | 'add' => '1.1', |
c3fc2621 CW |
277 | ], |
278 | 'contact_sub_type_a' => [ | |
e501603b TO |
279 | 'name' => 'contact_sub_type_a', |
280 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 281 | 'title' => ts('Contact Subtype A'), |
fb607354 | 282 | 'description' => ts('If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.'), |
e501603b TO |
283 | 'maxlength' => 64, |
284 | 'size' => CRM_Utils_Type::BIG, | |
a36434b9 | 285 | 'where' => 'civicrm_relationship_type.contact_sub_type_a', |
522a26c9 | 286 | 'table_name' => 'civicrm_relationship_type', |
287 | 'entity' => 'RelationshipType', | |
288 | 'bao' => 'CRM_Contact_BAO_RelationshipType', | |
6a7e5e5d | 289 | 'localizable' => 0, |
c3fc2621 | 290 | 'html' => [ |
e501603b | 291 | 'type' => 'Select', |
c3fc2621 CW |
292 | ], |
293 | 'pseudoconstant' => [ | |
e501603b TO |
294 | 'table' => 'civicrm_contact_type', |
295 | 'keyColumn' => 'name', | |
296 | 'labelColumn' => 'label', | |
297 | 'condition' => 'parent_id IS NOT NULL', | |
e6ca0a57 | 298 | ], |
a9d0587b | 299 | 'add' => '3.1', |
c3fc2621 CW |
300 | ], |
301 | 'contact_sub_type_b' => [ | |
e501603b TO |
302 | 'name' => 'contact_sub_type_b', |
303 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 304 | 'title' => ts('Contact Subtype B'), |
fb607354 | 305 | 'description' => ts('If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.'), |
e501603b TO |
306 | 'maxlength' => 64, |
307 | 'size' => CRM_Utils_Type::BIG, | |
a36434b9 | 308 | 'where' => 'civicrm_relationship_type.contact_sub_type_b', |
522a26c9 | 309 | 'table_name' => 'civicrm_relationship_type', |
310 | 'entity' => 'RelationshipType', | |
311 | 'bao' => 'CRM_Contact_BAO_RelationshipType', | |
6a7e5e5d | 312 | 'localizable' => 0, |
c3fc2621 | 313 | 'html' => [ |
e501603b | 314 | 'type' => 'Select', |
c3fc2621 CW |
315 | ], |
316 | 'pseudoconstant' => [ | |
e501603b TO |
317 | 'table' => 'civicrm_contact_type', |
318 | 'keyColumn' => 'name', | |
319 | 'labelColumn' => 'label', | |
320 | 'condition' => 'parent_id IS NOT NULL', | |
e6ca0a57 | 321 | ], |
a9d0587b | 322 | 'add' => '3.1', |
c3fc2621 CW |
323 | ], |
324 | 'is_reserved' => [ | |
e501603b TO |
325 | 'name' => 'is_reserved', |
326 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 327 | 'title' => ts('Relationship Type is Reserved'), |
215b423e | 328 | 'description' => ts('Is this relationship type a predefined system type (can not be changed or de-activated)?'), |
a36434b9 | 329 | 'where' => 'civicrm_relationship_type.is_reserved', |
522a26c9 | 330 | 'table_name' => 'civicrm_relationship_type', |
331 | 'entity' => 'RelationshipType', | |
332 | 'bao' => 'CRM_Contact_BAO_RelationshipType', | |
6a7e5e5d | 333 | 'localizable' => 0, |
a9999eb6 | 334 | 'html' => [ |
335 | 'type' => 'CheckBox', | |
336 | ], | |
a9d0587b | 337 | 'add' => '1.1', |
c3fc2621 CW |
338 | ], |
339 | 'is_active' => [ | |
e501603b TO |
340 | 'name' => 'is_active', |
341 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 342 | 'title' => ts('Relationship Type is Active'), |
fb607354 | 343 | 'description' => ts('Is this relationship type currently active (i.e. can be used when creating or editing relationships)?'), |
a36434b9 | 344 | 'where' => 'civicrm_relationship_type.is_active', |
e501603b | 345 | 'default' => '1', |
522a26c9 | 346 | 'table_name' => 'civicrm_relationship_type', |
347 | 'entity' => 'RelationshipType', | |
348 | 'bao' => 'CRM_Contact_BAO_RelationshipType', | |
6a7e5e5d | 349 | 'localizable' => 0, |
a9999eb6 | 350 | 'html' => [ |
351 | 'type' => 'CheckBox', | |
352 | ], | |
a9d0587b | 353 | 'add' => '1.1', |
c3fc2621 CW |
354 | ], |
355 | ]; | |
346aaaba | 356 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 357 | } |
346aaaba | 358 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 359 | } |
c3fc2621 | 360 | |
e501603b | 361 | /** |
bd8e0b14 | 362 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
363 | * |
364 | * @return array | |
bd8e0b14 | 365 | * Array(string $name => string $uniqueName). |
e501603b | 366 | */ |
c3fc2621 | 367 | public static function &fieldKeys() { |
bd8e0b14 TO |
368 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
369 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 370 | } |
bd8e0b14 | 371 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 372 | } |
c3fc2621 | 373 | |
e501603b TO |
374 | /** |
375 | * Returns the names of this table | |
376 | * | |
377 | * @return string | |
378 | */ | |
c3fc2621 | 379 | public static function getTableName() { |
e501603b TO |
380 | return CRM_Core_DAO::getLocaleTableName(self::$_tableName); |
381 | } | |
c3fc2621 | 382 | |
e501603b TO |
383 | /** |
384 | * Returns if this table needs to be logged | |
385 | * | |
c3fc2621 | 386 | * @return bool |
e501603b | 387 | */ |
c3fc2621 | 388 | public function getLog() { |
e501603b TO |
389 | return self::$_log; |
390 | } | |
c3fc2621 | 391 | |
e501603b TO |
392 | /** |
393 | * Returns the list of fields that can be imported | |
394 | * | |
395 | * @param bool $prefix | |
396 | * | |
397 | * @return array | |
398 | */ | |
c3fc2621 CW |
399 | public static function &import($prefix = FALSE) { |
400 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship_type', $prefix, []); | |
60808919 | 401 | return $r; |
e501603b | 402 | } |
c3fc2621 | 403 | |
e501603b TO |
404 | /** |
405 | * Returns the list of fields that can be exported | |
406 | * | |
407 | * @param bool $prefix | |
408 | * | |
409 | * @return array | |
410 | */ | |
c3fc2621 CW |
411 | public static function &export($prefix = FALSE) { |
412 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship_type', $prefix, []); | |
60808919 | 413 | return $r; |
e501603b | 414 | } |
c3fc2621 | 415 | |
e7a6b91a AS |
416 | /** |
417 | * Returns the list of indices | |
c3fc2621 CW |
418 | * |
419 | * @param bool $localize | |
420 | * | |
421 | * @return array | |
e7a6b91a AS |
422 | */ |
423 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
424 | $indices = [ |
425 | 'UI_name_a_b' => [ | |
e7a6b91a | 426 | 'name' => 'UI_name_a_b', |
c3fc2621 | 427 | 'field' => [ |
e7a6b91a | 428 | 0 => 'name_a_b', |
c3fc2621 CW |
429 | ], |
430 | 'localizable' => FALSE, | |
431 | 'unique' => TRUE, | |
e7a6b91a | 432 | 'sig' => 'civicrm_relationship_type::1::name_a_b', |
c3fc2621 CW |
433 | ], |
434 | 'UI_name_b_a' => [ | |
e7a6b91a | 435 | 'name' => 'UI_name_b_a', |
c3fc2621 | 436 | 'field' => [ |
e7a6b91a | 437 | 0 => 'name_b_a', |
c3fc2621 CW |
438 | ], |
439 | 'localizable' => FALSE, | |
440 | 'unique' => TRUE, | |
e7a6b91a | 441 | 'sig' => 'civicrm_relationship_type::1::name_b_a', |
c3fc2621 CW |
442 | ], |
443 | ]; | |
e7a6b91a AS |
444 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
445 | } | |
c3fc2621 | 446 | |
e501603b | 447 | } |