CRM-20312 regenerated DAOS with indexes
[civicrm-core.git] / CRM / Contact / DAO / Relationship.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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
29 * @copyright CiviCRM LLC (c) 2004-2017
30 *
31 * Generated from xml/schema/CRM/Contact/Relationship.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:a5a833da9d5016f0aeb06ba7c1058b3c)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Contact_DAO_Relationship constructor.
39 */
40 class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_relationship';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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 /**
122 * Class constructor.
123 */
124 function __construct() {
125 $this->__table = 'civicrm_relationship';
126 parent::__construct();
127 }
128 /**
129 * Returns foreign keys and entity references.
130 *
131 * @return array
132 * [CRM_Core_Reference_Interface]
133 */
134 static function getReferenceColumns() {
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']);
142 }
143 return Civi::$statics[__CLASS__]['links'];
144 }
145 /**
146 * Returns all the column names of this table
147 *
148 * @return array
149 */
150 static function &fields() {
151 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
152 Civi::$statics[__CLASS__]['fields'] = array(
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,
159 'table_name' => 'civicrm_relationship',
160 'entity' => 'Relationship',
161 'bao' => 'CRM_Contact_BAO_Relationship',
162 'localizable' => 0,
163 ) ,
164 'contact_id_a' => array(
165 'name' => 'contact_id_a',
166 'type' => CRM_Utils_Type::T_INT,
167 'title' => ts('Contact A') ,
168 'description' => 'id of the first contact',
169 'required' => true,
170 'table_name' => 'civicrm_relationship',
171 'entity' => 'Relationship',
172 'bao' => 'CRM_Contact_BAO_Relationship',
173 'localizable' => 0,
174 'FKClassName' => 'CRM_Contact_DAO_Contact',
175 ) ,
176 'contact_id_b' => array(
177 'name' => 'contact_id_b',
178 'type' => CRM_Utils_Type::T_INT,
179 'title' => ts('Contact B') ,
180 'description' => 'id of the second contact',
181 'required' => true,
182 'table_name' => 'civicrm_relationship',
183 'entity' => 'Relationship',
184 'bao' => 'CRM_Contact_BAO_Relationship',
185 'localizable' => 0,
186 'FKClassName' => 'CRM_Contact_DAO_Contact',
187 'html' => array(
188 'type' => 'EntityRef',
189 ) ,
190 ) ,
191 'relationship_type_id' => array(
192 'name' => 'relationship_type_id',
193 'type' => CRM_Utils_Type::T_INT,
194 'title' => ts('Relationship Type') ,
195 'description' => 'id of the relationship',
196 'required' => true,
197 'table_name' => 'civicrm_relationship',
198 'entity' => 'Relationship',
199 'bao' => 'CRM_Contact_BAO_Relationship',
200 'localizable' => 0,
201 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
202 'html' => array(
203 'type' => 'Select',
204 ) ,
205 ) ,
206 'start_date' => array(
207 'name' => 'start_date',
208 'type' => CRM_Utils_Type::T_DATE,
209 'title' => ts('Relationship Start Date') ,
210 'description' => 'date when the relationship started',
211 'table_name' => 'civicrm_relationship',
212 'entity' => 'Relationship',
213 'bao' => 'CRM_Contact_BAO_Relationship',
214 'localizable' => 0,
215 'html' => array(
216 'type' => 'Select Date',
217 ) ,
218 ) ,
219 'end_date' => array(
220 'name' => 'end_date',
221 'type' => CRM_Utils_Type::T_DATE,
222 'title' => ts('Relationship End Date') ,
223 'description' => 'date when the relationship ended',
224 'table_name' => 'civicrm_relationship',
225 'entity' => 'Relationship',
226 'bao' => 'CRM_Contact_BAO_Relationship',
227 'localizable' => 0,
228 'html' => array(
229 'type' => 'Select Date',
230 ) ,
231 ) ,
232 'is_active' => array(
233 'name' => 'is_active',
234 'type' => CRM_Utils_Type::T_BOOLEAN,
235 'title' => ts('Relationship Is Active') ,
236 'description' => 'is the relationship active ?',
237 'default' => '1',
238 'table_name' => 'civicrm_relationship',
239 'entity' => 'Relationship',
240 'bao' => 'CRM_Contact_BAO_Relationship',
241 'localizable' => 0,
242 'html' => array(
243 'type' => 'CheckBox',
244 ) ,
245 ) ,
246 'description' => array(
247 'name' => 'description',
248 'type' => CRM_Utils_Type::T_STRING,
249 'title' => ts('Relationship Description') ,
250 'description' => 'Optional verbose description for the relationship.',
251 'maxlength' => 255,
252 'size' => CRM_Utils_Type::HUGE,
253 'table_name' => 'civicrm_relationship',
254 'entity' => 'Relationship',
255 'bao' => 'CRM_Contact_BAO_Relationship',
256 'localizable' => 0,
257 'html' => array(
258 'type' => 'Text',
259 ) ,
260 ) ,
261 'is_permission_a_b' => array(
262 'name' => 'is_permission_a_b',
263 'type' => CRM_Utils_Type::T_BOOLEAN,
264 'title' => ts('Contact A has Permission Over Contact B') ,
265 'description' => 'is contact a has permission to view / edit contact and
266 related data for contact b ?
267 ',
268 'table_name' => 'civicrm_relationship',
269 'entity' => 'Relationship',
270 'bao' => 'CRM_Contact_BAO_Relationship',
271 'localizable' => 0,
272 'html' => array(
273 'type' => 'CheckBox',
274 ) ,
275 ) ,
276 'is_permission_b_a' => array(
277 'name' => 'is_permission_b_a',
278 'type' => CRM_Utils_Type::T_BOOLEAN,
279 'title' => ts('Contact B has Permission Over Contact A') ,
280 'description' => 'is contact b has permission to view / edit contact and
281 related data for contact a ?
282 ',
283 'table_name' => 'civicrm_relationship',
284 'entity' => 'Relationship',
285 'bao' => 'CRM_Contact_BAO_Relationship',
286 'localizable' => 0,
287 'html' => array(
288 'type' => 'CheckBox',
289 ) ,
290 ) ,
291 'case_id' => array(
292 'name' => 'case_id',
293 'type' => CRM_Utils_Type::T_INT,
294 'title' => ts('Relationship Case') ,
295 'description' => 'FK to civicrm_case',
296 'default' => 'NULL',
297 'table_name' => 'civicrm_relationship',
298 'entity' => 'Relationship',
299 'bao' => 'CRM_Contact_BAO_Relationship',
300 'localizable' => 0,
301 'FKClassName' => 'CRM_Case_DAO_Case',
302 ) ,
303 );
304 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
305 }
306 return Civi::$statics[__CLASS__]['fields'];
307 }
308 /**
309 * Return a mapping from field-name to the corresponding key (as used in fields()).
310 *
311 * @return array
312 * Array(string $name => string $uniqueName).
313 */
314 static function &fieldKeys() {
315 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
316 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
317 }
318 return Civi::$statics[__CLASS__]['fieldKeys'];
319 }
320 /**
321 * Returns the names of this table
322 *
323 * @return string
324 */
325 static function getTableName() {
326 return self::$_tableName;
327 }
328 /**
329 * Returns if this table needs to be logged
330 *
331 * @return boolean
332 */
333 function getLog() {
334 return self::$_log;
335 }
336 /**
337 * Returns the list of fields that can be imported
338 *
339 * @param bool $prefix
340 *
341 * @return array
342 */
343 static function &import($prefix = false) {
344 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, array());
345 return $r;
346 }
347 /**
348 * Returns the list of fields that can be exported
349 *
350 * @param bool $prefix
351 *
352 * @return array
353 */
354 static function &export($prefix = false) {
355 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, array());
356 return $r;
357 }
358 /**
359 * Returns the list of indices
360 */
361 public static function indices($localize = TRUE) {
362 $indices = array();
363 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
364 }
365 }