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