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