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