CRM-13148 update another place to get contact id from url/ checksum/ session as appro...
authoreileen <eileen@fuzion.co.nz>
Mon, 5 Aug 2013 08:08:37 +0000 (20:08 +1200)
committereileen <eileen@fuzion.co.nz>
Mon, 5 Aug 2013 08:08:37 +0000 (20:08 +1200)
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/Contribution/Main.php
CRM/Contribute/Form/Contribution/ThankYou.php
CRM/Contribute/Form/ContributionBase.php
CRM/Member/BAO/Membership.php

index 1c8d3a901cee314f76455d5d14c200a5ee401745..f106eb78b9d8f31181ab398427b28eacf5820d74 100644 (file)
@@ -415,10 +415,10 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       ) {
         CRM_Member_BAO_Membership::buildMembershipBlock($this,
           $this->_id,
+          $this->_membershipContactID,
           FALSE,
           $params['selectMembership'],
-          FALSE, NULL,
-          $this->_membershipContactID
+          FALSE
         );
       }
       else {
index cb0ded878ad8717f9ccf6007adcc3996958478d5..59d1ebf111cbc6c3d91bb3227e18d89b26b1254c 100644 (file)
@@ -437,8 +437,9 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
 
         $this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this,
           $this->_id,
+          $this->_membershipContactID,
           TRUE, NULL, FALSE,
-          $isTest, $this->_membershipContactID
+          $isTest
         );
       }
       $this->set('separateMembershipPayment', $this->_separateMembershipPayment);
index 8ff020b5c1ebd8670d0df1f583cc363cc98c1089..a44723c12bd4ca877ccda508d26804b35f656920 100644 (file)
@@ -162,10 +162,11 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
 
       CRM_Member_BAO_Membership::buildMembershipBlock($this,
         $this->_id,
+        $this->_membershipContactID,
         FALSE,
         $membershipTypeID,
-        TRUE, NULL,
-        $this->_membershipContactID
+        TRUE,
+        NULL
       );
     }
 
index c45e1d5a984944174213df2da7046558feae6492..2118a03de561bcc858af5f3f33a414f03347928d 100644 (file)
@@ -152,6 +152,13 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
    */
   public $_pcpInfo;
 
+  /**
+   * The contact id of the person for whom membership is being added or renewed based on the cid in the url,
+   * checksum, or session
+   * @var unknown_type
+   */
+  protected $_contactID;
+
   protected $_userID;
 
   /**
@@ -204,10 +211,12 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
     else {
       $session->set('pastContributionID', $this->_id);
     }
-
+    // this was used prior to the cleverer this_>getContactID - unsure now
     $this->_userID = $session->get('userID');
+
+    $this->_contactID = $this->_membershipContactID = $this->getContactID();
     $this->_mid = NULL;
-    if ($this->_userID) {
+    if ($this->_contactID) {
       $this->_mid = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
       if ($this->_mid) {
         $membership = new CRM_Member_DAO_Membership();
@@ -215,7 +224,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
 
         if ($membership->find(TRUE)) {
           $this->_defaultMemTypeId = $membership->membership_type_id;
-          if ($membership->contact_id != $this->_userID) {
+          if ($membership->contact_id != $this->_contactID) {
             $employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($this->_userID);
             if (array_key_exists($membership->contact_id, $employers)) {
               $this->_membershipContactID = $membership->contact_id;
index e3cd1b27705240244636029abadb67ea1d51a7e8..1ec61981d2911dff99676a1765f1de007284a636 100644 (file)
@@ -709,23 +709,16 @@ INNER JOIN  civicrm_membership_type type ON ( type.id = membership.membership_ty
    */
   static function buildMembershipBlock(&$form,
     $pageID,
+    $cid,
     $formItems = FALSE,
     $selectedMembershipTypeID = NULL,
     $thankPage = FALSE,
-    $isTest = NULL,
-    $memberContactId = NULL
+    $isTest = NULL
   ) {
 
     $separateMembershipPayment = FALSE;
     if ($form->_membershipBlock) {
       $form->_currentMemberships = array();
-      if (!$memberContactId) {
-        $session = CRM_Core_Session::singleton();
-        $cid = $session->get('userID');
-      }
-      else {
-        $cid = $memberContactId;
-      }
 
       $membershipBlock    = $form->_membershipBlock;
       $membershipTypeIds  = $membershipTypes = $radio = array();