From 048c31e14c9dbc3f1d2d4810d75930fb0879dd39 Mon Sep 17 00:00:00 2001 From: unclecheese Date: Tue, 30 Oct 2012 18:11:16 -0300 Subject: [PATCH] ENHANCEMENT: Force a realistic date range when in search mode --- code/Calendar.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/Calendar.php b/code/Calendar.php index febae84..d67a97d 100755 --- a/code/Calendar.php +++ b/code/Calendar.php @@ -791,19 +791,22 @@ public function parseURL(SS_HTTPRequest $r) { public function Events() { $event_filter = null; $announcement_filter = null; + $endDate = $this->endDate; if($search = $this->getRequest()->getVar('s')) { $s = Convert::raw2sql($search); $event_filter = "\"SiteTree\".Title LIKE '%$s%' OR \"SiteTree\".Content LIKE '%$s%'"; $announcement_filter = "\"CalendarAnnouncement\".Title LIKE '%$s%' OR \"CalendarAnnouncement\".Content LIKE '%$s%'"; $this->SearchQuery = $search; + $endDate = sfDate::getInstance()->addMonth($this->DefaultFutureMonths); } $all = $this->data()->getEventList( $this->startDate->date(), - $this->endDate->date(), + $endDate->date(), $event_filter, null, $announcement_filter - ); + ); + $list = $all->limit($this->EventsPerPage, $this->getOffset()); $next = $this->getOffset()+$this->EventsPerPage; $this->MoreEvents = ($next < $all->count());