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:258f862b2238ae69432d8955ae8df803)
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',
157 'name' => 'name_a_b',
158 'type' => CRM_Utils_Type
::T_STRING
,
159 'title' => ts('Relationship Type Name A to B'),
160 'description' => ts('name for relationship of contact_a to contact_b.'),
162 'size' => CRM_Utils_Type
::BIG
,
163 'where' => 'civicrm_relationship_type.name_a_b',
164 'table_name' => 'civicrm_relationship_type',
165 'entity' => 'RelationshipType',
166 'bao' => 'CRM_Contact_BAO_RelationshipType',
171 'name' => 'label_a_b',
172 'type' => CRM_Utils_Type
::T_STRING
,
173 'title' => ts('Relationship Type Label A to B'),
174 'description' => ts('label for relationship of contact_a to contact_b.'),
176 'size' => CRM_Utils_Type
::BIG
,
177 'where' => 'civicrm_relationship_type.label_a_b',
178 'table_name' => 'civicrm_relationship_type',
179 'entity' => 'RelationshipType',
180 'bao' => 'CRM_Contact_BAO_RelationshipType',
188 'name' => 'name_b_a',
189 'type' => CRM_Utils_Type
::T_STRING
,
190 'title' => ts('Relationship Type Name B to A'),
191 'description' => ts('Optional name for relationship of contact_b to contact_a.'),
193 'size' => CRM_Utils_Type
::BIG
,
194 'where' => 'civicrm_relationship_type.name_b_a',
195 'table_name' => 'civicrm_relationship_type',
196 'entity' => 'RelationshipType',
197 'bao' => 'CRM_Contact_BAO_RelationshipType',
202 'name' => 'label_b_a',
203 'type' => CRM_Utils_Type
::T_STRING
,
204 'title' => ts('Relationship Type Label B to A'),
205 'description' => ts('Optional label for relationship of contact_b to contact_a.'),
207 'size' => CRM_Utils_Type
::BIG
,
208 'where' => 'civicrm_relationship_type.label_b_a',
209 'table_name' => 'civicrm_relationship_type',
210 'entity' => 'RelationshipType',
211 'bao' => 'CRM_Contact_BAO_RelationshipType',
219 'name' => 'description',
220 'type' => CRM_Utils_Type
::T_STRING
,
221 'title' => ts('Relationship Description'),
222 'description' => ts('Optional verbose description of the relationship type.'),
224 'size' => CRM_Utils_Type
::HUGE
,
225 'where' => 'civicrm_relationship_type.description',
226 'table_name' => 'civicrm_relationship_type',
227 'entity' => 'RelationshipType',
228 'bao' => 'CRM_Contact_BAO_RelationshipType',
235 'contact_type_a' => [
236 'name' => 'contact_type_a',
237 'type' => CRM_Utils_Type
::T_STRING
,
238 'title' => ts('Contact Type for Contact A'),
239 'description' => ts('If defined, contact_a in a relationship of this type must be a specific contact_type.'),
241 'size' => CRM_Utils_Type
::TWELVE
,
242 'where' => 'civicrm_relationship_type.contact_type_a',
243 'table_name' => 'civicrm_relationship_type',
244 'entity' => 'RelationshipType',
245 'bao' => 'CRM_Contact_BAO_RelationshipType',
250 'pseudoconstant' => [
251 'table' => 'civicrm_contact_type',
252 'keyColumn' => 'name',
253 'labelColumn' => 'label',
254 'condition' => 'parent_id IS NULL',
258 'contact_type_b' => [
259 'name' => 'contact_type_b',
260 'type' => CRM_Utils_Type
::T_STRING
,
261 'title' => ts('Contact Type for Contact B'),
262 'description' => ts('If defined, contact_b in a relationship of this type must be a specific contact_type.'),
264 'size' => CRM_Utils_Type
::TWELVE
,
265 'where' => 'civicrm_relationship_type.contact_type_b',
266 'table_name' => 'civicrm_relationship_type',
267 'entity' => 'RelationshipType',
268 'bao' => 'CRM_Contact_BAO_RelationshipType',
273 'pseudoconstant' => [
274 'table' => 'civicrm_contact_type',
275 'keyColumn' => 'name',
276 'labelColumn' => 'label',
277 'condition' => 'parent_id IS NULL',
281 'contact_sub_type_a' => [
282 'name' => 'contact_sub_type_a',
283 'type' => CRM_Utils_Type
::T_STRING
,
284 'title' => ts('Contact Subtype A'),
285 'description' => ts('If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.'),
287 'size' => CRM_Utils_Type
::BIG
,
288 'where' => 'civicrm_relationship_type.contact_sub_type_a',
289 'table_name' => 'civicrm_relationship_type',
290 'entity' => 'RelationshipType',
291 'bao' => 'CRM_Contact_BAO_RelationshipType',
296 'pseudoconstant' => [
297 'table' => 'civicrm_contact_type',
298 'keyColumn' => 'name',
299 'labelColumn' => 'label',
300 'condition' => 'parent_id IS NOT NULL',
304 'contact_sub_type_b' => [
305 'name' => 'contact_sub_type_b',
306 'type' => CRM_Utils_Type
::T_STRING
,
307 'title' => ts('Contact Subtype B'),
308 'description' => ts('If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.'),
310 'size' => CRM_Utils_Type
::BIG
,
311 'where' => 'civicrm_relationship_type.contact_sub_type_b',
312 'table_name' => 'civicrm_relationship_type',
313 'entity' => 'RelationshipType',
314 'bao' => 'CRM_Contact_BAO_RelationshipType',
319 'pseudoconstant' => [
320 'table' => 'civicrm_contact_type',
321 'keyColumn' => 'name',
322 'labelColumn' => 'label',
323 'condition' => 'parent_id IS NOT NULL',
328 'name' => 'is_reserved',
329 'type' => CRM_Utils_Type
::T_BOOLEAN
,
330 'title' => ts('Relationship Type is Reserved'),
331 'description' => ts('Is this relationship type a predefined system type (can not be changed or de-activated)?'),
332 'where' => 'civicrm_relationship_type.is_reserved',
333 'table_name' => 'civicrm_relationship_type',
334 'entity' => 'RelationshipType',
335 'bao' => 'CRM_Contact_BAO_RelationshipType',
338 'type' => 'CheckBox',
343 'name' => 'is_active',
344 'type' => CRM_Utils_Type
::T_BOOLEAN
,
345 'title' => ts('Relationship Type is Active'),
346 'description' => ts('Is this relationship type currently active (i.e. can be used when creating or editing relationships)?'),
347 'where' => 'civicrm_relationship_type.is_active',
349 'table_name' => 'civicrm_relationship_type',
350 'entity' => 'RelationshipType',
351 'bao' => 'CRM_Contact_BAO_RelationshipType',
354 'type' => 'CheckBox',
359 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
361 return Civi
::$statics[__CLASS__
]['fields'];
365 * Return a mapping from field-name to the corresponding key (as used in fields()).
368 * Array(string $name => string $uniqueName).
370 public static function &fieldKeys() {
371 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
372 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
374 return Civi
::$statics[__CLASS__
]['fieldKeys'];
378 * Returns the names of this table
382 public static function getTableName() {
383 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
387 * Returns if this table needs to be logged
391 public function getLog() {
396 * Returns the list of fields that can be imported
398 * @param bool $prefix
402 public static function &import($prefix = FALSE) {
403 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship_type', $prefix, []);
408 * Returns the list of fields that can be exported
410 * @param bool $prefix
414 public static function &export($prefix = FALSE) {
415 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship_type', $prefix, []);
420 * Returns the list of indices
422 * @param bool $localize
426 public static function indices($localize = TRUE) {
429 'name' => 'UI_name_a_b',
433 'localizable' => FALSE,
435 'sig' => 'civicrm_relationship_type::1::name_a_b',
438 'name' => 'UI_name_b_a',
442 'localizable' => FALSE,
444 'sig' => 'civicrm_relationship_type::1::name_b_a',
447 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;