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