dev/core#117 Replace use of Deprecated function each in CRM/Member/BAO/Membership...
[civicrm-core.git] / CRM / Contact / DAO / Relationship.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
8c9251b3 5 * @copyright CiviCRM LLC (c) 2004-2018
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Contact/Relationship.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
022785d8 9 * (GenCodeChecksum:a5a833da9d5016f0aeb06ba7c1058b3c)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Relationship entity.
f41f0342 14 */
e501603b 15class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
22 static $_tableName = 'civicrm_relationship';
c3fc2621 23
e501603b 24 /**
f41f0342 25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 26 *
c3fc2621 27 * @var bool
e501603b 28 */
c3fc2621
CW
29 static $_log = TRUE;
30
e501603b
TO
31 /**
32 * Relationship ID
33 *
34 * @var int unsigned
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * id of the first contact
40 *
41 * @var int unsigned
42 */
43 public $contact_id_a;
c3fc2621 44
e501603b
TO
45 /**
46 * id of the second contact
47 *
48 * @var int unsigned
49 */
50 public $contact_id_b;
c3fc2621 51
e501603b
TO
52 /**
53 * id of the relationship
54 *
55 * @var int unsigned
56 */
57 public $relationship_type_id;
c3fc2621 58
e501603b
TO
59 /**
60 * date when the relationship started
61 *
62 * @var date
63 */
64 public $start_date;
c3fc2621 65
e501603b
TO
66 /**
67 * date when the relationship ended
68 *
69 * @var date
70 */
71 public $end_date;
c3fc2621 72
e501603b
TO
73 /**
74 * is the relationship active ?
75 *
76 * @var boolean
77 */
78 public $is_active;
c3fc2621 79
e501603b
TO
80 /**
81 * Optional verbose description for the relationship.
82 *
83 * @var string
84 */
85 public $description;
c3fc2621 86
e501603b
TO
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;
c3fc2621 94
e501603b
TO
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;
c3fc2621 102
e501603b
TO
103 /**
104 * FK to civicrm_case
105 *
106 * @var int unsigned
107 */
108 public $case_id;
c3fc2621 109
e501603b 110 /**
f41f0342 111 * Class constructor.
e501603b 112 */
c3fc2621 113 public function __construct() {
e501603b
TO
114 $this->__table = 'civicrm_relationship';
115 parent::__construct();
116 }
c3fc2621 117
e501603b 118 /**
f41f0342 119 * Returns foreign keys and entity references.
e501603b
TO
120 *
121 * @return array
122 * [CRM_Core_Reference_Interface]
123 */
c3fc2621 124 public static function getReferenceColumns() {
346aaaba
TO
125 if (!isset(Civi::$statics[__CLASS__]['links'])) {
126 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
c3fc2621
CW
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');
346aaaba 131 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 132 }
346aaaba 133 return Civi::$statics[__CLASS__]['links'];
e501603b 134 }
c3fc2621 135
e501603b
TO
136 /**
137 * Returns all the column names of this table
138 *
139 * @return array
140 */
c3fc2621 141 public static function &fields() {
346aaaba 142 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
143 Civi::$statics[__CLASS__]['fields'] = [
144 'id' => [
e501603b
TO
145 'name' => 'id',
146 'type' => CRM_Utils_Type::T_INT,
c3fc2621 147 'title' => ts('Relationship ID'),
e501603b 148 'description' => 'Relationship ID',
c3fc2621 149 'required' => TRUE,
522a26c9 150 'table_name' => 'civicrm_relationship',
151 'entity' => 'Relationship',
152 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 153 'localizable' => 0,
c3fc2621
CW
154 ],
155 'contact_id_a' => [
e501603b
TO
156 'name' => 'contact_id_a',
157 'type' => CRM_Utils_Type::T_INT,
c3fc2621 158 'title' => ts('Contact A'),
e501603b 159 'description' => 'id of the first contact',
c3fc2621 160 'required' => TRUE,
522a26c9 161 'table_name' => 'civicrm_relationship',
162 'entity' => 'Relationship',
163 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 164 'localizable' => 0,
e501603b 165 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
166 ],
167 'contact_id_b' => [
e501603b
TO
168 'name' => 'contact_id_b',
169 'type' => CRM_Utils_Type::T_INT,
c3fc2621 170 'title' => ts('Contact B'),
e501603b 171 'description' => 'id of the second contact',
c3fc2621 172 'required' => TRUE,
522a26c9 173 'table_name' => 'civicrm_relationship',
174 'entity' => 'Relationship',
175 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 176 'localizable' => 0,
e501603b 177 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621 178 'html' => [
e501603b 179 'type' => 'EntityRef',
c3fc2621
CW
180 ],
181 ],
182 'relationship_type_id' => [
e501603b
TO
183 'name' => 'relationship_type_id',
184 'type' => CRM_Utils_Type::T_INT,
c3fc2621 185 'title' => ts('Relationship Type'),
e501603b 186 'description' => 'id of the relationship',
c3fc2621 187 'required' => TRUE,
522a26c9 188 'table_name' => 'civicrm_relationship',
189 'entity' => 'Relationship',
190 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 191 'localizable' => 0,
e501603b 192 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
c3fc2621 193 'html' => [
e501603b 194 'type' => 'Select',
c3fc2621
CW
195 ],
196 ],
197 'start_date' => [
e501603b
TO
198 'name' => 'start_date',
199 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 200 'title' => ts('Relationship Start Date'),
e501603b 201 'description' => 'date when the relationship started',
522a26c9 202 'table_name' => 'civicrm_relationship',
203 'entity' => 'Relationship',
204 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 205 'localizable' => 0,
c3fc2621 206 'html' => [
e501603b 207 'type' => 'Select Date',
c3fc2621
CW
208 ],
209 ],
210 'end_date' => [
e501603b
TO
211 'name' => 'end_date',
212 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 213 'title' => ts('Relationship End Date'),
e501603b 214 'description' => 'date when the relationship ended',
522a26c9 215 'table_name' => 'civicrm_relationship',
216 'entity' => 'Relationship',
217 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 218 'localizable' => 0,
c3fc2621 219 'html' => [
e501603b 220 'type' => 'Select Date',
c3fc2621
CW
221 ],
222 ],
223 'is_active' => [
e501603b
TO
224 'name' => 'is_active',
225 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 226 'title' => ts('Relationship Is Active'),
e501603b
TO
227 'description' => 'is the relationship active ?',
228 'default' => '1',
522a26c9 229 'table_name' => 'civicrm_relationship',
230 'entity' => 'Relationship',
231 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 232 'localizable' => 0,
c3fc2621 233 'html' => [
e501603b 234 'type' => 'CheckBox',
c3fc2621
CW
235 ],
236 ],
237 'description' => [
e501603b
TO
238 'name' => 'description',
239 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 240 'title' => ts('Relationship Description'),
e501603b
TO
241 'description' => 'Optional verbose description for the relationship.',
242 'maxlength' => 255,
243 'size' => CRM_Utils_Type::HUGE,
522a26c9 244 'table_name' => 'civicrm_relationship',
245 'entity' => 'Relationship',
246 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 247 'localizable' => 0,
c3fc2621 248 'html' => [
e501603b 249 'type' => 'Text',
c3fc2621
CW
250 ],
251 ],
252 'is_permission_a_b' => [
e501603b
TO
253 'name' => 'is_permission_a_b',
254 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 255 'title' => ts('Contact A has Permission Over Contact B'),
e501603b
TO
256 'description' => 'is contact a has permission to view / edit contact and
257 related data for contact b ?
258 ',
522a26c9 259 'table_name' => 'civicrm_relationship',
260 'entity' => 'Relationship',
261 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 262 'localizable' => 0,
c3fc2621 263 'html' => [
e501603b 264 'type' => 'CheckBox',
c3fc2621
CW
265 ],
266 ],
267 'is_permission_b_a' => [
e501603b
TO
268 'name' => 'is_permission_b_a',
269 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 270 'title' => ts('Contact B has Permission Over Contact A'),
e501603b
TO
271 'description' => 'is contact b has permission to view / edit contact and
272 related data for contact a ?
273 ',
522a26c9 274 'table_name' => 'civicrm_relationship',
275 'entity' => 'Relationship',
276 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 277 'localizable' => 0,
c3fc2621 278 'html' => [
e501603b 279 'type' => 'CheckBox',
c3fc2621
CW
280 ],
281 ],
282 'case_id' => [
e501603b
TO
283 'name' => 'case_id',
284 'type' => CRM_Utils_Type::T_INT,
c3fc2621 285 'title' => ts('Relationship Case'),
e501603b
TO
286 'description' => 'FK to civicrm_case',
287 'default' => 'NULL',
522a26c9 288 'table_name' => 'civicrm_relationship',
289 'entity' => 'Relationship',
290 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 291 'localizable' => 0,
e501603b 292 'FKClassName' => 'CRM_Case_DAO_Case',
c3fc2621
CW
293 ],
294 ];
346aaaba 295 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 296 }
346aaaba 297 return Civi::$statics[__CLASS__]['fields'];
e501603b 298 }
c3fc2621 299
e501603b 300 /**
bd8e0b14 301 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
302 *
303 * @return array
bd8e0b14 304 * Array(string $name => string $uniqueName).
e501603b 305 */
c3fc2621 306 public static function &fieldKeys() {
bd8e0b14
TO
307 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
308 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 309 }
bd8e0b14 310 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 311 }
c3fc2621 312
e501603b
TO
313 /**
314 * Returns the names of this table
315 *
316 * @return string
317 */
c3fc2621 318 public static function getTableName() {
e501603b
TO
319 return self::$_tableName;
320 }
c3fc2621 321
e501603b
TO
322 /**
323 * Returns if this table needs to be logged
324 *
c3fc2621 325 * @return bool
e501603b 326 */
c3fc2621 327 public function getLog() {
e501603b
TO
328 return self::$_log;
329 }
c3fc2621 330
e501603b
TO
331 /**
332 * Returns the list of fields that can be imported
333 *
334 * @param bool $prefix
335 *
336 * @return array
337 */
c3fc2621
CW
338 public static function &import($prefix = FALSE) {
339 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, []);
60808919 340 return $r;
e501603b 341 }
c3fc2621 342
e501603b
TO
343 /**
344 * Returns the list of fields that can be exported
345 *
346 * @param bool $prefix
347 *
348 * @return array
349 */
c3fc2621
CW
350 public static function &export($prefix = FALSE) {
351 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, []);
60808919 352 return $r;
e501603b 353 }
c3fc2621 354
e7a6b91a
AS
355 /**
356 * Returns the list of indices
c3fc2621
CW
357 *
358 * @param bool $localize
359 *
360 * @return array
e7a6b91a
AS
361 */
362 public static function indices($localize = TRUE) {
c3fc2621 363 $indices = [];
e7a6b91a
AS
364 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
365 }
c3fc2621 366
e501603b 367}