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