From 7885e669808daaeefc7bdd9b3df7b7f43274ef7a Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Wed, 29 Apr 2020 11:31:42 +0100 Subject: [PATCH] Fix opening specific contribution page tab from Manage Contribution Pages --- .../Form/ContributionPage/Amount.php | 8 ++++++ .../Form/ContributionPage/Custom.php | 8 ++++++ .../Form/ContributionPage/Premium.php | 8 ++++++ .../Form/ContributionPage/Settings.php | 1 + .../Form/ContributionPage/ThankYou.php | 8 ++++++ .../Form/ContributionPage/Widget.php | 1 + CRM/Core/Form.php | 15 +++++++++++ CRM/Event/Form/ManageEvent.php | 15 ----------- CRM/Friend/Form/Contribute.php | 1 + CRM/Member/Form/MembershipBlock.php | 26 +++++++++---------- CRM/PCP/Form/Contribute.php | 1 + 11 files changed, 63 insertions(+), 29 deletions(-) diff --git a/CRM/Contribute/Form/ContributionPage/Amount.php b/CRM/Contribute/Form/ContributionPage/Amount.php index fa519e68bac3..b90b5ea054f7 100644 --- a/CRM/Contribute/Form/ContributionPage/Amount.php +++ b/CRM/Contribute/Form/ContributionPage/Amount.php @@ -32,6 +32,14 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co */ const NUM_OPTION = 11; + /** + * Set variables up before form is built. + */ + public function preProcess() { + parent::preProcess(); + $this->setSelectedChild('amount'); + } + /** * Build the form object. */ diff --git a/CRM/Contribute/Form/ContributionPage/Custom.php b/CRM/Contribute/Form/ContributionPage/Custom.php index 4c5757fd80ea..1dc607f2fffa 100644 --- a/CRM/Contribute/Form/ContributionPage/Custom.php +++ b/CRM/Contribute/Form/ContributionPage/Custom.php @@ -19,6 +19,14 @@ */ class CRM_Contribute_Form_ContributionPage_Custom extends CRM_Contribute_Form_ContributionPage { + /** + * Set variables up before form is built. + */ + public function preProcess() { + parent::preProcess(); + $this->setSelectedChild('custom'); + } + /** * Build the form object. */ diff --git a/CRM/Contribute/Form/ContributionPage/Premium.php b/CRM/Contribute/Form/ContributionPage/Premium.php index dbd591fe16ed..ba5b7863b777 100644 --- a/CRM/Contribute/Form/ContributionPage/Premium.php +++ b/CRM/Contribute/Form/ContributionPage/Premium.php @@ -20,6 +20,14 @@ */ class CRM_Contribute_Form_ContributionPage_Premium extends CRM_Contribute_Form_ContributionPage { + /** + * Set variables up before form is built. + */ + public function preProcess() { + parent::preProcess(); + $this->setSelectedChild('premium'); + } + /** * Set default values for the form. */ diff --git a/CRM/Contribute/Form/ContributionPage/Settings.php b/CRM/Contribute/Form/ContributionPage/Settings.php index 06c9821a77c3..1d7d518ce362 100644 --- a/CRM/Contribute/Form/ContributionPage/Settings.php +++ b/CRM/Contribute/Form/ContributionPage/Settings.php @@ -21,6 +21,7 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ */ public function preProcess() { parent::preProcess(); + $this->setSelectedChild('settings'); } /** diff --git a/CRM/Contribute/Form/ContributionPage/ThankYou.php b/CRM/Contribute/Form/ContributionPage/ThankYou.php index d0c37fd2b4fe..11dde185b6cb 100644 --- a/CRM/Contribute/Form/ContributionPage/ThankYou.php +++ b/CRM/Contribute/Form/ContributionPage/ThankYou.php @@ -20,6 +20,14 @@ */ class CRM_Contribute_Form_ContributionPage_ThankYou extends CRM_Contribute_Form_ContributionPage { + /** + * Set variables up before form is built. + */ + public function preProcess() { + parent::preProcess(); + $this->setSelectedChild('thankyou'); + } + /** * Set default values for the form. * diff --git a/CRM/Contribute/Form/ContributionPage/Widget.php b/CRM/Contribute/Form/ContributionPage/Widget.php index e703228a165a..d59c1f6c45bc 100644 --- a/CRM/Contribute/Form/ContributionPage/Widget.php +++ b/CRM/Contribute/Form/ContributionPage/Widget.php @@ -21,6 +21,7 @@ class CRM_Contribute_Form_ContributionPage_Widget extends CRM_Contribute_Form_Co public function preProcess() { parent::preProcess(); + $this->setSelectedChild('widget'); $this->_widget = new CRM_Contribute_DAO_Widget(); $this->_widget->contribution_page_id = $this->_id; diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index f19c4c317a41..416085c733a5 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -2571,4 +2571,19 @@ protected function isFormInViewOrEditMode() { ]); } + /** + * Set the active tab + * + * @param string $default + * + * @throws \CRM_Core_Exception + */ + public function setSelectedChild($default = NULL) { + $selectedChild = CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $this, FALSE, $default); + if (!empty($selectedChild)) { + $this->set('selectedChild', $selectedChild); + $this->assign('selectedChild', $selectedChild); + } + } + } diff --git a/CRM/Event/Form/ManageEvent.php b/CRM/Event/Form/ManageEvent.php index 6b027289aa03..74c595c4999b 100644 --- a/CRM/Event/Form/ManageEvent.php +++ b/CRM/Event/Form/ManageEvent.php @@ -84,21 +84,6 @@ public function getDefaultContext() { return 'create'; } - /** - * Set the active tab - * - * @param string $default - * - * @throws \CRM_Core_Exception - */ - public function setSelectedChild($default = NULL) { - $selectedChild = CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $this, FALSE, $default); - if (!empty($selectedChild)) { - $this->set('selectedChild', $selectedChild); - $this->assign('selectedChild', $selectedChild); - } - } - /** * Set variables up before form is built. */ diff --git a/CRM/Friend/Form/Contribute.php b/CRM/Friend/Form/Contribute.php index 56dac3ce18c2..1be8f42c1d44 100644 --- a/CRM/Friend/Form/Contribute.php +++ b/CRM/Friend/Form/Contribute.php @@ -32,6 +32,7 @@ class CRM_Friend_Form_Contribute extends CRM_Contribute_Form_ContributionPage { public function preProcess() { parent::preProcess(); + $this->setSelectedChild('friend'); } /** diff --git a/CRM/Member/Form/MembershipBlock.php b/CRM/Member/Form/MembershipBlock.php index 9f6b4ea0119c..19d82ee2445f 100644 --- a/CRM/Member/Form/MembershipBlock.php +++ b/CRM/Member/Form/MembershipBlock.php @@ -9,12 +9,6 @@ +--------------------------------------------------------------------+ */ -/** - * - * @package CRM - * @copyright CiviCRM LLC https://civicrm.org/licensing - */ - /** * form to process actions on Membership */ @@ -26,15 +20,19 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa */ protected $_memPriceSetId = NULL; + /** + * Set variables up before form is built. + */ + public function preProcess() { + parent::preProcess(); + $this->setSelectedChild('membership'); + } + /** * Set default values for the form. Note that in edit/view mode * the default values are retrieved from the database - * - * - * @return void */ public function setDefaultValues() { - //parent::setDefaultValues(); $defaults = []; if (isset($this->_id)) { $defaults = CRM_Member_BAO_Membership::getMembershipBlock($this->_id); @@ -94,7 +92,8 @@ public function setDefaultValues() { /** * Build the form object. * - * @return void + * @throws \CRM_Core_Exception + * @throws \CiviCRM_API3_Exception */ public function buildQuickForm() { $membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes(); @@ -207,12 +206,13 @@ public function buildQuickForm() { * * @param array $params * (ref.) an assoc array of name/value pairs. - * * @param $files * @param int $contributionPageId * * @return bool|array * mixed true or array of errors + * @throws \CRM_Core_Exception + * @throws \CiviCRM_API3_Exception */ public static function formRule($params, $files, $contributionPageId = NULL) { $errors = []; @@ -315,8 +315,6 @@ public static function formRule($params, $files, $contributionPageId = NULL) { /** * Process the form. - * - * @return void */ public function postProcess() { // get the submitted form values. diff --git a/CRM/PCP/Form/Contribute.php b/CRM/PCP/Form/Contribute.php index bbe080e1e46b..45d6a4b0263b 100644 --- a/CRM/PCP/Form/Contribute.php +++ b/CRM/PCP/Form/Contribute.php @@ -32,6 +32,7 @@ class CRM_PCP_Form_Contribute extends CRM_Contribute_Form_ContributionPage { public function preProcess() { parent::preProcess(); + $this->setSelectedChild('pcp'); } /**