Skip to content

Commit

Permalink
Merge pull request henare#13 from kenwest/0.7
Browse files Browse the repository at this point in the history
Don't need to set UserId to zero in CiviCRM 4.5 or above
  • Loading branch information
Chris Ward committed Sep 25, 2014
2 parents db6a6e3 + f162ea9 commit f4b0eb7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
32 changes: 15 additions & 17 deletions api/v3/Job/Eway.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,20 +447,16 @@ function send_receipt_email($contribution_id) {
'isTest' => $contribution->is_test
);

// TODO: Fix CRM_Core_Payment::subscriptionUrl()
//
// Currently that function fails to affix a checksum when the session's UserId
// is set, which is unfortunate since CiviCRM Jobs run with a user context for
// permissioning purposes.
//
// subscriptionUrl() just needs to check if the contactId associated with the
// subscription is equal to the userId, and if not, add a checksum.
//
// To work around this, I am temporarily setting the UserId to zero, and hoping
// there are no exceptions thrown.
$session = CRM_Core_Session::singleton();
$activeUser = $session->get('userID');
$session->set('userID', 0);
if (!_versionAtLeast(4.5)) {
// Prior to v4.5, CRM_Core_Payment::subscriptionUrl() failed to affix a
// checksum when the session's UserId is set, which is unfortunate since
// CiviCRM Jobs run with a user context for permissioning purposes.
//
// To work around this, temporarily set the UserId to zero.
$session = CRM_Core_Session::singleton();
$activeUser = $session->get('userID');
$session->set('userID', 0);
}

$processor = array();
$mode = empty($contribution->is_test) ? 'live' : 'test';
Expand All @@ -476,9 +472,11 @@ function send_receipt_email($contribution_id) {
$params['tplParams']['updateSubscriptionUrl'] = $eWayProcessor->subscriptionURL($contribution->contribution_recur_id, 'recur', 'update');
}

// TODO: Fix CRM_Core_Payment::subscriptionUrl()
// See comment above.
$session->set('userID', $activeUser);
if (!_versionAtLeast(4.5)) {
// See comment re CRM_Core_Payment::subscriptionUrl(), above.
$session->set('userID', $activeUser);
}

return _sendReceipt($params);
}

Expand Down
1 change: 1 addition & 0 deletions info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<ver>4.2</ver>
<ver>4.3</ver>
<ver>4.4</ver>
<ver>4.5</ver>
</compatibility>
<comments></comments>
<civix>
Expand Down

0 comments on commit f4b0eb7

Please sign in to comment.