<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
//get the log start date.
//it is set during renewal of membership.
- $logStartDate = CRM_Utils_array::value('log_start_date', $params);
+ $logStartDate = CRM_Utils_Array::value('log_start_date', $params);
$logStartDate = ($logStartDate) ? CRM_Utils_Date::isoToMysql($logStartDate) : CRM_Utils_Date::isoToMysql($membership->start_date);
$values = self::getStatusANDTypeValues($membership->id);
'source_contact_id' => $membershipLog['modified_id'],
'target_contact_id' => $membership->contact_id,
'source_record_id' => $membership->id,
- 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Change Membership Status'),
+ 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Change Membership Type'),
'status_id' => 2,
'priority_id' => 2,
'activity_date_time' => date('Y-m-d H:i:s'),
!CRM_Utils_Array::value('skipStatusCal', $params)
) {
$dates = array('start_date', 'end_date', 'join_date');
+ $start_date = $end_date = $join_date = NULL; // declare these out of courtesy as IDEs don't pick up the setting of them below
foreach ($dates as $date) {
- $$date = CRM_Utils_Date::processDate(CRM_Utils_Array::value($date, $params), NULL, TRUE, 'Ymd');
+ $$date = $params[$date] = CRM_Utils_Date::processDate(CRM_Utils_Array::value($date, $params), NULL, TRUE, 'Ymd');
}
//fix for CRM-3570, during import exclude the statuses those having is_admin = 1
CRM_Utils_Array::value('createActivity', $params)
) {
if (CRM_Utils_Array::value('membership', $ids)) {
+ $data = array();
CRM_Core_DAO::commonRetrieveAll('CRM_Member_DAO_Membership',
'id',
$membership->id,
if ($onlySameParentOrg && $memType) {
// require the same parent org as the $memType
$params = array('id' => $memType);
- $defaults = array();
+ $defaults = $membershipType = array();
if (CRM_Member_BAO_MembershipType::retrieve($params, $membershipType)) {
$memberTypesSameParentOrg = CRM_Member_BAO_MembershipType::getMembershipTypesByOrg($membershipType['member_of_contact_id']);
$memberTypesSameParentOrgList = implode(',', array_keys($memberTypesSameParentOrg));
*/
static function &exportableFields() {
$expFieldMembership = CRM_Member_DAO_Membership::export();
- //campaign fields.
- if (isset($expFieldMembership['member_campaign_id'])) {
- $expFieldMembership['member_campaign'] = array('title' => ts('Campaign Title'));
- }
$expFieldsMemType = CRM_Member_DAO_MembershipType::export();
$fields = array_merge($expFieldMembership, $expFieldsMemType);
'legacy_redirect_path' => 'civicrm/contribute/transact',
'legacy_redirect_query' => "_qf_Main_display=true&qfKey={$form->_params['qfKey']}",
);
- throw new CiviCRM_Exception($message, 0, $errorParams);
+ throw new CRM_Core_Exception($message, 0, $errorParams);
}
// CRM-7851
}
/**
+ * @todo - this form method needs to have the interaction with the form layer removed from it
+ * as a BAO function. Note that the api now supports membership renewals & it is not clear this function does anything
+ * not done by the membership.create api (with a lot less unit tests)
+ *
* This method will renew / create the membership depending on
* whether the given contact has a membership or not. And will add
* the modified dates for membership and in the log table.
// check is it pending. - CRM-4555
$pending = FALSE;
+ //@todo this is a BAO function & should not inspect the form - the form should do this
+ // & pass required params to the BAO
if (CRM_Utils_Array::value('minimum_fee', $membershipTypeDetails) > 0.0) {
if (((isset($form->_contributeMode) && $form->_contributeMode == 'notify') ||
CRM_Utils_Array::value('is_pay_later', $form->_params) ||
//decide status here, if needed.
$updateStatusId = NULL;
-
+ $membershipID = NULL;
+ //@todo would be better to accept $membershipID as an FN param & make form layer responsible for extracting it
+ if(isset($form->_membershipId)) {
+ $membershipID = $form->_membershipId;
+ }
// CRM-7297 - allow membership type to be be changed during renewal so long as the parent org of new membershipType
// is the same as the parent org of an existing membership of the contact
$currentMembership = CRM_Member_BAO_Membership::getContactMembership($contactID, $membershipTypeID,
- $is_test, $form->_membershipId, TRUE
+ $is_test, $membershipID, TRUE
);
if ($currentMembership) {
$activityType = 'Membership Renewal';
static function getMembershipFields($mode = NULL) {
$fields = CRM_Member_DAO_Membership::export();
- //campaign fields.
- if (isset($fields['member_campaign_id'])) {
- if ($mode == CRM_Export_Form_Select::MEMBER_EXPORT) {
- $fields['member_campaign'] = array('title' => ts('Campaign Title'));
- }
- else {
- $fields['member_campaign_id']['title'] = ts('Campaign');
- }
- }
-
unset($fields['membership_contact_id']);
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Membership'));
function processPriceSet($membershipId, $lineItem) {
//FIXME : need to move this too
if (!$membershipId || !is_array($lineItem)
- || CRM_Utils_system::isNull($lineItem)
+ || CRM_Utils_System::isNull($lineItem)
) {
return;
}
$allTypes = CRM_Member_PseudoConstant::membershipType();
$contribStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
+ // get only memberships with active membership types
$query = "
SELECT civicrm_membership.id as membership_id,
civicrm_membership.is_override as is_override,
civicrm_membership.contribution_recur_id as recur_id
FROM civicrm_membership
INNER JOIN civicrm_contact ON ( civicrm_membership.contact_id = civicrm_contact.id )
+INNER JOIN civicrm_membership_type ON
+ (civicrm_membership.membership_type_id = civicrm_membership_type.id AND civicrm_membership_type.is_active = 1)
WHERE civicrm_membership.is_test = 0";
$params = array();
// echo ".";
$processCount++;
- /**
- $count++;
- echo $dao->contact_id . ', '. CRM_Utils_System::memory( ) . "<p>\n";
-
- CRM_Core_Error::debug( 'fBegin', count( $GLOBALS['_DB_DATAOBJECT']['RESULTS'] ) );
- if ( $count > 2 ) {
- foreach ( $GLOBALS['_DB_DATAOBJECT']['RESULTS'] as $r ) {
- CRM_Core_Error::debug( 'r', $r->query );
- }
- // CRM_Core_Error::debug( 'f', $GLOBALS['_DB_DATAOBJECT']['RESULTS'] );
- exit( );
- }
- **/
-
// Put common parameters into array for easy access
$memberParams = array(
'id' => $dao->membership_id,