diff --git a/web/api/app/Controller/EventsController.php b/web/api/app/Controller/EventsController.php index 9cf18a004..de1e9eff0 100644 --- a/web/api/app/Controller/EventsController.php +++ b/web/api/app/Controller/EventsController.php @@ -110,6 +110,31 @@ class EventsController extends AppController { } } + public function search() { + $this->Event->recursive = -1; + $conditions = array(); + + foreach ($this->params['named'] as $param_name => $value) { + // Transform params into mysql + if (preg_match("/interval/i", $value, $matches)) { + $condition = array("$param_name >= (date_sub(now(), $value))"); + } else { + $condition = array($param_name => $value); + } + array_push($conditions, $condition); + } + + $results = $this->Event->find('all', array( + 'conditions' => $conditions + )); + + $this->set(array( + 'results' => $results, + '_serialize' => array('results') + )); + + + } public function consoleEvents($interval = null) { $this->Event->recursive = -1;