Skip to content

Commit

Permalink
ENHANCEMENT: Force a realistic date range when in search mode
Browse files Browse the repository at this point in the history
  • Loading branch information
unclecheese committed Oct 30, 2012
1 parent eeaf856 commit 048c31e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions code/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 048c31e

Please sign in to comment.