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