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