-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Configure Event Fees tab #25120
Configure Event Fees tab #25120
Conversation
(Standard links)
|
jenkins retest this please. |
jenkins retest this please |
@@ -66,7 +66,14 @@ public static function process(&$form) { | |||
$tabs = []; | |||
$tabs['settings'] = ['title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage'] + $default; | |||
$tabs['location'] = ['title' => ts('Event Location')] + $default; | |||
$tabs['fee'] = ['title' => ts('Fees')] + $default; | |||
// Check to see if CiviContribute is an enabled component. | |||
$components = \Civi\Api4\Setting::get() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The helper Civi::settings()->get('enable_components')
is a little pithier (we also support that for extensions/outside core)
->addSelect('enable_components') | ||
->execute()[0]['value']; | ||
// If CiviContribute is active, create the Fees tab. | ||
if (in_array('CiviContribute', $components)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually - even pithier....
if (CRM_Core_Component::isEnabled('CiviContribute')) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @eileenmcnaughton - that is much pithier! I've modified the code to use that helper instead of the API call to achieve the conditional logic.
Code makes sense - there is a helper |
Overview
This PR makes the Fees tab on the Configure Event page - as well as the link to the Fees page from the Configure button on an event - conditionally dependent on whether CiviContribute is enabled. This will prevent users from trying to set up a paid event when the Component that allows payment processing is not active.
Before
Previously, if the CiviContribute Component was disabled, the Configure Event page included the Fees tab, which would allow users to try to set up a paid event. However, users would receive an error because without CiviContribute, there are no Financial Types for a user to select from.
After
With this PR, the Fees tab and its corresponding link on the Configure menu of an event are not displayed if CiviContribute is disabled. (CiviContribute can be disabled by going to Administer > System Settings > Components, unchecking the box next to the component's name, and clicking Save.)
Technical Details
While ideally one shouldn't repeat themselves in code, since the code that controls the tab and the link are housed in two different classes, I made the same changes to both files; wrapping the line(s) of code that generate the Fees tab/link in an
if
block that is only entered if CiviComponent is within the['value']
array returned by an APIv4 call to theenable_components
Setting entity.