5 * @copyright CiviCRM LLC (c) 2004-2018
7 * Generated from xml/schema/CRM/Contact/Relationship.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:a5a833da9d5016f0aeb06ba7c1058b3c)
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 static $_tableName = 'civicrm_relationship';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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 * is contact a has permission to view / edit contact and
89 related data for contact b ?
93 public $is_permission_a_b;
96 * is contact b has permission to view / edit contact and
97 related data for contact a ?
101 public $is_permission_b_a;
113 public function __construct() {
114 $this->__table
= 'civicrm_relationship';
115 parent
::__construct();
119 * Returns foreign keys and entity references.
122 * [CRM_Core_Reference_Interface]
124 public static function getReferenceColumns() {
125 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
126 Civi
::$statics[__CLASS__
]['links'] = static ::createReferenceColumns(__CLASS__
);
127 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_a', 'civicrm_contact', 'id');
128 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_b', 'civicrm_contact', 'id');
129 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
130 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_id', 'civicrm_case', 'id');
131 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
133 return Civi
::$statics[__CLASS__
]['links'];
137 * Returns all the column names of this table
141 public static function &fields() {
142 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
143 Civi
::$statics[__CLASS__
]['fields'] = [
146 'type' => CRM_Utils_Type
::T_INT
,
147 'title' => ts('Relationship ID'),
148 'description' => 'Relationship ID',
150 'table_name' => 'civicrm_relationship',
151 'entity' => 'Relationship',
152 'bao' => 'CRM_Contact_BAO_Relationship',
156 'name' => 'contact_id_a',
157 'type' => CRM_Utils_Type
::T_INT
,
158 'title' => ts('Contact A'),
159 'description' => 'id of the first contact',
161 'table_name' => 'civicrm_relationship',
162 'entity' => 'Relationship',
163 'bao' => 'CRM_Contact_BAO_Relationship',
165 'FKClassName' => 'CRM_Contact_DAO_Contact',
168 'name' => 'contact_id_b',
169 'type' => CRM_Utils_Type
::T_INT
,
170 'title' => ts('Contact B'),
171 'description' => 'id of the second contact',
173 'table_name' => 'civicrm_relationship',
174 'entity' => 'Relationship',
175 'bao' => 'CRM_Contact_BAO_Relationship',
177 'FKClassName' => 'CRM_Contact_DAO_Contact',
179 'type' => 'EntityRef',
182 'relationship_type_id' => [
183 'name' => 'relationship_type_id',
184 'type' => CRM_Utils_Type
::T_INT
,
185 'title' => ts('Relationship Type'),
186 'description' => 'id of the relationship',
188 'table_name' => 'civicrm_relationship',
189 'entity' => 'Relationship',
190 'bao' => 'CRM_Contact_BAO_Relationship',
192 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
198 'name' => 'start_date',
199 'type' => CRM_Utils_Type
::T_DATE
,
200 'title' => ts('Relationship Start Date'),
201 'description' => 'date when the relationship started',
202 'table_name' => 'civicrm_relationship',
203 'entity' => 'Relationship',
204 'bao' => 'CRM_Contact_BAO_Relationship',
207 'type' => 'Select Date',
211 'name' => 'end_date',
212 'type' => CRM_Utils_Type
::T_DATE
,
213 'title' => ts('Relationship End Date'),
214 'description' => 'date when the relationship ended',
215 'table_name' => 'civicrm_relationship',
216 'entity' => 'Relationship',
217 'bao' => 'CRM_Contact_BAO_Relationship',
220 'type' => 'Select Date',
224 'name' => 'is_active',
225 'type' => CRM_Utils_Type
::T_BOOLEAN
,
226 'title' => ts('Relationship Is Active'),
227 'description' => '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' => '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_BOOLEAN
,
255 'title' => ts('Contact A has Permission Over Contact B'),
256 'description' => 'is contact a has permission to view / edit contact and
257 related data for contact b ?
259 'table_name' => 'civicrm_relationship',
260 'entity' => 'Relationship',
261 'bao' => 'CRM_Contact_BAO_Relationship',
264 'type' => 'CheckBox',
267 'is_permission_b_a' => [
268 'name' => 'is_permission_b_a',
269 'type' => CRM_Utils_Type
::T_BOOLEAN
,
270 'title' => ts('Contact B has Permission Over Contact A'),
271 'description' => 'is contact b has permission to view / edit contact and
272 related data for contact a ?
274 'table_name' => 'civicrm_relationship',
275 'entity' => 'Relationship',
276 'bao' => 'CRM_Contact_BAO_Relationship',
279 'type' => 'CheckBox',
284 'type' => CRM_Utils_Type
::T_INT
,
285 'title' => ts('Relationship Case'),
286 'description' => 'FK to civicrm_case',
288 'table_name' => 'civicrm_relationship',
289 'entity' => 'Relationship',
290 'bao' => 'CRM_Contact_BAO_Relationship',
292 'FKClassName' => 'CRM_Case_DAO_Case',
295 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
297 return Civi
::$statics[__CLASS__
]['fields'];
301 * Return a mapping from field-name to the corresponding key (as used in fields()).
304 * Array(string $name => string $uniqueName).
306 public static function &fieldKeys() {
307 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
308 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
310 return Civi
::$statics[__CLASS__
]['fieldKeys'];
314 * Returns the names of this table
318 public static function getTableName() {
319 return self
::$_tableName;
323 * Returns if this table needs to be logged
327 public function getLog() {
332 * Returns the list of fields that can be imported
334 * @param bool $prefix
338 public static function &import($prefix = FALSE) {
339 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship', $prefix, []);
344 * Returns the list of fields that can be exported
346 * @param bool $prefix
350 public static function &export($prefix = FALSE) {
351 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship', $prefix, []);
356 * Returns the list of indices
358 * @param bool $localize
362 public static function indices($localize = TRUE) {
364 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;