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:25faea8225f483ae95cf29af08a8542d)
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 public static function getEntityTitle() {
129 return ts('Relationships');
133 * Returns foreign keys and entity references.
136 * [CRM_Core_Reference_Interface]
138 public static function getReferenceColumns() {
139 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
140 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
141 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_a', 'civicrm_contact', 'id');
142 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_b', 'civicrm_contact', 'id');
143 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
144 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_id', 'civicrm_case', 'id');
145 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
147 return Civi
::$statics[__CLASS__
]['links'];
151 * Returns all the column names of this table
155 public static function &fields() {
156 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
157 Civi
::$statics[__CLASS__
]['fields'] = [
160 'type' => CRM_Utils_Type
::T_INT
,
161 'title' => ts('Relationship ID'),
162 'description' => ts('Relationship ID'),
164 'where' => 'civicrm_relationship.id',
165 'table_name' => 'civicrm_relationship',
166 'entity' => 'Relationship',
167 'bao' => 'CRM_Contact_BAO_Relationship',
172 'name' => 'contact_id_a',
173 'type' => CRM_Utils_Type
::T_INT
,
174 'title' => ts('Contact A'),
175 'description' => ts('id of the first contact'),
177 'where' => 'civicrm_relationship.contact_id_a',
178 'table_name' => 'civicrm_relationship',
179 'entity' => 'Relationship',
180 'bao' => 'CRM_Contact_BAO_Relationship',
182 'FKClassName' => 'CRM_Contact_DAO_Contact',
186 'name' => 'contact_id_b',
187 'type' => CRM_Utils_Type
::T_INT
,
188 'title' => ts('Contact B'),
189 'description' => ts('id of the second contact'),
191 'where' => 'civicrm_relationship.contact_id_b',
192 'table_name' => 'civicrm_relationship',
193 'entity' => 'Relationship',
194 'bao' => 'CRM_Contact_BAO_Relationship',
196 'FKClassName' => 'CRM_Contact_DAO_Contact',
198 'type' => 'EntityRef',
202 'relationship_type_id' => [
203 'name' => 'relationship_type_id',
204 'type' => CRM_Utils_Type
::T_INT
,
205 'title' => ts('Relationship Type'),
206 'description' => ts('id of the relationship'),
208 'where' => 'civicrm_relationship.relationship_type_id',
209 'table_name' => 'civicrm_relationship',
210 'entity' => 'Relationship',
211 'bao' => 'CRM_Contact_BAO_Relationship',
213 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
219 'relationship_start_date' => [
220 'name' => 'start_date',
221 'type' => CRM_Utils_Type
::T_DATE
,
222 'title' => ts('Relationship Start Date'),
223 'description' => ts('date when the relationship started'),
224 'where' => 'civicrm_relationship.start_date',
225 'table_name' => 'civicrm_relationship',
226 'entity' => 'Relationship',
227 'bao' => 'CRM_Contact_BAO_Relationship',
230 'type' => 'Select Date',
231 'formatType' => 'activityDate',
235 'relationship_end_date' => [
236 'name' => 'end_date',
237 'type' => CRM_Utils_Type
::T_DATE
,
238 'title' => ts('Relationship End Date'),
239 'description' => ts('date when the relationship ended'),
240 'where' => 'civicrm_relationship.end_date',
241 'table_name' => 'civicrm_relationship',
242 'entity' => 'Relationship',
243 'bao' => 'CRM_Contact_BAO_Relationship',
246 'type' => 'Select Date',
247 'formatType' => 'activityDate',
252 'name' => 'is_active',
253 'type' => CRM_Utils_Type
::T_BOOLEAN
,
254 'title' => ts('Relationship Is Active'),
255 'description' => ts('is the relationship active ?'),
256 'where' => 'civicrm_relationship.is_active',
258 'table_name' => 'civicrm_relationship',
259 'entity' => 'Relationship',
260 'bao' => 'CRM_Contact_BAO_Relationship',
263 'type' => 'CheckBox',
268 'name' => 'description',
269 'type' => CRM_Utils_Type
::T_STRING
,
270 'title' => ts('Relationship Description'),
271 'description' => ts('Optional verbose description for the relationship.'),
273 'size' => CRM_Utils_Type
::HUGE
,
274 'where' => 'civicrm_relationship.description',
275 'table_name' => 'civicrm_relationship',
276 'entity' => 'Relationship',
277 'bao' => 'CRM_Contact_BAO_Relationship',
284 'is_permission_a_b' => [
285 'name' => 'is_permission_a_b',
286 'type' => CRM_Utils_Type
::T_INT
,
287 'title' => ts('Contact A has Permission Over Contact B'),
288 'description' => ts('Permission that Contact A has to view/update Contact B'),
290 'where' => 'civicrm_relationship.is_permission_a_b',
292 'table_name' => 'civicrm_relationship',
293 'entity' => 'Relationship',
294 'bao' => 'CRM_Contact_BAO_Relationship',
299 'pseudoconstant' => [
300 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
304 'is_permission_b_a' => [
305 'name' => 'is_permission_b_a',
306 'type' => CRM_Utils_Type
::T_INT
,
307 'title' => ts('Contact B has Permission Over Contact A'),
308 'description' => ts('Permission that Contact B has to view/update Contact A'),
310 'where' => 'civicrm_relationship.is_permission_b_a',
312 'table_name' => 'civicrm_relationship',
313 'entity' => 'Relationship',
314 'bao' => 'CRM_Contact_BAO_Relationship',
319 'pseudoconstant' => [
320 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
326 'type' => CRM_Utils_Type
::T_INT
,
327 'title' => ts('Relationship Case'),
328 'description' => ts('FK to civicrm_case'),
329 'where' => 'civicrm_relationship.case_id',
331 'table_name' => 'civicrm_relationship',
332 'entity' => 'Relationship',
333 'bao' => 'CRM_Contact_BAO_Relationship',
335 'FKClassName' => 'CRM_Case_DAO_Case',
339 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
341 return Civi
::$statics[__CLASS__
]['fields'];
345 * Return a mapping from field-name to the corresponding key (as used in fields()).
348 * Array(string $name => string $uniqueName).
350 public static function &fieldKeys() {
351 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
352 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
354 return Civi
::$statics[__CLASS__
]['fieldKeys'];
358 * Returns the names of this table
362 public static function getTableName() {
363 return self
::$_tableName;
367 * Returns if this table needs to be logged
371 public function getLog() {
376 * Returns the list of fields that can be imported
378 * @param bool $prefix
382 public static function &import($prefix = FALSE) {
383 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship', $prefix, []);
388 * Returns the list of fields that can be exported
390 * @param bool $prefix
394 public static function &export($prefix = FALSE) {
395 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship', $prefix, []);
400 * Returns the list of indices
402 * @param bool $localize
406 public static function indices($localize = TRUE) {
408 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;