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