Merge pull request #12641 from mfb/reply-forwarding
[civicrm-core.git] / CRM / Core / DAO / OptionGroup.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Core/OptionGroup.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:2437cfeb4ae146ce21397bb38dfa08e1)
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 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 static $_log = TRUE;
30
31 /**
32 * Option Group ID
33 *
34 * @var int unsigned
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 boolean
70 */
71 public $is_reserved;
72
73 /**
74 * Is this option group active?
75 *
76 * @var boolean
77 */
78 public $is_active;
79
80 /**
81 * A lock to remove the ability to add new options via the UI.
82 *
83 * @var boolean
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 all the column names of this table
97 *
98 * @return array
99 */
100 public static function &fields() {
101 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
102 Civi::$statics[__CLASS__]['fields'] = [
103 'id' => [
104 'name' => 'id',
105 'type' => CRM_Utils_Type::T_INT,
106 'title' => ts('Option Group ID'),
107 'description' => ts('Option Group ID'),
108 'required' => TRUE,
109 'table_name' => 'civicrm_option_group',
110 'entity' => 'OptionGroup',
111 'bao' => 'CRM_Core_BAO_OptionGroup',
112 'localizable' => 0,
113 ],
114 'name' => [
115 'name' => 'name',
116 'type' => CRM_Utils_Type::T_STRING,
117 'title' => ts('Option Group Name'),
118 'description' => ts('Option group name. Used as selection key by class properties which lookup options in civicrm_option_value.'),
119 'required' => TRUE,
120 'maxlength' => 64,
121 'size' => CRM_Utils_Type::BIG,
122 'table_name' => 'civicrm_option_group',
123 'entity' => 'OptionGroup',
124 'bao' => 'CRM_Core_BAO_OptionGroup',
125 'localizable' => 0,
126 ],
127 'title' => [
128 'name' => 'title',
129 'type' => CRM_Utils_Type::T_STRING,
130 'title' => ts('Option Group title'),
131 'description' => ts('Option Group title.'),
132 'maxlength' => 255,
133 'size' => CRM_Utils_Type::HUGE,
134 'table_name' => 'civicrm_option_group',
135 'entity' => 'OptionGroup',
136 'bao' => 'CRM_Core_BAO_OptionGroup',
137 'localizable' => 1,
138 ],
139 'description' => [
140 'name' => 'description',
141 'type' => CRM_Utils_Type::T_STRING,
142 'title' => ts('Option Group Description'),
143 'description' => ts('Option group description.'),
144 'maxlength' => 255,
145 'size' => CRM_Utils_Type::HUGE,
146 'table_name' => 'civicrm_option_group',
147 'entity' => 'OptionGroup',
148 'bao' => 'CRM_Core_BAO_OptionGroup',
149 'localizable' => 1,
150 ],
151 'data_type' => [
152 'name' => 'data_type',
153 'type' => CRM_Utils_Type::T_STRING,
154 'title' => ts('Data Type for this option group'),
155 'description' => ts('Option group description.'),
156 'maxlength' => 128,
157 'size' => CRM_Utils_Type::HUGE,
158 'table_name' => 'civicrm_option_group',
159 'entity' => 'OptionGroup',
160 'bao' => 'CRM_Core_BAO_OptionGroup',
161 'localizable' => 0,
162 'pseudoconstant' => [
163 'callback' => 'CRM_Utils_Type::dataTypes',
164 ]
165 ],
166 'is_reserved' => [
167 'name' => 'is_reserved',
168 'type' => CRM_Utils_Type::T_BOOLEAN,
169 'title' => ts('Option Group Is Reserved?'),
170 'description' => ts('Is this a predefined system option group (i.e. it can not be deleted)?'),
171 'required' => TRUE,
172 'default' => '1',
173 'table_name' => 'civicrm_option_group',
174 'entity' => 'OptionGroup',
175 'bao' => 'CRM_Core_BAO_OptionGroup',
176 'localizable' => 0,
177 ],
178 'is_active' => [
179 'name' => 'is_active',
180 'type' => CRM_Utils_Type::T_BOOLEAN,
181 'title' => ts('Option Group Is Active?'),
182 'description' => ts('Is this option group active?'),
183 'required' => TRUE,
184 'default' => '1',
185 'table_name' => 'civicrm_option_group',
186 'entity' => 'OptionGroup',
187 'bao' => 'CRM_Core_BAO_OptionGroup',
188 'localizable' => 0,
189 ],
190 'is_locked' => [
191 'name' => 'is_locked',
192 'type' => CRM_Utils_Type::T_BOOLEAN,
193 'title' => ts('Option Group Is Locked'),
194 'description' => ts('A lock to remove the ability to add new options via the UI.'),
195 'required' => TRUE,
196 'default' => '0',
197 'table_name' => 'civicrm_option_group',
198 'entity' => 'OptionGroup',
199 'bao' => 'CRM_Core_BAO_OptionGroup',
200 'localizable' => 0,
201 ],
202 ];
203 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
204 }
205 return Civi::$statics[__CLASS__]['fields'];
206 }
207
208 /**
209 * Return a mapping from field-name to the corresponding key (as used in fields()).
210 *
211 * @return array
212 * Array(string $name => string $uniqueName).
213 */
214 public static function &fieldKeys() {
215 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
216 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
217 }
218 return Civi::$statics[__CLASS__]['fieldKeys'];
219 }
220
221 /**
222 * Returns the names of this table
223 *
224 * @return string
225 */
226 public static function getTableName() {
227 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
228 }
229
230 /**
231 * Returns if this table needs to be logged
232 *
233 * @return bool
234 */
235 public function getLog() {
236 return self::$_log;
237 }
238
239 /**
240 * Returns the list of fields that can be imported
241 *
242 * @param bool $prefix
243 *
244 * @return array
245 */
246 public static function &import($prefix = FALSE) {
247 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'option_group', $prefix, []);
248 return $r;
249 }
250
251 /**
252 * Returns the list of fields that can be exported
253 *
254 * @param bool $prefix
255 *
256 * @return array
257 */
258 public static function &export($prefix = FALSE) {
259 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'option_group', $prefix, []);
260 return $r;
261 }
262
263 /**
264 * Returns the list of indices
265 *
266 * @param bool $localize
267 *
268 * @return array
269 */
270 public static function indices($localize = TRUE) {
271 $indices = [
272 'UI_name' => [
273 'name' => 'UI_name',
274 'field' => [
275 0 => 'name',
276 ],
277 'localizable' => FALSE,
278 'unique' => TRUE,
279 'sig' => 'civicrm_option_group::1::name',
280 ],
281 ];
282 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
283 }
284
285 }