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