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