From f5e8cb7b954148734311c8bde119522771f86f13 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 29 Oct 2018 20:37:04 +1300 Subject: [PATCH] Fix event preferences form --- CRM/Admin/Form/Preferences/Event.php | 37 ++++------------------------ CRM/Core/SelectValues.php | 15 +++++++++++ settings/Event.setting.php | 21 ++++++++-------- 3 files changed, 31 insertions(+), 42 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Event.php b/CRM/Admin/Form/Preferences/Event.php index 67009eacf9..b6d6d2c68c 100644 --- a/CRM/Admin/Form/Preferences/Event.php +++ b/CRM/Admin/Form/Preferences/Event.php @@ -29,44 +29,17 @@ * * @package CRM * @copyright CiviCRM LLC (c) 2004-2018 - * $Id: Display.php 36505 2011-10-03 14:19:56Z lobo $ - * */ /** - * This class generates form components for the display preferences + * This class generates the form for event preferences. * */ class CRM_Admin_Form_Preferences_Event extends CRM_Admin_Form_Preferences { - public function preProcess() { - CRM_Utils_System::setTitle(ts('CiviEvent Component Settings')); - // pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org - $docLink = CRM_Utils_System::docURL2("CiviEvent Cart Checkout", NULL, NULL, NULL, NULL, "wiki"); - // build an array containing all selectable option values for show_events - $optionValues = array(); - for ($i = 10; $i <= 100; $i += 10) { - $optionValues[$i] = $i; - } - $this->_varNames = array( - CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => array( - 'enable_cart' => array( - 'html_type' => 'checkbox', - 'title' => ts('Use Shopping Cart Style Event Registration'), - 'weight' => 1, - 'description' => ts('This feature allows users to register for more than one event at a time. When enabled, users will add event(s) to a "cart" and then pay for them all at once. Enabling this setting will affect online registration for all active events. The code is an alpha state, and you will potentially need to have developer resources to debug and fix sections of the codebase while testing and deploying it. %1', - array(1 => $docLink)), - ), - 'show_events' => array( - 'html_type' => 'select', - 'title' => ts('Dashboard entries'), - 'weight' => 2, - 'description' => ts('Configure how many events should be shown on the dashboard. This overrides the default value of 10 entries.'), - 'option_values' => array('' => ts('- select -')) + $optionValues + array(-1 => ts('show all')), - ), - ), - ); - parent::preProcess(); - } + protected $_settings = [ + 'enable_cart' => CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, + 'show_events' => CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, + ]; } diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index 3d429fa36e..c34c51619a 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -1109,4 +1109,19 @@ class CRM_Core_SelectValues { ); } + /** + * Get option values for dashboard entries (used for 'how many events to display on dashboard'). + * + * @return array + * Dashboard entries options - in practice [-1 => 'Show All', 10 => 10, 20 => 20, ... 100 => 100]. + */ + public static function getDashboardEntriesCount() { + $optionValues = []; + $optionValues[-1] = ts('show all'); + for ($i = 10; $i <= 100; $i += 10) { + $optionValues[$i] = $i; + } + return $optionValues; + } + } diff --git a/settings/Event.setting.php b/settings/Event.setting.php index 9c8312073e..70d0ddb767 100644 --- a/settings/Event.setting.php +++ b/settings/Event.setting.php @@ -29,10 +29,9 @@ * * @package CRM * @copyright CiviCRM LLC (c) 2004-2017 - * $Id$ - * */ -/* + +/** * Settings metadata file */ return array( @@ -41,28 +40,30 @@ return array( 'group_name' => 'Event Preferences', 'group' => 'event', 'type' => 'Boolean', - 'quick_form_type' => 'Element', + 'quick_form_type' => 'CheckBox', 'default' => '0', 'add' => '4.1', - 'title' => 'Enable Event Cart', + 'title' => ts('Use Shopping Cart Style Event Registration'), 'is_domain' => 1, 'is_contact' => 0, - 'description' => "WRITE ME", - 'help_text' => 'WRITE ME', + 'description' => ts('This feature allows users to register for more than one event at a time. When enabled, users will add event(s) to a "cart" and then pay for them all at once. Enabling this setting will affect online registration for all active events. The code is an alpha state, and you will potentially need to have developer resources to debug and fix sections of the codebase while testing and deploying it'), + 'help_text' => '', + 'help_link' => ['page' => 'CiviEvent Cart Checkout', 'resource' => 'wiki'], ), 'show_events' => array( 'name' => 'show_events', 'group_name' => 'Event Preferences', 'group' => 'event', 'type' => 'Integer', - 'quick_form_type' => 'Element', + 'quick_form_type' => 'Select', 'default' => 10, 'add' => '4.5', - 'title' => 'Dashboard entries', + 'title' => ts('Dashboard entries'), 'html_type' => 'select', 'is_domain' => 1, 'is_contact' => 0, - 'description' => "Configure how many events should be shown on the dashboard. This overrides the default value of 10 entries.", + 'description' => ts('Configure how many events should be shown on the dashboard. This overrides the default value of 10 entries.'), 'help_text' => NULL, + 'pseudoconstant' => ['callback' => 'CRM_Core_SelectValues::getDashboardEntriesCount'], ), ); -- 2.25.1