Merge pull request #10340 from Stoob/master
[civicrm-core.git] / CRM / Contact / DAO / RelationshipType.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/RelationshipType.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:8fb00d8376af049ce62bc57ca01bc1bf)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Contact_DAO_RelationshipType constructor.
39 */
40 class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_relationship_type';
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 * Primary key
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * name for relationship of contact_a to contact_b.
61 *
62 * @var string
63 */
64 public $name_a_b;
65 /**
66 * label for relationship of contact_a to contact_b.
67 *
68 * @var string
69 */
70 public $label_a_b;
71 /**
72 * Optional name for relationship of contact_b to contact_a.
73 *
74 * @var string
75 */
76 public $name_b_a;
77 /**
78 * Optional label for relationship of contact_b to contact_a.
79 *
80 * @var string
81 */
82 public $label_b_a;
83 /**
84 * Optional verbose description of the relationship type.
85 *
86 * @var string
87 */
88 public $description;
89 /**
90 * If defined, contact_a in a relationship of this type must be a specific contact_type.
91 *
92 * @var string
93 */
94 public $contact_type_a;
95 /**
96 * If defined, contact_b in a relationship of this type must be a specific contact_type.
97 *
98 * @var string
99 */
100 public $contact_type_b;
101 /**
102 * If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.
103 *
104 * @var string
105 */
106 public $contact_sub_type_a;
107 /**
108 * If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.
109 *
110 * @var string
111 */
112 public $contact_sub_type_b;
113 /**
114 * Is this relationship type a predefined system type (can not be changed or de-activated)?
115 *
116 * @var boolean
117 */
118 public $is_reserved;
119 /**
120 * Is this relationship type currently active (i.e. can be used when creating or editing relationships)?
121 *
122 * @var boolean
123 */
124 public $is_active;
125 /**
126 * Class constructor.
127 */
128 function __construct() {
129 $this->__table = 'civicrm_relationship_type';
130 parent::__construct();
131 }
132 /**
133 * Returns all the column names of this table
134 *
135 * @return array
136 */
137 static function &fields() {
138 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
139 Civi::$statics[__CLASS__]['fields'] = array(
140 'id' => array(
141 'name' => 'id',
142 'type' => CRM_Utils_Type::T_INT,
143 'title' => ts('Relationship Type ID') ,
144 'description' => 'Primary key',
145 'required' => true,
146 'table_name' => 'civicrm_relationship_type',
147 'entity' => 'RelationshipType',
148 'bao' => 'CRM_Contact_BAO_RelationshipType',
149 'localizable' => 0,
150 ) ,
151 'name_a_b' => array(
152 'name' => 'name_a_b',
153 'type' => CRM_Utils_Type::T_STRING,
154 'title' => ts('Relationship Type Name A to B') ,
155 'description' => 'name for relationship of contact_a to contact_b.',
156 'maxlength' => 64,
157 'size' => CRM_Utils_Type::BIG,
158 'table_name' => 'civicrm_relationship_type',
159 'entity' => 'RelationshipType',
160 'bao' => 'CRM_Contact_BAO_RelationshipType',
161 'localizable' => 0,
162 ) ,
163 'label_a_b' => array(
164 'name' => 'label_a_b',
165 'type' => CRM_Utils_Type::T_STRING,
166 'title' => ts('Relationship Type Label A to B') ,
167 'description' => 'label for relationship of contact_a to contact_b.',
168 'maxlength' => 64,
169 'size' => CRM_Utils_Type::BIG,
170 'table_name' => 'civicrm_relationship_type',
171 'entity' => 'RelationshipType',
172 'bao' => 'CRM_Contact_BAO_RelationshipType',
173 'localizable' => 1,
174 ) ,
175 'name_b_a' => array(
176 'name' => 'name_b_a',
177 'type' => CRM_Utils_Type::T_STRING,
178 'title' => ts('Relationship Type Name B to A') ,
179 'description' => 'Optional name for relationship of contact_b to contact_a.',
180 'maxlength' => 64,
181 'size' => CRM_Utils_Type::BIG,
182 'table_name' => 'civicrm_relationship_type',
183 'entity' => 'RelationshipType',
184 'bao' => 'CRM_Contact_BAO_RelationshipType',
185 'localizable' => 0,
186 ) ,
187 'label_b_a' => array(
188 'name' => 'label_b_a',
189 'type' => CRM_Utils_Type::T_STRING,
190 'title' => ts('Relationship Type Label B to A') ,
191 'description' => 'Optional label for relationship of contact_b to contact_a.',
192 'maxlength' => 64,
193 'size' => CRM_Utils_Type::BIG,
194 'table_name' => 'civicrm_relationship_type',
195 'entity' => 'RelationshipType',
196 'bao' => 'CRM_Contact_BAO_RelationshipType',
197 'localizable' => 1,
198 ) ,
199 'description' => array(
200 'name' => 'description',
201 'type' => CRM_Utils_Type::T_STRING,
202 'title' => ts('Relationship Description') ,
203 'description' => 'Optional verbose description of the relationship type.',
204 'maxlength' => 255,
205 'size' => CRM_Utils_Type::HUGE,
206 'table_name' => 'civicrm_relationship_type',
207 'entity' => 'RelationshipType',
208 'bao' => 'CRM_Contact_BAO_RelationshipType',
209 'localizable' => 1,
210 ) ,
211 'contact_type_a' => array(
212 'name' => 'contact_type_a',
213 'type' => CRM_Utils_Type::T_STRING,
214 'title' => ts('Contact Type for Contact A') ,
215 'description' => 'If defined, contact_a in a relationship of this type must be a specific contact_type.',
216 'maxlength' => 12,
217 'size' => CRM_Utils_Type::TWELVE,
218 'table_name' => 'civicrm_relationship_type',
219 'entity' => 'RelationshipType',
220 'bao' => 'CRM_Contact_BAO_RelationshipType',
221 'localizable' => 0,
222 'html' => array(
223 'type' => 'Select',
224 ) ,
225 'pseudoconstant' => array(
226 'table' => 'civicrm_contact_type',
227 'keyColumn' => 'name',
228 'labelColumn' => 'label',
229 'condition' => 'parent_id IS NULL',
230 )
231 ) ,
232 'contact_type_b' => array(
233 'name' => 'contact_type_b',
234 'type' => CRM_Utils_Type::T_STRING,
235 'title' => ts('Contact Type for Contact B') ,
236 'description' => 'If defined, contact_b in a relationship of this type must be a specific contact_type.',
237 'maxlength' => 12,
238 'size' => CRM_Utils_Type::TWELVE,
239 'table_name' => 'civicrm_relationship_type',
240 'entity' => 'RelationshipType',
241 'bao' => 'CRM_Contact_BAO_RelationshipType',
242 'localizable' => 0,
243 'html' => array(
244 'type' => 'Select',
245 ) ,
246 'pseudoconstant' => array(
247 'table' => 'civicrm_contact_type',
248 'keyColumn' => 'name',
249 'labelColumn' => 'label',
250 'condition' => 'parent_id IS NULL',
251 )
252 ) ,
253 'contact_sub_type_a' => array(
254 'name' => 'contact_sub_type_a',
255 'type' => CRM_Utils_Type::T_STRING,
256 'title' => ts('Contact Subtype A') ,
257 'description' => 'If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.
258 ',
259 'maxlength' => 64,
260 'size' => CRM_Utils_Type::BIG,
261 'table_name' => 'civicrm_relationship_type',
262 'entity' => 'RelationshipType',
263 'bao' => 'CRM_Contact_BAO_RelationshipType',
264 'localizable' => 0,
265 'html' => array(
266 'type' => 'Select',
267 ) ,
268 'pseudoconstant' => array(
269 'table' => 'civicrm_contact_type',
270 'keyColumn' => 'name',
271 'labelColumn' => 'label',
272 'condition' => 'parent_id IS NOT NULL',
273 )
274 ) ,
275 'contact_sub_type_b' => array(
276 'name' => 'contact_sub_type_b',
277 'type' => CRM_Utils_Type::T_STRING,
278 'title' => ts('Contact Subtype B') ,
279 'description' => 'If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.
280 ',
281 'maxlength' => 64,
282 'size' => CRM_Utils_Type::BIG,
283 'table_name' => 'civicrm_relationship_type',
284 'entity' => 'RelationshipType',
285 'bao' => 'CRM_Contact_BAO_RelationshipType',
286 'localizable' => 0,
287 'html' => array(
288 'type' => 'Select',
289 ) ,
290 'pseudoconstant' => array(
291 'table' => 'civicrm_contact_type',
292 'keyColumn' => 'name',
293 'labelColumn' => 'label',
294 'condition' => 'parent_id IS NOT NULL',
295 )
296 ) ,
297 'is_reserved' => array(
298 'name' => 'is_reserved',
299 'type' => CRM_Utils_Type::T_BOOLEAN,
300 'title' => ts('Relationship Type is Reserved') ,
301 'description' => 'Is this relationship type a predefined system type (can not be changed or de-activated)?',
302 'table_name' => 'civicrm_relationship_type',
303 'entity' => 'RelationshipType',
304 'bao' => 'CRM_Contact_BAO_RelationshipType',
305 'localizable' => 0,
306 ) ,
307 'is_active' => array(
308 'name' => 'is_active',
309 'type' => CRM_Utils_Type::T_BOOLEAN,
310 'title' => ts('Relationship Type is Active') ,
311 'description' => 'Is this relationship type currently active (i.e. can be used when creating or editing relationships)?
312 ',
313 'default' => '1',
314 'table_name' => 'civicrm_relationship_type',
315 'entity' => 'RelationshipType',
316 'bao' => 'CRM_Contact_BAO_RelationshipType',
317 'localizable' => 0,
318 ) ,
319 );
320 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
321 }
322 return Civi::$statics[__CLASS__]['fields'];
323 }
324 /**
325 * Return a mapping from field-name to the corresponding key (as used in fields()).
326 *
327 * @return array
328 * Array(string $name => string $uniqueName).
329 */
330 static function &fieldKeys() {
331 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
332 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
333 }
334 return Civi::$statics[__CLASS__]['fieldKeys'];
335 }
336 /**
337 * Returns the names of this table
338 *
339 * @return string
340 */
341 static function getTableName() {
342 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
343 }
344 /**
345 * Returns if this table needs to be logged
346 *
347 * @return boolean
348 */
349 function getLog() {
350 return self::$_log;
351 }
352 /**
353 * Returns the list of fields that can be imported
354 *
355 * @param bool $prefix
356 *
357 * @return array
358 */
359 static function &import($prefix = false) {
360 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship_type', $prefix, array());
361 return $r;
362 }
363 /**
364 * Returns the list of fields that can be exported
365 *
366 * @param bool $prefix
367 *
368 * @return array
369 */
370 static function &export($prefix = false) {
371 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship_type', $prefix, array());
372 return $r;
373 }
374 /**
375 * Returns the list of indices
376 */
377 public static function indices($localize = TRUE) {
378 $indices = array(
379 'UI_name_a_b' => array(
380 'name' => 'UI_name_a_b',
381 'field' => array(
382 0 => 'name_a_b',
383 ) ,
384 'localizable' => false,
385 'unique' => true,
386 'sig' => 'civicrm_relationship_type::1::name_a_b',
387 ) ,
388 'UI_name_b_a' => array(
389 'name' => 'UI_name_b_a',
390 'field' => array(
391 0 => 'name_b_a',
392 ) ,
393 'localizable' => false,
394 'unique' => true,
395 'sig' => 'civicrm_relationship_type::1::name_b_a',
396 ) ,
397 );
398 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
399 }
400 }