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