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:f512c36730defcd334c0e6ccc896e7fb)
13 * Database access object for the Relationship entity.
15 class CRM_Contact_DAO_Relationship
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_relationship';
25 * Icon associated with this entity.
29 public static $_icon = 'fa-handshake-o';
32 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 public static $_log = TRUE;
46 * id of the first contact
53 * id of the second contact
60 * id of the relationship
64 public $relationship_type_id;
67 * date when the relationship started
74 * date when the relationship ended
81 * is the relationship active ?
88 * Optional verbose description for the relationship.
95 * Permission that Contact A has to view/update Contact B
99 public $is_permission_a_b;
102 * Permission that Contact B has to view/update Contact A
106 public $is_permission_b_a;
118 public function __construct() {
119 $this->__table
= 'civicrm_relationship';
120 parent
::__construct();
124 * Returns localized title of this entity.
126 public static function getEntityTitle() {
127 return ts('Relationships');
131 * Returns foreign keys and entity references.
134 * [CRM_Core_Reference_Interface]
136 public static function getReferenceColumns() {
137 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
138 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
139 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_a', 'civicrm_contact', 'id');
140 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_b', 'civicrm_contact', 'id');
141 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
142 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_id', 'civicrm_case', 'id');
143 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
145 return Civi
::$statics[__CLASS__
]['links'];
149 * Returns all the column names of this table
153 public static function &fields() {
154 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
155 Civi
::$statics[__CLASS__
]['fields'] = [
158 'type' => CRM_Utils_Type
::T_INT
,
159 'title' => ts('Relationship ID'),
160 'description' => ts('Relationship ID'),
162 'where' => 'civicrm_relationship.id',
163 'table_name' => 'civicrm_relationship',
164 'entity' => 'Relationship',
165 'bao' => 'CRM_Contact_BAO_Relationship',
169 'name' => 'contact_id_a',
170 'type' => CRM_Utils_Type
::T_INT
,
171 'title' => ts('Contact A'),
172 'description' => ts('id of the first contact'),
174 'where' => 'civicrm_relationship.contact_id_a',
175 'table_name' => 'civicrm_relationship',
176 'entity' => 'Relationship',
177 'bao' => 'CRM_Contact_BAO_Relationship',
179 'FKClassName' => 'CRM_Contact_DAO_Contact',
182 'name' => 'contact_id_b',
183 'type' => CRM_Utils_Type
::T_INT
,
184 'title' => ts('Contact B'),
185 'description' => ts('id of the second contact'),
187 'where' => 'civicrm_relationship.contact_id_b',
188 'table_name' => 'civicrm_relationship',
189 'entity' => 'Relationship',
190 'bao' => 'CRM_Contact_BAO_Relationship',
192 'FKClassName' => 'CRM_Contact_DAO_Contact',
194 'type' => 'EntityRef',
197 'relationship_type_id' => [
198 'name' => 'relationship_type_id',
199 'type' => CRM_Utils_Type
::T_INT
,
200 'title' => ts('Relationship Type'),
201 'description' => ts('id of the relationship'),
203 'where' => 'civicrm_relationship.relationship_type_id',
204 'table_name' => 'civicrm_relationship',
205 'entity' => 'Relationship',
206 'bao' => 'CRM_Contact_BAO_Relationship',
208 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
213 'relationship_start_date' => [
214 'name' => 'start_date',
215 'type' => CRM_Utils_Type
::T_DATE
,
216 'title' => ts('Relationship Start Date'),
217 'description' => ts('date when the relationship started'),
218 'where' => 'civicrm_relationship.start_date',
219 'table_name' => 'civicrm_relationship',
220 'entity' => 'Relationship',
221 'bao' => 'CRM_Contact_BAO_Relationship',
224 'type' => 'Select Date',
225 'formatType' => 'activityDate',
228 'relationship_end_date' => [
229 'name' => 'end_date',
230 'type' => CRM_Utils_Type
::T_DATE
,
231 'title' => ts('Relationship End Date'),
232 'description' => ts('date when the relationship ended'),
233 'where' => 'civicrm_relationship.end_date',
234 'table_name' => 'civicrm_relationship',
235 'entity' => 'Relationship',
236 'bao' => 'CRM_Contact_BAO_Relationship',
239 'type' => 'Select Date',
240 'formatType' => 'activityDate',
244 'name' => 'is_active',
245 'type' => CRM_Utils_Type
::T_BOOLEAN
,
246 'title' => ts('Relationship Is Active'),
247 'description' => ts('is the relationship active ?'),
248 'where' => 'civicrm_relationship.is_active',
250 'table_name' => 'civicrm_relationship',
251 'entity' => 'Relationship',
252 'bao' => 'CRM_Contact_BAO_Relationship',
255 'type' => 'CheckBox',
259 'name' => 'description',
260 'type' => CRM_Utils_Type
::T_STRING
,
261 'title' => ts('Relationship Description'),
262 'description' => ts('Optional verbose description for the relationship.'),
264 'size' => CRM_Utils_Type
::HUGE
,
265 'where' => 'civicrm_relationship.description',
266 'table_name' => 'civicrm_relationship',
267 'entity' => 'Relationship',
268 'bao' => 'CRM_Contact_BAO_Relationship',
274 'is_permission_a_b' => [
275 'name' => 'is_permission_a_b',
276 'type' => CRM_Utils_Type
::T_INT
,
277 'title' => ts('Contact A has Permission Over Contact B'),
278 'description' => ts('Permission that Contact A has to view/update Contact B'),
280 'where' => 'civicrm_relationship.is_permission_a_b',
282 'table_name' => 'civicrm_relationship',
283 'entity' => 'Relationship',
284 'bao' => 'CRM_Contact_BAO_Relationship',
289 'pseudoconstant' => [
290 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
293 'is_permission_b_a' => [
294 'name' => 'is_permission_b_a',
295 'type' => CRM_Utils_Type
::T_INT
,
296 'title' => ts('Contact B has Permission Over Contact A'),
297 'description' => ts('Permission that Contact B has to view/update Contact A'),
299 'where' => 'civicrm_relationship.is_permission_b_a',
301 'table_name' => 'civicrm_relationship',
302 'entity' => 'Relationship',
303 'bao' => 'CRM_Contact_BAO_Relationship',
308 'pseudoconstant' => [
309 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
314 'type' => CRM_Utils_Type
::T_INT
,
315 'title' => ts('Relationship Case'),
316 'description' => ts('FK to civicrm_case'),
317 'where' => 'civicrm_relationship.case_id',
319 'table_name' => 'civicrm_relationship',
320 'entity' => 'Relationship',
321 'bao' => 'CRM_Contact_BAO_Relationship',
323 'FKClassName' => 'CRM_Case_DAO_Case',
326 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
328 return Civi
::$statics[__CLASS__
]['fields'];
332 * Return a mapping from field-name to the corresponding key (as used in fields()).
335 * Array(string $name => string $uniqueName).
337 public static function &fieldKeys() {
338 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
339 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
341 return Civi
::$statics[__CLASS__
]['fieldKeys'];
345 * Returns the names of this table
349 public static function getTableName() {
350 return self
::$_tableName;
354 * Returns if this table needs to be logged
358 public function getLog() {
363 * Returns the list of fields that can be imported
365 * @param bool $prefix
369 public static function &import($prefix = FALSE) {
370 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship', $prefix, []);
375 * Returns the list of fields that can be exported
377 * @param bool $prefix
381 public static function &export($prefix = FALSE) {
382 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship', $prefix, []);
387 * Returns the list of indices
389 * @param bool $localize
393 public static function indices($localize = TRUE) {
395 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;