CRM-13981 handling SC on Gift Membership minor fix
[civicrm-core.git] / CRM / Member / Page / Tab.php
index 2222123da648c10cd08f8129edb63fea6864f77a..412850068e140b01cfc1247c2885e55d9bb8c781 100644 (file)
@@ -323,10 +323,21 @@ class CRM_Member_Page_Tab extends CRM_Core_Page {
     if (CRM_Core_Permission::access('CiviContribute')) {
       $this->_accessContribution = TRUE;
       $this->assign('accessContribution', TRUE);
+
+      //show associated soft credit when contribution payment is paid by different person
+      if ($this->_id && $this->_contactId) {
+        $filter = " AND cc.id IN (SELECT contribution_id FROM civicrm_membership_payment WHERE membership_id = {$this->_id})";
+        $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, $filter);
+        if (!empty($softCreditList)) {
+          $this->assign('softCredit', TRUE);
+          $this->assign('softCreditRows', $softCreditList);
+        }
+      }
     }
     else {
       $this->_accessContribution = FALSE;
       $this->assign('accessContribution', FALSE);
+      $this->assign('softCredit', FALSE);
     }
 
     if ($this->_action & CRM_Core_Action::VIEW) {
@@ -349,6 +360,9 @@ class CRM_Member_Page_Tab extends CRM_Core_Page {
     $context = CRM_Utils_Request::retrieve('context', 'String', $form, FALSE, 'search' );
 
     $qfKey = CRM_Utils_Request::retrieve('key', 'String', $form);
+
+    $searchContext = CRM_Utils_Request::retrieve('searchContext', 'String', $this);
+
     //validate the qfKey
     if (!CRM_Utils_Rule::qfKey($qfKey)) {
       $qfKey = NULL;
@@ -374,7 +388,12 @@ class CRM_Member_Page_Tab extends CRM_Core_Page {
         }
         $form->assign('searchKey', $qfKey);
 
-        $url = CRM_Utils_System::url('civicrm/member/search', $urlParams);
+        if ($searchContext) {
+          $url = CRM_Utils_System::url("civicrm/$searchContext/search", $urlParams);
+        }
+        else {
+          $url = CRM_Utils_System::url('civicrm/member/search', $urlParams);
+        }
         break;
 
       case 'home':
@@ -427,6 +446,12 @@ class CRM_Member_Page_Tab extends CRM_Core_Page {
   /**
    * Get action links
    *
+   * @param string $status
+   * @param null $isPaymentProcessor
+   * @param null $accessContribution
+   * @param bool $isCancelSupported
+   * @param bool $isUpdateBilling
+   *
    * @return array (reference) of action links
    * @static
    */