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')); + } } }