fixup CRM-14885 - Import DAOs
[civicrm-core.git] / CRM / Core / DAO / OptionValue.php
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/Core/OptionValue.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:cfa37dbb4bcb24f01ea8c59d2e2705e3)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_option_value';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 */
68 static $_import = null;
69 /**
70 * static instance to hold the values that can
71 * be exported
72 *
73 * @var array
74 */
75 static $_export = null;
76 /**
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
79 *
80 * @var boolean
81 */
82 static $_log = true;
83 /**
84 * Option ID
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * Group which this option belongs to.
91 *
92 * @var int unsigned
93 */
94 public $option_group_id;
95 /**
96 * Option string as displayed to users - e.g. the label in an HTML OPTION tag.
97 *
98 * @var string
99 */
100 public $label;
101 /**
102 * The actual value stored (as a foreign key) in the data record. Functions which need lookup option_value.title should use civicrm_option_value.option_group_id plus civicrm_option_value.value as the key.
103 *
104 * @var string
105 */
106 public $value;
107 /**
108 * Stores a fixed (non-translated) name for this option value. Lookup functions should use the name as the key for the option value row.
109 *
110 * @var string
111 */
112 public $name;
113 /**
114 * Use to sort and/or set display properties for sub-set(s) of options within an option group. EXAMPLE: Use for college_interest field, to differentiate partners from non-partners.
115 *
116 * @var string
117 */
118 public $grouping;
119 /**
120 * Bitwise logic can be used to create subsets of options within an option_group for different uses.
121 *
122 * @var int unsigned
123 */
124 public $filter;
125 /**
126 * Is this the default option for the group?
127 *
128 * @var boolean
129 */
130 public $is_default;
131 /**
132 * Controls display sort order.
133 *
134 * @var int unsigned
135 */
136 public $weight;
137 /**
138 * Optional description.
139 *
140 * @var text
141 */
142 public $description;
143 /**
144 * Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?
145 *
146 * @var boolean
147 */
148 public $is_optgroup;
149 /**
150 * Is this a predefined system object?
151 *
152 * @var boolean
153 */
154 public $is_reserved;
155 /**
156 * Is this option active?
157 *
158 * @var boolean
159 */
160 public $is_active;
161 /**
162 * Component that this option value belongs/caters to.
163 *
164 * @var int unsigned
165 */
166 public $component_id;
167 /**
168 * Which Domain is this option value for
169 *
170 * @var int unsigned
171 */
172 public $domain_id;
173 /**
174 *
175 * @var int unsigned
176 */
177 public $visibility_id;
178 /**
179 * class constructor
180 *
181 * @return civicrm_option_value
182 */
183 function __construct() {
184 $this->__table = 'civicrm_option_value';
185 parent::__construct();
186 }
187 /**
188 * Returns foreign keys and entity references
189 *
190 * @return array
191 * [CRM_Core_Reference_Interface]
192 */
193 static function getReferenceColumns() {
194 if (!self::$_links) {
195 self::$_links = static ::createReferenceColumns(__CLASS__);
196 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'option_group_id', 'civicrm_option_group', 'id');
197 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'component_id', 'civicrm_component', 'id');
198 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'domain_id', 'civicrm_domain', 'id');
199 }
200 return self::$_links;
201 }
202 /**
203 * Returns all the column names of this table
204 *
205 * @return array
206 */
207 static function &fields() {
208 if (!(self::$_fields)) {
209 self::$_fields = array(
210 'id' => array(
211 'name' => 'id',
212 'type' => CRM_Utils_Type::T_INT,
213 'title' => ts('Option Value ID') ,
214 'description' => 'Option ID',
215 'required' => true,
216 ) ,
217 'option_group_id' => array(
218 'name' => 'option_group_id',
219 'type' => CRM_Utils_Type::T_INT,
220 'title' => ts('Option Group ID') ,
221 'description' => 'Group which this option belongs to.',
222 'required' => true,
223 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
224 'html' => array(
225 'type' => 'Select',
226 ) ,
227 'pseudoconstant' => array(
228 'table' => 'civicrm_option_group',
229 'keyColumn' => 'id',
230 'labelColumn' => 'name',
231 )
232 ) ,
233 'label' => array(
234 'name' => 'label',
235 'type' => CRM_Utils_Type::T_STRING,
236 'title' => ts('Option Label') ,
237 'description' => 'Option string as displayed to users - e.g. the label in an HTML OPTION tag.',
238 'required' => true,
239 'maxlength' => 512,
240 'size' => CRM_Utils_Type::HUGE,
241 ) ,
242 'value' => array(
243 'name' => 'value',
244 'type' => CRM_Utils_Type::T_STRING,
245 'title' => ts('Option Value') ,
246 'description' => 'The actual value stored (as a foreign key) in the data record. Functions which need lookup option_value.title should use civicrm_option_value.option_group_id plus civicrm_option_value.value as the key.',
247 'required' => true,
248 'maxlength' => 512,
249 'size' => CRM_Utils_Type::HUGE,
250 ) ,
251 'name' => array(
252 'name' => 'name',
253 'type' => CRM_Utils_Type::T_STRING,
254 'title' => ts('Option Name') ,
255 'description' => 'Stores a fixed (non-translated) name for this option value. Lookup functions should use the name as the key for the option value row.',
256 'maxlength' => 255,
257 'size' => CRM_Utils_Type::HUGE,
258 'import' => true,
259 'where' => 'civicrm_option_value.name',
260 'headerPattern' => '',
261 'dataPattern' => '',
262 'export' => true,
263 ) ,
264 'grouping' => array(
265 'name' => 'grouping',
266 'type' => CRM_Utils_Type::T_STRING,
267 'title' => ts('Option Grouping Name') ,
268 'description' => 'Use to sort and/or set display properties for sub-set(s) of options within an option group. EXAMPLE: Use for college_interest field, to differentiate partners from non-partners.',
269 'maxlength' => 255,
270 'size' => CRM_Utils_Type::HUGE,
271 ) ,
272 'filter' => array(
273 'name' => 'filter',
274 'type' => CRM_Utils_Type::T_INT,
275 'title' => ts('Filter') ,
276 'description' => 'Bitwise logic can be used to create subsets of options within an option_group for different uses.',
277 ) ,
278 'is_default' => array(
279 'name' => 'is_default',
280 'type' => CRM_Utils_Type::T_BOOLEAN,
281 'title' => ts('Option is Default?') ,
282 'description' => 'Is this the default option for the group?',
283 ) ,
284 'weight' => array(
285 'name' => 'weight',
286 'type' => CRM_Utils_Type::T_INT,
287 'title' => ts('Order') ,
288 'description' => 'Controls display sort order.',
289 'required' => true,
290 ) ,
291 'description' => array(
292 'name' => 'description',
293 'type' => CRM_Utils_Type::T_TEXT,
294 'title' => ts('Option Description') ,
295 'description' => 'Optional description.',
296 'rows' => 8,
297 'cols' => 60,
298 'html' => array(
299 'type' => 'TextArea',
300 ) ,
301 ) ,
302 'is_optgroup' => array(
303 'name' => 'is_optgroup',
304 'type' => CRM_Utils_Type::T_BOOLEAN,
305 'title' => ts('Option is Header?') ,
306 'description' => 'Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?',
307 ) ,
308 'is_reserved' => array(
309 'name' => 'is_reserved',
310 'type' => CRM_Utils_Type::T_BOOLEAN,
311 'title' => ts('Option Is Reserved?') ,
312 'description' => 'Is this a predefined system object?',
313 ) ,
314 'is_active' => array(
315 'name' => 'is_active',
316 'type' => CRM_Utils_Type::T_BOOLEAN,
317 'title' => ts('Option Is Active') ,
318 'description' => 'Is this option active?',
319 'default' => '1',
320 ) ,
321 'component_id' => array(
322 'name' => 'component_id',
323 'type' => CRM_Utils_Type::T_INT,
324 'title' => ts('Option Component') ,
325 'description' => 'Component that this option value belongs/caters to.',
326 'FKClassName' => 'CRM_Core_DAO_Component',
327 'html' => array(
328 'type' => 'Select',
329 ) ,
330 'pseudoconstant' => array(
331 'table' => 'civicrm_component',
332 'keyColumn' => 'id',
333 'labelColumn' => 'name',
334 )
335 ) ,
336 'domain_id' => array(
337 'name' => 'domain_id',
338 'type' => CRM_Utils_Type::T_INT,
339 'title' => ts('Option Domain') ,
340 'description' => 'Which Domain is this option value for',
341 'FKClassName' => 'CRM_Core_DAO_Domain',
342 'pseudoconstant' => array(
343 'table' => 'civicrm_domain',
344 'keyColumn' => 'id',
345 'labelColumn' => 'name',
346 )
347 ) ,
348 'visibility_id' => array(
349 'name' => 'visibility_id',
350 'type' => CRM_Utils_Type::T_INT,
351 'title' => ts('Option Visibility') ,
352 'default' => 'NULL',
353 ) ,
354 );
355 }
356 return self::$_fields;
357 }
358 /**
359 * Returns an array containing, for each field, the arary key used for that
360 * field in self::$_fields.
361 *
362 * @return array
363 */
364 static function &fieldKeys() {
365 if (!(self::$_fieldKeys)) {
366 self::$_fieldKeys = array(
367 'id' => 'id',
368 'option_group_id' => 'option_group_id',
369 'label' => 'label',
370 'value' => 'value',
371 'name' => 'name',
372 'grouping' => 'grouping',
373 'filter' => 'filter',
374 'is_default' => 'is_default',
375 'weight' => 'weight',
376 'description' => 'description',
377 'is_optgroup' => 'is_optgroup',
378 'is_reserved' => 'is_reserved',
379 'is_active' => 'is_active',
380 'component_id' => 'component_id',
381 'domain_id' => 'domain_id',
382 'visibility_id' => 'visibility_id',
383 );
384 }
385 return self::$_fieldKeys;
386 }
387 /**
388 * Returns the names of this table
389 *
390 * @return string
391 */
392 static function getTableName() {
393 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
394 }
395 /**
396 * Returns if this table needs to be logged
397 *
398 * @return boolean
399 */
400 function getLog() {
401 return self::$_log;
402 }
403 /**
404 * Returns the list of fields that can be imported
405 *
406 * @param bool $prefix
407 *
408 * @return array
409 */
410 static function &import($prefix = false) {
411 if (!(self::$_import)) {
412 self::$_import = array();
413 $fields = self::fields();
414 foreach($fields as $name => $field) {
415 if (CRM_Utils_Array::value('import', $field)) {
416 if ($prefix) {
417 self::$_import['option_value'] = & $fields[$name];
418 } else {
419 self::$_import[$name] = & $fields[$name];
420 }
421 }
422 }
423 }
424 return self::$_import;
425 }
426 /**
427 * Returns the list of fields that can be exported
428 *
429 * @param bool $prefix
430 *
431 * @return array
432 */
433 static function &export($prefix = false) {
434 if (!(self::$_export)) {
435 self::$_export = array();
436 $fields = self::fields();
437 foreach($fields as $name => $field) {
438 if (CRM_Utils_Array::value('export', $field)) {
439 if ($prefix) {
440 self::$_export['option_value'] = & $fields[$name];
441 } else {
442 self::$_export[$name] = & $fields[$name];
443 }
444 }
445 }
446 }
447 return self::$_export;
448 }
449 }