Total Complexity | 3 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class postModification extends AjaxController |
||
10 | { |
||
11 | |||
12 | |||
13 | private $postModule; |
||
14 | |||
15 | public function __construct(Container $container) |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * Ajax call to update the published state of a post |
||
23 | * @throws \Core\JsonException |
||
24 | */ |
||
25 | public function modifyPublished() |
||
26 | { |
||
27 | $this->onlyAdmin(); |
||
28 | $this->onlyPost(); |
||
29 | $state = (bool)($this->request->getData("state") === 'true'); |
||
30 | $postId = (int)$this->request->getData("postId"); |
||
31 | |||
32 | $result = array(); |
||
33 | $result["success"] = $this->postModule->setPublished(!$state, $postId); |
||
34 | $result["state"] = !$state; |
||
35 | $result["postId"] = $postId; |
||
36 | echo json_encode($result); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Ajax call to update the on front page state of a post |
||
41 | * @throws \Core\JsonException |
||
42 | */ |
||
43 | public function modifyOnFrontPage() |
||
55 | } |
||
56 | } |