1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Icinga\Module\TrapDirector\Controllers; |
4
|
|
|
|
5
|
|
|
use Icinga\Module\Trapdirector\TrapsController; |
6
|
|
|
use Icinga\Module\Trapdirector\Rest\RestAPI as RestAPI; |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
*/ |
11
|
|
|
class ApiController extends TrapsController |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
private $json_options=JSON_PRETTY_PRINT; |
15
|
|
|
|
16
|
|
|
protected function send_json($object) |
17
|
|
|
{ |
18
|
|
|
if (isset($object['Error'])) |
19
|
|
|
{ |
20
|
|
|
$this->send_json_error($object); |
21
|
|
|
return; |
22
|
|
|
} |
23
|
|
|
$this->_helper->layout()->disableLayout(); |
24
|
|
|
$this->getResponse()->setHeader('Content-Type', 'application/json', true); |
25
|
|
|
$this->getResponse()->sendHeaders(); |
26
|
|
|
echo json_encode($object, $this->json_options) . "\n"; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
protected function send_json_error($object) |
30
|
|
|
{ |
31
|
|
|
$this->_helper->layout()->disableLayout(); |
32
|
|
|
$this->getResponse()->setHeader('Content-Type', 'application/json', true); |
33
|
|
|
$this->getResponse()->sendHeaders(); |
34
|
|
|
echo json_encode($object, $this->json_options) . "\n"; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function indexAction() |
38
|
|
|
{ |
39
|
|
|
$this->checkReadPermission(); |
40
|
|
|
$apiObj= new RestAPI($this); |
41
|
|
|
|
42
|
|
|
$modif = $apiObj->last_modified(); |
43
|
|
|
$this->send_json($modif); |
44
|
|
|
//print_r($modif); |
45
|
|
|
return; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function dboptionActions() |
49
|
|
|
{ |
50
|
|
|
$this->checkReadPermission(); |
51
|
|
|
$apiObj= new RestAPI($this); |
|
|
|
|
52
|
|
|
|
53
|
|
|
$params = $this->getRequest()->getParams(); |
54
|
|
|
if (isset($params['name'])) |
55
|
|
|
{ |
56
|
|
|
|
57
|
|
|
} |
58
|
|
|
else |
59
|
|
|
{ |
60
|
|
|
|
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
} |