Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAE-391: Fix Giftaid Processing on Contribution Pages #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions CRM/Civigiftaid/Hook/Post/SetContributionGiftAidEligibility.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function run($op, $objectName, $objectId, &$objectRef) {
*/
private function setGiftAidEligibilityStatus($contributionId) {
$currentPath = CRM_Utils_System::currentPath();
if (!in_array($currentPath, $this->getRequiredPaths())) {
if (!$this->isAllowedPath($currentPath)) {
return;
}

Expand Down Expand Up @@ -147,20 +147,26 @@ private function getEligibilityFieldId() {
catch (Exception $e) {}
}


/**
* Returns paths/Urls where that needs this functionality implemented.
* Checks if the given path requires giftaid processing.
*
* @param $path
* Path to be evaluated.
*
* @return array
* Required paths.
* @return bool
* If the path is one of the ones that needs to be processed for giftaid
* info.
*/
private function getRequiredPaths() {
return [
'civicrm/member/add', // Add membership page
'civicrm/contact/view/membership', // Add membership from contact view page
'civicrm/participant/add', // Register event participant page
'civicrm/contact/view/participant' //Add participant from contact view page
private function isAllowedPath($path) {
$allowedPaths = [
'civicrm/member/add', // Add membership page
'civicrm/contact/view/membership', // Add membership from contact view page
'civicrm/participant/add', // Register event participant page
'civicrm/contact/view/participant', // Add participant from contact view page
'civicrm/contribute/transact', // Create contribution from contribution page
];

return in_array($path, $allowedPaths);
}

/**
Expand Down