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