From: eileen Date: Thu, 1 Nov 2018 21:55:17 +0000 (+1300) Subject: Replace event form with a generic replacement form X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f167c7a9f5b5d146eca4cefd8aab89dc4f995a9a;p=civicrm-core.git Replace event form with a generic replacement form --- diff --git a/CRM/Admin/Form/Generic.php b/CRM/Admin/Form/Generic.php new file mode 100644 index 0000000000..c61e223c2b --- /dev/null +++ b/CRM/Admin/Form/Generic.php @@ -0,0 +1,112 @@ +setDefaultsForMetadataDefinedFields(); + return $this->_defaults; + } + /** + * Build the form object. + */ + public function buildQuickForm() { + $filter = array_pop($this->urlPath); + $settings = civicrm_api3('Setting', 'getfields', [])['values']; + foreach ($settings as $key => $setting) { + if (isset($setting['settings_pages'][$filter])) { + $this->_settings[$key] = $setting; + } + } + // @todo sort settings by weight. + $this->addFieldsDefinedInSettingsMetadata(); + + // @todo look at sharing the code below in the settings trait. + if ($this->includesReadOnlyFields) { + CRM_Core_Session::setStatus(ts("Some fields are loaded as 'readonly' as they have been set (overridden) in civicrm.settings.php."), '', 'info', array('expires' => 0)); + } + + // @todo - do we still like this redirect? + CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); + $this->addButtons(array( + array( + 'type' => 'next', + 'name' => ts('Save'), + 'isDefault' => TRUE, + ), + array( + 'type' => 'cancel', + 'name' => ts('Cancel'), + ), + ) + ); + } + + /** + * Process the form submission. + */ + public function postProcess() { + $params = $this->controller->exportValues($this->_name); + try { + $this->saveMetadataDefinedSettings($params); + } + catch (CiviCRM_API3_Exception $e) { + CRM_Core_Session::setStatus($e->getMessage(), ts('Save Failed'), 'error'); + } + } + +} diff --git a/CRM/Admin/Form/Preferences/Event.php b/CRM/Admin/Form/Preferences/Event.php deleted file mode 100644 index b6d6d2c68c..0000000000 --- a/CRM/Admin/Form/Preferences/Event.php +++ /dev/null @@ -1,45 +0,0 @@ - CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, - 'show_events' => CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, - ]; - -} diff --git a/CRM/Core/xml/Menu/Admin.xml b/CRM/Core/xml/Menu/Admin.xml index 38377d0850..918d372cae 100644 --- a/CRM/Core/xml/Menu/Admin.xml +++ b/CRM/Core/xml/Menu/Admin.xml @@ -563,7 +563,7 @@ civicrm/admin/setting/preferences/event CiviEvent Component Settings - CRM_Admin_Form_Preferences_Event + CRM_Admin_Form_Generic civicrm/admin/setting/preferences/mailing diff --git a/CRM/Event/xml/Menu/Event.xml b/CRM/Event/xml/Menu/Event.xml index f9d1d464ef..7cc9a3ba68 100644 --- a/CRM/Event/xml/Menu/Event.xml +++ b/CRM/Event/xml/Menu/Event.xml @@ -138,7 +138,7 @@ civicrm/admin/setting/preferences/event CiviEvent Component Settings - CRM_Admin_Form_Preferences_Event + CRM_Admin_Form_Generic Configure global CiviEvent behaviors. access CiviEvent,administer CiviCRM CiviEvent diff --git a/settings/Event.setting.php b/settings/Event.setting.php index e9ce8749f4..29413fdfb1 100644 --- a/settings/Event.setting.php +++ b/settings/Event.setting.php @@ -38,6 +38,7 @@ return array( 'enable_cart' => array( 'name' => 'enable_cart', 'group_name' => 'Event Preferences', + 'settings_pages' => ['event' => ['weight' => 10]], 'group' => 'event', 'type' => 'Boolean', 'quick_form_type' => 'CheckBox', @@ -54,6 +55,7 @@ return array( 'name' => 'show_events', 'group_name' => 'Event Preferences', 'group' => 'event', + 'settings_pages' => ['event' => ['weight' => 20]], 'type' => 'Integer', 'quick_form_type' => 'Select', 'default' => 10, diff --git a/templates/CRM/Admin/Form/Preferences/Event.tpl b/templates/CRM/Admin/Form/Preferences/Event.tpl deleted file mode 100644 index 9baa42d3f2..0000000000 --- a/templates/CRM/Admin/Form/Preferences/Event.tpl +++ /dev/null @@ -1,26 +0,0 @@ -{* - +--------------------------------------------------------------------+ - | CiviCRM version 5 | - +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | - +--------------------------------------------------------------------+ - | This file is a part of CiviCRM. | - | | - | CiviCRM is free software; you can copy, modify, and distribute it | - | under the terms of the GNU Affero General Public License | - | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | - | | - | CiviCRM is distributed in the hope that it will be useful, but | - | WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | - | See the GNU Affero General Public License for more details. | - | | - | You should have received a copy of the GNU Affero General Public | - | License and the CiviCRM Licensing Exception along | - | with this program; if not, contact CiviCRM LLC | - | at info[AT]civicrm[DOT]org. If you have questions about the | - | GNU Affero General Public License or the licensing of CiviCRM, | - | see the CiviCRM license FAQ at http://civicrm.org/licensing | - +--------------------------------------------------------------------+ -*} -{include file="CRM/Form/basicForm.tpl"}