Merge pull request #19564 from civicrm/5.35
[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:6bcfbc78f5995c4930d1f12dd19a30b7)
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 'add' => '1.5',
130 ],
131 'name' => [
132 'name' => 'name',
133 'type' => CRM_Utils_Type::T_STRING,
134 'title' => ts('Option Group Name'),
135 'description' => ts('Option group name. Used as selection key by class properties which lookup options in civicrm_option_value.'),
136 'required' => TRUE,
137 'maxlength' => 64,
138 'size' => CRM_Utils_Type::BIG,
139 'where' => 'civicrm_option_group.name',
140 'table_name' => 'civicrm_option_group',
141 'entity' => 'OptionGroup',
142 'bao' => 'CRM_Core_BAO_OptionGroup',
143 'localizable' => 0,
144 'add' => '1.5',
145 ],
146 'title' => [
147 'name' => 'title',
148 'type' => CRM_Utils_Type::T_STRING,
149 'title' => ts('Option Group title'),
150 'description' => ts('Option Group title.'),
151 'maxlength' => 255,
152 'size' => CRM_Utils_Type::HUGE,
153 'where' => 'civicrm_option_group.title',
154 'table_name' => 'civicrm_option_group',
155 'entity' => 'OptionGroup',
156 'bao' => 'CRM_Core_BAO_OptionGroup',
157 'localizable' => 1,
158 'add' => '1.5',
159 ],
160 'description' => [
161 'name' => 'description',
162 'type' => CRM_Utils_Type::T_STRING,
163 'title' => ts('Option Group Description'),
164 'description' => ts('Option group description.'),
165 'maxlength' => 255,
166 'size' => CRM_Utils_Type::HUGE,
167 'where' => 'civicrm_option_group.description',
168 'table_name' => 'civicrm_option_group',
169 'entity' => 'OptionGroup',
170 'bao' => 'CRM_Core_BAO_OptionGroup',
171 'localizable' => 1,
172 'add' => '1.5',
173 ],
174 'data_type' => [
175 'name' => 'data_type',
176 'type' => CRM_Utils_Type::T_STRING,
177 'title' => ts('Data Type for this option group'),
178 'description' => ts('Option group description.'),
179 'maxlength' => 128,
180 'size' => CRM_Utils_Type::HUGE,
181 'where' => 'civicrm_option_group.data_type',
182 'table_name' => 'civicrm_option_group',
183 'entity' => 'OptionGroup',
184 'bao' => 'CRM_Core_BAO_OptionGroup',
185 'localizable' => 0,
186 'pseudoconstant' => [
187 'callback' => 'CRM_Utils_Type::dataTypes',
188 ],
189 'add' => '4.7',
190 ],
191 'is_reserved' => [
192 'name' => 'is_reserved',
193 'type' => CRM_Utils_Type::T_BOOLEAN,
194 'title' => ts('Option Group Is Reserved?'),
195 'description' => ts('Is this a predefined system option group (i.e. it can not be deleted)?'),
196 'required' => TRUE,
197 'where' => 'civicrm_option_group.is_reserved',
198 'default' => '1',
199 'table_name' => 'civicrm_option_group',
200 'entity' => 'OptionGroup',
201 'bao' => 'CRM_Core_BAO_OptionGroup',
202 'localizable' => 0,
203 'add' => '1.5',
204 ],
205 'is_active' => [
206 'name' => 'is_active',
207 'type' => CRM_Utils_Type::T_BOOLEAN,
208 'title' => ts('Option Group Is Active?'),
209 'description' => ts('Is this option group active?'),
210 'required' => TRUE,
211 'where' => 'civicrm_option_group.is_active',
212 'default' => '1',
213 'table_name' => 'civicrm_option_group',
214 'entity' => 'OptionGroup',
215 'bao' => 'CRM_Core_BAO_OptionGroup',
216 'localizable' => 0,
217 'add' => '1.5',
218 ],
219 'is_locked' => [
220 'name' => 'is_locked',
221 'type' => CRM_Utils_Type::T_BOOLEAN,
222 'title' => ts('Option Group Is Locked'),
223 'description' => ts('A lock to remove the ability to add new options via the UI.'),
224 'required' => TRUE,
225 'where' => 'civicrm_option_group.is_locked',
226 'default' => '0',
227 'table_name' => 'civicrm_option_group',
228 'entity' => 'OptionGroup',
229 'bao' => 'CRM_Core_BAO_OptionGroup',
230 'localizable' => 0,
231 'add' => '4.5',
232 ],
233 ];
234 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
235 }
236 return Civi::$statics[__CLASS__]['fields'];
237 }
238
239 /**
240 * Return a mapping from field-name to the corresponding key (as used in fields()).
241 *
242 * @return array
243 * Array(string $name => string $uniqueName).
244 */
245 public static function &fieldKeys() {
246 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
247 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
248 }
249 return Civi::$statics[__CLASS__]['fieldKeys'];
250 }
251
252 /**
253 * Returns the names of this table
254 *
255 * @return string
256 */
257 public static function getTableName() {
258 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
259 }
260
261 /**
262 * Returns if this table needs to be logged
263 *
264 * @return bool
265 */
266 public function getLog() {
267 return self::$_log;
268 }
269
270 /**
271 * Returns the list of fields that can be imported
272 *
273 * @param bool $prefix
274 *
275 * @return array
276 */
277 public static function &import($prefix = FALSE) {
278 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'option_group', $prefix, []);
279 return $r;
280 }
281
282 /**
283 * Returns the list of fields that can be exported
284 *
285 * @param bool $prefix
286 *
287 * @return array
288 */
289 public static function &export($prefix = FALSE) {
290 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'option_group', $prefix, []);
291 return $r;
292 }
293
294 /**
295 * Returns the list of indices
296 *
297 * @param bool $localize
298 *
299 * @return array
300 */
301 public static function indices($localize = TRUE) {
302 $indices = [
303 'UI_name' => [
304 'name' => 'UI_name',
305 'field' => [
306 0 => 'name',
307 ],
308 'localizable' => FALSE,
309 'unique' => TRUE,
310 'sig' => 'civicrm_option_group::1::name',
311 ],
312 ];
313 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
314 }
315
316 }