Commit | Line | Data |
---|---|---|
e501603b | 1 | <?php |
c3fc2621 | 2 | |
e501603b TO |
3 | /** |
4 | * @package CRM | |
ca5cec67 | 5 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
e501603b TO |
6 | * |
7 | * Generated from xml/schema/CRM/Core/OptionGroup.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
c9ae8a39 | 9 | * (GenCodeChecksum:c9bc7ac897d9d7ef0bc421f6e58bdf27) |
e501603b | 10 | */ |
c3fc2621 | 11 | |
f41f0342 | 12 | /** |
c3fc2621 | 13 | * Database access object for the OptionGroup entity. |
f41f0342 | 14 | */ |
e501603b | 15 | class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO { |
929a1c14 CW |
16 | const EXT = 'civicrm'; |
17 | const TABLE_ADDED = '1.5'; | |
c3fc2621 | 18 | |
e501603b | 19 | /** |
f41f0342 | 20 | * Static instance to hold the table name. |
e501603b TO |
21 | * |
22 | * @var string | |
23 | */ | |
fa45b5b9 | 24 | public static $_tableName = 'civicrm_option_group'; |
c3fc2621 | 25 | |
e501603b | 26 | /** |
f41f0342 | 27 | * Should CiviCRM log any modifications to this table in the civicrm_log table. |
e501603b | 28 | * |
c3fc2621 | 29 | * @var bool |
e501603b | 30 | */ |
fa45b5b9 | 31 | public static $_log = TRUE; |
c3fc2621 | 32 | |
e501603b TO |
33 | /** |
34 | * Option Group ID | |
35 | * | |
28979d65 CW |
36 | * @var int|string|null |
37 | * (SQL type: int unsigned) | |
38 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
39 | */ |
40 | public $id; | |
c3fc2621 | 41 | |
e501603b TO |
42 | /** |
43 | * Option group name. Used as selection key by class properties which lookup options in civicrm_option_value. | |
44 | * | |
45 | * @var string | |
28979d65 CW |
46 | * (SQL type: varchar(64)) |
47 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
48 | */ |
49 | public $name; | |
c3fc2621 | 50 | |
e501603b TO |
51 | /** |
52 | * Option Group title. | |
53 | * | |
28979d65 CW |
54 | * @var string|null |
55 | * (SQL type: varchar(255)) | |
56 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
57 | */ |
58 | public $title; | |
c3fc2621 | 59 | |
e501603b TO |
60 | /** |
61 | * Option group description. | |
62 | * | |
28979d65 CW |
63 | * @var string|null |
64 | * (SQL type: varchar(255)) | |
65 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
66 | */ |
67 | public $description; | |
c3fc2621 | 68 | |
7c61320c | 69 | /** |
c9ae8a39 | 70 | * Type of data stored by this option group. |
7c61320c | 71 | * |
28979d65 CW |
72 | * @var string|null |
73 | * (SQL type: varchar(128)) | |
74 | * Note that values will be retrieved from the database as a string. | |
7c61320c SL |
75 | */ |
76 | public $data_type; | |
c3fc2621 | 77 | |
e501603b TO |
78 | /** |
79 | * Is this a predefined system option group (i.e. it can not be deleted)? | |
80 | * | |
28979d65 CW |
81 | * @var bool|string |
82 | * (SQL type: tinyint) | |
83 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
84 | */ |
85 | public $is_reserved; | |
c3fc2621 | 86 | |
e501603b TO |
87 | /** |
88 | * Is this option group active? | |
89 | * | |
28979d65 CW |
90 | * @var bool|string |
91 | * (SQL type: tinyint) | |
92 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
93 | */ |
94 | public $is_active; | |
c3fc2621 | 95 | |
e501603b TO |
96 | /** |
97 | * A lock to remove the ability to add new options via the UI. | |
98 | * | |
28979d65 CW |
99 | * @var bool|string |
100 | * (SQL type: tinyint) | |
101 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
102 | */ |
103 | public $is_locked; | |
c3fc2621 | 104 | |
c9ae8a39 CW |
105 | /** |
106 | * Which optional columns from the option_value table are in use by this group. | |
107 | * | |
108 | * @var string|null | |
109 | * (SQL type: varchar(128)) | |
110 | * Note that values will be retrieved from the database as a string. | |
111 | */ | |
112 | public $option_value_fields; | |
113 | ||
e501603b | 114 | /** |
f41f0342 | 115 | * Class constructor. |
e501603b | 116 | */ |
c3fc2621 | 117 | public function __construct() { |
e501603b TO |
118 | $this->__table = 'civicrm_option_group'; |
119 | parent::__construct(); | |
120 | } | |
c3fc2621 | 121 | |
449c4e6b CW |
122 | /** |
123 | * Returns localized title of this entity. | |
7b66c3b5 AH |
124 | * |
125 | * @param bool $plural | |
126 | * Whether to return the plural version of the title. | |
449c4e6b | 127 | */ |
7b66c3b5 AH |
128 | public static function getEntityTitle($plural = FALSE) { |
129 | return $plural ? ts('Option Groups') : ts('Option Group'); | |
449c4e6b CW |
130 | } |
131 | ||
e501603b TO |
132 | /** |
133 | * Returns all the column names of this table | |
134 | * | |
135 | * @return array | |
136 | */ | |
c3fc2621 | 137 | public static function &fields() { |
346aaaba | 138 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
c3fc2621 CW |
139 | Civi::$statics[__CLASS__]['fields'] = [ |
140 | 'id' => [ | |
e501603b TO |
141 | 'name' => 'id', |
142 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 143 | 'title' => ts('Option Group ID'), |
215b423e | 144 | 'description' => ts('Option Group ID'), |
c3fc2621 | 145 | 'required' => TRUE, |
a36434b9 | 146 | 'where' => 'civicrm_option_group.id', |
522a26c9 | 147 | 'table_name' => 'civicrm_option_group', |
148 | 'entity' => 'OptionGroup', | |
149 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 150 | 'localizable' => 0, |
2cbbebe8 A |
151 | 'html' => [ |
152 | 'type' => 'Number', | |
153 | ], | |
1fe423d6 | 154 | 'readonly' => TRUE, |
a9d0587b | 155 | 'add' => '1.5', |
c3fc2621 CW |
156 | ], |
157 | 'name' => [ | |
e501603b TO |
158 | 'name' => 'name', |
159 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 160 | 'title' => ts('Option Group Name'), |
215b423e | 161 | 'description' => ts('Option group name. Used as selection key by class properties which lookup options in civicrm_option_value.'), |
c3fc2621 | 162 | 'required' => TRUE, |
e501603b TO |
163 | 'maxlength' => 64, |
164 | 'size' => CRM_Utils_Type::BIG, | |
a36434b9 | 165 | 'where' => 'civicrm_option_group.name', |
522a26c9 | 166 | 'table_name' => 'civicrm_option_group', |
167 | 'entity' => 'OptionGroup', | |
168 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 169 | 'localizable' => 0, |
a9d0587b | 170 | 'add' => '1.5', |
c3fc2621 CW |
171 | ], |
172 | 'title' => [ | |
e501603b TO |
173 | 'name' => 'title', |
174 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 175 | 'title' => ts('Option Group title'), |
215b423e | 176 | 'description' => ts('Option Group title.'), |
e501603b TO |
177 | 'maxlength' => 255, |
178 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 179 | 'where' => 'civicrm_option_group.title', |
522a26c9 | 180 | 'table_name' => 'civicrm_option_group', |
181 | 'entity' => 'OptionGroup', | |
182 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 183 | 'localizable' => 1, |
a9d0587b | 184 | 'add' => '1.5', |
c3fc2621 CW |
185 | ], |
186 | 'description' => [ | |
e501603b TO |
187 | 'name' => 'description', |
188 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 189 | 'title' => ts('Option Group Description'), |
215b423e | 190 | 'description' => ts('Option group description.'), |
e501603b TO |
191 | 'maxlength' => 255, |
192 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 193 | 'where' => 'civicrm_option_group.description', |
522a26c9 | 194 | 'table_name' => 'civicrm_option_group', |
195 | 'entity' => 'OptionGroup', | |
196 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 197 | 'localizable' => 1, |
a9d0587b | 198 | 'add' => '1.5', |
c3fc2621 CW |
199 | ], |
200 | 'data_type' => [ | |
7c61320c SL |
201 | 'name' => 'data_type', |
202 | 'type' => CRM_Utils_Type::T_STRING, | |
c9ae8a39 CW |
203 | 'title' => ts('Data Type'), |
204 | 'description' => ts('Type of data stored by this option group.'), | |
7c61320c SL |
205 | 'maxlength' => 128, |
206 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 207 | 'where' => 'civicrm_option_group.data_type', |
522a26c9 | 208 | 'table_name' => 'civicrm_option_group', |
209 | 'entity' => 'OptionGroup', | |
210 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 211 | 'localizable' => 0, |
c3fc2621 | 212 | 'pseudoconstant' => [ |
7c61320c | 213 | 'callback' => 'CRM_Utils_Type::dataTypes', |
e6ca0a57 | 214 | ], |
a9d0587b | 215 | 'add' => '4.7', |
c3fc2621 CW |
216 | ], |
217 | 'is_reserved' => [ | |
e501603b TO |
218 | 'name' => 'is_reserved', |
219 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 220 | 'title' => ts('Option Group Is Reserved?'), |
215b423e | 221 | 'description' => ts('Is this a predefined system option group (i.e. it can not be deleted)?'), |
c8728154 | 222 | 'required' => TRUE, |
a36434b9 | 223 | 'where' => 'civicrm_option_group.is_reserved', |
e501603b | 224 | 'default' => '1', |
522a26c9 | 225 | 'table_name' => 'civicrm_option_group', |
226 | 'entity' => 'OptionGroup', | |
227 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 228 | 'localizable' => 0, |
a9d0587b | 229 | 'add' => '1.5', |
c3fc2621 CW |
230 | ], |
231 | 'is_active' => [ | |
e501603b TO |
232 | 'name' => 'is_active', |
233 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 234 | 'title' => ts('Option Group Is Active?'), |
215b423e | 235 | 'description' => ts('Is this option group active?'), |
c8728154 | 236 | 'required' => TRUE, |
a36434b9 | 237 | 'where' => 'civicrm_option_group.is_active', |
c8728154 | 238 | 'default' => '1', |
522a26c9 | 239 | 'table_name' => 'civicrm_option_group', |
240 | 'entity' => 'OptionGroup', | |
241 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 242 | 'localizable' => 0, |
a9d0587b | 243 | 'add' => '1.5', |
c3fc2621 CW |
244 | ], |
245 | 'is_locked' => [ | |
e501603b TO |
246 | 'name' => 'is_locked', |
247 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 248 | 'title' => ts('Option Group Is Locked'), |
215b423e | 249 | 'description' => ts('A lock to remove the ability to add new options via the UI.'), |
c8728154 | 250 | 'required' => TRUE, |
a36434b9 | 251 | 'where' => 'civicrm_option_group.is_locked', |
45a83e42 | 252 | 'default' => '0', |
522a26c9 | 253 | 'table_name' => 'civicrm_option_group', |
254 | 'entity' => 'OptionGroup', | |
255 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 256 | 'localizable' => 0, |
a9d0587b | 257 | 'add' => '4.5', |
c3fc2621 | 258 | ], |
c9ae8a39 CW |
259 | 'option_value_fields' => [ |
260 | 'name' => 'option_value_fields', | |
261 | 'type' => CRM_Utils_Type::T_STRING, | |
262 | 'title' => ts('Option Value Fields'), | |
263 | 'description' => ts('Which optional columns from the option_value table are in use by this group.'), | |
264 | 'maxlength' => 128, | |
265 | 'size' => CRM_Utils_Type::HUGE, | |
266 | 'where' => 'civicrm_option_group.option_value_fields', | |
267 | 'default' => 'name,label,description', | |
268 | 'table_name' => 'civicrm_option_group', | |
269 | 'entity' => 'OptionGroup', | |
270 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
271 | 'localizable' => 0, | |
272 | 'serialize' => self::SERIALIZE_COMMA, | |
273 | 'pseudoconstant' => [ | |
274 | 'callback' => 'CRM_Core_SelectValues::optionValueFields', | |
275 | ], | |
276 | 'add' => '5.49', | |
277 | ], | |
c3fc2621 | 278 | ]; |
346aaaba | 279 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 280 | } |
346aaaba | 281 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 282 | } |
c3fc2621 | 283 | |
e501603b | 284 | /** |
bd8e0b14 | 285 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
286 | * |
287 | * @return array | |
bd8e0b14 | 288 | * Array(string $name => string $uniqueName). |
e501603b | 289 | */ |
c3fc2621 | 290 | public static function &fieldKeys() { |
bd8e0b14 TO |
291 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
292 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 293 | } |
bd8e0b14 | 294 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 295 | } |
c3fc2621 | 296 | |
e501603b TO |
297 | /** |
298 | * Returns the names of this table | |
299 | * | |
300 | * @return string | |
301 | */ | |
c3fc2621 | 302 | public static function getTableName() { |
e501603b TO |
303 | return CRM_Core_DAO::getLocaleTableName(self::$_tableName); |
304 | } | |
c3fc2621 | 305 | |
e501603b TO |
306 | /** |
307 | * Returns if this table needs to be logged | |
308 | * | |
c3fc2621 | 309 | * @return bool |
e501603b | 310 | */ |
c3fc2621 | 311 | public function getLog() { |
e501603b TO |
312 | return self::$_log; |
313 | } | |
c3fc2621 | 314 | |
e501603b TO |
315 | /** |
316 | * Returns the list of fields that can be imported | |
317 | * | |
318 | * @param bool $prefix | |
319 | * | |
320 | * @return array | |
321 | */ | |
c3fc2621 CW |
322 | public static function &import($prefix = FALSE) { |
323 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'option_group', $prefix, []); | |
60808919 | 324 | return $r; |
e501603b | 325 | } |
c3fc2621 | 326 | |
e501603b TO |
327 | /** |
328 | * Returns the list of fields that can be exported | |
329 | * | |
330 | * @param bool $prefix | |
331 | * | |
332 | * @return array | |
333 | */ | |
c3fc2621 CW |
334 | public static function &export($prefix = FALSE) { |
335 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'option_group', $prefix, []); | |
60808919 | 336 | return $r; |
e501603b | 337 | } |
c3fc2621 | 338 | |
e7a6b91a AS |
339 | /** |
340 | * Returns the list of indices | |
c3fc2621 CW |
341 | * |
342 | * @param bool $localize | |
343 | * | |
344 | * @return array | |
e7a6b91a AS |
345 | */ |
346 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
347 | $indices = [ |
348 | 'UI_name' => [ | |
e7a6b91a | 349 | 'name' => 'UI_name', |
c3fc2621 | 350 | 'field' => [ |
e7a6b91a | 351 | 0 => 'name', |
c3fc2621 CW |
352 | ], |
353 | 'localizable' => FALSE, | |
354 | 'unique' => TRUE, | |
e7a6b91a | 355 | 'sig' => 'civicrm_option_group::1::name', |
c3fc2621 CW |
356 | ], |
357 | ]; | |
e7a6b91a AS |
358 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
359 | } | |
c3fc2621 | 360 | |
e501603b | 361 | } |