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