5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contact/RelationshipType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:8212489988aab524bb6353113ae01b66)
13 * Database access object for the RelationshipType entity.
15 class CRM_Contact_DAO_RelationshipType
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_relationship_type';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = TRUE;
41 * name for relationship of contact_a to contact_b.
48 * label for relationship of contact_a to contact_b.
55 * Optional name for relationship of contact_b to contact_a.
62 * Optional label for relationship of contact_b to contact_a.
69 * Optional verbose description of the relationship type.
76 * If defined, contact_a in a relationship of this type must be a specific contact_type.
80 public $contact_type_a;
83 * If defined, contact_b in a relationship of this type must be a specific contact_type.
87 public $contact_type_b;
90 * If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.
94 public $contact_sub_type_a;
97 * If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.
101 public $contact_sub_type_b;
104 * Is this relationship type a predefined system type (can not be changed or de-activated)?
111 * Is this relationship type currently active (i.e. can be used when creating or editing relationships)?
120 public function __construct() {
121 $this->__table
= 'civicrm_relationship_type';
122 parent
::__construct();
126 * Returns localized title of this entity.
128 * @param bool $plural
129 * Whether to return the plural version of the title.
131 public static function getEntityTitle($plural = FALSE) {
132 return $plural ?
ts('Relationship Types') : ts('Relationship Type');
136 * Returns all the column names of this table
140 public static function &fields() {
141 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
142 Civi
::$statics[__CLASS__
]['fields'] = [
145 'type' => CRM_Utils_Type
::T_INT
,
146 'title' => ts('Relationship Type ID'),
147 'description' => ts('Primary key'),
149 'where' => 'civicrm_relationship_type.id',
150 'table_name' => 'civicrm_relationship_type',
151 'entity' => 'RelationshipType',
152 'bao' => 'CRM_Contact_BAO_RelationshipType',
161 'name' => 'name_a_b',
162 'type' => CRM_Utils_Type
::T_STRING
,
163 'title' => ts('Relationship Type Name A to B'),
164 'description' => ts('name for relationship of contact_a to contact_b.'),
166 'size' => CRM_Utils_Type
::BIG
,
167 'where' => 'civicrm_relationship_type.name_a_b',
168 'table_name' => 'civicrm_relationship_type',
169 'entity' => 'RelationshipType',
170 'bao' => 'CRM_Contact_BAO_RelationshipType',
175 'name' => 'label_a_b',
176 'type' => CRM_Utils_Type
::T_STRING
,
177 'title' => ts('Relationship Type Label A to B'),
178 'description' => ts('label for relationship of contact_a to contact_b.'),
180 'size' => CRM_Utils_Type
::BIG
,
181 'where' => 'civicrm_relationship_type.label_a_b',
182 'table_name' => 'civicrm_relationship_type',
183 'entity' => 'RelationshipType',
184 'bao' => 'CRM_Contact_BAO_RelationshipType',
192 'name' => 'name_b_a',
193 'type' => CRM_Utils_Type
::T_STRING
,
194 'title' => ts('Relationship Type Name B to A'),
195 'description' => ts('Optional name for relationship of contact_b to contact_a.'),
197 'size' => CRM_Utils_Type
::BIG
,
198 'where' => 'civicrm_relationship_type.name_b_a',
199 'table_name' => 'civicrm_relationship_type',
200 'entity' => 'RelationshipType',
201 'bao' => 'CRM_Contact_BAO_RelationshipType',
206 'name' => 'label_b_a',
207 'type' => CRM_Utils_Type
::T_STRING
,
208 'title' => ts('Relationship Type Label B to A'),
209 'description' => ts('Optional label for relationship of contact_b to contact_a.'),
211 'size' => CRM_Utils_Type
::BIG
,
212 'where' => 'civicrm_relationship_type.label_b_a',
213 'table_name' => 'civicrm_relationship_type',
214 'entity' => 'RelationshipType',
215 'bao' => 'CRM_Contact_BAO_RelationshipType',
223 'name' => 'description',
224 'type' => CRM_Utils_Type
::T_STRING
,
225 'title' => ts('Relationship Description'),
226 'description' => ts('Optional verbose description of the relationship type.'),
228 'size' => CRM_Utils_Type
::HUGE
,
229 'where' => 'civicrm_relationship_type.description',
230 'table_name' => 'civicrm_relationship_type',
231 'entity' => 'RelationshipType',
232 'bao' => 'CRM_Contact_BAO_RelationshipType',
239 'contact_type_a' => [
240 'name' => 'contact_type_a',
241 'type' => CRM_Utils_Type
::T_STRING
,
242 'title' => ts('Contact Type for Contact A'),
243 'description' => ts('If defined, contact_a in a relationship of this type must be a specific contact_type.'),
245 'size' => CRM_Utils_Type
::TWELVE
,
246 'where' => 'civicrm_relationship_type.contact_type_a',
247 'table_name' => 'civicrm_relationship_type',
248 'entity' => 'RelationshipType',
249 'bao' => 'CRM_Contact_BAO_RelationshipType',
254 'pseudoconstant' => [
255 'table' => 'civicrm_contact_type',
256 'keyColumn' => 'name',
257 'labelColumn' => 'label',
258 'condition' => 'parent_id IS NULL',
262 'contact_type_b' => [
263 'name' => 'contact_type_b',
264 'type' => CRM_Utils_Type
::T_STRING
,
265 'title' => ts('Contact Type for Contact B'),
266 'description' => ts('If defined, contact_b in a relationship of this type must be a specific contact_type.'),
268 'size' => CRM_Utils_Type
::TWELVE
,
269 'where' => 'civicrm_relationship_type.contact_type_b',
270 'table_name' => 'civicrm_relationship_type',
271 'entity' => 'RelationshipType',
272 'bao' => 'CRM_Contact_BAO_RelationshipType',
277 'pseudoconstant' => [
278 'table' => 'civicrm_contact_type',
279 'keyColumn' => 'name',
280 'labelColumn' => 'label',
281 'condition' => 'parent_id IS NULL',
285 'contact_sub_type_a' => [
286 'name' => 'contact_sub_type_a',
287 'type' => CRM_Utils_Type
::T_STRING
,
288 'title' => ts('Contact Subtype A'),
289 'description' => ts('If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.'),
291 'size' => CRM_Utils_Type
::BIG
,
292 'where' => 'civicrm_relationship_type.contact_sub_type_a',
293 'table_name' => 'civicrm_relationship_type',
294 'entity' => 'RelationshipType',
295 'bao' => 'CRM_Contact_BAO_RelationshipType',
300 'pseudoconstant' => [
301 'table' => 'civicrm_contact_type',
302 'keyColumn' => 'name',
303 'labelColumn' => 'label',
304 'condition' => 'parent_id IS NOT NULL',
308 'contact_sub_type_b' => [
309 'name' => 'contact_sub_type_b',
310 'type' => CRM_Utils_Type
::T_STRING
,
311 'title' => ts('Contact Subtype B'),
312 'description' => ts('If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.'),
314 'size' => CRM_Utils_Type
::BIG
,
315 'where' => 'civicrm_relationship_type.contact_sub_type_b',
316 'table_name' => 'civicrm_relationship_type',
317 'entity' => 'RelationshipType',
318 'bao' => 'CRM_Contact_BAO_RelationshipType',
323 'pseudoconstant' => [
324 'table' => 'civicrm_contact_type',
325 'keyColumn' => 'name',
326 'labelColumn' => 'label',
327 'condition' => 'parent_id IS NOT NULL',
332 'name' => 'is_reserved',
333 'type' => CRM_Utils_Type
::T_BOOLEAN
,
334 'title' => ts('Relationship Type is Reserved'),
335 'description' => ts('Is this relationship type a predefined system type (can not be changed or de-activated)?'),
336 'where' => 'civicrm_relationship_type.is_reserved',
337 'table_name' => 'civicrm_relationship_type',
338 'entity' => 'RelationshipType',
339 'bao' => 'CRM_Contact_BAO_RelationshipType',
342 'type' => 'CheckBox',
347 'name' => 'is_active',
348 'type' => CRM_Utils_Type
::T_BOOLEAN
,
349 'title' => ts('Relationship Type is Active'),
350 'description' => ts('Is this relationship type currently active (i.e. can be used when creating or editing relationships)?'),
351 'where' => 'civicrm_relationship_type.is_active',
353 'table_name' => 'civicrm_relationship_type',
354 'entity' => 'RelationshipType',
355 'bao' => 'CRM_Contact_BAO_RelationshipType',
358 'type' => 'CheckBox',
363 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
365 return Civi
::$statics[__CLASS__
]['fields'];
369 * Return a mapping from field-name to the corresponding key (as used in fields()).
372 * Array(string $name => string $uniqueName).
374 public static function &fieldKeys() {
375 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
376 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
378 return Civi
::$statics[__CLASS__
]['fieldKeys'];
382 * Returns the names of this table
386 public static function getTableName() {
387 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
391 * Returns if this table needs to be logged
395 public function getLog() {
400 * Returns the list of fields that can be imported
402 * @param bool $prefix
406 public static function &import($prefix = FALSE) {
407 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship_type', $prefix, []);
412 * Returns the list of fields that can be exported
414 * @param bool $prefix
418 public static function &export($prefix = FALSE) {
419 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship_type', $prefix, []);
424 * Returns the list of indices
426 * @param bool $localize
430 public static function indices($localize = TRUE) {
433 'name' => 'UI_name_a_b',
437 'localizable' => FALSE,
439 'sig' => 'civicrm_relationship_type::1::name_a_b',
442 'name' => 'UI_name_b_a',
446 'localizable' => FALSE,
448 'sig' => 'civicrm_relationship_type::1::name_b_a',
451 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;