Merge pull request #14070 from eileenmcnaughton/bee_free
[civicrm-core.git] / CRM / Contact / DAO / Relationship.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Contact/Relationship.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:0722d901c4eac4e462bc7de9887e605a)
10 */
11
12 /**
13 * Database access object for the Relationship entity.
14 */
15 class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_relationship';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 public static $_log = TRUE;
30
31 /**
32 * Relationship ID
33 *
34 * @var int unsigned
35 */
36 public $id;
37
38 /**
39 * id of the first contact
40 *
41 * @var int unsigned
42 */
43 public $contact_id_a;
44
45 /**
46 * id of the second contact
47 *
48 * @var int unsigned
49 */
50 public $contact_id_b;
51
52 /**
53 * id of the relationship
54 *
55 * @var int unsigned
56 */
57 public $relationship_type_id;
58
59 /**
60 * date when the relationship started
61 *
62 * @var date
63 */
64 public $start_date;
65
66 /**
67 * date when the relationship ended
68 *
69 * @var date
70 */
71 public $end_date;
72
73 /**
74 * is the relationship active ?
75 *
76 * @var boolean
77 */
78 public $is_active;
79
80 /**
81 * Optional verbose description for the relationship.
82 *
83 * @var string
84 */
85 public $description;
86
87 /**
88 * Permission that Contact A has to view/update Contact B
89 *
90 * @var int unsigned
91 */
92 public $is_permission_a_b;
93
94 /**
95 * Permission that Contact B has to view/update Contact A
96 *
97 * @var int unsigned
98 */
99 public $is_permission_b_a;
100
101 /**
102 * FK to civicrm_case
103 *
104 * @var int unsigned
105 */
106 public $case_id;
107
108 /**
109 * Class constructor.
110 */
111 public function __construct() {
112 $this->__table = 'civicrm_relationship';
113 parent::__construct();
114 }
115
116 /**
117 * Returns foreign keys and entity references.
118 *
119 * @return array
120 * [CRM_Core_Reference_Interface]
121 */
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']);
130 }
131 return Civi::$statics[__CLASS__]['links'];
132 }
133
134 /**
135 * Returns all the column names of this table
136 *
137 * @return array
138 */
139 public static function &fields() {
140 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
141 Civi::$statics[__CLASS__]['fields'] = [
142 'id' => [
143 'name' => 'id',
144 'type' => CRM_Utils_Type::T_INT,
145 'title' => ts('Relationship ID'),
146 'description' => ts('Relationship ID'),
147 'required' => TRUE,
148 'where' => 'civicrm_relationship.id',
149 'table_name' => 'civicrm_relationship',
150 'entity' => 'Relationship',
151 'bao' => 'CRM_Contact_BAO_Relationship',
152 'localizable' => 0,
153 ],
154 'contact_id_a' => [
155 'name' => 'contact_id_a',
156 'type' => CRM_Utils_Type::T_INT,
157 'title' => ts('Contact A'),
158 'description' => ts('id of the first contact'),
159 'required' => TRUE,
160 'where' => 'civicrm_relationship.contact_id_a',
161 'table_name' => 'civicrm_relationship',
162 'entity' => 'Relationship',
163 'bao' => 'CRM_Contact_BAO_Relationship',
164 'localizable' => 0,
165 'FKClassName' => 'CRM_Contact_DAO_Contact',
166 ],
167 'contact_id_b' => [
168 'name' => 'contact_id_b',
169 'type' => CRM_Utils_Type::T_INT,
170 'title' => ts('Contact B'),
171 'description' => ts('id of the second contact'),
172 'required' => TRUE,
173 'where' => 'civicrm_relationship.contact_id_b',
174 'table_name' => 'civicrm_relationship',
175 'entity' => 'Relationship',
176 'bao' => 'CRM_Contact_BAO_Relationship',
177 'localizable' => 0,
178 'FKClassName' => 'CRM_Contact_DAO_Contact',
179 'html' => [
180 'type' => 'EntityRef',
181 ],
182 ],
183 'relationship_type_id' => [
184 'name' => 'relationship_type_id',
185 'type' => CRM_Utils_Type::T_INT,
186 'title' => ts('Relationship Type'),
187 'description' => ts('id of the relationship'),
188 'required' => TRUE,
189 'where' => 'civicrm_relationship.relationship_type_id',
190 'table_name' => 'civicrm_relationship',
191 'entity' => 'Relationship',
192 'bao' => 'CRM_Contact_BAO_Relationship',
193 'localizable' => 0,
194 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
195 'html' => [
196 'type' => 'Select',
197 ],
198 ],
199 'start_date' => [
200 'name' => 'start_date',
201 'type' => CRM_Utils_Type::T_DATE,
202 'title' => ts('Relationship Start Date'),
203 'description' => ts('date when the relationship started'),
204 'where' => 'civicrm_relationship.start_date',
205 'table_name' => 'civicrm_relationship',
206 'entity' => 'Relationship',
207 'bao' => 'CRM_Contact_BAO_Relationship',
208 'localizable' => 0,
209 'html' => [
210 'type' => 'Select Date',
211 'formatType' => 'activityDate',
212 ],
213 ],
214 'end_date' => [
215 'name' => 'end_date',
216 'type' => CRM_Utils_Type::T_DATE,
217 'title' => ts('Relationship End Date'),
218 'description' => ts('date when the relationship ended'),
219 'where' => 'civicrm_relationship.end_date',
220 'table_name' => 'civicrm_relationship',
221 'entity' => 'Relationship',
222 'bao' => 'CRM_Contact_BAO_Relationship',
223 'localizable' => 0,
224 'html' => [
225 'type' => 'Select Date',
226 'formatType' => 'activityDate',
227 ],
228 ],
229 'is_active' => [
230 'name' => 'is_active',
231 'type' => CRM_Utils_Type::T_BOOLEAN,
232 'title' => ts('Relationship Is Active'),
233 'description' => ts('is the relationship active ?'),
234 'where' => 'civicrm_relationship.is_active',
235 'default' => '1',
236 'table_name' => 'civicrm_relationship',
237 'entity' => 'Relationship',
238 'bao' => 'CRM_Contact_BAO_Relationship',
239 'localizable' => 0,
240 'html' => [
241 'type' => 'CheckBox',
242 ],
243 ],
244 'description' => [
245 'name' => 'description',
246 'type' => CRM_Utils_Type::T_STRING,
247 'title' => ts('Relationship Description'),
248 'description' => ts('Optional verbose description for the relationship.'),
249 'maxlength' => 255,
250 'size' => CRM_Utils_Type::HUGE,
251 'where' => 'civicrm_relationship.description',
252 'table_name' => 'civicrm_relationship',
253 'entity' => 'Relationship',
254 'bao' => 'CRM_Contact_BAO_Relationship',
255 'localizable' => 0,
256 'html' => [
257 'type' => 'Text',
258 ],
259 ],
260 'is_permission_a_b' => [
261 'name' => 'is_permission_a_b',
262 'type' => CRM_Utils_Type::T_INT,
263 'title' => ts('Contact A has Permission Over Contact B'),
264 'description' => ts('Permission that Contact A has to view/update Contact B'),
265 'required' => TRUE,
266 'where' => 'civicrm_relationship.is_permission_a_b',
267 'default' => '0',
268 'table_name' => 'civicrm_relationship',
269 'entity' => 'Relationship',
270 'bao' => 'CRM_Contact_BAO_Relationship',
271 'localizable' => 0,
272 'html' => [
273 'type' => 'Radio',
274 ],
275 'pseudoconstant' => [
276 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
277 ]
278 ],
279 'is_permission_b_a' => [
280 'name' => 'is_permission_b_a',
281 'type' => CRM_Utils_Type::T_INT,
282 'title' => ts('Contact B has Permission Over Contact A'),
283 'description' => ts('Permission that Contact B has to view/update Contact A'),
284 'required' => TRUE,
285 'where' => 'civicrm_relationship.is_permission_b_a',
286 'default' => '0',
287 'table_name' => 'civicrm_relationship',
288 'entity' => 'Relationship',
289 'bao' => 'CRM_Contact_BAO_Relationship',
290 'localizable' => 0,
291 'html' => [
292 'type' => 'Radio',
293 ],
294 'pseudoconstant' => [
295 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
296 ]
297 ],
298 'case_id' => [
299 'name' => 'case_id',
300 'type' => CRM_Utils_Type::T_INT,
301 'title' => ts('Relationship Case'),
302 'description' => ts('FK to civicrm_case'),
303 'where' => 'civicrm_relationship.case_id',
304 'default' => 'NULL',
305 'table_name' => 'civicrm_relationship',
306 'entity' => 'Relationship',
307 'bao' => 'CRM_Contact_BAO_Relationship',
308 'localizable' => 0,
309 'FKClassName' => 'CRM_Case_DAO_Case',
310 ],
311 ];
312 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
313 }
314 return Civi::$statics[__CLASS__]['fields'];
315 }
316
317 /**
318 * Return a mapping from field-name to the corresponding key (as used in fields()).
319 *
320 * @return array
321 * Array(string $name => string $uniqueName).
322 */
323 public static function &fieldKeys() {
324 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
325 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
326 }
327 return Civi::$statics[__CLASS__]['fieldKeys'];
328 }
329
330 /**
331 * Returns the names of this table
332 *
333 * @return string
334 */
335 public static function getTableName() {
336 return self::$_tableName;
337 }
338
339 /**
340 * Returns if this table needs to be logged
341 *
342 * @return bool
343 */
344 public function getLog() {
345 return self::$_log;
346 }
347
348 /**
349 * Returns the list of fields that can be imported
350 *
351 * @param bool $prefix
352 *
353 * @return array
354 */
355 public static function &import($prefix = FALSE) {
356 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, []);
357 return $r;
358 }
359
360 /**
361 * Returns the list of fields that can be exported
362 *
363 * @param bool $prefix
364 *
365 * @return array
366 */
367 public static function &export($prefix = FALSE) {
368 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, []);
369 return $r;
370 }
371
372 /**
373 * Returns the list of indices
374 *
375 * @param bool $localize
376 *
377 * @return array
378 */
379 public static function indices($localize = TRUE) {
380 $indices = [];
381 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
382 }
383
384 }