5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contact/Relationship.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:2046fac3c61cd88a17bf21dfe3e6f970)
13 * Database access object for the Relationship entity.
15 class CRM_Contact_DAO_Relationship
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';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-handshake-o';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
48 * id of the first contact
55 * id of the second contact
62 * id of the relationship
66 public $relationship_type_id;
69 * date when the relationship started
76 * date when the relationship ended
83 * is the relationship active ?
90 * Optional verbose description for the relationship.
97 * Permission that Contact A has to view/update Contact B
101 public $is_permission_a_b;
104 * Permission that Contact B has to view/update Contact A
108 public $is_permission_b_a;
120 public function __construct() {
121 $this->__table
= 'civicrm_relationship';
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('Relationships') : ts('Relationship');
136 * Returns foreign keys and entity references.
139 * [CRM_Core_Reference_Interface]
141 public static function getReferenceColumns() {
142 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
143 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
144 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_a', 'civicrm_contact', 'id');
145 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_b', 'civicrm_contact', 'id');
146 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
147 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_id', 'civicrm_case', 'id');
148 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
150 return Civi
::$statics[__CLASS__
]['links'];
154 * Returns all the column names of this table
158 public static function &fields() {
159 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
160 Civi
::$statics[__CLASS__
]['fields'] = [
163 'type' => CRM_Utils_Type
::T_INT
,
164 'title' => ts('Relationship ID'),
165 'description' => ts('Relationship ID'),
167 'where' => 'civicrm_relationship.id',
168 'table_name' => 'civicrm_relationship',
169 'entity' => 'Relationship',
170 'bao' => 'CRM_Contact_BAO_Relationship',
175 'name' => 'contact_id_a',
176 'type' => CRM_Utils_Type
::T_INT
,
177 'title' => ts('Contact A'),
178 'description' => ts('id of the first contact'),
180 'where' => 'civicrm_relationship.contact_id_a',
181 'table_name' => 'civicrm_relationship',
182 'entity' => 'Relationship',
183 'bao' => 'CRM_Contact_BAO_Relationship',
185 'FKClassName' => 'CRM_Contact_DAO_Contact',
189 'name' => 'contact_id_b',
190 'type' => CRM_Utils_Type
::T_INT
,
191 'title' => ts('Contact B'),
192 'description' => ts('id of the second contact'),
194 'where' => 'civicrm_relationship.contact_id_b',
195 'table_name' => 'civicrm_relationship',
196 'entity' => 'Relationship',
197 'bao' => 'CRM_Contact_BAO_Relationship',
199 'FKClassName' => 'CRM_Contact_DAO_Contact',
201 'type' => 'EntityRef',
205 'relationship_type_id' => [
206 'name' => 'relationship_type_id',
207 'type' => CRM_Utils_Type
::T_INT
,
208 'title' => ts('Relationship Type'),
209 'description' => ts('id of the relationship'),
211 'where' => 'civicrm_relationship.relationship_type_id',
212 'table_name' => 'civicrm_relationship',
213 'entity' => 'Relationship',
214 'bao' => 'CRM_Contact_BAO_Relationship',
216 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
222 'relationship_start_date' => [
223 'name' => 'start_date',
224 'type' => CRM_Utils_Type
::T_DATE
,
225 'title' => ts('Relationship Start Date'),
226 'description' => ts('date when the relationship started'),
227 'where' => 'civicrm_relationship.start_date',
228 'table_name' => 'civicrm_relationship',
229 'entity' => 'Relationship',
230 'bao' => 'CRM_Contact_BAO_Relationship',
233 'type' => 'Select Date',
234 'formatType' => 'activityDate',
238 'relationship_end_date' => [
239 'name' => 'end_date',
240 'type' => CRM_Utils_Type
::T_DATE
,
241 'title' => ts('Relationship End Date'),
242 'description' => ts('date when the relationship ended'),
243 'where' => 'civicrm_relationship.end_date',
244 'table_name' => 'civicrm_relationship',
245 'entity' => 'Relationship',
246 'bao' => 'CRM_Contact_BAO_Relationship',
249 'type' => 'Select Date',
250 'formatType' => 'activityDate',
255 'name' => 'is_active',
256 'type' => CRM_Utils_Type
::T_BOOLEAN
,
257 'title' => ts('Relationship Is Active'),
258 'description' => ts('is the relationship active ?'),
259 'where' => 'civicrm_relationship.is_active',
261 'table_name' => 'civicrm_relationship',
262 'entity' => 'Relationship',
263 'bao' => 'CRM_Contact_BAO_Relationship',
266 'type' => 'CheckBox',
271 'name' => 'description',
272 'type' => CRM_Utils_Type
::T_STRING
,
273 'title' => ts('Relationship Description'),
274 'description' => ts('Optional verbose description for the relationship.'),
276 'size' => CRM_Utils_Type
::HUGE
,
277 'where' => 'civicrm_relationship.description',
278 'table_name' => 'civicrm_relationship',
279 'entity' => 'Relationship',
280 'bao' => 'CRM_Contact_BAO_Relationship',
287 'is_permission_a_b' => [
288 'name' => 'is_permission_a_b',
289 'type' => CRM_Utils_Type
::T_INT
,
290 'title' => ts('Contact A has Permission Over Contact B'),
291 'description' => ts('Permission that Contact A has to view/update Contact B'),
293 'where' => 'civicrm_relationship.is_permission_a_b',
295 'table_name' => 'civicrm_relationship',
296 'entity' => 'Relationship',
297 'bao' => 'CRM_Contact_BAO_Relationship',
302 'pseudoconstant' => [
303 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
307 'is_permission_b_a' => [
308 'name' => 'is_permission_b_a',
309 'type' => CRM_Utils_Type
::T_INT
,
310 'title' => ts('Contact B has Permission Over Contact A'),
311 'description' => ts('Permission that Contact B has to view/update Contact A'),
313 'where' => 'civicrm_relationship.is_permission_b_a',
315 'table_name' => 'civicrm_relationship',
316 'entity' => 'Relationship',
317 'bao' => 'CRM_Contact_BAO_Relationship',
322 'pseudoconstant' => [
323 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
329 'type' => CRM_Utils_Type
::T_INT
,
330 'title' => ts('Relationship Case'),
331 'description' => ts('FK to civicrm_case'),
332 'where' => 'civicrm_relationship.case_id',
334 'table_name' => 'civicrm_relationship',
335 'entity' => 'Relationship',
336 'bao' => 'CRM_Contact_BAO_Relationship',
338 'FKClassName' => 'CRM_Case_DAO_Case',
342 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
344 return Civi
::$statics[__CLASS__
]['fields'];
348 * Return a mapping from field-name to the corresponding key (as used in fields()).
351 * Array(string $name => string $uniqueName).
353 public static function &fieldKeys() {
354 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
355 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
357 return Civi
::$statics[__CLASS__
]['fieldKeys'];
361 * Returns the names of this table
365 public static function getTableName() {
366 return self
::$_tableName;
370 * Returns if this table needs to be logged
374 public function getLog() {
379 * Returns the list of fields that can be imported
381 * @param bool $prefix
385 public static function &import($prefix = FALSE) {
386 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship', $prefix, []);
391 * Returns the list of fields that can be exported
393 * @param bool $prefix
397 public static function &export($prefix = FALSE) {
398 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship', $prefix, []);
403 * Returns the list of indices
405 * @param bool $localize
409 public static function indices($localize = TRUE) {
411 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;