Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
6a488035 TO |
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 | * | |
29 | * @package CRM | |
e7112fa7 | 30 | * @copyright CiviCRM LLC (c) 2004-2015 |
6a488035 TO |
31 | * $Id$ |
32 | * | |
33 | */ | |
34 | require_once 'CRM/Core/DAO.php'; | |
35 | require_once 'CRM/Utils/Type.php'; | |
624e56fa EM |
36 | |
37 | /** | |
38 | * Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set | |
39 | */ | |
353ffa53 TO |
40 | class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set extends CRM_Core_DAO { |
41 | /** | |
42 | * static instance to hold the table name | |
43 | * | |
44 | * @var string | |
353ffa53 TO |
45 | */ |
46 | static $_tableName = 'civicrm_price_set'; | |
47 | /** | |
48 | * static instance to hold the field values | |
49 | * | |
50 | * @var array | |
353ffa53 TO |
51 | */ |
52 | static $_fields = NULL; | |
53 | /** | |
54 | * static instance to hold the FK relationships | |
55 | * | |
56 | * @var string | |
353ffa53 TO |
57 | */ |
58 | static $_links = NULL; | |
59 | /** | |
60 | * static instance to hold the values that can | |
61 | * be imported | |
62 | * | |
63 | * @var array | |
353ffa53 TO |
64 | */ |
65 | static $_import = NULL; | |
66 | /** | |
67 | * static instance to hold the values that can | |
68 | * be exported | |
69 | * | |
70 | * @var array | |
353ffa53 TO |
71 | */ |
72 | static $_export = NULL; | |
73 | /** | |
74 | * static value to see if we should log any modifications to | |
75 | * this table in the civicrm_log table | |
76 | * | |
77 | * @var boolean | |
353ffa53 TO |
78 | */ |
79 | static $_log = TRUE; | |
80 | /** | |
81 | * Price Set | |
82 | * | |
83 | * @var int unsigned | |
84 | */ | |
85 | public $id; | |
86 | /** | |
87 | * Which Domain is this price-set for | |
88 | * | |
89 | * @var int unsigned | |
90 | */ | |
91 | public $domain_id; | |
92 | /** | |
93 | * Variable name/programmatic handle for this set of price fields. | |
94 | * | |
95 | * @var string | |
96 | */ | |
97 | public $name; | |
98 | /** | |
99 | * Displayed title for the Price Set. | |
100 | * | |
101 | * @var string | |
102 | */ | |
103 | public $title; | |
104 | /** | |
105 | * Is this price set active | |
106 | * | |
107 | * @var boolean | |
108 | */ | |
109 | public $is_active; | |
110 | /** | |
111 | * Description and/or help text to display before fields in form. | |
112 | * | |
113 | * @var text | |
114 | */ | |
115 | public $help_pre; | |
116 | /** | |
117 | * Description and/or help text to display after fields in form. | |
118 | * | |
119 | * @var text | |
120 | */ | |
121 | public $help_post; | |
122 | /** | |
123 | * Optional Javascript script function(s) included on the form with this price_set. Can be used for conditional | |
124 | * | |
125 | * @var string | |
126 | */ | |
127 | public $javascript; | |
128 | /** | |
129 | * What components are using this price set? | |
130 | * | |
131 | * @var string | |
132 | */ | |
133 | public $extends; | |
134 | /** | |
135 | * FK to Contribution Type(for membership price sets only). | |
136 | * | |
137 | * @var int unsigned | |
138 | */ | |
139 | public $contribution_type_id; | |
140 | /** | |
141 | * Is set if edited on Contribution or Event Page rather than through Manage Price Sets | |
142 | * | |
143 | * @var boolean | |
144 | */ | |
145 | public $is_quick_config; | |
146 | /** | |
147 | * Is this a predefined system price set (i.e. it can not be deleted, edited)? | |
148 | * | |
149 | * @var boolean | |
150 | */ | |
151 | public $is_reserved; | |
77b97be7 EM |
152 | |
153 | /** | |
fe482240 | 154 | * Class constructor. |
77b97be7 | 155 | * |
77b97be7 EM |
156 | * @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set |
157 | */ | |
353ffa53 TO |
158 | public function __construct() { |
159 | $this->__table = 'civicrm_price_set'; | |
160 | parent::__construct(); | |
161 | } | |
162 | ||
163 | /** | |
fe482240 | 164 | * Return foreign links. |
353ffa53 TO |
165 | * |
166 | * @return array | |
167 | */ | |
168 | public function links() { | |
169 | if (!(self::$_links)) { | |
170 | self::$_links = array( | |
171 | 'domain_id' => 'civicrm_domain:id', | |
172 | 'contribution_type_id' => 'civicrm_contribution_type:id', | |
173 | ); | |
6a488035 | 174 | } |
353ffa53 TO |
175 | return self::$_links; |
176 | } | |
177 | ||
178 | /** | |
fe482240 | 179 | * Returns all the column names of this table. |
353ffa53 TO |
180 | * |
181 | * @return array | |
182 | */ | |
183 | static function &fields() { | |
184 | if (!(self::$_fields)) { | |
185 | self::$_fields = array( | |
186 | 'id' => array( | |
187 | 'name' => 'id', | |
188 | 'type' => CRM_Utils_Type::T_INT, | |
189 | 'required' => TRUE, | |
190 | ), | |
191 | 'domain_id' => array( | |
192 | 'name' => 'domain_id', | |
193 | 'type' => CRM_Utils_Type::T_INT, | |
194 | 'FKClassName' => 'CRM_Core_DAO_Domain', | |
195 | ), | |
196 | 'name' => array( | |
197 | 'name' => 'name', | |
198 | 'type' => CRM_Utils_Type::T_STRING, | |
199 | 'title' => ts('Name'), | |
200 | 'required' => TRUE, | |
201 | 'maxlength' => 255, | |
202 | 'size' => CRM_Utils_Type::HUGE, | |
203 | ), | |
204 | 'title' => array( | |
205 | 'name' => 'title', | |
206 | 'type' => CRM_Utils_Type::T_STRING, | |
207 | 'title' => ts('Title'), | |
208 | 'required' => TRUE, | |
209 | 'maxlength' => 255, | |
210 | 'size' => CRM_Utils_Type::HUGE, | |
211 | ), | |
212 | 'is_active' => array( | |
213 | 'name' => 'is_active', | |
214 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
215 | 'default' => '', | |
216 | ), | |
217 | 'help_pre' => array( | |
218 | 'name' => 'help_pre', | |
219 | 'type' => CRM_Utils_Type::T_TEXT, | |
220 | 'title' => ts('Help Pre'), | |
221 | 'rows' => 4, | |
222 | 'cols' => 80, | |
223 | ), | |
224 | 'help_post' => array( | |
225 | 'name' => 'help_post', | |
226 | 'type' => CRM_Utils_Type::T_TEXT, | |
227 | 'title' => ts('Help Post'), | |
228 | 'rows' => 4, | |
229 | 'cols' => 80, | |
230 | ), | |
231 | 'javascript' => array( | |
232 | 'name' => 'javascript', | |
233 | 'type' => CRM_Utils_Type::T_STRING, | |
234 | 'title' => ts('Javascript'), | |
235 | 'maxlength' => 64, | |
236 | 'size' => CRM_Utils_Type::BIG, | |
237 | ), | |
238 | 'extends' => array( | |
239 | 'name' => 'extends', | |
240 | 'type' => CRM_Utils_Type::T_STRING, | |
241 | 'title' => ts('Extends'), | |
242 | 'required' => TRUE, | |
243 | 'maxlength' => 255, | |
244 | 'size' => CRM_Utils_Type::HUGE, | |
245 | ), | |
246 | 'contribution_type_id' => array( | |
247 | 'name' => 'contribution_type_id', | |
248 | 'type' => CRM_Utils_Type::T_INT, | |
249 | 'default' => 'UL', | |
250 | 'FKClassName' => 'CRM_Contribute_DAO_ContributionType', | |
251 | ), | |
252 | 'is_quick_config' => array( | |
253 | 'name' => 'is_quick_config', | |
254 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
255 | ), | |
256 | 'is_reserved' => array( | |
257 | 'name' => 'is_reserved', | |
258 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
259 | ), | |
260 | ); | |
6a488035 | 261 | } |
353ffa53 TO |
262 | return self::$_fields; |
263 | } | |
264 | ||
265 | /** | |
fe482240 | 266 | * returns the names of this table. |
353ffa53 | 267 | * |
353ffa53 TO |
268 | * @return string |
269 | */ | |
270 | public static function getTableName() { | |
271 | return CRM_Core_DAO::getLocaleTableName(self::$_tableName); | |
272 | } | |
273 | ||
274 | /** | |
fe482240 | 275 | * returns if this table needs to be logged. |
353ffa53 TO |
276 | * |
277 | * @return boolean | |
278 | */ | |
279 | public function getLog() { | |
280 | return self::$_log; | |
281 | } | |
282 | ||
283 | /** | |
fe482240 | 284 | * returns the list of fields that can be imported. |
353ffa53 | 285 | * |
76e7a76c | 286 | * @return array |
353ffa53 TO |
287 | */ |
288 | static function &import($prefix = FALSE) { | |
289 | if (!(self::$_import)) { | |
290 | self::$_import = array(); | |
291 | $fields = self::fields(); | |
292 | foreach ($fields as $name => $field) { | |
293 | if (!empty($field['import'])) { | |
294 | if ($prefix) { | |
295 | self::$_import['price_set'] = &$fields[$name]; | |
296 | } | |
297 | else { | |
298 | self::$_import[$name] = &$fields[$name]; | |
299 | } | |
6a488035 | 300 | } |
353ffa53 | 301 | } |
6a488035 | 302 | } |
353ffa53 TO |
303 | return self::$_import; |
304 | } | |
305 | ||
306 | /** | |
fe482240 | 307 | * returns the list of fields that can be exported. |
353ffa53 | 308 | * |
76e7a76c | 309 | * @return array |
353ffa53 TO |
310 | */ |
311 | static function &export($prefix = FALSE) { | |
312 | if (!(self::$_export)) { | |
313 | self::$_export = array(); | |
314 | $fields = self::fields(); | |
315 | foreach ($fields as $name => $field) { | |
316 | if (!empty($field['export'])) { | |
317 | if ($prefix) { | |
318 | self::$_export['price_set'] = &$fields[$name]; | |
319 | } | |
320 | else { | |
321 | self::$_export[$name] = &$fields[$name]; | |
322 | } | |
6a488035 | 323 | } |
353ffa53 | 324 | } |
6a488035 | 325 | } |
353ffa53 TO |
326 | return self::$_export; |
327 | } | |
6a488035 | 328 | } |