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