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 | |
2562d09a | 9 | * (GenCodeChecksum:6be4b908c7861e9026d1f2d78c42a0ac) |
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 | * | |
e6ca0a57 | 36 | * @var int |
e501603b TO |
37 | */ |
38 | public $id; | |
c3fc2621 | 39 | |
e501603b TO |
40 | /** |
41 | * Option group name. Used as selection key by class properties which lookup options in civicrm_option_value. | |
42 | * | |
43 | * @var string | |
44 | */ | |
45 | public $name; | |
c3fc2621 | 46 | |
e501603b TO |
47 | /** |
48 | * Option Group title. | |
49 | * | |
50 | * @var string | |
51 | */ | |
52 | public $title; | |
c3fc2621 | 53 | |
e501603b TO |
54 | /** |
55 | * Option group description. | |
56 | * | |
57 | * @var string | |
58 | */ | |
59 | public $description; | |
c3fc2621 | 60 | |
7c61320c SL |
61 | /** |
62 | * Option group description. | |
63 | * | |
64 | * @var string | |
65 | */ | |
66 | public $data_type; | |
c3fc2621 | 67 | |
e501603b TO |
68 | /** |
69 | * Is this a predefined system option group (i.e. it can not be deleted)? | |
70 | * | |
e6ca0a57 | 71 | * @var bool |
e501603b TO |
72 | */ |
73 | public $is_reserved; | |
c3fc2621 | 74 | |
e501603b TO |
75 | /** |
76 | * Is this option group active? | |
77 | * | |
e6ca0a57 | 78 | * @var bool |
e501603b TO |
79 | */ |
80 | public $is_active; | |
c3fc2621 | 81 | |
e501603b TO |
82 | /** |
83 | * A lock to remove the ability to add new options via the UI. | |
84 | * | |
e6ca0a57 | 85 | * @var bool |
e501603b TO |
86 | */ |
87 | public $is_locked; | |
c3fc2621 | 88 | |
e501603b | 89 | /** |
f41f0342 | 90 | * Class constructor. |
e501603b | 91 | */ |
c3fc2621 | 92 | public function __construct() { |
e501603b TO |
93 | $this->__table = 'civicrm_option_group'; |
94 | parent::__construct(); | |
95 | } | |
c3fc2621 | 96 | |
449c4e6b CW |
97 | /** |
98 | * Returns localized title of this entity. | |
7b66c3b5 AH |
99 | * |
100 | * @param bool $plural | |
101 | * Whether to return the plural version of the title. | |
449c4e6b | 102 | */ |
7b66c3b5 AH |
103 | public static function getEntityTitle($plural = FALSE) { |
104 | return $plural ? ts('Option Groups') : ts('Option Group'); | |
449c4e6b CW |
105 | } |
106 | ||
e501603b TO |
107 | /** |
108 | * Returns all the column names of this table | |
109 | * | |
110 | * @return array | |
111 | */ | |
c3fc2621 | 112 | public static function &fields() { |
346aaaba | 113 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
c3fc2621 CW |
114 | Civi::$statics[__CLASS__]['fields'] = [ |
115 | 'id' => [ | |
e501603b TO |
116 | 'name' => 'id', |
117 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 118 | 'title' => ts('Option Group ID'), |
215b423e | 119 | 'description' => ts('Option Group ID'), |
c3fc2621 | 120 | 'required' => TRUE, |
a36434b9 | 121 | 'where' => 'civicrm_option_group.id', |
522a26c9 | 122 | 'table_name' => 'civicrm_option_group', |
123 | 'entity' => 'OptionGroup', | |
124 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 125 | 'localizable' => 0, |
2cbbebe8 A |
126 | 'html' => [ |
127 | 'type' => 'Number', | |
128 | ], | |
1fe423d6 | 129 | 'readonly' => TRUE, |
a9d0587b | 130 | 'add' => '1.5', |
c3fc2621 CW |
131 | ], |
132 | 'name' => [ | |
e501603b TO |
133 | 'name' => 'name', |
134 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 135 | 'title' => ts('Option Group Name'), |
215b423e | 136 | 'description' => ts('Option group name. Used as selection key by class properties which lookup options in civicrm_option_value.'), |
c3fc2621 | 137 | 'required' => TRUE, |
e501603b TO |
138 | 'maxlength' => 64, |
139 | 'size' => CRM_Utils_Type::BIG, | |
a36434b9 | 140 | 'where' => 'civicrm_option_group.name', |
522a26c9 | 141 | 'table_name' => 'civicrm_option_group', |
142 | 'entity' => 'OptionGroup', | |
143 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 144 | 'localizable' => 0, |
a9d0587b | 145 | 'add' => '1.5', |
c3fc2621 CW |
146 | ], |
147 | 'title' => [ | |
e501603b TO |
148 | 'name' => 'title', |
149 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 150 | 'title' => ts('Option Group title'), |
215b423e | 151 | 'description' => ts('Option Group title.'), |
e501603b TO |
152 | 'maxlength' => 255, |
153 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 154 | 'where' => 'civicrm_option_group.title', |
522a26c9 | 155 | 'table_name' => 'civicrm_option_group', |
156 | 'entity' => 'OptionGroup', | |
157 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 158 | 'localizable' => 1, |
a9d0587b | 159 | 'add' => '1.5', |
c3fc2621 CW |
160 | ], |
161 | 'description' => [ | |
e501603b TO |
162 | 'name' => 'description', |
163 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 164 | 'title' => ts('Option Group Description'), |
215b423e | 165 | 'description' => ts('Option group description.'), |
e501603b TO |
166 | 'maxlength' => 255, |
167 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 168 | 'where' => 'civicrm_option_group.description', |
522a26c9 | 169 | 'table_name' => 'civicrm_option_group', |
170 | 'entity' => 'OptionGroup', | |
171 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 172 | 'localizable' => 1, |
a9d0587b | 173 | 'add' => '1.5', |
c3fc2621 CW |
174 | ], |
175 | 'data_type' => [ | |
7c61320c SL |
176 | 'name' => 'data_type', |
177 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 178 | 'title' => ts('Data Type for this option group'), |
215b423e | 179 | 'description' => ts('Option group description.'), |
7c61320c SL |
180 | 'maxlength' => 128, |
181 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 182 | 'where' => 'civicrm_option_group.data_type', |
522a26c9 | 183 | 'table_name' => 'civicrm_option_group', |
184 | 'entity' => 'OptionGroup', | |
185 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 186 | 'localizable' => 0, |
c3fc2621 | 187 | 'pseudoconstant' => [ |
7c61320c | 188 | 'callback' => 'CRM_Utils_Type::dataTypes', |
e6ca0a57 | 189 | ], |
a9d0587b | 190 | 'add' => '4.7', |
c3fc2621 CW |
191 | ], |
192 | 'is_reserved' => [ | |
e501603b TO |
193 | 'name' => 'is_reserved', |
194 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 195 | 'title' => ts('Option Group Is Reserved?'), |
215b423e | 196 | 'description' => ts('Is this a predefined system option group (i.e. it can not be deleted)?'), |
c8728154 | 197 | 'required' => TRUE, |
a36434b9 | 198 | 'where' => 'civicrm_option_group.is_reserved', |
e501603b | 199 | 'default' => '1', |
522a26c9 | 200 | 'table_name' => 'civicrm_option_group', |
201 | 'entity' => 'OptionGroup', | |
202 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 203 | 'localizable' => 0, |
a9d0587b | 204 | 'add' => '1.5', |
c3fc2621 CW |
205 | ], |
206 | 'is_active' => [ | |
e501603b TO |
207 | 'name' => 'is_active', |
208 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 209 | 'title' => ts('Option Group Is Active?'), |
215b423e | 210 | 'description' => ts('Is this option group active?'), |
c8728154 | 211 | 'required' => TRUE, |
a36434b9 | 212 | 'where' => 'civicrm_option_group.is_active', |
c8728154 | 213 | 'default' => '1', |
522a26c9 | 214 | 'table_name' => 'civicrm_option_group', |
215 | 'entity' => 'OptionGroup', | |
216 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 217 | 'localizable' => 0, |
a9d0587b | 218 | 'add' => '1.5', |
c3fc2621 CW |
219 | ], |
220 | 'is_locked' => [ | |
e501603b TO |
221 | 'name' => 'is_locked', |
222 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 223 | 'title' => ts('Option Group Is Locked'), |
215b423e | 224 | 'description' => ts('A lock to remove the ability to add new options via the UI.'), |
c8728154 | 225 | 'required' => TRUE, |
a36434b9 | 226 | 'where' => 'civicrm_option_group.is_locked', |
45a83e42 | 227 | 'default' => '0', |
522a26c9 | 228 | 'table_name' => 'civicrm_option_group', |
229 | 'entity' => 'OptionGroup', | |
230 | 'bao' => 'CRM_Core_BAO_OptionGroup', | |
6a7e5e5d | 231 | 'localizable' => 0, |
a9d0587b | 232 | 'add' => '4.5', |
c3fc2621 CW |
233 | ], |
234 | ]; | |
346aaaba | 235 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 236 | } |
346aaaba | 237 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 238 | } |
c3fc2621 | 239 | |
e501603b | 240 | /** |
bd8e0b14 | 241 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
242 | * |
243 | * @return array | |
bd8e0b14 | 244 | * Array(string $name => string $uniqueName). |
e501603b | 245 | */ |
c3fc2621 | 246 | public static function &fieldKeys() { |
bd8e0b14 TO |
247 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
248 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 249 | } |
bd8e0b14 | 250 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 251 | } |
c3fc2621 | 252 | |
e501603b TO |
253 | /** |
254 | * Returns the names of this table | |
255 | * | |
256 | * @return string | |
257 | */ | |
c3fc2621 | 258 | public static function getTableName() { |
e501603b TO |
259 | return CRM_Core_DAO::getLocaleTableName(self::$_tableName); |
260 | } | |
c3fc2621 | 261 | |
e501603b TO |
262 | /** |
263 | * Returns if this table needs to be logged | |
264 | * | |
c3fc2621 | 265 | * @return bool |
e501603b | 266 | */ |
c3fc2621 | 267 | public function getLog() { |
e501603b TO |
268 | return self::$_log; |
269 | } | |
c3fc2621 | 270 | |
e501603b TO |
271 | /** |
272 | * Returns the list of fields that can be imported | |
273 | * | |
274 | * @param bool $prefix | |
275 | * | |
276 | * @return array | |
277 | */ | |
c3fc2621 CW |
278 | public static function &import($prefix = FALSE) { |
279 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'option_group', $prefix, []); | |
60808919 | 280 | return $r; |
e501603b | 281 | } |
c3fc2621 | 282 | |
e501603b TO |
283 | /** |
284 | * Returns the list of fields that can be exported | |
285 | * | |
286 | * @param bool $prefix | |
287 | * | |
288 | * @return array | |
289 | */ | |
c3fc2621 CW |
290 | public static function &export($prefix = FALSE) { |
291 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'option_group', $prefix, []); | |
60808919 | 292 | return $r; |
e501603b | 293 | } |
c3fc2621 | 294 | |
e7a6b91a AS |
295 | /** |
296 | * Returns the list of indices | |
c3fc2621 CW |
297 | * |
298 | * @param bool $localize | |
299 | * | |
300 | * @return array | |
e7a6b91a AS |
301 | */ |
302 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
303 | $indices = [ |
304 | 'UI_name' => [ | |
e7a6b91a | 305 | 'name' => 'UI_name', |
c3fc2621 | 306 | 'field' => [ |
e7a6b91a | 307 | 0 => 'name', |
c3fc2621 CW |
308 | ], |
309 | 'localizable' => FALSE, | |
310 | 'unique' => TRUE, | |
e7a6b91a | 311 | 'sig' => 'civicrm_option_group::1::name', |
c3fc2621 CW |
312 | ], |
313 | ]; | |
e7a6b91a AS |
314 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
315 | } | |
c3fc2621 | 316 | |
e501603b | 317 | } |