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