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