Add titles and icons to entities
[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:f512c36730defcd334c0e6ccc896e7fb)
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 ],
168 'contact_id_a' => [
169 'name' => 'contact_id_a',
170 'type' => CRM_Utils_Type::T_INT,
171 'title' => ts('Contact A'),
172 'description' => ts('id of the first contact'),
173 'required' => TRUE,
174 'where' => 'civicrm_relationship.contact_id_a',
175 'table_name' => 'civicrm_relationship',
176 'entity' => 'Relationship',
177 'bao' => 'CRM_Contact_BAO_Relationship',
178 'localizable' => 0,
179 'FKClassName' => 'CRM_Contact_DAO_Contact',
180 ],
181 'contact_id_b' => [
182 'name' => 'contact_id_b',
183 'type' => CRM_Utils_Type::T_INT,
184 'title' => ts('Contact B'),
185 'description' => ts('id of the second contact'),
186 'required' => TRUE,
187 'where' => 'civicrm_relationship.contact_id_b',
188 'table_name' => 'civicrm_relationship',
189 'entity' => 'Relationship',
190 'bao' => 'CRM_Contact_BAO_Relationship',
191 'localizable' => 0,
192 'FKClassName' => 'CRM_Contact_DAO_Contact',
193 'html' => [
194 'type' => 'EntityRef',
195 ],
196 ],
197 'relationship_type_id' => [
198 'name' => 'relationship_type_id',
199 'type' => CRM_Utils_Type::T_INT,
200 'title' => ts('Relationship Type'),
201 'description' => ts('id of the relationship'),
202 'required' => TRUE,
203 'where' => 'civicrm_relationship.relationship_type_id',
204 'table_name' => 'civicrm_relationship',
205 'entity' => 'Relationship',
206 'bao' => 'CRM_Contact_BAO_Relationship',
207 'localizable' => 0,
208 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
209 'html' => [
210 'type' => 'Select',
211 ],
212 ],
213 'relationship_start_date' => [
214 'name' => 'start_date',
215 'type' => CRM_Utils_Type::T_DATE,
216 'title' => ts('Relationship Start Date'),
217 'description' => ts('date when the relationship started'),
218 'where' => 'civicrm_relationship.start_date',
219 'table_name' => 'civicrm_relationship',
220 'entity' => 'Relationship',
221 'bao' => 'CRM_Contact_BAO_Relationship',
222 'localizable' => 0,
223 'html' => [
224 'type' => 'Select Date',
225 'formatType' => 'activityDate',
226 ],
227 ],
228 'relationship_end_date' => [
229 'name' => 'end_date',
230 'type' => CRM_Utils_Type::T_DATE,
231 'title' => ts('Relationship End Date'),
232 'description' => ts('date when the relationship ended'),
233 'where' => 'civicrm_relationship.end_date',
234 'table_name' => 'civicrm_relationship',
235 'entity' => 'Relationship',
236 'bao' => 'CRM_Contact_BAO_Relationship',
237 'localizable' => 0,
238 'html' => [
239 'type' => 'Select Date',
240 'formatType' => 'activityDate',
241 ],
242 ],
243 'is_active' => [
244 'name' => 'is_active',
245 'type' => CRM_Utils_Type::T_BOOLEAN,
246 'title' => ts('Relationship Is Active'),
247 'description' => ts('is the relationship active ?'),
248 'where' => 'civicrm_relationship.is_active',
249 'default' => '1',
250 'table_name' => 'civicrm_relationship',
251 'entity' => 'Relationship',
252 'bao' => 'CRM_Contact_BAO_Relationship',
253 'localizable' => 0,
254 'html' => [
255 'type' => 'CheckBox',
256 ],
257 ],
258 'description' => [
259 'name' => 'description',
260 'type' => CRM_Utils_Type::T_STRING,
261 'title' => ts('Relationship Description'),
262 'description' => ts('Optional verbose description for the relationship.'),
263 'maxlength' => 255,
264 'size' => CRM_Utils_Type::HUGE,
265 'where' => 'civicrm_relationship.description',
266 'table_name' => 'civicrm_relationship',
267 'entity' => 'Relationship',
268 'bao' => 'CRM_Contact_BAO_Relationship',
269 'localizable' => 0,
270 'html' => [
271 'type' => 'Text',
272 ],
273 ],
274 'is_permission_a_b' => [
275 'name' => 'is_permission_a_b',
276 'type' => CRM_Utils_Type::T_INT,
277 'title' => ts('Contact A has Permission Over Contact B'),
278 'description' => ts('Permission that Contact A has to view/update Contact B'),
279 'required' => TRUE,
280 'where' => 'civicrm_relationship.is_permission_a_b',
281 'default' => '0',
282 'table_name' => 'civicrm_relationship',
283 'entity' => 'Relationship',
284 'bao' => 'CRM_Contact_BAO_Relationship',
285 'localizable' => 0,
286 'html' => [
287 'type' => 'Radio',
288 ],
289 'pseudoconstant' => [
290 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
291 ],
292 ],
293 'is_permission_b_a' => [
294 'name' => 'is_permission_b_a',
295 'type' => CRM_Utils_Type::T_INT,
296 'title' => ts('Contact B has Permission Over Contact A'),
297 'description' => ts('Permission that Contact B has to view/update Contact A'),
298 'required' => TRUE,
299 'where' => 'civicrm_relationship.is_permission_b_a',
300 'default' => '0',
301 'table_name' => 'civicrm_relationship',
302 'entity' => 'Relationship',
303 'bao' => 'CRM_Contact_BAO_Relationship',
304 'localizable' => 0,
305 'html' => [
306 'type' => 'Radio',
307 ],
308 'pseudoconstant' => [
309 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
310 ],
311 ],
312 'case_id' => [
313 'name' => 'case_id',
314 'type' => CRM_Utils_Type::T_INT,
315 'title' => ts('Relationship Case'),
316 'description' => ts('FK to civicrm_case'),
317 'where' => 'civicrm_relationship.case_id',
318 'default' => 'NULL',
319 'table_name' => 'civicrm_relationship',
320 'entity' => 'Relationship',
321 'bao' => 'CRM_Contact_BAO_Relationship',
322 'localizable' => 0,
323 'FKClassName' => 'CRM_Case_DAO_Case',
324 ],
325 ];
326 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
327 }
328 return Civi::$statics[__CLASS__]['fields'];
329 }
330
331 /**
332 * Return a mapping from field-name to the corresponding key (as used in fields()).
333 *
334 * @return array
335 * Array(string $name => string $uniqueName).
336 */
337 public static function &fieldKeys() {
338 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
339 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
340 }
341 return Civi::$statics[__CLASS__]['fieldKeys'];
342 }
343
344 /**
345 * Returns the names of this table
346 *
347 * @return string
348 */
349 public static function getTableName() {
350 return self::$_tableName;
351 }
352
353 /**
354 * Returns if this table needs to be logged
355 *
356 * @return bool
357 */
358 public function getLog() {
359 return self::$_log;
360 }
361
362 /**
363 * Returns the list of fields that can be imported
364 *
365 * @param bool $prefix
366 *
367 * @return array
368 */
369 public static function &import($prefix = FALSE) {
370 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, []);
371 return $r;
372 }
373
374 /**
375 * Returns the list of fields that can be exported
376 *
377 * @param bool $prefix
378 *
379 * @return array
380 */
381 public static function &export($prefix = FALSE) {
382 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, []);
383 return $r;
384 }
385
386 /**
387 * Returns the list of indices
388 *
389 * @param bool $localize
390 *
391 * @return array
392 */
393 public static function indices($localize = TRUE) {
394 $indices = [];
395 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
396 }
397
398 }