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