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