From b8ce33285d994a17a6563177663154d8dd6ec3d0 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Mon, 26 May 2014 19:38:37 +0530 Subject: [PATCH] CRM-14739 --- CRM/Admin/Form/Preferences.php | 8 ++++++++ CRM/Admin/Form/Preferences/Event.php | 12 ++++++++++++ CRM/Event/BAO/Event.php | 17 ++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/CRM/Admin/Form/Preferences.php b/CRM/Admin/Form/Preferences.php index 6010d59015..d1f7b25219 100644 --- a/CRM/Admin/Form/Preferences.php +++ b/CRM/Admin/Form/Preferences.php @@ -195,6 +195,14 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { ); break; + case 'select': + $this->addElement('select', + $fieldName, + $fieldValue['title'], + $fieldValue['option_values'] + ); + break; + case 'entity_reference': $this->addEntityRef($fieldName, $fieldValue['title'], CRM_Utils_Array::value('options', $fieldValue, array())); } diff --git a/CRM/Admin/Form/Preferences/Event.php b/CRM/Admin/Form/Preferences/Event.php index fd218211c2..f5e36d43b2 100644 --- a/CRM/Admin/Form/Preferences/Event.php +++ b/CRM/Admin/Form/Preferences/Event.php @@ -42,6 +42,11 @@ class CRM_Admin_Form_Preferences_Event extends CRM_Admin_Form_Preferences { 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( @@ -52,6 +57,13 @@ class CRM_Admin_Form_Preferences_Event extends CRM_Admin_Form_Preferences { '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')) + ) ), ); diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 64174b804a..55a667d900 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -379,6 +379,21 @@ WHERE civicrm_event.is_active = 1 AND if ($optionGroupDAO->find(TRUE)) { $optionGroupId = $optionGroupDAO->id; } + // Get the event summary display preferences + $show_max_events = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, + 'show_events' + ); + // default to 10 if no option is set + if (is_null($show_max_events)) { + $show_max_events = 10; + } + // show all events if show_events is set to a negative value + if ($show_max_events >= 0) { + $event_summary_limit = "LIMIT 0, $show_max_events"; + } + else { + $event_summary_limit = ""; + } $query = " SELECT civicrm_event.id as id, civicrm_event.title as event_title, civicrm_event.is_public as is_public, @@ -399,7 +414,7 @@ WHERE civicrm_event.is_active = 1 AND $validEventIDs GROUP BY civicrm_event.id ORDER BY civicrm_event.start_date ASC -LIMIT 0, 10 +$event_summary_limit "; $eventParticipant = array(); -- 2.25.1