Merge pull request #1 from civicrm/master
[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,
a36434b9 131 'where' => 'civicrm_setting.id',
522a26c9 132 'table_name' => 'civicrm_setting',
133 'entity' => 'Setting',
134 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 135 'localizable' => 0,
c3fc2621
CW
136 ],
137 'name' => [
e501603b
TO
138 'name' => 'name',
139 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 140 'title' => ts('Setting Name'),
215b423e 141 'description' => ts('Unique name for setting'),
e501603b
TO
142 'maxlength' => 255,
143 'size' => CRM_Utils_Type::HUGE,
a36434b9 144 'where' => 'civicrm_setting.name',
522a26c9 145 'table_name' => 'civicrm_setting',
146 'entity' => 'Setting',
147 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 148 'localizable' => 0,
c3fc2621
CW
149 ],
150 'value' => [
e501603b
TO
151 'name' => 'value',
152 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 153 'title' => ts('Value'),
215b423e 154 'description' => ts('data associated with this group / name combo'),
a36434b9 155 'where' => 'civicrm_setting.value',
522a26c9 156 'table_name' => 'civicrm_setting',
157 'entity' => 'Setting',
158 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 159 'localizable' => 0,
2a5c9b4d 160 'serialize' => self::SERIALIZE_PHP,
c3fc2621
CW
161 ],
162 'domain_id' => [
e501603b
TO
163 'name' => 'domain_id',
164 'type' => CRM_Utils_Type::T_INT,
c3fc2621 165 'title' => ts('Setting Domain'),
215b423e 166 'description' => ts('Which Domain is this menu item for'),
c3fc2621 167 'required' => TRUE,
a36434b9 168 'where' => 'civicrm_setting.domain_id',
522a26c9 169 'table_name' => 'civicrm_setting',
170 'entity' => 'Setting',
171 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 172 'localizable' => 0,
e501603b 173 'FKClassName' => 'CRM_Core_DAO_Domain',
c3fc2621 174 'pseudoconstant' => [
e501603b
TO
175 'table' => 'civicrm_domain',
176 'keyColumn' => 'id',
177 'labelColumn' => 'name',
c3fc2621
CW
178 ]
179 ],
180 'contact_id' => [
e501603b
TO
181 'name' => 'contact_id',
182 'type' => CRM_Utils_Type::T_INT,
c3fc2621 183 'title' => ts('Setting Contact'),
215b423e 184 'description' => ts('FK to Contact ID if the setting is localized to a contact'),
a36434b9 185 'where' => 'civicrm_setting.contact_id',
522a26c9 186 'table_name' => 'civicrm_setting',
187 'entity' => 'Setting',
188 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 189 'localizable' => 0,
e501603b 190 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
191 ],
192 'is_domain' => [
e501603b
TO
193 'name' => 'is_domain',
194 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 195 'title' => ts('Is Domain Setting?'),
215b423e 196 'description' => ts('Is this setting a contact specific or site wide setting?'),
a36434b9 197 'where' => 'civicrm_setting.is_domain',
522a26c9 198 'table_name' => 'civicrm_setting',
199 'entity' => 'Setting',
200 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 201 'localizable' => 0,
c3fc2621
CW
202 ],
203 'component_id' => [
e501603b
TO
204 'name' => 'component_id',
205 'type' => CRM_Utils_Type::T_INT,
c3fc2621 206 'title' => ts('Setting Component'),
215b423e 207 'description' => ts('Component that this menu item belongs to'),
a36434b9 208 'where' => 'civicrm_setting.component_id',
522a26c9 209 'table_name' => 'civicrm_setting',
210 'entity' => 'Setting',
211 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 212 'localizable' => 0,
e501603b 213 'FKClassName' => 'CRM_Core_DAO_Component',
c3fc2621 214 'html' => [
e501603b 215 'type' => 'Select',
c3fc2621
CW
216 ],
217 'pseudoconstant' => [
e501603b
TO
218 'table' => 'civicrm_component',
219 'keyColumn' => 'id',
220 'labelColumn' => 'name',
c3fc2621
CW
221 ]
222 ],
223 'created_date' => [
e501603b
TO
224 'name' => 'created_date',
225 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 226 'title' => ts('Setting Created Date'),
215b423e 227 'description' => ts('When was the setting created'),
a36434b9 228 'where' => 'civicrm_setting.created_date',
522a26c9 229 'table_name' => 'civicrm_setting',
230 'entity' => 'Setting',
231 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 232 'localizable' => 0,
c3fc2621
CW
233 ],
234 'created_id' => [
e501603b
TO
235 'name' => 'created_id',
236 'type' => CRM_Utils_Type::T_INT,
c3fc2621 237 'title' => ts('Setting Created By'),
215b423e 238 'description' => ts('FK to civicrm_contact, who created this setting'),
a36434b9 239 'where' => 'civicrm_setting.created_id',
522a26c9 240 'table_name' => 'civicrm_setting',
241 'entity' => 'Setting',
242 'bao' => 'CRM_Core_BAO_Setting',
6a7e5e5d 243 'localizable' => 0,
e501603b 244 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
245 ],
246 ];
346aaaba 247 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 248 }
346aaaba 249 return Civi::$statics[__CLASS__]['fields'];
e501603b 250 }
c3fc2621 251
e501603b 252 /**
bd8e0b14 253 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
254 *
255 * @return array
bd8e0b14 256 * Array(string $name => string $uniqueName).
e501603b 257 */
c3fc2621 258 public static function &fieldKeys() {
bd8e0b14
TO
259 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
260 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 261 }
bd8e0b14 262 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 263 }
c3fc2621 264
e501603b
TO
265 /**
266 * Returns the names of this table
267 *
268 * @return string
269 */
c3fc2621 270 public static function getTableName() {
e501603b
TO
271 return self::$_tableName;
272 }
c3fc2621 273
e501603b
TO
274 /**
275 * Returns if this table needs to be logged
276 *
c3fc2621 277 * @return bool
e501603b 278 */
c3fc2621 279 public function getLog() {
e501603b
TO
280 return self::$_log;
281 }
c3fc2621 282
e501603b
TO
283 /**
284 * Returns the list of fields that can be imported
285 *
286 * @param bool $prefix
287 *
288 * @return array
289 */
c3fc2621
CW
290 public static function &import($prefix = FALSE) {
291 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'setting', $prefix, []);
60808919 292 return $r;
e501603b 293 }
c3fc2621 294
e501603b
TO
295 /**
296 * Returns the list of fields that can be exported
297 *
298 * @param bool $prefix
299 *
300 * @return array
301 */
c3fc2621
CW
302 public static function &export($prefix = FALSE) {
303 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'setting', $prefix, []);
60808919 304 return $r;
e501603b 305 }
c3fc2621 306
e7a6b91a
AS
307 /**
308 * Returns the list of indices
c3fc2621
CW
309 *
310 * @param bool $localize
311 *
312 * @return array
e7a6b91a
AS
313 */
314 public static function indices($localize = TRUE) {
c3fc2621
CW
315 $indices = [
316 'index_domain_contact_name' => [
e7a6b91a 317 'name' => 'index_domain_contact_name',
c3fc2621 318 'field' => [
e7a6b91a
AS
319 0 => 'domain_id',
320 1 => 'contact_id',
321 2 => 'name',
c3fc2621
CW
322 ],
323 'localizable' => FALSE,
324 'unique' => TRUE,
e7a6b91a 325 'sig' => 'civicrm_setting::1::domain_id::contact_id::name',
c3fc2621
CW
326 ],
327 ];
e7a6b91a
AS
328 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
329 }
c3fc2621 330
e501603b 331}