Merge pull request #22428 from civicrm/5.46
[civicrm-core.git] / CRM / Core / DAO / Setting.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/Setting.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
2562d09a 9 * (GenCodeChecksum:1cc77a956cd4dfc7dd2a7f22579ad742)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Setting entity.
f41f0342 14 */
e501603b 15class CRM_Core_DAO_Setting extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.1';
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_setting';
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 = FALSE;
c3fc2621 32
e501603b 33 /**
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * Unique name for setting
40 *
41 * @var string
42 */
43 public $name;
c3fc2621 44
e501603b
TO
45 /**
46 * data associated with this group / name combo
47 *
48 * @var text
49 */
50 public $value;
c3fc2621 51
e501603b
TO
52 /**
53 * Which Domain is this menu item for
54 *
e6ca0a57 55 * @var int
e501603b
TO
56 */
57 public $domain_id;
c3fc2621 58
e501603b
TO
59 /**
60 * FK to Contact ID if the setting is localized to a contact
61 *
e6ca0a57 62 * @var int
e501603b
TO
63 */
64 public $contact_id;
c3fc2621 65
e501603b
TO
66 /**
67 * Is this setting a contact specific or site wide setting?
68 *
e6ca0a57 69 * @var bool
e501603b
TO
70 */
71 public $is_domain;
c3fc2621 72
e501603b
TO
73 /**
74 * Component that this menu item belongs to
75 *
e6ca0a57 76 * @var int
e501603b
TO
77 */
78 public $component_id;
c3fc2621 79
e501603b
TO
80 /**
81 * When was the setting created
82 *
83 * @var datetime
84 */
85 public $created_date;
c3fc2621 86
e501603b
TO
87 /**
88 * FK to civicrm_contact, who created this setting
89 *
e6ca0a57 90 * @var int
e501603b
TO
91 */
92 public $created_id;
c3fc2621 93
e501603b 94 /**
f41f0342 95 * Class constructor.
e501603b 96 */
c3fc2621 97 public function __construct() {
e501603b
TO
98 $this->__table = 'civicrm_setting';
99 parent::__construct();
100 }
c3fc2621 101
449c4e6b
CW
102 /**
103 * Returns localized title of this entity.
7b66c3b5
AH
104 *
105 * @param bool $plural
106 * Whether to return the plural version of the title.
449c4e6b 107 */
7b66c3b5
AH
108 public static function getEntityTitle($plural = FALSE) {
109 return $plural ? ts('Settings') : ts('Setting');
449c4e6b
CW
110 }
111
e501603b 112 /**
f41f0342 113 * Returns foreign keys and entity references.
e501603b
TO
114 *
115 * @return array
116 * [CRM_Core_Reference_Interface]
117 */
c3fc2621 118 public static function getReferenceColumns() {
346aaaba 119 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 120 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
121 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id');
122 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
123 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'component_id', 'civicrm_component', 'id');
124 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
346aaaba 125 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 126 }
346aaaba 127 return Civi::$statics[__CLASS__]['links'];
e501603b 128 }
c3fc2621 129
e501603b
TO
130 /**
131 * Returns all the column names of this table
132 *
133 * @return array
134 */
c3fc2621 135 public static function &fields() {
346aaaba 136 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
137 Civi::$statics[__CLASS__]['fields'] = [
138 'id' => [
e501603b
TO
139 'name' => 'id',
140 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
141 'title' => ts('Setting ID'),
142 'required' => TRUE,
a36434b9 143 'where' => 'civicrm_setting.id',
522a26c9 144 'table_name' => 'civicrm_setting',
145 'entity' => 'Setting',
146 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 147 'localizable' => 0,
2cbbebe8
A
148 'html' => [
149 'type' => 'Number',
150 ],
1fe423d6 151 'readonly' => TRUE,
a9d0587b 152 'add' => '4.1',
c3fc2621
CW
153 ],
154 'name' => [
e501603b
TO
155 'name' => 'name',
156 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 157 'title' => ts('Setting Name'),
215b423e 158 'description' => ts('Unique name for setting'),
e501603b
TO
159 'maxlength' => 255,
160 'size' => CRM_Utils_Type::HUGE,
a36434b9 161 'where' => 'civicrm_setting.name',
522a26c9 162 'table_name' => 'civicrm_setting',
163 'entity' => 'Setting',
164 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 165 'localizable' => 0,
a9d0587b 166 'add' => '4.1',
c3fc2621
CW
167 ],
168 'value' => [
e501603b
TO
169 'name' => 'value',
170 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 171 'title' => ts('Value'),
215b423e 172 'description' => ts('data associated with this group / name combo'),
a36434b9 173 'where' => 'civicrm_setting.value',
522a26c9 174 'table_name' => 'civicrm_setting',
175 'entity' => 'Setting',
176 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 177 'localizable' => 0,
2a5c9b4d 178 'serialize' => self::SERIALIZE_PHP,
c23563e3
SL
179 'html' => [
180 'label' => ts("Value"),
181 ],
a9d0587b 182 'add' => '4.1',
c3fc2621
CW
183 ],
184 'domain_id' => [
e501603b
TO
185 'name' => 'domain_id',
186 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 187 'title' => ts('Domain ID'),
215b423e 188 'description' => ts('Which Domain is this menu item for'),
c3fc2621 189 'required' => TRUE,
a36434b9 190 'where' => 'civicrm_setting.domain_id',
522a26c9 191 'table_name' => 'civicrm_setting',
192 'entity' => 'Setting',
193 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 194 'localizable' => 0,
e501603b 195 'FKClassName' => 'CRM_Core_DAO_Domain',
2cbbebe8
A
196 'html' => [
197 'label' => ts("Domain"),
198 ],
c3fc2621 199 'pseudoconstant' => [
e501603b
TO
200 'table' => 'civicrm_domain',
201 'keyColumn' => 'id',
202 'labelColumn' => 'name',
e6ca0a57 203 ],
a9d0587b 204 'add' => '4.1',
c3fc2621
CW
205 ],
206 'contact_id' => [
e501603b
TO
207 'name' => 'contact_id',
208 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 209 'title' => ts('Contact ID'),
215b423e 210 'description' => ts('FK to Contact ID if the setting is localized to a contact'),
a36434b9 211 'where' => 'civicrm_setting.contact_id',
522a26c9 212 'table_name' => 'civicrm_setting',
213 'entity' => 'Setting',
214 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 215 'localizable' => 0,
e501603b 216 'FKClassName' => 'CRM_Contact_DAO_Contact',
2cbbebe8
A
217 'html' => [
218 'label' => ts("Contact"),
219 ],
a9d0587b 220 'add' => '4.1',
c3fc2621
CW
221 ],
222 'is_domain' => [
e501603b
TO
223 'name' => 'is_domain',
224 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 225 'title' => ts('Is Domain Setting?'),
215b423e 226 'description' => ts('Is this setting a contact specific or site wide setting?'),
a36434b9 227 'where' => 'civicrm_setting.is_domain',
522a26c9 228 'table_name' => 'civicrm_setting',
229 'entity' => 'Setting',
230 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 231 'localizable' => 0,
a9d0587b 232 'add' => '4.1',
c3fc2621
CW
233 ],
234 'component_id' => [
e501603b
TO
235 'name' => 'component_id',
236 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 237 'title' => ts('Component ID'),
215b423e 238 'description' => ts('Component that this menu item belongs to'),
a36434b9 239 'where' => 'civicrm_setting.component_id',
522a26c9 240 'table_name' => 'civicrm_setting',
241 'entity' => 'Setting',
242 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 243 'localizable' => 0,
e501603b 244 'FKClassName' => 'CRM_Core_DAO_Component',
c3fc2621 245 'html' => [
e501603b 246 'type' => 'Select',
2cbbebe8 247 'label' => ts("Component"),
c3fc2621
CW
248 ],
249 'pseudoconstant' => [
e501603b
TO
250 'table' => 'civicrm_component',
251 'keyColumn' => 'id',
252 'labelColumn' => 'name',
e6ca0a57 253 ],
a9d0587b 254 'add' => '4.1',
c3fc2621
CW
255 ],
256 'created_date' => [
e501603b
TO
257 'name' => 'created_date',
258 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 259 'title' => ts('Setting Created Date'),
215b423e 260 'description' => ts('When was the setting created'),
a36434b9 261 'where' => 'civicrm_setting.created_date',
522a26c9 262 'table_name' => 'civicrm_setting',
263 'entity' => 'Setting',
264 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 265 'localizable' => 0,
a9d0587b 266 'add' => '4.1',
c3fc2621
CW
267 ],
268 'created_id' => [
e501603b
TO
269 'name' => 'created_id',
270 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 271 'title' => ts('Created By Contact ID'),
215b423e 272 'description' => ts('FK to civicrm_contact, who created this setting'),
a36434b9 273 'where' => 'civicrm_setting.created_id',
522a26c9 274 'table_name' => 'civicrm_setting',
275 'entity' => 'Setting',
276 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 277 'localizable' => 0,
e501603b 278 'FKClassName' => 'CRM_Contact_DAO_Contact',
2cbbebe8
A
279 'html' => [
280 'label' => ts("Created By"),
281 ],
a9d0587b 282 'add' => '4.1',
c3fc2621
CW
283 ],
284 ];
346aaaba 285 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 286 }
346aaaba 287 return Civi::$statics[__CLASS__]['fields'];
e501603b 288 }
c3fc2621 289
e501603b 290 /**
bd8e0b14 291 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
292 *
293 * @return array
bd8e0b14 294 * Array(string $name => string $uniqueName).
e501603b 295 */
c3fc2621 296 public static function &fieldKeys() {
bd8e0b14
TO
297 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
298 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 299 }
bd8e0b14 300 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 301 }
c3fc2621 302
e501603b
TO
303 /**
304 * Returns the names of this table
305 *
306 * @return string
307 */
c3fc2621 308 public static function getTableName() {
e501603b
TO
309 return self::$_tableName;
310 }
c3fc2621 311
e501603b
TO
312 /**
313 * Returns if this table needs to be logged
314 *
c3fc2621 315 * @return bool
e501603b 316 */
c3fc2621 317 public function getLog() {
e501603b
TO
318 return self::$_log;
319 }
c3fc2621 320
e501603b
TO
321 /**
322 * Returns the list of fields that can be imported
323 *
324 * @param bool $prefix
325 *
326 * @return array
327 */
c3fc2621
CW
328 public static function &import($prefix = FALSE) {
329 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'setting', $prefix, []);
60808919 330 return $r;
e501603b 331 }
c3fc2621 332
e501603b
TO
333 /**
334 * Returns the list of fields that can be exported
335 *
336 * @param bool $prefix
337 *
338 * @return array
339 */
c3fc2621
CW
340 public static function &export($prefix = FALSE) {
341 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'setting', $prefix, []);
60808919 342 return $r;
e501603b 343 }
c3fc2621 344
e7a6b91a
AS
345 /**
346 * Returns the list of indices
c3fc2621
CW
347 *
348 * @param bool $localize
349 *
350 * @return array
e7a6b91a
AS
351 */
352 public static function indices($localize = TRUE) {
c3fc2621
CW
353 $indices = [
354 'index_domain_contact_name' => [
e7a6b91a 355 'name' => 'index_domain_contact_name',
c3fc2621 356 'field' => [
e7a6b91a
AS
357 0 => 'domain_id',
358 1 => 'contact_id',
359 2 => 'name',
c3fc2621
CW
360 ],
361 'localizable' => FALSE,
362 'unique' => TRUE,
e7a6b91a 363 'sig' => 'civicrm_setting::1::domain_id::contact_id::name',
c3fc2621
CW
364 ],
365 ];
e7a6b91a
AS
366 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
367 }
c3fc2621 368
e501603b 369}