CRM-19925 Updated DAO files
[civicrm-core.git] / CRM / Contact / DAO / Relationship.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
7+--------------------------------------------------------------------+
8| This file is a part of CiviCRM. |
9| |
10| CiviCRM is free software; you can copy, modify, and distribute it |
11| under the terms of the GNU Affero General Public License |
12| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13| |
14| CiviCRM is distributed in the hope that it will be useful, but |
15| WITHOUT ANY WARRANTY; without even the implied warranty of |
16| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17| See the GNU Affero General Public License for more details. |
18| |
19| You should have received a copy of the GNU Affero General Public |
20| License and the CiviCRM Licensing Exception along |
21| with this program; if not, contact CiviCRM LLC |
22| at info[AT]civicrm[DOT]org. If you have questions about the |
23| GNU Affero General Public License or the licensing of CiviCRM, |
24| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Contact/Relationship.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
522a26c9 33 * (GenCodeChecksum:7435ce706f5392235ecda689d0f55bba)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
f41f0342 37/**
38 * CRM_Contact_DAO_Relationship constructor.
39 */
e501603b
TO
40class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
41 /**
f41f0342 42 * Static instance to hold the table name.
e501603b
TO
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_relationship';
e501603b 47 /**
f41f0342 48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b
TO
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 * Relationship ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * id of the first contact
61 *
62 * @var int unsigned
63 */
64 public $contact_id_a;
65 /**
66 * id of the second contact
67 *
68 * @var int unsigned
69 */
70 public $contact_id_b;
71 /**
72 * id of the relationship
73 *
74 * @var int unsigned
75 */
76 public $relationship_type_id;
77 /**
78 * date when the relationship started
79 *
80 * @var date
81 */
82 public $start_date;
83 /**
84 * date when the relationship ended
85 *
86 * @var date
87 */
88 public $end_date;
89 /**
90 * is the relationship active ?
91 *
92 * @var boolean
93 */
94 public $is_active;
95 /**
96 * Optional verbose description for the relationship.
97 *
98 * @var string
99 */
100 public $description;
101 /**
102 * is contact a has permission to view / edit contact and
103 related data for contact b ?
104 *
105 * @var boolean
106 */
107 public $is_permission_a_b;
108 /**
109 * is contact b has permission to view / edit contact and
110 related data for contact a ?
111 *
112 * @var boolean
113 */
114 public $is_permission_b_a;
115 /**
116 * FK to civicrm_case
117 *
118 * @var int unsigned
119 */
120 public $case_id;
121 /**
f41f0342 122 * Class constructor.
e501603b
TO
123 */
124 function __construct() {
125 $this->__table = 'civicrm_relationship';
126 parent::__construct();
127 }
128 /**
f41f0342 129 * Returns foreign keys and entity references.
e501603b
TO
130 *
131 * @return array
132 * [CRM_Core_Reference_Interface]
133 */
134 static function getReferenceColumns() {
346aaaba
TO
135 if (!isset(Civi::$statics[__CLASS__]['links'])) {
136 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
137 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id_a', 'civicrm_contact', 'id');
138 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id_b', 'civicrm_contact', 'id');
139 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'relationship_type_id', 'civicrm_relationship_type', 'id');
140 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'case_id', 'civicrm_case', 'id');
141 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 142 }
346aaaba 143 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
144 }
145 /**
146 * Returns all the column names of this table
147 *
148 * @return array
149 */
150 static function &fields() {
346aaaba
TO
151 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
152 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
153 'id' => array(
154 'name' => 'id',
155 'type' => CRM_Utils_Type::T_INT,
156 'title' => ts('Relationship ID') ,
157 'description' => 'Relationship ID',
158 'required' => true,
522a26c9 159 'table_name' => 'civicrm_relationship',
160 'entity' => 'Relationship',
161 'bao' => 'CRM_Contact_BAO_Relationship',
e501603b
TO
162 ) ,
163 'contact_id_a' => array(
164 'name' => 'contact_id_a',
165 'type' => CRM_Utils_Type::T_INT,
166 'title' => ts('Contact A') ,
167 'description' => 'id of the first contact',
168 'required' => true,
522a26c9 169 'table_name' => 'civicrm_relationship',
170 'entity' => 'Relationship',
171 'bao' => 'CRM_Contact_BAO_Relationship',
e501603b
TO
172 'FKClassName' => 'CRM_Contact_DAO_Contact',
173 ) ,
174 'contact_id_b' => array(
175 'name' => 'contact_id_b',
176 'type' => CRM_Utils_Type::T_INT,
177 'title' => ts('Contact B') ,
178 'description' => 'id of the second contact',
179 'required' => true,
522a26c9 180 'table_name' => 'civicrm_relationship',
181 'entity' => 'Relationship',
182 'bao' => 'CRM_Contact_BAO_Relationship',
e501603b
TO
183 'FKClassName' => 'CRM_Contact_DAO_Contact',
184 'html' => array(
185 'type' => 'EntityRef',
186 ) ,
187 ) ,
188 'relationship_type_id' => array(
189 'name' => 'relationship_type_id',
190 'type' => CRM_Utils_Type::T_INT,
191 'title' => ts('Relationship Type') ,
192 'description' => 'id of the relationship',
193 'required' => true,
522a26c9 194 'table_name' => 'civicrm_relationship',
195 'entity' => 'Relationship',
196 'bao' => 'CRM_Contact_BAO_Relationship',
e501603b
TO
197 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
198 'html' => array(
199 'type' => 'Select',
200 ) ,
201 ) ,
202 'start_date' => array(
203 'name' => 'start_date',
204 'type' => CRM_Utils_Type::T_DATE,
205 'title' => ts('Relationship Start Date') ,
206 'description' => 'date when the relationship started',
522a26c9 207 'table_name' => 'civicrm_relationship',
208 'entity' => 'Relationship',
209 'bao' => 'CRM_Contact_BAO_Relationship',
e501603b
TO
210 'html' => array(
211 'type' => 'Select Date',
212 ) ,
213 ) ,
214 'end_date' => array(
215 'name' => 'end_date',
216 'type' => CRM_Utils_Type::T_DATE,
217 'title' => ts('Relationship End Date') ,
218 'description' => 'date when the relationship ended',
522a26c9 219 'table_name' => 'civicrm_relationship',
220 'entity' => 'Relationship',
221 'bao' => 'CRM_Contact_BAO_Relationship',
e501603b
TO
222 'html' => array(
223 'type' => 'Select Date',
224 ) ,
225 ) ,
226 'is_active' => array(
227 'name' => 'is_active',
228 'type' => CRM_Utils_Type::T_BOOLEAN,
229 'title' => ts('Relationship Is Active') ,
230 'description' => 'is the relationship active ?',
231 'default' => '1',
522a26c9 232 'table_name' => 'civicrm_relationship',
233 'entity' => 'Relationship',
234 'bao' => 'CRM_Contact_BAO_Relationship',
e501603b
TO
235 'html' => array(
236 'type' => 'CheckBox',
237 ) ,
238 ) ,
239 'description' => array(
240 'name' => 'description',
241 'type' => CRM_Utils_Type::T_STRING,
242 'title' => ts('Relationship Description') ,
243 'description' => 'Optional verbose description for the relationship.',
244 'maxlength' => 255,
245 'size' => CRM_Utils_Type::HUGE,
522a26c9 246 'table_name' => 'civicrm_relationship',
247 'entity' => 'Relationship',
248 'bao' => 'CRM_Contact_BAO_Relationship',
e501603b
TO
249 'html' => array(
250 'type' => 'Text',
251 ) ,
252 ) ,
253 'is_permission_a_b' => array(
254 'name' => 'is_permission_a_b',
255 'type' => CRM_Utils_Type::T_BOOLEAN,
256 'title' => ts('Contact A has Permission Over Contact B') ,
257 'description' => 'is contact a has permission to view / edit contact and
258 related data for contact b ?
259 ',
522a26c9 260 'table_name' => 'civicrm_relationship',
261 'entity' => 'Relationship',
262 'bao' => 'CRM_Contact_BAO_Relationship',
e501603b
TO
263 'html' => array(
264 'type' => 'CheckBox',
265 ) ,
266 ) ,
267 'is_permission_b_a' => array(
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 ',
522a26c9 274 'table_name' => 'civicrm_relationship',
275 'entity' => 'Relationship',
276 'bao' => 'CRM_Contact_BAO_Relationship',
e501603b
TO
277 'html' => array(
278 'type' => 'CheckBox',
279 ) ,
280 ) ,
281 'case_id' => array(
282 'name' => 'case_id',
283 'type' => CRM_Utils_Type::T_INT,
284 'title' => ts('Relationship Case') ,
285 'description' => 'FK to civicrm_case',
286 'default' => 'NULL',
522a26c9 287 'table_name' => 'civicrm_relationship',
288 'entity' => 'Relationship',
289 'bao' => 'CRM_Contact_BAO_Relationship',
e501603b
TO
290 'FKClassName' => 'CRM_Case_DAO_Case',
291 ) ,
292 );
346aaaba 293 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 294 }
346aaaba 295 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
296 }
297 /**
bd8e0b14 298 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
299 *
300 * @return array
bd8e0b14 301 * Array(string $name => string $uniqueName).
e501603b
TO
302 */
303 static function &fieldKeys() {
bd8e0b14
TO
304 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
305 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 306 }
bd8e0b14 307 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
308 }
309 /**
310 * Returns the names of this table
311 *
312 * @return string
313 */
314 static function getTableName() {
315 return self::$_tableName;
316 }
317 /**
318 * Returns if this table needs to be logged
319 *
320 * @return boolean
321 */
322 function getLog() {
323 return self::$_log;
324 }
325 /**
326 * Returns the list of fields that can be imported
327 *
328 * @param bool $prefix
329 *
330 * @return array
331 */
332 static function &import($prefix = false) {
60808919
TO
333 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, array());
334 return $r;
e501603b
TO
335 }
336 /**
337 * Returns the list of fields that can be exported
338 *
339 * @param bool $prefix
340 *
341 * @return array
342 */
343 static function &export($prefix = false) {
60808919
TO
344 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, array());
345 return $r;
e501603b
TO
346 }
347}