-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move financial acl check on Main contribution page to the extension
Note that after our snaffu with memberships I tested with the setting enabled & disabled
- Loading branch information
1 parent
98be66a
commit 07382eb
Showing
3 changed files
with
132 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
use Civi\API\EntityLookupTrait; | ||
|
||
/** | ||
* Trait implements functions to retrieve contribution related values. | ||
*/ | ||
trait CRM_Contribute_Form_ContributeFormTrait { | ||
|
||
use EntityLookupTrait; | ||
|
||
/** | ||
* Get the value for a field relating to the event. | ||
* | ||
* All values returned in apiv4 format. Escaping may be required. | ||
* | ||
* @api This function will not change in a minor release and is supported for | ||
* use outside of core. This annotation / external support for properties | ||
* is only given where there is specific test cover. | ||
* | ||
* @param string $fieldName | ||
* | ||
* @return mixed | ||
* @throws \CRM_Core_Exception | ||
*/ | ||
public function getContributionValue(string $fieldName) { | ||
if ($this->isDefined('Contribution')) { | ||
return $this->lookup('Contribution', $fieldName); | ||
} | ||
$id = $this->getContributionID(); | ||
if ($id) { | ||
$this->define('Contribution', 'Contribution', ['id' => $id]); | ||
return $this->lookup('Contribution', $fieldName); | ||
} | ||
return NULL; | ||
} | ||
|
||
/** | ||
* Get the selected Contribution ID. | ||
* | ||
* @api This function will not change in a minor release and is supported for | ||
* use outside of core. This annotation / external support for properties | ||
* is only given where there is specific test cover. | ||
* | ||
* @noinspection PhpUnhandledExceptionInspection | ||
*/ | ||
public function getContributionID(): ?int { | ||
throw new CRM_Core_Exception('`getContributionID` must be implemented'); | ||
} | ||
|
||
/** | ||
* Get id of contribution page being acted on. | ||
* | ||
* @api This function will not change in a minor release and is supported for | ||
* use outside of core. This annotation / external support for properties | ||
* is only given where there is specific test cover. | ||
* | ||
* @noinspection PhpUnhandledExceptionInspection | ||
*/ | ||
public function getContributionPageID(): ?int { | ||
throw new CRM_Core_Exception('`ContributionPageID` must be implemented'); | ||
} | ||
|
||
/** | ||
* Get a value from the participant being acted on. | ||
* | ||
* All values returned in apiv4 format. Escaping may be required. | ||
* | ||
* @param string $fieldName | ||
* | ||
* @return mixed | ||
* @noinspection PhpUnhandledExceptionInspection | ||
* | ||
* @api This function will not change in a minor release and is supported for | ||
* use outside of core. This annotation / external support for properties | ||
* is only given where there is specific test cover. | ||
* | ||
*/ | ||
public function getContributionPageValue(string $fieldName) { | ||
if ($this->isDefined('ContributionPage')) { | ||
return $this->lookup('ContributionPage', $fieldName); | ||
} | ||
$id = $this->getContributionPageID(); | ||
if ($id) { | ||
$this->define('ContributionPage', 'ContributionPage', ['id' => $id]); | ||
return $this->lookup('ContributionPage', $fieldName); | ||
} | ||
return NULL; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters