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