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