Commit | Line | Data |
---|---|---|
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 | |
e7a6b91a | 33 | * (GenCodeChecksum:8cf699b034cbd9d7b8fe0a69250a79ba) |
e501603b TO |
34 | */ |
35 | require_once 'CRM/Core/DAO.php'; | |
36 | require_once 'CRM/Utils/Type.php'; | |
f41f0342 | 37 | /** |
38 | * CRM_Core_DAO_OptionValue constructor. | |
39 | */ | |
e501603b TO |
40 | class 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, | |
522a26c9 | 197 | 'table_name' => 'civicrm_option_value', |
198 | 'entity' => 'OptionValue', | |
199 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 200 | 'localizable' => 0, |
e501603b TO |
201 | ) , |
202 | 'option_group_id' => array( | |
203 | 'name' => 'option_group_id', | |
204 | 'type' => CRM_Utils_Type::T_INT, | |
205 | 'title' => ts('Option Group ID') , | |
206 | 'description' => 'Group which this option belongs to.', | |
207 | 'required' => true, | |
522a26c9 | 208 | 'table_name' => 'civicrm_option_value', |
209 | 'entity' => 'OptionValue', | |
210 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 211 | 'localizable' => 0, |
e501603b TO |
212 | 'FKClassName' => 'CRM_Core_DAO_OptionGroup', |
213 | 'html' => array( | |
214 | 'type' => 'Select', | |
215 | ) , | |
216 | 'pseudoconstant' => array( | |
217 | 'table' => 'civicrm_option_group', | |
218 | 'keyColumn' => 'id', | |
219 | 'labelColumn' => 'name', | |
220 | ) | |
221 | ) , | |
222 | 'label' => array( | |
223 | 'name' => 'label', | |
224 | 'type' => CRM_Utils_Type::T_STRING, | |
225 | 'title' => ts('Option Label') , | |
226 | 'description' => 'Option string as displayed to users - e.g. the label in an HTML OPTION tag.', | |
227 | 'required' => true, | |
228 | 'maxlength' => 512, | |
229 | 'size' => CRM_Utils_Type::HUGE, | |
522a26c9 | 230 | 'table_name' => 'civicrm_option_value', |
231 | 'entity' => 'OptionValue', | |
232 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 233 | 'localizable' => 1, |
e501603b TO |
234 | ) , |
235 | 'value' => array( | |
236 | 'name' => 'value', | |
237 | 'type' => CRM_Utils_Type::T_STRING, | |
238 | 'title' => ts('Option Value') , | |
239 | '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.', | |
240 | 'required' => true, | |
241 | 'maxlength' => 512, | |
242 | 'size' => CRM_Utils_Type::HUGE, | |
522a26c9 | 243 | 'table_name' => 'civicrm_option_value', |
244 | 'entity' => 'OptionValue', | |
245 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 246 | 'localizable' => 0, |
e501603b TO |
247 | ) , |
248 | 'name' => array( | |
249 | 'name' => 'name', | |
250 | 'type' => CRM_Utils_Type::T_STRING, | |
251 | 'title' => ts('Option Name') , | |
252 | '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.', | |
253 | 'maxlength' => 255, | |
254 | 'size' => CRM_Utils_Type::HUGE, | |
255 | 'import' => true, | |
256 | 'where' => 'civicrm_option_value.name', | |
257 | 'headerPattern' => '', | |
258 | 'dataPattern' => '', | |
259 | 'export' => true, | |
522a26c9 | 260 | 'table_name' => 'civicrm_option_value', |
261 | 'entity' => 'OptionValue', | |
262 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 263 | 'localizable' => 0, |
e501603b TO |
264 | ) , |
265 | 'grouping' => array( | |
266 | 'name' => 'grouping', | |
267 | 'type' => CRM_Utils_Type::T_STRING, | |
268 | 'title' => ts('Option Grouping Name') , | |
269 | '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.', | |
270 | 'maxlength' => 255, | |
271 | 'size' => CRM_Utils_Type::HUGE, | |
522a26c9 | 272 | 'table_name' => 'civicrm_option_value', |
273 | 'entity' => 'OptionValue', | |
274 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 275 | 'localizable' => 0, |
e501603b TO |
276 | ) , |
277 | 'filter' => array( | |
278 | 'name' => 'filter', | |
279 | 'type' => CRM_Utils_Type::T_INT, | |
280 | 'title' => ts('Filter') , | |
281 | 'description' => 'Bitwise logic can be used to create subsets of options within an option_group for different uses.', | |
522a26c9 | 282 | 'table_name' => 'civicrm_option_value', |
283 | 'entity' => 'OptionValue', | |
284 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 285 | 'localizable' => 0, |
e501603b TO |
286 | ) , |
287 | 'is_default' => array( | |
288 | 'name' => 'is_default', | |
289 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
290 | 'title' => ts('Option is Default?') , | |
291 | 'description' => 'Is this the default option for the group?', | |
522a26c9 | 292 | 'table_name' => 'civicrm_option_value', |
293 | 'entity' => 'OptionValue', | |
294 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 295 | 'localizable' => 0, |
e501603b TO |
296 | ) , |
297 | 'weight' => array( | |
298 | 'name' => 'weight', | |
299 | 'type' => CRM_Utils_Type::T_INT, | |
300 | 'title' => ts('Order') , | |
301 | 'description' => 'Controls display sort order.', | |
302 | 'required' => true, | |
522a26c9 | 303 | 'table_name' => 'civicrm_option_value', |
304 | 'entity' => 'OptionValue', | |
305 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 306 | 'localizable' => 0, |
e501603b TO |
307 | ) , |
308 | 'description' => array( | |
309 | 'name' => 'description', | |
310 | 'type' => CRM_Utils_Type::T_TEXT, | |
311 | 'title' => ts('Option Description') , | |
312 | 'description' => 'Optional description.', | |
313 | 'rows' => 8, | |
314 | 'cols' => 60, | |
522a26c9 | 315 | 'table_name' => 'civicrm_option_value', |
316 | 'entity' => 'OptionValue', | |
317 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 318 | 'localizable' => 1, |
e501603b TO |
319 | 'html' => array( |
320 | 'type' => 'TextArea', | |
321 | ) , | |
322 | ) , | |
323 | 'is_optgroup' => array( | |
324 | 'name' => 'is_optgroup', | |
325 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
326 | 'title' => ts('Option is Header?') , | |
327 | 'description' => 'Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?', | |
522a26c9 | 328 | 'table_name' => 'civicrm_option_value', |
329 | 'entity' => 'OptionValue', | |
330 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 331 | 'localizable' => 0, |
e501603b TO |
332 | ) , |
333 | 'is_reserved' => array( | |
334 | 'name' => 'is_reserved', | |
335 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
336 | 'title' => ts('Option Is Reserved?') , | |
337 | 'description' => 'Is this a predefined system object?', | |
522a26c9 | 338 | 'table_name' => 'civicrm_option_value', |
339 | 'entity' => 'OptionValue', | |
340 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 341 | 'localizable' => 0, |
e501603b TO |
342 | ) , |
343 | 'is_active' => array( | |
344 | 'name' => 'is_active', | |
345 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
346 | 'title' => ts('Option Is Active') , | |
347 | 'description' => 'Is this option active?', | |
348 | 'default' => '1', | |
522a26c9 | 349 | 'table_name' => 'civicrm_option_value', |
350 | 'entity' => 'OptionValue', | |
351 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 352 | 'localizable' => 0, |
e501603b TO |
353 | ) , |
354 | 'component_id' => array( | |
355 | 'name' => 'component_id', | |
356 | 'type' => CRM_Utils_Type::T_INT, | |
357 | 'title' => ts('Option Component') , | |
358 | 'description' => 'Component that this option value belongs/caters to.', | |
522a26c9 | 359 | 'table_name' => 'civicrm_option_value', |
360 | 'entity' => 'OptionValue', | |
361 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 362 | 'localizable' => 0, |
e501603b TO |
363 | 'FKClassName' => 'CRM_Core_DAO_Component', |
364 | 'html' => array( | |
365 | 'type' => 'Select', | |
366 | ) , | |
367 | 'pseudoconstant' => array( | |
368 | 'table' => 'civicrm_component', | |
369 | 'keyColumn' => 'id', | |
370 | 'labelColumn' => 'name', | |
371 | ) | |
372 | ) , | |
373 | 'domain_id' => array( | |
374 | 'name' => 'domain_id', | |
375 | 'type' => CRM_Utils_Type::T_INT, | |
376 | 'title' => ts('Option Domain') , | |
377 | 'description' => 'Which Domain is this option value for', | |
522a26c9 | 378 | 'table_name' => 'civicrm_option_value', |
379 | 'entity' => 'OptionValue', | |
380 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 381 | 'localizable' => 0, |
e501603b TO |
382 | 'FKClassName' => 'CRM_Core_DAO_Domain', |
383 | 'pseudoconstant' => array( | |
384 | 'table' => 'civicrm_domain', | |
385 | 'keyColumn' => 'id', | |
386 | 'labelColumn' => 'name', | |
387 | ) | |
388 | ) , | |
389 | 'visibility_id' => array( | |
390 | 'name' => 'visibility_id', | |
391 | 'type' => CRM_Utils_Type::T_INT, | |
392 | 'title' => ts('Option Visibility') , | |
393 | 'default' => 'NULL', | |
522a26c9 | 394 | 'table_name' => 'civicrm_option_value', |
395 | 'entity' => 'OptionValue', | |
396 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 397 | 'localizable' => 0, |
e501603b | 398 | ) , |
b412f764 CW |
399 | 'icon' => array( |
400 | 'name' => 'icon', | |
401 | 'type' => CRM_Utils_Type::T_STRING, | |
402 | 'title' => ts('Icon') , | |
403 | 'description' => 'crm-i icon class', | |
404 | 'maxlength' => 255, | |
405 | 'size' => CRM_Utils_Type::HUGE, | |
406 | 'default' => 'NULL', | |
522a26c9 | 407 | 'table_name' => 'civicrm_option_value', |
408 | 'entity' => 'OptionValue', | |
409 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 410 | 'localizable' => 0, |
b412f764 | 411 | ) , |
d73974ac CW |
412 | 'color' => array( |
413 | 'name' => 'color', | |
414 | 'type' => CRM_Utils_Type::T_STRING, | |
415 | 'title' => ts('Color') , | |
416 | 'description' => 'Hex color value e.g. #ffffff', | |
417 | 'maxlength' => 255, | |
418 | 'size' => CRM_Utils_Type::HUGE, | |
419 | 'default' => 'NULL', | |
522a26c9 | 420 | 'table_name' => 'civicrm_option_value', |
421 | 'entity' => 'OptionValue', | |
422 | 'bao' => 'CRM_Core_BAO_OptionValue', | |
6a7e5e5d | 423 | 'localizable' => 0, |
d73974ac | 424 | ) , |
e501603b | 425 | ); |
346aaaba | 426 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 427 | } |
346aaaba | 428 | return Civi::$statics[__CLASS__]['fields']; |
e501603b TO |
429 | } |
430 | /** | |
bd8e0b14 | 431 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
432 | * |
433 | * @return array | |
bd8e0b14 | 434 | * Array(string $name => string $uniqueName). |
e501603b TO |
435 | */ |
436 | static function &fieldKeys() { | |
bd8e0b14 TO |
437 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
438 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 439 | } |
bd8e0b14 | 440 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b TO |
441 | } |
442 | /** | |
443 | * Returns the names of this table | |
444 | * | |
445 | * @return string | |
446 | */ | |
447 | static function getTableName() { | |
448 | return CRM_Core_DAO::getLocaleTableName(self::$_tableName); | |
449 | } | |
450 | /** | |
451 | * Returns if this table needs to be logged | |
452 | * | |
453 | * @return boolean | |
454 | */ | |
455 | function getLog() { | |
456 | return self::$_log; | |
457 | } | |
458 | /** | |
459 | * Returns the list of fields that can be imported | |
460 | * | |
461 | * @param bool $prefix | |
462 | * | |
463 | * @return array | |
464 | */ | |
465 | static function &import($prefix = false) { | |
60808919 TO |
466 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'option_value', $prefix, array()); |
467 | return $r; | |
e501603b TO |
468 | } |
469 | /** | |
470 | * Returns the list of fields that can be exported | |
471 | * | |
472 | * @param bool $prefix | |
473 | * | |
474 | * @return array | |
475 | */ | |
476 | static function &export($prefix = false) { | |
60808919 TO |
477 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'option_value', $prefix, array()); |
478 | return $r; | |
e501603b | 479 | } |
e7a6b91a AS |
480 | /** |
481 | * Returns the list of indices | |
482 | */ | |
483 | public static function indices($localize = TRUE) { | |
484 | $indices = array( | |
485 | 'index_option_group_id_value' => array( | |
486 | 'name' => 'index_option_group_id_value', | |
487 | 'field' => array( | |
488 | 0 => 'value(128)', | |
489 | 1 => 'option_group_id', | |
490 | ) , | |
491 | 'localizable' => false, | |
492 | 'sig' => 'civicrm_option_value::0::value(128)::option_group_id', | |
493 | ) , | |
494 | 'index_option_group_id_name' => array( | |
495 | 'name' => 'index_option_group_id_name', | |
496 | 'field' => array( | |
497 | 0 => 'name(128)', | |
498 | 1 => 'option_group_id', | |
499 | ) , | |
500 | 'localizable' => false, | |
501 | 'sig' => 'civicrm_option_value::0::name(128)::option_group_id', | |
502 | ) , | |
503 | ); | |
504 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; | |
505 | } | |
e501603b | 506 | } |