dev/core#117 Replace use of Deprecated function each in CRM/Member/BAO/Membership...
[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:a5a833da9d5016f0aeb06ba7c1058b3c)
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 * is contact a has permission to view / edit contact and
89 related data for contact b ?
90 *
91 * @var boolean
92 */
93 public $is_permission_a_b;
94
95 /**
96 * is contact b has permission to view / edit contact and
97 related data for contact a ?
98 *
99 * @var boolean
100 */
101 public $is_permission_b_a;
102
103 /**
104 * FK to civicrm_case
105 *
106 * @var int unsigned
107 */
108 public $case_id;
109
110 /**
111 * Class constructor.
112 */
113 public function __construct() {
114 $this->__table = 'civicrm_relationship';
115 parent::__construct();
116 }
117
118 /**
119 * Returns foreign keys and entity references.
120 *
121 * @return array
122 * [CRM_Core_Reference_Interface]
123 */
124 public static function getReferenceColumns() {
125 if (!isset(Civi::$statics[__CLASS__]['links'])) {
126 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
127 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id_a', 'civicrm_contact', 'id');
128 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id_b', 'civicrm_contact', 'id');
129 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
130 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'case_id', 'civicrm_case', 'id');
131 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
132 }
133 return Civi::$statics[__CLASS__]['links'];
134 }
135
136 /**
137 * Returns all the column names of this table
138 *
139 * @return array
140 */
141 public static function &fields() {
142 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
143 Civi::$statics[__CLASS__]['fields'] = [
144 'id' => [
145 'name' => 'id',
146 'type' => CRM_Utils_Type::T_INT,
147 'title' => ts('Relationship ID'),
148 'description' => 'Relationship ID',
149 'required' => TRUE,
150 'table_name' => 'civicrm_relationship',
151 'entity' => 'Relationship',
152 'bao' => 'CRM_Contact_BAO_Relationship',
153 'localizable' => 0,
154 ],
155 'contact_id_a' => [
156 'name' => 'contact_id_a',
157 'type' => CRM_Utils_Type::T_INT,
158 'title' => ts('Contact A'),
159 'description' => 'id of the first contact',
160 'required' => TRUE,
161 'table_name' => 'civicrm_relationship',
162 'entity' => 'Relationship',
163 'bao' => 'CRM_Contact_BAO_Relationship',
164 'localizable' => 0,
165 'FKClassName' => 'CRM_Contact_DAO_Contact',
166 ],
167 'contact_id_b' => [
168 'name' => 'contact_id_b',
169 'type' => CRM_Utils_Type::T_INT,
170 'title' => ts('Contact B'),
171 'description' => 'id of the second contact',
172 'required' => TRUE,
173 'table_name' => 'civicrm_relationship',
174 'entity' => 'Relationship',
175 'bao' => 'CRM_Contact_BAO_Relationship',
176 'localizable' => 0,
177 'FKClassName' => 'CRM_Contact_DAO_Contact',
178 'html' => [
179 'type' => 'EntityRef',
180 ],
181 ],
182 'relationship_type_id' => [
183 'name' => 'relationship_type_id',
184 'type' => CRM_Utils_Type::T_INT,
185 'title' => ts('Relationship Type'),
186 'description' => 'id of the relationship',
187 'required' => TRUE,
188 'table_name' => 'civicrm_relationship',
189 'entity' => 'Relationship',
190 'bao' => 'CRM_Contact_BAO_Relationship',
191 'localizable' => 0,
192 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
193 'html' => [
194 'type' => 'Select',
195 ],
196 ],
197 'start_date' => [
198 'name' => 'start_date',
199 'type' => CRM_Utils_Type::T_DATE,
200 'title' => ts('Relationship Start Date'),
201 'description' => 'date when the relationship started',
202 'table_name' => 'civicrm_relationship',
203 'entity' => 'Relationship',
204 'bao' => 'CRM_Contact_BAO_Relationship',
205 'localizable' => 0,
206 'html' => [
207 'type' => 'Select Date',
208 ],
209 ],
210 'end_date' => [
211 'name' => 'end_date',
212 'type' => CRM_Utils_Type::T_DATE,
213 'title' => ts('Relationship End Date'),
214 'description' => 'date when the relationship ended',
215 'table_name' => 'civicrm_relationship',
216 'entity' => 'Relationship',
217 'bao' => 'CRM_Contact_BAO_Relationship',
218 'localizable' => 0,
219 'html' => [
220 'type' => 'Select Date',
221 ],
222 ],
223 'is_active' => [
224 'name' => 'is_active',
225 'type' => CRM_Utils_Type::T_BOOLEAN,
226 'title' => ts('Relationship Is Active'),
227 'description' => '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' => '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_BOOLEAN,
255 'title' => ts('Contact A has Permission Over Contact B'),
256 'description' => 'is contact a has permission to view / edit contact and
257 related data for contact b ?
258 ',
259 'table_name' => 'civicrm_relationship',
260 'entity' => 'Relationship',
261 'bao' => 'CRM_Contact_BAO_Relationship',
262 'localizable' => 0,
263 'html' => [
264 'type' => 'CheckBox',
265 ],
266 ],
267 'is_permission_b_a' => [
268 'name' => 'is_permission_b_a',
269 'type' => CRM_Utils_Type::T_BOOLEAN,
270 'title' => ts('Contact B has Permission Over Contact A'),
271 'description' => 'is contact b has permission to view / edit contact and
272 related data for contact a ?
273 ',
274 'table_name' => 'civicrm_relationship',
275 'entity' => 'Relationship',
276 'bao' => 'CRM_Contact_BAO_Relationship',
277 'localizable' => 0,
278 'html' => [
279 'type' => 'CheckBox',
280 ],
281 ],
282 'case_id' => [
283 'name' => 'case_id',
284 'type' => CRM_Utils_Type::T_INT,
285 'title' => ts('Relationship Case'),
286 'description' => 'FK to civicrm_case',
287 'default' => 'NULL',
288 'table_name' => 'civicrm_relationship',
289 'entity' => 'Relationship',
290 'bao' => 'CRM_Contact_BAO_Relationship',
291 'localizable' => 0,
292 'FKClassName' => 'CRM_Case_DAO_Case',
293 ],
294 ];
295 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
296 }
297 return Civi::$statics[__CLASS__]['fields'];
298 }
299
300 /**
301 * Return a mapping from field-name to the corresponding key (as used in fields()).
302 *
303 * @return array
304 * Array(string $name => string $uniqueName).
305 */
306 public static function &fieldKeys() {
307 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
308 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
309 }
310 return Civi::$statics[__CLASS__]['fieldKeys'];
311 }
312
313 /**
314 * Returns the names of this table
315 *
316 * @return string
317 */
318 public static function getTableName() {
319 return self::$_tableName;
320 }
321
322 /**
323 * Returns if this table needs to be logged
324 *
325 * @return bool
326 */
327 public function getLog() {
328 return self::$_log;
329 }
330
331 /**
332 * Returns the list of fields that can be imported
333 *
334 * @param bool $prefix
335 *
336 * @return array
337 */
338 public static function &import($prefix = FALSE) {
339 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, []);
340 return $r;
341 }
342
343 /**
344 * Returns the list of fields that can be exported
345 *
346 * @param bool $prefix
347 *
348 * @return array
349 */
350 public static function &export($prefix = FALSE) {
351 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, []);
352 return $r;
353 }
354
355 /**
356 * Returns the list of indices
357 *
358 * @param bool $localize
359 *
360 * @return array
361 */
362 public static function indices($localize = TRUE) {
363 $indices = [];
364 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
365 }
366
367 }