Merge pull request #9599 from colemanw/CRM-19812
[civicrm-core.git] / CRM / Contact / DAO / Relationship.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
6| Copyright CiviCRM LLC (c) 2004-2016 |
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-2016
30 *
31 * Generated from xml/schema/CRM/Contact/Relationship.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:935010ec18927fdebfa19965f5f73b48)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_relationship';
e501603b
TO
44 /**
45 * static value to see if we should log any modifications to
46 * this table in the civicrm_log table
47 *
48 * @var boolean
49 */
50 static $_log = true;
51 /**
52 * Relationship ID
53 *
54 * @var int unsigned
55 */
56 public $id;
57 /**
58 * id of the first contact
59 *
60 * @var int unsigned
61 */
62 public $contact_id_a;
63 /**
64 * id of the second contact
65 *
66 * @var int unsigned
67 */
68 public $contact_id_b;
69 /**
70 * id of the relationship
71 *
72 * @var int unsigned
73 */
74 public $relationship_type_id;
75 /**
76 * date when the relationship started
77 *
78 * @var date
79 */
80 public $start_date;
81 /**
82 * date when the relationship ended
83 *
84 * @var date
85 */
86 public $end_date;
87 /**
88 * is the relationship active ?
89 *
90 * @var boolean
91 */
92 public $is_active;
93 /**
94 * Optional verbose description for the relationship.
95 *
96 * @var string
97 */
98 public $description;
99 /**
100 * is contact a has permission to view / edit contact and
101 related data for contact b ?
102 *
103 * @var boolean
104 */
105 public $is_permission_a_b;
106 /**
107 * is contact b has permission to view / edit contact and
108 related data for contact a ?
109 *
110 * @var boolean
111 */
112 public $is_permission_b_a;
113 /**
114 * FK to civicrm_case
115 *
116 * @var int unsigned
117 */
118 public $case_id;
119 /**
120 * class constructor
121 *
122 * @return civicrm_relationship
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() {
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,
159 ) ,
160 'contact_id_a' => array(
161 'name' => 'contact_id_a',
162 'type' => CRM_Utils_Type::T_INT,
163 'title' => ts('Contact A') ,
164 'description' => 'id of the first contact',
165 'required' => true,
166 'FKClassName' => 'CRM_Contact_DAO_Contact',
167 ) ,
168 'contact_id_b' => array(
169 'name' => 'contact_id_b',
170 'type' => CRM_Utils_Type::T_INT,
171 'title' => ts('Contact B') ,
172 'description' => 'id of the second contact',
173 'required' => true,
174 'FKClassName' => 'CRM_Contact_DAO_Contact',
175 'html' => array(
176 'type' => 'EntityRef',
177 ) ,
178 ) ,
179 'relationship_type_id' => array(
180 'name' => 'relationship_type_id',
181 'type' => CRM_Utils_Type::T_INT,
182 'title' => ts('Relationship Type') ,
183 'description' => 'id of the relationship',
184 'required' => true,
185 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
186 'html' => array(
187 'type' => 'Select',
188 ) ,
189 ) ,
190 'start_date' => array(
191 'name' => 'start_date',
192 'type' => CRM_Utils_Type::T_DATE,
193 'title' => ts('Relationship Start Date') ,
194 'description' => 'date when the relationship started',
195 'html' => array(
196 'type' => 'Select Date',
197 ) ,
198 ) ,
199 'end_date' => array(
200 'name' => 'end_date',
201 'type' => CRM_Utils_Type::T_DATE,
202 'title' => ts('Relationship End Date') ,
203 'description' => 'date when the relationship ended',
204 'html' => array(
205 'type' => 'Select Date',
206 ) ,
207 ) ,
208 'is_active' => array(
209 'name' => 'is_active',
210 'type' => CRM_Utils_Type::T_BOOLEAN,
211 'title' => ts('Relationship Is Active') ,
212 'description' => 'is the relationship active ?',
213 'default' => '1',
214 'html' => array(
215 'type' => 'CheckBox',
216 ) ,
217 ) ,
218 'description' => array(
219 'name' => 'description',
220 'type' => CRM_Utils_Type::T_STRING,
221 'title' => ts('Relationship Description') ,
222 'description' => 'Optional verbose description for the relationship.',
223 'maxlength' => 255,
224 'size' => CRM_Utils_Type::HUGE,
225 'html' => array(
226 'type' => 'Text',
227 ) ,
228 ) ,
229 'is_permission_a_b' => array(
230 'name' => 'is_permission_a_b',
231 'type' => CRM_Utils_Type::T_BOOLEAN,
232 'title' => ts('Contact A has Permission Over Contact B') ,
233 'description' => 'is contact a has permission to view / edit contact and
234 related data for contact b ?
235 ',
236 'html' => array(
237 'type' => 'CheckBox',
238 ) ,
239 ) ,
240 'is_permission_b_a' => array(
241 'name' => 'is_permission_b_a',
242 'type' => CRM_Utils_Type::T_BOOLEAN,
243 'title' => ts('Contact B has Permission Over Contact A') ,
244 'description' => 'is contact b has permission to view / edit contact and
245 related data for contact a ?
246 ',
247 'html' => array(
248 'type' => 'CheckBox',
249 ) ,
250 ) ,
251 'case_id' => array(
252 'name' => 'case_id',
253 'type' => CRM_Utils_Type::T_INT,
254 'title' => ts('Relationship Case') ,
255 'description' => 'FK to civicrm_case',
256 'default' => 'NULL',
257 'FKClassName' => 'CRM_Case_DAO_Case',
258 ) ,
259 );
346aaaba 260 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 261 }
346aaaba 262 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
263 }
264 /**
bd8e0b14 265 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
266 *
267 * @return array
bd8e0b14 268 * Array(string $name => string $uniqueName).
e501603b
TO
269 */
270 static function &fieldKeys() {
bd8e0b14
TO
271 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
272 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 273 }
bd8e0b14 274 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
275 }
276 /**
277 * Returns the names of this table
278 *
279 * @return string
280 */
281 static function getTableName() {
282 return self::$_tableName;
283 }
284 /**
285 * Returns if this table needs to be logged
286 *
287 * @return boolean
288 */
289 function getLog() {
290 return self::$_log;
291 }
292 /**
293 * Returns the list of fields that can be imported
294 *
295 * @param bool $prefix
296 *
297 * @return array
298 */
299 static function &import($prefix = false) {
60808919
TO
300 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, array());
301 return $r;
e501603b
TO
302 }
303 /**
304 * Returns the list of fields that can be exported
305 *
306 * @param bool $prefix
307 *
308 * @return array
309 */
310 static function &export($prefix = false) {
60808919
TO
311 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, array());
312 return $r;
e501603b
TO
313 }
314}