5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Contact/Relationship.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:0722d901c4eac4e462bc7de9887e605a)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
39 * id of the first contact
46 * id of the second contact
53 * id of the relationship
57 public $relationship_type_id;
60 * date when the relationship started
67 * date when the relationship ended
74 * is the relationship active ?
81 * Optional verbose description for the relationship.
88 * Permission that Contact A has to view/update Contact B
92 public $is_permission_a_b;
95 * Permission that Contact B has to view/update Contact A
99 public $is_permission_b_a;
111 public function __construct() {
112 $this->__table
= 'civicrm_relationship';
113 parent
::__construct();
117 * Returns foreign keys and entity references.
120 * [CRM_Core_Reference_Interface]
122 public static function getReferenceColumns() {
123 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
124 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
125 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_a', 'civicrm_contact', 'id');
126 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_b', 'civicrm_contact', 'id');
127 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
128 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_id', 'civicrm_case', 'id');
129 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
131 return Civi
::$statics[__CLASS__
]['links'];
135 * Returns all the column names of this table
139 public static function &fields() {
140 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
141 Civi
::$statics[__CLASS__
]['fields'] = [
144 'type' => CRM_Utils_Type
::T_INT
,
145 'title' => ts('Relationship ID'),
146 'description' => ts('Relationship ID'),
148 'table_name' => 'civicrm_relationship',
149 'entity' => 'Relationship',
150 'bao' => 'CRM_Contact_BAO_Relationship',
154 'name' => 'contact_id_a',
155 'type' => CRM_Utils_Type
::T_INT
,
156 'title' => ts('Contact A'),
157 'description' => ts('id of the first contact'),
159 'table_name' => 'civicrm_relationship',
160 'entity' => 'Relationship',
161 'bao' => 'CRM_Contact_BAO_Relationship',
163 'FKClassName' => 'CRM_Contact_DAO_Contact',
166 'name' => 'contact_id_b',
167 'type' => CRM_Utils_Type
::T_INT
,
168 'title' => ts('Contact B'),
169 'description' => ts('id of the second contact'),
171 'table_name' => 'civicrm_relationship',
172 'entity' => 'Relationship',
173 'bao' => 'CRM_Contact_BAO_Relationship',
175 'FKClassName' => 'CRM_Contact_DAO_Contact',
177 'type' => 'EntityRef',
180 'relationship_type_id' => [
181 'name' => 'relationship_type_id',
182 'type' => CRM_Utils_Type
::T_INT
,
183 'title' => ts('Relationship Type'),
184 'description' => ts('id of the relationship'),
186 'table_name' => 'civicrm_relationship',
187 'entity' => 'Relationship',
188 'bao' => 'CRM_Contact_BAO_Relationship',
190 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
196 'name' => 'start_date',
197 'type' => CRM_Utils_Type
::T_DATE
,
198 'title' => ts('Relationship Start Date'),
199 'description' => ts('date when the relationship started'),
200 'table_name' => 'civicrm_relationship',
201 'entity' => 'Relationship',
202 'bao' => 'CRM_Contact_BAO_Relationship',
205 'type' => 'Select Date',
206 'formatType' => 'activityDate',
210 'name' => 'end_date',
211 'type' => CRM_Utils_Type
::T_DATE
,
212 'title' => ts('Relationship End Date'),
213 'description' => ts('date when the relationship ended'),
214 'table_name' => 'civicrm_relationship',
215 'entity' => 'Relationship',
216 'bao' => 'CRM_Contact_BAO_Relationship',
219 'type' => 'Select Date',
220 'formatType' => 'activityDate',
224 'name' => 'is_active',
225 'type' => CRM_Utils_Type
::T_BOOLEAN
,
226 'title' => ts('Relationship Is Active'),
227 'description' => ts('is the relationship active ?'),
229 'table_name' => 'civicrm_relationship',
230 'entity' => 'Relationship',
231 'bao' => 'CRM_Contact_BAO_Relationship',
234 'type' => 'CheckBox',
238 'name' => 'description',
239 'type' => CRM_Utils_Type
::T_STRING
,
240 'title' => ts('Relationship Description'),
241 'description' => ts('Optional verbose description for the relationship.'),
243 'size' => CRM_Utils_Type
::HUGE
,
244 'table_name' => 'civicrm_relationship',
245 'entity' => 'Relationship',
246 'bao' => 'CRM_Contact_BAO_Relationship',
252 'is_permission_a_b' => [
253 'name' => 'is_permission_a_b',
254 'type' => CRM_Utils_Type
::T_INT
,
255 'title' => ts('Contact A has Permission Over Contact B'),
256 'description' => ts('Permission that Contact A has to view/update Contact B'),
259 'table_name' => 'civicrm_relationship',
260 'entity' => 'Relationship',
261 'bao' => 'CRM_Contact_BAO_Relationship',
266 'pseudoconstant' => [
267 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
270 'is_permission_b_a' => [
271 'name' => 'is_permission_b_a',
272 'type' => CRM_Utils_Type
::T_INT
,
273 'title' => ts('Contact B has Permission Over Contact A'),
274 'description' => ts('Permission that Contact B has to view/update Contact A'),
277 'table_name' => 'civicrm_relationship',
278 'entity' => 'Relationship',
279 'bao' => 'CRM_Contact_BAO_Relationship',
284 'pseudoconstant' => [
285 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
290 'type' => CRM_Utils_Type
::T_INT
,
291 'title' => ts('Relationship Case'),
292 'description' => ts('FK to civicrm_case'),
294 'table_name' => 'civicrm_relationship',
295 'entity' => 'Relationship',
296 'bao' => 'CRM_Contact_BAO_Relationship',
298 'FKClassName' => 'CRM_Case_DAO_Case',
301 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
303 return Civi
::$statics[__CLASS__
]['fields'];
307 * Return a mapping from field-name to the corresponding key (as used in fields()).
310 * Array(string $name => string $uniqueName).
312 public static function &fieldKeys() {
313 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
314 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
316 return Civi
::$statics[__CLASS__
]['fieldKeys'];
320 * Returns the names of this table
324 public static function getTableName() {
325 return self
::$_tableName;
329 * Returns if this table needs to be logged
333 public function getLog() {
338 * Returns the list of fields that can be imported
340 * @param bool $prefix
344 public static function &import($prefix = FALSE) {
345 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship', $prefix, []);
350 * Returns the list of fields that can be exported
352 * @param bool $prefix
356 public static function &export($prefix = FALSE) {
357 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship', $prefix, []);
362 * Returns the list of indices
364 * @param bool $localize
368 public static function indices($localize = TRUE) {
370 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;