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