copyright and version fixes
[civicrm-core.git] / CRM / Upgrade / Snapshot / V4p2 / Price / DAO / FieldValue.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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
30 * @copyright CiviCRM LLC (c) 2004-2014
31 * $Id$
32 *
33 */
34 require_once 'CRM/Core/DAO.php';
35 require_once 'CRM/Utils/Type.php';
36 class CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue extends CRM_Core_DAO
37 {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 * @static
43 */
44 static $_tableName = 'civicrm_price_field_value';
45 /**
46 * static instance to hold the field values
47 *
48 * @var array
49 * @static
50 */
51 static $_fields = null;
52 /**
53 * static instance to hold the FK relationships
54 *
55 * @var string
56 * @static
57 */
58 static $_links = null;
59 /**
60 * static instance to hold the values that can
61 * be imported
62 *
63 * @var array
64 * @static
65 */
66 static $_import = null;
67 /**
68 * static instance to hold the values that can
69 * be exported
70 *
71 * @var array
72 * @static
73 */
74 static $_export = null;
75 /**
76 * static value to see if we should log any modifications to
77 * this table in the civicrm_log table
78 *
79 * @var boolean
80 * @static
81 */
82 static $_log = false;
83 /**
84 * Price Field Value
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * FK to civicrm_price_field
91 *
92 * @var int unsigned
93 */
94 public $price_field_id;
95 /**
96 * Price field option name
97 *
98 * @var string
99 */
100 public $name;
101 /**
102 * Price field option label
103 *
104 * @var string
105 */
106 public $label;
107 /**
108 * >Price field option description.
109 *
110 * @var text
111 */
112 public $description;
113 /**
114 * Price field option amount
115 *
116 * @var string
117 */
118 public $amount;
119 /**
120 * Number of participants per field option
121 *
122 * @var int unsigned
123 */
124 public $count;
125 /**
126 * Max number of participants per field options
127 *
128 * @var int unsigned
129 */
130 public $max_value;
131 /**
132 * Order in which the field options should appear
133 *
134 * @var int
135 */
136 public $weight;
137 /**
138 * FK to Membership Type
139 *
140 * @var int unsigned
141 */
142 public $membership_type_id;
143 /**
144 * Is this default price field option
145 *
146 * @var boolean
147 */
148 public $is_default;
149 /**
150 * Is this price field value active
151 *
152 * @var boolean
153 */
154 public $is_active;
155 /**
156 * class constructor
157 *
158 * @access public
159 * @return civicrm_price_field_value
160 */
161 function __construct()
162 {
163 $this->__table = 'civicrm_price_field_value';
164 parent::__construct();
165 }
166 /**
167 * return foreign links
168 *
169 * @access public
170 * @return array
171 */
172 function links()
173 {
174 if (!(self::$_links)) {
175 self::$_links = array(
176 'price_field_id' => 'civicrm_price_field:id',
177 'membership_type_id' => 'civicrm_membership_type:id',
178 );
179 }
180 return self::$_links;
181 }
182 /**
183 * returns all the column names of this table
184 *
185 * @access public
186 * @return array
187 */
188 static function &fields()
189 {
190 if (!(self::$_fields)) {
191 self::$_fields = array(
192 'id' => array(
193 'name' => 'id',
194 'type' => CRM_Utils_Type::T_INT,
195 'required' => true,
196 ) ,
197 'price_field_id' => array(
198 'name' => 'price_field_id',
199 'type' => CRM_Utils_Type::T_INT,
200 'required' => true,
201 'FKClassName' => 'Snapshot_v4p2_Price_DAO_Field',
202 ) ,
203 'name' => array(
204 'name' => 'name',
205 'type' => CRM_Utils_Type::T_STRING,
206 'title' => ts('Name') ,
207 'maxlength' => 255,
208 'size' => CRM_Utils_Type::HUGE,
209 ) ,
210 'label' => array(
211 'name' => 'label',
212 'type' => CRM_Utils_Type::T_STRING,
213 'title' => ts('Label') ,
214 'maxlength' => 255,
215 'size' => CRM_Utils_Type::HUGE,
216 ) ,
217 'description' => array(
218 'name' => 'description',
219 'type' => CRM_Utils_Type::T_TEXT,
220 'title' => ts('Description') ,
221 'rows' => 2,
222 'cols' => 60,
223 'default' => 'UL',
224 ) ,
225 'amount' => array(
226 'name' => 'amount',
227 'type' => CRM_Utils_Type::T_STRING,
228 'title' => ts('Amount') ,
229 'required' => true,
230 'maxlength' => 512,
231 'size' => CRM_Utils_Type::HUGE,
232 ) ,
233 'count' => array(
234 'name' => 'count',
235 'type' => CRM_Utils_Type::T_INT,
236 'title' => ts('Count') ,
237 'default' => 'UL',
238 ) ,
239 'max_value' => array(
240 'name' => 'max_value',
241 'type' => CRM_Utils_Type::T_INT,
242 'title' => ts('Max Value') ,
243 'default' => 'UL',
244 ) ,
245 'weight' => array(
246 'name' => 'weight',
247 'type' => CRM_Utils_Type::T_INT,
248 'title' => ts('Weight') ,
249 'default' => '',
250 ) ,
251 'membership_type_id' => array(
252 'name' => 'membership_type_id',
253 'type' => CRM_Utils_Type::T_INT,
254 'default' => 'UL',
255 'FKClassName' => 'CRM_Member_DAO_MembershipType',
256 ) ,
257 'is_default' => array(
258 'name' => 'is_default',
259 'type' => CRM_Utils_Type::T_BOOLEAN,
260 ) ,
261 'is_active' => array(
262 'name' => 'is_active',
263 'type' => CRM_Utils_Type::T_BOOLEAN,
264 'default' => '',
265 ) ,
266 );
267 }
268 return self::$_fields;
269 }
270 /**
271 * returns the names of this table
272 *
273 * @access public
274 * @static
275 * @return string
276 */
277 static function getTableName()
278 {
279 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
280 }
281 /**
282 * returns if this table needs to be logged
283 *
284 * @access public
285 * @return boolean
286 */
287 function getLog()
288 {
289 return self::$_log;
290 }
291 /**
292 * returns the list of fields that can be imported
293 *
294 * @access public
295 * return array
296 * @static
297 */
298 static function &import($prefix = false)
299 {
300 if (!(self::$_import)) {
301 self::$_import = array();
302 $fields = self::fields();
303 foreach($fields as $name => $field) {
304 if (!empty($field['import'])) {
305 if ($prefix) {
306 self::$_import['price_field_value'] = & $fields[$name];
307 } else {
308 self::$_import[$name] = & $fields[$name];
309 }
310 }
311 }
312 }
313 return self::$_import;
314 }
315 /**
316 * returns the list of fields that can be exported
317 *
318 * @access public
319 * return array
320 * @static
321 */
322 static function &export($prefix = false)
323 {
324 if (!(self::$_export)) {
325 self::$_export = array();
326 $fields = self::fields();
327 foreach($fields as $name => $field) {
328 if (!empty($field['export'])) {
329 if ($prefix) {
330 self::$_export['price_field_value'] = & $fields[$name];
331 } else {
332 self::$_export[$name] = & $fields[$name];
333 }
334 }
335 }
336 }
337 return self::$_export;
338 }
339 }