| Conditions | 3 |
| Paths | 3 |
| Total Lines | 25 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | public function update() |
||
| 28 | { |
||
| 29 | //security checks |
||
| 30 | $this->onlyAdmin(); |
||
| 31 | $this->onlyPost(); |
||
| 32 | //preparing our return results |
||
| 33 | $result = array(); |
||
| 34 | $result['successId'] = []; |
||
| 35 | $result['errorId'] = []; |
||
| 36 | $result['success'] = true; |
||
| 37 | $configUpdateJson = $this->container->getRequest()->getData('config-update'); |
||
| 38 | $configUpdate = json_decode($configUpdateJson); |
||
| 39 | |||
| 40 | foreach ($configUpdate as $update) { |
||
| 41 | |||
| 42 | |||
| 43 | if (!$this->configModel->updateConfig($update->name, $update->value)) { |
||
| 44 | $result['success'] = false; |
||
| 45 | $result['errorId'][] = $update->name; |
||
| 46 | } else { |
||
| 47 | $result['successId'][] = $update->name; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | echo json_encode($result); |
||
| 52 | } |
||
| 53 | } |