2013-05-01 19:02:12 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class EventsController extends AppController {
|
2013-05-03 19:34:45 +08:00
|
|
|
public $helpers = array('Paginator');
|
2013-05-01 19:02:12 +08:00
|
|
|
public $components = array('Paginator');
|
|
|
|
|
2013-05-16 05:42:42 +08:00
|
|
|
$this->loadModel('Monitor');
|
|
|
|
$this->loadModel('Config');
|
2013-05-01 19:02:12 +08:00
|
|
|
|
2013-05-16 05:46:11 +08:00
|
|
|
$events_per_page = $this->Config->find('first', array('conditions' => array('Name' => 'ZM_WEB_EVENTS_PER_PAGE'), 'fields' => 'Value'));
|
2013-05-01 19:02:12 +08:00
|
|
|
|
|
|
|
public function index() {
|
2013-05-16 05:46:11 +08:00
|
|
|
$this->paginate = array(
|
|
|
|
'fields' => array('Event.Name', 'Event.Length', 'Event.MonitorId', 'Event.Id', 'Monitor.Name'),
|
|
|
|
'limit' => $events_per_page['Config']['Value'],
|
|
|
|
'order' => array( 'Event.Id' => 'asc')
|
|
|
|
);
|
2013-05-01 19:02:12 +08:00
|
|
|
$data = $this->paginate('Event');
|
|
|
|
$this->set('events', $data);
|
2013-05-06 20:40:25 +08:00
|
|
|
$options = array('fields' => array('DISTINCT Monitor.Id'));
|
|
|
|
$this->set('monitors', $this->Event->Monitor->Find('all', $options));
|
2013-05-01 19:02:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function view($id = null) {
|
|
|
|
if (!$id) {
|
|
|
|
throw new NotFoundException(__('Invalid event'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$event = $this->Event->findById($id);
|
|
|
|
if (!$event) {
|
|
|
|
throw new NotFoundException(__('Invalid event'));
|
|
|
|
}
|
|
|
|
$this->set('event', $event);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|