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

dev/core#1738 Fix opening specific contribution page tab from Manage Contribution Pages #17190

Merged
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions CRM/Contribute/Form/ContributionPage/Amount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
8 changes: 8 additions & 0 deletions CRM/Contribute/Form/ContributionPage/Custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
8 changes: 8 additions & 0 deletions CRM/Contribute/Form/ContributionPage/Premium.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
1 change: 1 addition & 0 deletions CRM/Contribute/Form/ContributionPage/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
*/
public function preProcess() {
parent::preProcess();
$this->setSelectedChild('settings');
}

/**
Expand Down
8 changes: 8 additions & 0 deletions CRM/Contribute/Form/ContributionPage/ThankYou.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
1 change: 1 addition & 0 deletions CRM/Contribute/Form/ContributionPage/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

}
15 changes: 0 additions & 15 deletions CRM/Event/Form/ManageEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
1 change: 1 addition & 0 deletions CRM/Friend/Form/Contribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CRM_Friend_Form_Contribute extends CRM_Contribute_Form_ContributionPage {

public function preProcess() {
parent::preProcess();
$this->setSelectedChild('friend');
}

/**
Expand Down
26 changes: 12 additions & 14 deletions CRM/Member/Form/MembershipBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/

/**
* form to process actions on Membership
*/
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions CRM/PCP/Form/Contribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CRM_PCP_Form_Contribute extends CRM_Contribute_Form_ContributionPage {

public function preProcess() {
parent::preProcess();
$this->setSelectedChild('pcp');
}

/**
Expand Down