diff --git a/web/app/Controller/AppController.php b/web/app/Controller/AppController.php index 60066e2ee..584c206d2 100644 --- a/web/app/Controller/AppController.php +++ b/web/app/Controller/AppController.php @@ -45,12 +45,7 @@ class AppController extends Controller { parent::beforeFilter(); $this->loadModel('Config'); $this->loadModel('AppModel'); - $this->Cookie->name = 'ZoneMinder'; - if (!$this->Cookie->read('zmBandwidth')) { - $this->Cookie->write('zmBandwidth', 'low', false); - } - $this->set('zmBandwidth', $this->Cookie->read('zmBandwidth')); - + $this->Cookie->name = 'ZoneMinder'; $configFile = "/usr/local/etc/zm.conf"; $lines = file($configFile); @@ -84,6 +79,14 @@ class AppController extends Controller { $this->set('zmVersion', $zmVersion); } + public function beforeRender() { + parent::beforeRender(); + if (!$this->Cookie->read('zmBandwidth')) { + $this->Cookie->write('zmBandwidth', 'low', false); + } + $this->set('zmBandwidth', $this->Cookie->read('zmBandwidth')); + } + function extractNamedParams($mandatory, $optional = array()) { $params = $this->params['named']; diff --git a/web/app/Controller/BandwidthController.php b/web/app/Controller/BandwidthController.php index 8d580cf85..5dc6fa694 100644 --- a/web/app/Controller/BandwidthController.php +++ b/web/app/Controller/BandwidthController.php @@ -2,17 +2,18 @@ class BandwidthController extends AppController { public function index() { - $this->set('bandwidth', $this->Cookie->read('zmBandwidth')); - if (!empty($this->request->data)) { $bandwidth = $this->request->data['Bandwidth']['Bandwidth']; $this->Cookie->write('zmBandwidth', $bandwidth, false); - if ($this->Cookie->read('zmBandwidth') == $bandwidth) { + $this->set('bandwidth', $bandwidth); + if ($this->Cookie->read('zmBandwidth') == $bandwidth) { $this->Session->setFlash('Successfully updated bandwidth'); } else { $this->Session->setFlash('Failed to update bandwidth'); } - } + } else { + $this->set('bandwidth', $this->Cookie->read('zmBandwidth')); + } } } diff --git a/web/app/Controller/EventsController.php b/web/app/Controller/EventsController.php index 80185face..50fb864ea 100644 --- a/web/app/Controller/EventsController.php +++ b/web/app/Controller/EventsController.php @@ -69,7 +69,13 @@ public function index() { return $this->redirect(array('action' => 'index')); } } - + + public function deleteSelected() { + foreach($this->data['Events'] as $key => $value) { + $this->Event->delete($value); + } + $this->redirect($this->referer()); + } } ?> diff --git a/web/app/Controller/MonitorsController.php b/web/app/Controller/MonitorsController.php index 9e7fa9221..06c659d0d 100644 --- a/web/app/Controller/MonitorsController.php +++ b/web/app/Controller/MonitorsController.php @@ -5,7 +5,7 @@ public function index() { $zmBandwidth = $this->Cookie->read('zmBandwidth'); $this->set('width', Configure::read('ZM_WEB_LIST_THUMB_WIDTH')); - $monitoroptions = array('fields' => array('Name', 'Id', 'Function', 'Enabled', 'Sequence'), 'order' => 'Sequence ASC', 'recursive' => -1); + $monitoroptions = array('fields' => array('Name', 'Id', 'Function', 'Enabled', 'Sequence', 'Function'), 'order' => 'Sequence ASC', 'recursive' => -1); $this->set('monitors', $this->Monitor->find('all', $monitoroptions)); $monitors = $this->Monitor->find('all', array('recursive' => -1, 'fields' => array('Id', 'StreamReplayBuffer'))); foreach ($monitors as $monitor => $mon) { diff --git a/web/app/View/Events/index.ctp b/web/app/View/Events/index.ctp index 146e3502c..370748739 100644 --- a/web/app/View/Events/index.ctp +++ b/web/app/View/Events/index.ctp @@ -52,7 +52,8 @@ echo $this->Form->inputs(array( ?> -Form->end(array('label' => 'Search', 'id' => 'EventsButtonSearch')); ?> +Form->end(array('label' => 'Search', 'id' => 'EventsButtonSearch', 'class' => 'btn btn-default')); ?> +Html->link('Delete Selected','#',array('class' => 'btn btn-default', 'onClick' => '$("#EventsDeleteSelectedForm").submit();')); ?> end(); ?> @@ -61,13 +62,21 @@ echo $this->Form->inputs(array( Paginator->numbers(array('tag' => 'li', 'separator' => false, 'currentClass' => 'active', 'currentTag' => 'span')); ?> +Form->create('Events', array('action' => 'deleteSelected')); +?> + Html->tableHeaders(array( 'Thumbnail', 'Id', 'Name', 'Monitor', 'Cause', 'Time', 'Duration', 'Alarm Frames', 'Total Score', 'Avg. Score', 'Max Score', '' )); + echo $this->Html->tableHeaders(array('', 'Thumbnail', 'Id', 'Name', 'Monitor', 'Cause', 'Time', 'Duration', 'Alarm Frames', 'Total Score', 'Avg. Score', 'Max Score')); foreach ($events as $key => $value) { echo $this->Html->tableCells(array( - $this->Html->link($this->Html->image('/events/'.$thumbData[$key]['Path'], array( + $this->Form->checkbox('delete.', array( + 'value' => $value['Event']['Id'], + 'hiddenField' => false + )), + $this->Html->link($this->Html->image('/events/'.$thumbData[$key]['Path'], array( 'alt' => $thumbData[$key]['Frame']['FrameId'].'/'.$thumbData[$key]['Event']['MaxScore'], 'width' => $thumbData[$key]['Width'], 'height' => $thumbData[$key]['Height'] @@ -82,16 +91,16 @@ foreach ($events as $key => $value) { $value['Event']['AlarmFrames'], $value['Event']['TotScore'], $value['Event']['AvgScore'], - $value['Event']['MaxScore'], - $this->Form->postLink( - 'Delete', - array('action' => 'delete', $value['Event']['Id']), - array('confirm' => 'Are you sure?')) + $value['Event']['MaxScore'] )); } ?>
+Form->end(); +?> + + \ No newline at end of file