Merge pull request #8944 from totten/master-givi
[civicrm-core.git] / CRM / Core / DAO / OptionValue.php
CommitLineData
e501603b
TO
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
437fafcf 33 * (GenCodeChecksum:cfa37dbb4bcb24f01ea8c59d2e2705e3)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class 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;
146 /**
147 * class constructor
148 *
149 * @return civicrm_option_value
150 */
151 function __construct() {
152 $this->__table = 'civicrm_option_value';
153 parent::__construct();
154 }
155 /**
156 * Returns foreign keys and entity references
157 *
158 * @return array
159 * [CRM_Core_Reference_Interface]
160 */
161 static function getReferenceColumns() {
346aaaba
TO
162 if (!isset(Civi::$statics[__CLASS__]['links'])) {
163 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
164 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'option_group_id', 'civicrm_option_group', 'id');
165 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'component_id', 'civicrm_component', 'id');
166 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'domain_id', 'civicrm_domain', 'id');
167 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 168 }
346aaaba 169 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
170 }
171 /**
172 * Returns all the column names of this table
173 *
174 * @return array
175 */
176 static function &fields() {
346aaaba
TO
177 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
178 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
179 'id' => array(
180 'name' => 'id',
181 'type' => CRM_Utils_Type::T_INT,
182 'title' => ts('Option Value ID') ,
183 'description' => 'Option ID',
184 'required' => true,
185 ) ,
186 'option_group_id' => array(
187 'name' => 'option_group_id',
188 'type' => CRM_Utils_Type::T_INT,
189 'title' => ts('Option Group ID') ,
190 'description' => 'Group which this option belongs to.',
191 'required' => true,
192 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
193 'html' => array(
194 'type' => 'Select',
195 ) ,
196 'pseudoconstant' => array(
197 'table' => 'civicrm_option_group',
198 'keyColumn' => 'id',
199 'labelColumn' => 'name',
200 )
201 ) ,
202 'label' => array(
203 'name' => 'label',
204 'type' => CRM_Utils_Type::T_STRING,
205 'title' => ts('Option Label') ,
206 'description' => 'Option string as displayed to users - e.g. the label in an HTML OPTION tag.',
207 'required' => true,
208 'maxlength' => 512,
209 'size' => CRM_Utils_Type::HUGE,
210 ) ,
211 'value' => array(
212 'name' => 'value',
213 'type' => CRM_Utils_Type::T_STRING,
214 'title' => ts('Option Value') ,
215 '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.',
216 'required' => true,
217 'maxlength' => 512,
218 'size' => CRM_Utils_Type::HUGE,
219 ) ,
220 'name' => array(
221 'name' => 'name',
222 'type' => CRM_Utils_Type::T_STRING,
223 'title' => ts('Option Name') ,
224 '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.',
225 'maxlength' => 255,
226 'size' => CRM_Utils_Type::HUGE,
227 'import' => true,
228 'where' => 'civicrm_option_value.name',
229 'headerPattern' => '',
230 'dataPattern' => '',
231 'export' => true,
232 ) ,
233 'grouping' => array(
234 'name' => 'grouping',
235 'type' => CRM_Utils_Type::T_STRING,
236 'title' => ts('Option Grouping Name') ,
237 '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.',
238 'maxlength' => 255,
239 'size' => CRM_Utils_Type::HUGE,
240 ) ,
241 'filter' => array(
242 'name' => 'filter',
243 'type' => CRM_Utils_Type::T_INT,
244 'title' => ts('Filter') ,
245 'description' => 'Bitwise logic can be used to create subsets of options within an option_group for different uses.',
246 ) ,
247 'is_default' => array(
248 'name' => 'is_default',
249 'type' => CRM_Utils_Type::T_BOOLEAN,
250 'title' => ts('Option is Default?') ,
251 'description' => 'Is this the default option for the group?',
252 ) ,
253 'weight' => array(
254 'name' => 'weight',
255 'type' => CRM_Utils_Type::T_INT,
256 'title' => ts('Order') ,
257 'description' => 'Controls display sort order.',
258 'required' => true,
259 ) ,
260 'description' => array(
261 'name' => 'description',
262 'type' => CRM_Utils_Type::T_TEXT,
263 'title' => ts('Option Description') ,
264 'description' => 'Optional description.',
265 'rows' => 8,
266 'cols' => 60,
267 'html' => array(
268 'type' => 'TextArea',
269 ) ,
270 ) ,
271 'is_optgroup' => array(
272 'name' => 'is_optgroup',
273 'type' => CRM_Utils_Type::T_BOOLEAN,
274 'title' => ts('Option is Header?') ,
275 'description' => 'Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?',
276 ) ,
277 'is_reserved' => array(
278 'name' => 'is_reserved',
279 'type' => CRM_Utils_Type::T_BOOLEAN,
280 'title' => ts('Option Is Reserved?') ,
281 'description' => 'Is this a predefined system object?',
282 ) ,
283 'is_active' => array(
284 'name' => 'is_active',
285 'type' => CRM_Utils_Type::T_BOOLEAN,
286 'title' => ts('Option Is Active') ,
287 'description' => 'Is this option active?',
288 'default' => '1',
289 ) ,
290 'component_id' => array(
291 'name' => 'component_id',
292 'type' => CRM_Utils_Type::T_INT,
293 'title' => ts('Option Component') ,
294 'description' => 'Component that this option value belongs/caters to.',
295 'FKClassName' => 'CRM_Core_DAO_Component',
296 'html' => array(
297 'type' => 'Select',
298 ) ,
299 'pseudoconstant' => array(
300 'table' => 'civicrm_component',
301 'keyColumn' => 'id',
302 'labelColumn' => 'name',
303 )
304 ) ,
305 'domain_id' => array(
306 'name' => 'domain_id',
307 'type' => CRM_Utils_Type::T_INT,
308 'title' => ts('Option Domain') ,
309 'description' => 'Which Domain is this option value for',
310 'FKClassName' => 'CRM_Core_DAO_Domain',
311 'pseudoconstant' => array(
312 'table' => 'civicrm_domain',
313 'keyColumn' => 'id',
314 'labelColumn' => 'name',
315 )
316 ) ,
317 'visibility_id' => array(
318 'name' => 'visibility_id',
319 'type' => CRM_Utils_Type::T_INT,
320 'title' => ts('Option Visibility') ,
321 'default' => 'NULL',
322 ) ,
323 );
346aaaba 324 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 325 }
346aaaba 326 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
327 }
328 /**
bd8e0b14 329 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
330 *
331 * @return array
bd8e0b14 332 * Array(string $name => string $uniqueName).
e501603b
TO
333 */
334 static function &fieldKeys() {
bd8e0b14
TO
335 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
336 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 337 }
bd8e0b14 338 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
339 }
340 /**
341 * Returns the names of this table
342 *
343 * @return string
344 */
345 static function getTableName() {
346 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
347 }
348 /**
349 * Returns if this table needs to be logged
350 *
351 * @return boolean
352 */
353 function getLog() {
354 return self::$_log;
355 }
356 /**
357 * Returns the list of fields that can be imported
358 *
359 * @param bool $prefix
360 *
361 * @return array
362 */
363 static function &import($prefix = false) {
60808919
TO
364 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'option_value', $prefix, array());
365 return $r;
e501603b
TO
366 }
367 /**
368 * Returns the list of fields that can be exported
369 *
370 * @param bool $prefix
371 *
372 * @return array
373 */
374 static function &export($prefix = false) {
60808919
TO
375 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'option_value', $prefix, array());
376 return $r;
e501603b
TO
377 }
378}