| Conditions | 5 |
| Paths | 12 |
| Total Lines | 23 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public function updateConfig() |
||
| 21 | { |
||
| 22 | $this->onlyAdmin(); |
||
| 23 | if (!$this->container->getRequest()->isPost()) { |
||
| 24 | $this->alertBox->setAlert('Only post messages allowed', 'error'); |
||
| 25 | $this->container->getResponse()->redirect('admin'); |
||
| 26 | } |
||
| 27 | $configModel = new ConfigModel($this->container); |
||
| 28 | $posts = $this->container->getRequest()->getDataFull(); |
||
| 29 | |||
| 30 | $success = true; |
||
| 31 | foreach ($posts as $key => $config) { |
||
| 32 | $configId = $this->removeFromBeginning($key, 'config-'); |
||
| 33 | if (!$configModel->updateConfig($configId, $config)) { |
||
| 34 | $success = false; |
||
| 35 | } |
||
| 36 | } |
||
| 37 | if ($success) { |
||
| 38 | $this->alertBox->setAlert('Configuration updates successfully'); |
||
| 39 | } else { |
||
| 40 | $this->alertBox->setAlert('error in configuration update', 'error'); |
||
| 41 | } |
||
| 42 | $this->container->getResponse()->redirect('admin/config'); |
||
| 43 | } |
||
| 44 | } |