Merge pull request #13213 from eileenmcnaughton/export_array
[civicrm-core.git] / CRM / Contact / DAO / Relationship.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Contact/Relationship.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:0722d901c4eac4e462bc7de9887e605a)
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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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 'formatType' => 'activityDate',
207 ],
208 ],
209 'end_date' => [
210 'name' => 'end_date',
211 'type' => CRM_Utils_Type::T_DATE,
212 'title' => ts('Relationship End Date'),
213 'description' => ts('date when the relationship ended'),
214 'table_name' => 'civicrm_relationship',
215 'entity' => 'Relationship',
216 'bao' => 'CRM_Contact_BAO_Relationship',
217 'localizable' => 0,
218 'html' => [
219 'type' => 'Select Date',
220 'formatType' => 'activityDate',
221 ],
222 ],
223 'is_active' => [
224 'name' => 'is_active',
225 'type' => CRM_Utils_Type::T_BOOLEAN,
226 'title' => ts('Relationship Is Active'),
227 'description' => ts('is the relationship active ?'),
228 'default' => '1',
229 'table_name' => 'civicrm_relationship',
230 'entity' => 'Relationship',
231 'bao' => 'CRM_Contact_BAO_Relationship',
232 'localizable' => 0,
233 'html' => [
234 'type' => 'CheckBox',
235 ],
236 ],
237 'description' => [
238 'name' => 'description',
239 'type' => CRM_Utils_Type::T_STRING,
240 'title' => ts('Relationship Description'),
241 'description' => ts('Optional verbose description for the relationship.'),
242 'maxlength' => 255,
243 'size' => CRM_Utils_Type::HUGE,
244 'table_name' => 'civicrm_relationship',
245 'entity' => 'Relationship',
246 'bao' => 'CRM_Contact_BAO_Relationship',
247 'localizable' => 0,
248 'html' => [
249 'type' => 'Text',
250 ],
251 ],
252 'is_permission_a_b' => [
253 'name' => 'is_permission_a_b',
254 'type' => CRM_Utils_Type::T_INT,
255 'title' => ts('Contact A has Permission Over Contact B'),
256 'description' => ts('Permission that Contact A has to view/update Contact B'),
257 'required' => TRUE,
258 'default' => '0',
259 'table_name' => 'civicrm_relationship',
260 'entity' => 'Relationship',
261 'bao' => 'CRM_Contact_BAO_Relationship',
262 'localizable' => 0,
263 'html' => [
264 'type' => 'Radio',
265 ],
266 'pseudoconstant' => [
267 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
268 ]
269 ],
270 'is_permission_b_a' => [
271 'name' => 'is_permission_b_a',
272 'type' => CRM_Utils_Type::T_INT,
273 'title' => ts('Contact B has Permission Over Contact A'),
274 'description' => ts('Permission that Contact B has to view/update Contact A'),
275 'required' => TRUE,
276 'default' => '0',
277 'table_name' => 'civicrm_relationship',
278 'entity' => 'Relationship',
279 'bao' => 'CRM_Contact_BAO_Relationship',
280 'localizable' => 0,
281 'html' => [
282 'type' => 'Radio',
283 ],
284 'pseudoconstant' => [
285 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
286 ]
287 ],
288 'case_id' => [
289 'name' => 'case_id',
290 'type' => CRM_Utils_Type::T_INT,
291 'title' => ts('Relationship Case'),
292 'description' => ts('FK to civicrm_case'),
293 'default' => 'NULL',
294 'table_name' => 'civicrm_relationship',
295 'entity' => 'Relationship',
296 'bao' => 'CRM_Contact_BAO_Relationship',
297 'localizable' => 0,
298 'FKClassName' => 'CRM_Case_DAO_Case',
299 ],
300 ];
301 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
302 }
303 return Civi::$statics[__CLASS__]['fields'];
304 }
305
306 /**
307 * Return a mapping from field-name to the corresponding key (as used in fields()).
308 *
309 * @return array
310 * Array(string $name => string $uniqueName).
311 */
312 public static function &fieldKeys() {
313 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
314 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
315 }
316 return Civi::$statics[__CLASS__]['fieldKeys'];
317 }
318
319 /**
320 * Returns the names of this table
321 *
322 * @return string
323 */
324 public static function getTableName() {
325 return self::$_tableName;
326 }
327
328 /**
329 * Returns if this table needs to be logged
330 *
331 * @return bool
332 */
333 public function getLog() {
334 return self::$_log;
335 }
336
337 /**
338 * Returns the list of fields that can be imported
339 *
340 * @param bool $prefix
341 *
342 * @return array
343 */
344 public static function &import($prefix = FALSE) {
345 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, []);
346 return $r;
347 }
348
349 /**
350 * Returns the list of fields that can be exported
351 *
352 * @param bool $prefix
353 *
354 * @return array
355 */
356 public static function &export($prefix = FALSE) {
357 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, []);
358 return $r;
359 }
360
361 /**
362 * Returns the list of indices
363 *
364 * @param bool $localize
365 *
366 * @return array
367 */
368 public static function indices($localize = TRUE) {
369 $indices = [];
370 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
371 }
372
373 }