Commit | Line | Data |
---|---|---|
7f254ad8 AE |
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 | * @package CRM | |
29 | * @copyright CiviCRM LLC (c) 2004-2015 | |
30 | * | |
31 | * Generated from xml/schema/CRM/Member/Membership.xml | |
32 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
33 | */ | |
34 | require_once 'CRM/Core/DAO.php'; | |
35 | require_once 'CRM/Utils/Type.php'; | |
36 | class CRM_Member_DAO_Membership extends CRM_Core_DAO { | |
37 | /** | |
38 | * static instance to hold the table name | |
39 | * | |
40 | * @var string | |
41 | */ | |
42 | static $_tableName = 'civicrm_membership'; | |
43 | /** | |
44 | * static instance to hold the field values | |
45 | * | |
46 | * @var array | |
47 | */ | |
48 | static $_fields = null; | |
49 | /** | |
50 | * static instance to hold the keys used in $_fields for each field. | |
51 | * | |
52 | * @var array | |
53 | */ | |
54 | static $_fieldKeys = null; | |
55 | /** | |
56 | * static instance to hold the FK relationships | |
57 | * | |
58 | * @var string | |
59 | */ | |
60 | static $_links = null; | |
61 | /** | |
62 | * static instance to hold the values that can | |
63 | * be imported | |
64 | * | |
65 | * @var array | |
66 | */ | |
67 | static $_import = null; | |
68 | /** | |
69 | * static instance to hold the values that can | |
70 | * be exported | |
71 | * | |
72 | * @var array | |
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 | */ | |
81 | static $_log = true; | |
82 | /** | |
83 | * Membership Id | |
84 | * | |
85 | * @var int unsigned | |
86 | */ | |
87 | public $id; | |
88 | /** | |
89 | * FK to Contact ID | |
90 | * | |
91 | * @var int unsigned | |
92 | */ | |
93 | public $contact_id; | |
94 | /** | |
95 | * FK to Membership Type | |
96 | * | |
97 | * @var int unsigned | |
98 | */ | |
99 | public $membership_type_id; | |
100 | /** | |
101 | * Beginning of initial membership period (member since...). | |
102 | * | |
103 | * @var date | |
104 | */ | |
105 | public $join_date; | |
106 | /** | |
107 | * Beginning of current uninterrupted membership period. | |
108 | * | |
109 | * @var date | |
110 | */ | |
111 | public $start_date; | |
112 | /** | |
113 | * Current membership period expire date. | |
114 | * | |
115 | * @var date | |
116 | */ | |
117 | public $end_date; | |
118 | /** | |
119 | * | |
120 | * @var string | |
121 | */ | |
122 | public $source; | |
123 | /** | |
124 | * FK to Membership Status | |
125 | * | |
126 | * @var int unsigned | |
127 | */ | |
128 | public $status_id; | |
129 | /** | |
130 | * Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record. | |
131 | * | |
132 | * @var boolean | |
133 | */ | |
134 | public $is_override; | |
135 | /** | |
136 | * Optional FK to Parent Membership. | |
137 | * | |
138 | * @var int unsigned | |
139 | */ | |
140 | public $owner_membership_id; | |
141 | /** | |
142 | * Maximum number of related memberships (membership_type override). | |
143 | * | |
144 | * @var int | |
145 | */ | |
146 | public $max_related; | |
147 | /** | |
148 | * | |
149 | * @var boolean | |
150 | */ | |
151 | public $is_test; | |
152 | /** | |
153 | * | |
154 | * @var boolean | |
155 | */ | |
156 | public $is_pay_later; | |
157 | /** | |
158 | * Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events. | |
159 | * | |
160 | * @var int unsigned | |
161 | */ | |
162 | public $contribution_recur_id; | |
163 | /** | |
164 | * The campaign for which this membership is attached. | |
165 | * | |
166 | * @var int unsigned | |
167 | */ | |
168 | public $campaign_id; | |
169 | /** | |
170 | * class constructor | |
171 | * | |
172 | * @return civicrm_membership | |
173 | */ | |
174 | function __construct() { | |
175 | $this->__table = 'civicrm_membership'; | |
176 | parent::__construct(); | |
177 | } | |
178 | /** | |
179 | * Returns foreign keys and entity references | |
180 | * | |
181 | * @return array | |
182 | * [CRM_Core_Reference_Interface] | |
183 | */ | |
184 | static function getReferenceColumns() { | |
185 | if (!self::$_links) { | |
186 | self::$_links = static ::createReferenceColumns(__CLASS__); | |
187 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id'); | |
188 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'membership_type_id', 'civicrm_membership_type', 'id'); | |
189 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'status_id', 'civicrm_membership_status', 'id'); | |
190 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'owner_membership_id', 'civicrm_membership', 'id'); | |
191 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contribution_recur_id', 'civicrm_contribution_recur', 'id'); | |
192 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'campaign_id', 'civicrm_campaign', 'id'); | |
193 | } | |
194 | return self::$_links; | |
195 | } | |
196 | /** | |
197 | * Returns all the column names of this table | |
198 | * | |
199 | * @return array | |
200 | */ | |
201 | static function &fields() { | |
202 | if (!(self::$_fields)) { | |
203 | self::$_fields = array( | |
204 | 'membership_id' => array( | |
205 | 'name' => 'id', | |
206 | 'type' => CRM_Utils_Type::T_INT, | |
207 | 'title' => ts('Membership ID') , | |
208 | 'description' => 'Membership Id', | |
209 | 'required' => true, | |
210 | 'import' => true, | |
211 | 'where' => 'civicrm_membership.id', | |
212 | 'headerPattern' => '/^(m(embership\s)?id)$/i', | |
213 | 'dataPattern' => '', | |
214 | 'export' => true, | |
215 | ) , | |
216 | 'membership_contact_id' => array( | |
217 | 'name' => 'contact_id', | |
218 | 'type' => CRM_Utils_Type::T_INT, | |
219 | 'title' => ts('Contact ID') , | |
220 | 'description' => 'FK to Contact ID', | |
221 | 'required' => true, | |
222 | 'import' => true, | |
223 | 'where' => 'civicrm_membership.contact_id', | |
224 | 'headerPattern' => '/contact(.?id)?/i', | |
225 | 'dataPattern' => '/^\d+$/', | |
226 | 'export' => true, | |
227 | 'FKClassName' => 'CRM_Contact_DAO_Contact', | |
228 | 'html' => array( | |
229 | 'type' => 'Autocomplete-Select', | |
230 | ) , | |
231 | ) , | |
232 | 'membership_type_id' => array( | |
233 | 'name' => 'membership_type_id', | |
234 | 'type' => CRM_Utils_Type::T_INT, | |
235 | 'title' => ts('Membership Type Id') , | |
236 | 'description' => 'FK to Membership Type', | |
237 | 'required' => true, | |
238 | 'import' => true, | |
239 | 'where' => 'civicrm_membership.membership_type_id', | |
240 | 'headerPattern' => '/^(m(embership\s)?type)$/i', | |
241 | 'dataPattern' => '', | |
242 | 'export' => false, | |
243 | 'FKClassName' => 'CRM_Member_DAO_MembershipType', | |
244 | 'html' => array( | |
245 | 'type' => 'Select', | |
246 | ) , | |
247 | 'pseudoconstant' => array( | |
248 | 'table' => 'civicrm_membership_type', | |
249 | 'keyColumn' => 'id', | |
250 | 'labelColumn' => 'name', | |
251 | ) | |
252 | ) , | |
253 | 'join_date' => array( | |
254 | 'name' => 'join_date', | |
255 | 'type' => CRM_Utils_Type::T_DATE, | |
256 | 'title' => ts('Member Since') , | |
257 | 'description' => 'Beginning of initial membership period (member since...).', | |
258 | 'import' => true, | |
259 | 'where' => 'civicrm_membership.join_date', | |
260 | 'headerPattern' => '/^join|(j(oin\s)?date)$/i', | |
261 | 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/', | |
262 | 'export' => true, | |
263 | 'html' => array( | |
264 | 'type' => 'Select Date', | |
265 | ) , | |
266 | ) , | |
267 | 'membership_start_date' => array( | |
268 | 'name' => 'start_date', | |
269 | 'type' => CRM_Utils_Type::T_DATE, | |
270 | 'title' => ts('Membership Start Date') , | |
271 | 'description' => 'Beginning of current uninterrupted membership period.', | |
272 | 'import' => true, | |
273 | 'where' => 'civicrm_membership.start_date', | |
274 | 'headerPattern' => '/(member(ship)?.)?start(s)?(.date$)?/i', | |
275 | 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/', | |
276 | 'export' => true, | |
277 | 'html' => array( | |
278 | 'type' => 'Select Date', | |
279 | ) , | |
280 | ) , | |
281 | 'membership_end_date' => array( | |
282 | 'name' => 'end_date', | |
283 | 'type' => CRM_Utils_Type::T_DATE, | |
284 | 'title' => ts('Membership Expiration Date') , | |
285 | 'description' => 'Current membership period expire date.', | |
286 | 'import' => true, | |
287 | 'where' => 'civicrm_membership.end_date', | |
288 | 'headerPattern' => '/(member(ship)?.)?end(s)?(.date$)?/i', | |
289 | 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/', | |
290 | 'export' => true, | |
291 | 'html' => array( | |
292 | 'type' => 'Select Date', | |
293 | ) , | |
294 | ) , | |
295 | 'membership_source' => array( | |
296 | 'name' => 'source', | |
297 | 'type' => CRM_Utils_Type::T_STRING, | |
298 | 'title' => ts('Source') , | |
299 | 'maxlength' => 128, | |
300 | 'size' => CRM_Utils_Type::HUGE, | |
301 | 'import' => true, | |
302 | 'where' => 'civicrm_membership.source', | |
303 | 'headerPattern' => '/^(member(ship?))?source$/i', | |
304 | 'dataPattern' => '', | |
305 | 'export' => true, | |
306 | 'html' => array( | |
307 | 'type' => 'Text', | |
308 | ) , | |
309 | ) , | |
310 | 'status_id' => array( | |
311 | 'name' => 'status_id', | |
312 | 'type' => CRM_Utils_Type::T_INT, | |
313 | 'title' => ts('Membership Status Id') , | |
314 | 'description' => 'FK to Membership Status', | |
315 | 'required' => true, | |
316 | 'import' => true, | |
317 | 'where' => 'civicrm_membership.status_id', | |
318 | 'headerPattern' => '/(member(ship|).)?(status)$/i', | |
319 | 'dataPattern' => '', | |
320 | 'export' => false, | |
321 | 'FKClassName' => 'CRM_Member_DAO_MembershipStatus', | |
322 | 'html' => array( | |
323 | 'type' => 'Select', | |
324 | ) , | |
325 | 'pseudoconstant' => array( | |
326 | 'table' => 'civicrm_membership_status', | |
327 | 'keyColumn' => 'id', | |
328 | 'labelColumn' => 'label', | |
329 | ) | |
330 | ) , | |
331 | 'is_override' => array( | |
332 | 'name' => 'is_override', | |
333 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
334 | 'title' => ts('Status Override') , | |
335 | 'description' => 'Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.', | |
336 | 'import' => true, | |
337 | 'where' => 'civicrm_membership.is_override', | |
338 | 'headerPattern' => '/override$/i', | |
339 | 'dataPattern' => '', | |
340 | 'export' => true, | |
341 | 'html' => array( | |
342 | 'type' => 'CheckBox', | |
343 | ) , | |
344 | ) , | |
345 | 'owner_membership_id' => array( | |
346 | 'name' => 'owner_membership_id', | |
347 | 'type' => CRM_Utils_Type::T_INT, | |
348 | 'title' => ts('Primary Member ID') , | |
349 | 'description' => 'Optional FK to Parent Membership.', | |
350 | 'export' => true, | |
351 | 'where' => 'civicrm_membership.owner_membership_id', | |
352 | 'headerPattern' => '', | |
353 | 'dataPattern' => '', | |
354 | 'FKClassName' => 'CRM_Member_DAO_Membership', | |
355 | ) , | |
356 | 'max_related' => array( | |
357 | 'name' => 'max_related', | |
358 | 'type' => CRM_Utils_Type::T_INT, | |
359 | 'title' => ts('Max Related') , | |
360 | 'description' => 'Maximum number of related memberships (membership_type override).', | |
361 | 'html' => array( | |
362 | 'type' => 'Text', | |
363 | ) , | |
364 | ) , | |
365 | 'member_is_test' => array( | |
366 | 'name' => 'is_test', | |
367 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
368 | 'title' => ts('Test') , | |
369 | 'import' => true, | |
370 | 'where' => 'civicrm_membership.is_test', | |
371 | 'headerPattern' => '/(is.)?test(.member(ship)?)?/i', | |
372 | 'dataPattern' => '', | |
373 | 'export' => true, | |
374 | 'html' => array( | |
375 | 'type' => 'CheckBox', | |
376 | ) , | |
377 | ) , | |
378 | 'member_is_pay_later' => array( | |
379 | 'name' => 'is_pay_later', | |
380 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
381 | 'title' => ts('Is Pay Later') , | |
382 | 'import' => true, | |
383 | 'where' => 'civicrm_membership.is_pay_later', | |
384 | 'headerPattern' => '/(is.)?(pay(.)?later)$/i', | |
385 | 'dataPattern' => '', | |
386 | 'export' => true, | |
387 | 'html' => array( | |
388 | 'type' => 'CheckBox', | |
389 | ) , | |
390 | ) , | |
391 | 'contribution_recur_id' => array( | |
392 | 'name' => 'contribution_recur_id', | |
393 | 'type' => CRM_Utils_Type::T_INT, | |
394 | 'title' => ts('Memberhip Recurring Contribution') , | |
395 | 'description' => 'Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.', | |
396 | 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur', | |
397 | ) , | |
398 | 'member_campaign_id' => array( | |
399 | 'name' => 'campaign_id', | |
400 | 'type' => CRM_Utils_Type::T_INT, | |
401 | 'title' => ts('Campaign') , | |
402 | 'description' => 'The campaign for which this membership is attached.', | |
403 | 'import' => true, | |
404 | 'where' => 'civicrm_membership.campaign_id', | |
405 | 'headerPattern' => '', | |
406 | 'dataPattern' => '', | |
407 | 'export' => true, | |
408 | 'FKClassName' => 'CRM_Campaign_DAO_Campaign', | |
409 | 'html' => array( | |
410 | 'type' => 'Select', | |
411 | ) , | |
412 | 'pseudoconstant' => array( | |
413 | 'table' => 'civicrm_campaign', | |
414 | 'keyColumn' => 'id', | |
415 | 'labelColumn' => 'title', | |
416 | ) | |
417 | ) , | |
418 | ); | |
419 | } | |
420 | return self::$_fields; | |
421 | } | |
422 | /** | |
423 | * Returns an array containing, for each field, the arary key used for that | |
424 | * field in self::$_fields. | |
425 | * | |
426 | * @return array | |
427 | */ | |
428 | static function &fieldKeys() { | |
429 | if (!(self::$_fieldKeys)) { | |
430 | self::$_fieldKeys = array( | |
431 | 'id' => 'membership_id', | |
432 | 'contact_id' => 'membership_contact_id', | |
433 | 'membership_type_id' => 'membership_type_id', | |
434 | 'join_date' => 'join_date', | |
435 | 'start_date' => 'membership_start_date', | |
436 | 'end_date' => 'membership_end_date', | |
437 | 'source' => 'membership_source', | |
438 | 'status_id' => 'status_id', | |
439 | 'is_override' => 'is_override', | |
440 | 'owner_membership_id' => 'owner_membership_id', | |
441 | 'max_related' => 'max_related', | |
442 | 'is_test' => 'member_is_test', | |
443 | 'is_pay_later' => 'member_is_pay_later', | |
444 | 'contribution_recur_id' => 'contribution_recur_id', | |
445 | 'campaign_id' => 'member_campaign_id', | |
446 | ); | |
447 | } | |
448 | return self::$_fieldKeys; | |
449 | } | |
450 | /** | |
451 | * Returns the names of this table | |
452 | * | |
453 | * @return string | |
454 | */ | |
455 | static function getTableName() { | |
456 | return self::$_tableName; | |
457 | } | |
458 | /** | |
459 | * Returns if this table needs to be logged | |
460 | * | |
461 | * @return boolean | |
462 | */ | |
463 | function getLog() { | |
464 | return self::$_log; | |
465 | } | |
466 | /** | |
467 | * Returns the list of fields that can be imported | |
468 | * | |
469 | * @param bool $prefix | |
470 | * | |
471 | * @return array | |
472 | */ | |
473 | static function &import($prefix = false) { | |
474 | if (!(self::$_import)) { | |
475 | self::$_import = array(); | |
476 | $fields = self::fields(); | |
477 | foreach($fields as $name => $field) { | |
478 | if (CRM_Utils_Array::value('import', $field)) { | |
479 | if ($prefix) { | |
480 | self::$_import['membership'] = & $fields[$name]; | |
481 | } else { | |
482 | self::$_import[$name] = & $fields[$name]; | |
483 | } | |
484 | } | |
485 | } | |
486 | } | |
487 | return self::$_import; | |
488 | } | |
489 | /** | |
490 | * Returns the list of fields that can be exported | |
491 | * | |
492 | * @param bool $prefix | |
493 | * | |
494 | * @return array | |
495 | */ | |
496 | static function &export($prefix = false) { | |
497 | if (!(self::$_export)) { | |
498 | self::$_export = array(); | |
499 | $fields = self::fields(); | |
500 | foreach($fields as $name => $field) { | |
501 | if (CRM_Utils_Array::value('export', $field)) { | |
502 | if ($prefix) { | |
503 | self::$_export['membership'] = & $fields[$name]; | |
504 | } else { | |
505 | self::$_export[$name] = & $fields[$name]; | |
506 | } | |
507 | } | |
508 | } | |
509 | } | |
510 | return self::$_export; | |
511 | } | |
512 | } |