1<?php
2/*
3** Zabbix
4** Copyright (C) 2001-2021 Zabbix SIA
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation; either version 2 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19**/
20
21
22class CControllerHousekeepingEdit extends CController {
23
24	protected function init() {
25		$this->disableSIDValidation();
26	}
27
28	protected function checkInput() {
29		$fields = [
30			'hk_events_mode'			=> 'db config.hk_events_mode',
31			'hk_events_trigger'			=> 'db config.hk_events_trigger',
32			'hk_events_internal'		=> 'db config.hk_events_internal',
33			'hk_events_discovery'		=> 'db config.hk_events_discovery',
34			'hk_events_autoreg'			=> 'db config.hk_events_autoreg',
35			'hk_services_mode'			=> 'db config.hk_services_mode',
36			'hk_services'				=> 'db config.hk_services',
37			'hk_audit_mode'				=> 'db config.hk_audit_mode',
38			'hk_audit'					=> 'db config.hk_audit',
39			'hk_sessions_mode'			=> 'db config.hk_sessions_mode',
40			'hk_sessions'				=> 'db config.hk_sessions',
41			'hk_history_mode'			=> 'db config.hk_history_mode',
42			'hk_history_global'			=> 'db config.hk_history_global',
43			'hk_history'				=> 'db config.hk_history',
44			'hk_trends_mode'			=> 'db config.hk_trends_mode',
45			'hk_trends_global'			=> 'db config.hk_trends_global',
46			'hk_trends'					=> 'db config.hk_trends',
47			'compression_status'		=> 'db config.compression_status',
48			'compress_older'			=> 'db config.compress_older'
49		];
50
51		$ret = $this->validateInput($fields);
52
53		if (!$ret) {
54			$this->setResponse(new CControllerResponseFatal());
55		}
56
57		return $ret;
58	}
59
60	protected function checkPermissions() {
61		return ($this->getUserType() == USER_TYPE_SUPER_ADMIN);
62	}
63
64	protected function doAction() {
65		$config = select_config();
66
67		$data = [
68			'hk_events_mode'			=> $this->getInput('hk_events_mode',			$config['hk_events_mode']),
69			'hk_events_trigger'			=> $this->getInput('hk_events_trigger',			$config['hk_events_trigger']),
70			'hk_events_internal'		=> $this->getInput('hk_events_internal',		$config['hk_events_internal']),
71			'hk_events_discovery'		=> $this->getInput('hk_events_discovery',		$config['hk_events_discovery']),
72			'hk_events_autoreg'			=> $this->getInput('hk_events_autoreg',			$config['hk_events_autoreg']),
73			'hk_services_mode'			=> $this->getInput('hk_services_mode',			$config['hk_services_mode']),
74			'hk_services'				=> $this->getInput('hk_services',				$config['hk_services']),
75			'hk_audit_mode'				=> $this->getInput('hk_audit_mode',				$config['hk_audit_mode']),
76			'hk_audit'					=> $this->getInput('hk_audit',					$config['hk_audit']),
77			'hk_sessions_mode'			=> $this->getInput('hk_sessions_mode',			$config['hk_sessions_mode']),
78			'hk_sessions'				=> $this->getInput('hk_sessions',				$config['hk_sessions']),
79			'hk_history_mode'			=> $this->getInput('hk_history_mode',			$config['hk_history_mode']),
80			'hk_history_global'			=> $this->getInput('hk_history_global',			$config['hk_history_global']),
81			'hk_history'				=> $this->getInput('hk_history',				$config['hk_history']),
82			'hk_trends_mode'			=> $this->getInput('hk_trends_mode',			$config['hk_trends_mode']),
83			'hk_trends_global'			=> $this->getInput('hk_trends_global',			$config['hk_trends_global']),
84			'hk_trends'					=> $this->getInput('hk_trends',					$config['hk_trends']),
85			'compression_status'		=> $this->getInput('compression_status',		$config['compression_status']),
86			'compress_older'			=> $this->getInput('compress_older',			$config['compress_older']),
87			'db_extension'				=> $config['db_extension'],
88			'compression_availability'	=> $config['compression_availability']
89		];
90
91		$response = new CControllerResponseData($data);
92		$response->setTitle(_('Configuration of housekeeping'));
93		$this->setResponse($response);
94	}
95}
96