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