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