Add view-only option on permissioned relationships:
[civicrm-core.git] / CRM / Contact / DAO / Relationship.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2018
6 *
7 * Generated from xml/schema/CRM/Contact/Relationship.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:49381da59affbf165a4c9ce87c9a68ec)
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 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 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' => 'Relationship ID',
147 'required' => TRUE,
148 'table_name' => 'civicrm_relationship',
149 'entity' => 'Relationship',
150 'bao' => 'CRM_Contact_BAO_Relationship',
151 'localizable' => 0,
152 ],
153 'contact_id_a' => [
154 'name' => 'contact_id_a',
155 'type' => CRM_Utils_Type::T_INT,
156 'title' => ts('Contact A'),
157 'description' => 'id of the first contact',
158 'required' => TRUE,
159 'table_name' => 'civicrm_relationship',
160 'entity' => 'Relationship',
161 'bao' => 'CRM_Contact_BAO_Relationship',
162 'localizable' => 0,
163 'FKClassName' => 'CRM_Contact_DAO_Contact',
164 ],
165 'contact_id_b' => [
166 'name' => 'contact_id_b',
167 'type' => CRM_Utils_Type::T_INT,
168 'title' => ts('Contact B'),
169 'description' => 'id of the second contact',
170 'required' => TRUE,
171 'table_name' => 'civicrm_relationship',
172 'entity' => 'Relationship',
173 'bao' => 'CRM_Contact_BAO_Relationship',
174 'localizable' => 0,
175 'FKClassName' => 'CRM_Contact_DAO_Contact',
176 'html' => [
177 'type' => 'EntityRef',
178 ],
179 ],
180 'relationship_type_id' => [
181 'name' => 'relationship_type_id',
182 'type' => CRM_Utils_Type::T_INT,
183 'title' => ts('Relationship Type'),
184 'description' => 'id of the relationship',
185 'required' => TRUE,
186 'table_name' => 'civicrm_relationship',
187 'entity' => 'Relationship',
188 'bao' => 'CRM_Contact_BAO_Relationship',
189 'localizable' => 0,
190 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
191 'html' => [
192 'type' => 'Select',
193 ],
194 ],
195 'start_date' => [
196 'name' => 'start_date',
197 'type' => CRM_Utils_Type::T_DATE,
198 'title' => ts('Relationship Start Date'),
199 'description' => 'date when the relationship started',
200 'table_name' => 'civicrm_relationship',
201 'entity' => 'Relationship',
202 'bao' => 'CRM_Contact_BAO_Relationship',
203 'localizable' => 0,
204 'html' => [
205 'type' => 'Select Date',
206 ],
207 ],
208 'end_date' => [
209 'name' => 'end_date',
210 'type' => CRM_Utils_Type::T_DATE,
211 'title' => ts('Relationship End Date'),
212 'description' => 'date when the relationship ended',
213 'table_name' => 'civicrm_relationship',
214 'entity' => 'Relationship',
215 'bao' => 'CRM_Contact_BAO_Relationship',
216 'localizable' => 0,
217 'html' => [
218 'type' => 'Select Date',
219 ],
220 ],
221 'is_active' => [
222 'name' => 'is_active',
223 'type' => CRM_Utils_Type::T_BOOLEAN,
224 'title' => ts('Relationship Is Active'),
225 'description' => 'is the relationship active ?',
226 'default' => '1',
227 'table_name' => 'civicrm_relationship',
228 'entity' => 'Relationship',
229 'bao' => 'CRM_Contact_BAO_Relationship',
230 'localizable' => 0,
231 'html' => [
232 'type' => 'CheckBox',
233 ],
234 ],
235 'description' => [
236 'name' => 'description',
237 'type' => CRM_Utils_Type::T_STRING,
238 'title' => ts('Relationship Description'),
239 'description' => 'Optional verbose description for the relationship.',
240 'maxlength' => 255,
241 'size' => CRM_Utils_Type::HUGE,
242 'table_name' => 'civicrm_relationship',
243 'entity' => 'Relationship',
244 'bao' => 'CRM_Contact_BAO_Relationship',
245 'localizable' => 0,
246 'html' => [
247 'type' => 'Text',
248 ],
249 ],
250 'is_permission_a_b' => [
251 'name' => 'is_permission_a_b',
252 'type' => CRM_Utils_Type::T_INT,
253 'title' => ts('Contact A has Permission Over Contact B'),
254 'description' => 'Permission that Contact A has to view/update Contact B',
255 'required' => TRUE,
256 'table_name' => 'civicrm_relationship',
257 'entity' => 'Relationship',
258 'bao' => 'CRM_Contact_BAO_Relationship',
259 'localizable' => 0,
260 'html' => [
261 'type' => 'Radio',
262 ],
263 'pseudoconstant' => [
264 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
265 ]
266 ],
267 'is_permission_b_a' => [
268 'name' => 'is_permission_b_a',
269 'type' => CRM_Utils_Type::T_INT,
270 'title' => ts('Contact B has Permission Over Contact A'),
271 'description' => 'Permission that Contact B has to view/update Contact A',
272 'required' => TRUE,
273 'table_name' => 'civicrm_relationship',
274 'entity' => 'Relationship',
275 'bao' => 'CRM_Contact_BAO_Relationship',
276 'localizable' => 0,
277 'html' => [
278 'type' => 'Radio',
279 ],
280 'pseudoconstant' => [
281 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
282 ]
283 ],
284 'case_id' => [
285 'name' => 'case_id',
286 'type' => CRM_Utils_Type::T_INT,
287 'title' => ts('Relationship Case'),
288 'description' => 'FK to civicrm_case',
289 'default' => 'NULL',
290 'table_name' => 'civicrm_relationship',
291 'entity' => 'Relationship',
292 'bao' => 'CRM_Contact_BAO_Relationship',
293 'localizable' => 0,
294 'FKClassName' => 'CRM_Case_DAO_Case',
295 ],
296 ];
297 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
298 }
299 return Civi::$statics[__CLASS__]['fields'];
300 }
301
302 /**
303 * Return a mapping from field-name to the corresponding key (as used in fields()).
304 *
305 * @return array
306 * Array(string $name => string $uniqueName).
307 */
308 public static function &fieldKeys() {
309 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
310 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
311 }
312 return Civi::$statics[__CLASS__]['fieldKeys'];
313 }
314
315 /**
316 * Returns the names of this table
317 *
318 * @return string
319 */
320 public static function getTableName() {
321 return self::$_tableName;
322 }
323
324 /**
325 * Returns if this table needs to be logged
326 *
327 * @return bool
328 */
329 public function getLog() {
330 return self::$_log;
331 }
332
333 /**
334 * Returns the list of fields that can be imported
335 *
336 * @param bool $prefix
337 *
338 * @return array
339 */
340 public static function &import($prefix = FALSE) {
341 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, []);
342 return $r;
343 }
344
345 /**
346 * Returns the list of fields that can be exported
347 *
348 * @param bool $prefix
349 *
350 * @return array
351 */
352 public static function &export($prefix = FALSE) {
353 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, []);
354 return $r;
355 }
356
357 /**
358 * Returns the list of indices
359 *
360 * @param bool $localize
361 *
362 * @return array
363 */
364 public static function indices($localize = TRUE) {
365 $indices = [];
366 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
367 }
368
369 }