From: kurund Date: Mon, 29 Sep 2014 12:17:27 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/4.4' into 4.4-4.5-2014-09-29-13-10-47 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=68acd6ae8e764d8e713829675cfadfdefff770e8;p=civicrm-core.git Merge remote-tracking branch 'upstream/4.4' into 4.4-4.5-2014-09-29-13-10-47 Conflicts: CRM/Core/Payment.php --- 68acd6ae8e764d8e713829675cfadfdefff770e8 diff --cc CRM/Core/Payment.php index 7993fd4ecb,a7f21fde65..9d143ea7ba --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@@ -342,54 -310,44 +342,52 @@@ abstract class CRM_Core_Payment return method_exists(CRM_Utils_System::getClassName($this), $method); } + /** + * @param null $entityID + * @param null $entity + * @param string $action + * + * @return string + */ function subscriptionURL($entityID = NULL, $entity = NULL, $action = 'cancel') { - if ($action == 'cancel') { - $url = 'civicrm/contribute/unsubscribe'; - } - elseif ($action == 'billing') { - if (!$this->isSupported('updateSubscriptionBillingInfo')) { - return NULL; - } - $url = 'civicrm/contribute/updatebilling'; - } - elseif ($action == 'update') { - $url = 'civicrm/contribute/updaterecur'; + // Set URL + switch ($action) { + case 'cancel' : + $url = 'civicrm/contribute/unsubscribe'; + break; - + case 'billing' : + //in notify mode don't return the update billing url - if ($this->_paymentProcessor['billing_mode'] == self::BILLING_MODE_NOTIFY) { ++ if (!$this->isSupported('updateSubscriptionBillingInfo')) { + return NULL; + } - $url = 'civicrm/contribute/updatebilling'; ++ $url = 'civicrm/contribute/updatebilling'; + break; - + case 'update' : + $url = 'civicrm/contribute/updaterecur'; + break; } + $session = CRM_Core_Session::singleton(); $userId = $session->get('userID'); - $checksumValue = ""; - - if ($entityID && $entity == 'membership') { - if (!$userId) { - $contactID = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $entityID, "contact_id"); - $checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, 'inf'); - $checksumValue = "&cs={$checksumValue}"; - } - return CRM_Utils_System::url($url, "reset=1&mid={$entityID}{$checksumValue}", TRUE, NULL, FALSE, TRUE); - } - - if ($entityID && $entity == 'contribution') { - if (!$userId) { - $contactID = CRM_Core_DAO::getFieldValue("CRM_Contribute_DAO_Contribution", $entityID, "contact_id"); - $checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, 'inf'); - $checksumValue = "&cs={$checksumValue}"; - } - return CRM_Utils_System::url($url, "reset=1&coid={$entityID}{$checksumValue}", TRUE, NULL, FALSE, TRUE); - } - - if ($entityID && $entity == 'recur') { - if (!$userId) { - $sql = " + $contactID = 0; + $checksumValue = ''; + $entityArg = ''; + + // Find related Contact + if ($entityID) { + switch ($entity) { + case 'membership' : + $contactID = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $entityID, "contact_id"); + $entityArg = 'mid'; + break; + + case 'contribution' : + $contactID = CRM_Core_DAO::getFieldValue("CRM_Contribute_DAO_Contribution", $entityID, "contact_id"); + $entityArg = 'coid'; + break; + + case 'recur' : + $sql = " SELECT con.contact_id FROM civicrm_contribution_recur rec INNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id )