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:402d6e2cc8ffa3be531d291a20f59560)
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;
41 * Paths for accessing this entity in the UI.
45 protected static $_paths = [
46 'view' => 'civicrm/contact/view/rel?action=view&reset=1&cid=[contact_id_a]&id=[id]',
47 'delete' => 'civicrm/contact/view/rel?action=delete&reset=1&cid=[contact_id_a]&id=[id]',
58 * id of the first contact
65 * id of the second contact
72 * Type of relationship
76 public $relationship_type_id;
79 * date when the relationship started
86 * date when the relationship ended
93 * is the relationship active ?
100 * Optional verbose description for the relationship.
107 * Permission that Contact A has to view/update Contact B
111 public $is_permission_a_b;
114 * Permission that Contact B has to view/update Contact A
118 public $is_permission_b_a;
130 public function __construct() {
131 $this->__table
= 'civicrm_relationship';
132 parent
::__construct();
136 * Returns localized title of this entity.
138 * @param bool $plural
139 * Whether to return the plural version of the title.
141 public static function getEntityTitle($plural = FALSE) {
142 return $plural ?
ts('Relationships') : ts('Relationship');
146 * Returns foreign keys and entity references.
149 * [CRM_Core_Reference_Interface]
151 public static function getReferenceColumns() {
152 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
153 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
154 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_a', 'civicrm_contact', 'id');
155 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_b', 'civicrm_contact', 'id');
156 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
157 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_id', 'civicrm_case', 'id');
158 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
160 return Civi
::$statics[__CLASS__
]['links'];
164 * Returns all the column names of this table
168 public static function &fields() {
169 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
170 Civi
::$statics[__CLASS__
]['fields'] = [
173 'type' => CRM_Utils_Type
::T_INT
,
174 'title' => ts('Relationship ID'),
175 'description' => ts('Relationship ID'),
177 'where' => 'civicrm_relationship.id',
178 'table_name' => 'civicrm_relationship',
179 'entity' => 'Relationship',
180 'bao' => 'CRM_Contact_BAO_Relationship',
189 'name' => 'contact_id_a',
190 'type' => CRM_Utils_Type
::T_INT
,
191 'title' => ts('Contact A ID'),
192 'description' => ts('id of the first contact'),
194 'where' => 'civicrm_relationship.contact_id_a',
195 'table_name' => 'civicrm_relationship',
196 'entity' => 'Relationship',
197 'bao' => 'CRM_Contact_BAO_Relationship',
199 'FKClassName' => 'CRM_Contact_DAO_Contact',
201 'label' => ts("Contact A"),
206 'name' => 'contact_id_b',
207 'type' => CRM_Utils_Type
::T_INT
,
208 'title' => ts('Contact B ID'),
209 'description' => ts('id of the second contact'),
211 'where' => 'civicrm_relationship.contact_id_b',
212 'table_name' => 'civicrm_relationship',
213 'entity' => 'Relationship',
214 'bao' => 'CRM_Contact_BAO_Relationship',
216 'FKClassName' => 'CRM_Contact_DAO_Contact',
218 'type' => 'EntityRef',
219 'label' => ts("Contact B"),
223 'relationship_type_id' => [
224 'name' => 'relationship_type_id',
225 'type' => CRM_Utils_Type
::T_INT
,
226 'title' => ts('Relationship Type ID'),
227 'description' => ts('Type of relationship'),
229 'where' => 'civicrm_relationship.relationship_type_id',
230 'table_name' => 'civicrm_relationship',
231 'entity' => 'Relationship',
232 'bao' => 'CRM_Contact_BAO_Relationship',
234 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
237 'label' => ts("Relationship Type"),
239 'pseudoconstant' => [
240 'table' => 'civicrm_relationship_type',
242 'labelColumn' => 'label_a_b',
243 'nameColumn' => 'name_a_b',
247 'relationship_start_date' => [
248 'name' => 'start_date',
249 'type' => CRM_Utils_Type
::T_DATE
,
250 'title' => ts('Relationship Start Date'),
251 'description' => ts('date when the relationship started'),
252 'where' => 'civicrm_relationship.start_date',
253 'table_name' => 'civicrm_relationship',
254 'entity' => 'Relationship',
255 'bao' => 'CRM_Contact_BAO_Relationship',
258 'type' => 'Select Date',
259 'formatType' => 'activityDate',
263 'relationship_end_date' => [
264 'name' => 'end_date',
265 'type' => CRM_Utils_Type
::T_DATE
,
266 'title' => ts('Relationship End Date'),
267 'description' => ts('date when the relationship ended'),
268 'where' => 'civicrm_relationship.end_date',
269 'table_name' => 'civicrm_relationship',
270 'entity' => 'Relationship',
271 'bao' => 'CRM_Contact_BAO_Relationship',
274 'type' => 'Select Date',
275 'formatType' => 'activityDate',
280 'name' => 'is_active',
281 'type' => CRM_Utils_Type
::T_BOOLEAN
,
282 'title' => ts('Relationship Is Active'),
283 'description' => ts('is the relationship active ?'),
284 'where' => 'civicrm_relationship.is_active',
286 'table_name' => 'civicrm_relationship',
287 'entity' => 'Relationship',
288 'bao' => 'CRM_Contact_BAO_Relationship',
291 'type' => 'CheckBox',
296 'name' => 'description',
297 'type' => CRM_Utils_Type
::T_STRING
,
298 'title' => ts('Relationship Description'),
299 'description' => ts('Optional verbose description for the relationship.'),
301 'size' => CRM_Utils_Type
::HUGE
,
302 'where' => 'civicrm_relationship.description',
303 'table_name' => 'civicrm_relationship',
304 'entity' => 'Relationship',
305 'bao' => 'CRM_Contact_BAO_Relationship',
312 'is_permission_a_b' => [
313 'name' => 'is_permission_a_b',
314 'type' => CRM_Utils_Type
::T_INT
,
315 'title' => ts('Contact A has Permission Over Contact B'),
316 'description' => ts('Permission that Contact A has to view/update Contact B'),
318 'where' => 'civicrm_relationship.is_permission_a_b',
320 'table_name' => 'civicrm_relationship',
321 'entity' => 'Relationship',
322 'bao' => 'CRM_Contact_BAO_Relationship',
327 'pseudoconstant' => [
328 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
332 'is_permission_b_a' => [
333 'name' => 'is_permission_b_a',
334 'type' => CRM_Utils_Type
::T_INT
,
335 'title' => ts('Contact B has Permission Over Contact A'),
336 'description' => ts('Permission that Contact B has to view/update Contact A'),
338 'where' => 'civicrm_relationship.is_permission_b_a',
340 'table_name' => 'civicrm_relationship',
341 'entity' => 'Relationship',
342 'bao' => 'CRM_Contact_BAO_Relationship',
347 'pseudoconstant' => [
348 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
354 'type' => CRM_Utils_Type
::T_INT
,
355 'title' => ts('Case ID'),
356 'description' => ts('FK to civicrm_case'),
357 'where' => 'civicrm_relationship.case_id',
359 'table_name' => 'civicrm_relationship',
360 'entity' => 'Relationship',
361 'bao' => 'CRM_Contact_BAO_Relationship',
363 'FKClassName' => 'CRM_Case_DAO_Case',
365 'label' => ts("Case"),
370 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
372 return Civi
::$statics[__CLASS__
]['fields'];
376 * Return a mapping from field-name to the corresponding key (as used in fields()).
379 * Array(string $name => string $uniqueName).
381 public static function &fieldKeys() {
382 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
383 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
385 return Civi
::$statics[__CLASS__
]['fieldKeys'];
389 * Returns the names of this table
393 public static function getTableName() {
394 return self
::$_tableName;
398 * Returns if this table needs to be logged
402 public function getLog() {
407 * Returns the list of fields that can be imported
409 * @param bool $prefix
413 public static function &import($prefix = FALSE) {
414 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship', $prefix, []);
419 * Returns the list of fields that can be exported
421 * @param bool $prefix
425 public static function &export($prefix = FALSE) {
426 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship', $prefix, []);
431 * Returns the list of indices
433 * @param bool $localize
437 public static function indices($localize = TRUE) {
439 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;