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