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