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 | |
d73974ac | 33 | * (GenCodeChecksum:fdf2f62ba69b54da0567362493827448) |
e501603b TO |
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'; | |
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 | * Option ID | |
53 | * | |
54 | * @var int unsigned | |
55 | */ | |
56 | public $id; | |
57 | /** | |
58 | * Group which this option belongs to. | |
59 | * | |
60 | * @var int unsigned | |
61 | */ | |
62 | public $option_group_id; | |
63 | /** | |
64 | * Option string as displayed to users - e.g. the label in an HTML OPTION tag. | |
65 | * | |
66 | * @var string | |
67 | */ | |
68 | public $label; | |
69 | /** | |
70 | * 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. | |
71 | * | |
72 | * @var string | |
73 | */ | |
74 | public $value; | |
75 | /** | |
76 | * Stores a fixed (non-translated) name for this option value. Lookup functions should use the name as the key for the option value row. | |
77 | * | |
78 | * @var string | |
79 | */ | |
80 | public $name; | |
81 | /** | |
82 | * 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. | |
83 | * | |
84 | * @var string | |
85 | */ | |
86 | public $grouping; | |
87 | /** | |
88 | * Bitwise logic can be used to create subsets of options within an option_group for different uses. | |
89 | * | |
90 | * @var int unsigned | |
91 | */ | |
92 | public $filter; | |
93 | /** | |
94 | * Is this the default option for the group? | |
95 | * | |
96 | * @var boolean | |
97 | */ | |
98 | public $is_default; | |
99 | /** | |
100 | * Controls display sort order. | |
101 | * | |
102 | * @var int unsigned | |
103 | */ | |
104 | public $weight; | |
105 | /** | |
106 | * Optional description. | |
107 | * | |
108 | * @var text | |
109 | */ | |
110 | public $description; | |
111 | /** | |
112 | * Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options? | |
113 | * | |
114 | * @var boolean | |
115 | */ | |
116 | public $is_optgroup; | |
117 | /** | |
118 | * Is this a predefined system object? | |
119 | * | |
120 | * @var boolean | |
121 | */ | |
122 | public $is_reserved; | |
123 | /** | |
124 | * Is this option active? | |
125 | * | |
126 | * @var boolean | |
127 | */ | |
128 | public $is_active; | |
129 | /** | |
130 | * Component that this option value belongs/caters to. | |
131 | * | |
132 | * @var int unsigned | |
133 | */ | |
134 | public $component_id; | |
135 | /** | |
136 | * Which Domain is this option value for | |
137 | * | |
138 | * @var int unsigned | |
139 | */ | |
140 | public $domain_id; | |
141 | /** | |
142 | * | |
143 | * @var int unsigned | |
144 | */ | |
145 | public $visibility_id; | |
b412f764 CW |
146 | /** |
147 | * crm-i icon class | |
148 | * | |
149 | * @var string | |
150 | */ | |
151 | public $icon; | |
d73974ac CW |
152 | /** |
153 | * Hex color value e.g. #ffffff | |
154 | * | |
155 | * @var string | |
156 | */ | |
157 | public $color; | |
e501603b TO |
158 | /** |
159 | * class constructor | |
160 | * | |
161 | * @return civicrm_option_value | |
162 | */ | |
163 | function __construct() { | |
164 | $this->__table = 'civicrm_option_value'; | |
165 | parent::__construct(); | |
166 | } | |
167 | /** | |
168 | * Returns foreign keys and entity references | |
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 | } |