mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Added get event_responses to API
This commit is contained in:
parent
cab90a4fd3
commit
c0afbf0b6f
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
include_once($config['homedir'] . "/include/functions_event_responses.php");
|
||||||
|
|
||||||
check_login ();
|
check_login ();
|
||||||
|
|
||||||
if (! check_acl($config['id_user'], 0, "PM")) {
|
if (! check_acl($config['id_user'], 0, "PM")) {
|
||||||
@ -25,14 +27,7 @@ if (! check_acl($config['id_user'], 0, "PM")) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_user_admin($config['id_user'])) {
|
$event_responses = event_responses_get_responses();
|
||||||
$id_groups = array_keys(users_get_groups(false, "PM"));
|
|
||||||
$event_responses = db_get_all_rows_filter('tevent_response',
|
|
||||||
array('id_group' => $id_groups));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$event_responses = db_get_all_rows_in_table('tevent_response');
|
|
||||||
}
|
|
||||||
|
|
||||||
if(empty($event_responses)) {
|
if(empty($event_responses)) {
|
||||||
ui_print_info_message ( array('no_close'=>true, 'message'=> __('No responses found') ) );
|
ui_print_info_message ( array('no_close'=>true, 'message'=> __('No responses found') ) );
|
||||||
|
@ -31,6 +31,7 @@ include_once($config['homedir'] . "/include/functions_netflow.php");
|
|||||||
include_once($config['homedir'] . "/include/functions_servers.php");
|
include_once($config['homedir'] . "/include/functions_servers.php");
|
||||||
include_once($config['homedir'] . "/include/functions_planned_downtimes.php");
|
include_once($config['homedir'] . "/include/functions_planned_downtimes.php");
|
||||||
include_once($config['homedir'] . "/include/functions_db.php");
|
include_once($config['homedir'] . "/include/functions_db.php");
|
||||||
|
include_once($config['homedir'] . "/include/functions_event_responses.php");
|
||||||
enterprise_include_once ('include/functions_local_components.php');
|
enterprise_include_once ('include/functions_local_components.php');
|
||||||
enterprise_include_once ('include/functions_events.php');
|
enterprise_include_once ('include/functions_events.php');
|
||||||
enterprise_include_once ('include/functions_agents.php');
|
enterprise_include_once ('include/functions_agents.php');
|
||||||
@ -11453,6 +11454,24 @@ function api_get_modules_id_name_by_cluster_name ($cluster_name){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function api_get_event_responses($trash1, $trash2, $trash3, $returnType) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
// Error if user cannot read agents.
|
||||||
|
if (!check_acl($config['id_user'], 0, "PM")) {
|
||||||
|
returnError('forbidden', $returnType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$responses = event_responses_get_responses();
|
||||||
|
if (empty($responses)) {
|
||||||
|
returnError('no_data_to_show', $returnType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
returnData ($returnType, array('type' => 'array', 'data' => $responses));
|
||||||
|
}
|
||||||
|
|
||||||
function api_get_cluster_items ($cluster_id){
|
function api_get_cluster_items ($cluster_id){
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
39
pandora_console/include/functions_event_responses.php
Normal file
39
pandora_console/include/functions_event_responses.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// Pandora FMS - http://pandorafms.com
|
||||||
|
// ==================================================
|
||||||
|
// Copyright (c) 2005-2018 Artica Soluciones Tecnologicas
|
||||||
|
// Please see http://pandorafms.org for full contribution list
|
||||||
|
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License
|
||||||
|
// as published by the Free Software Foundation; version 2
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package Include
|
||||||
|
* @subpackage Event Responses
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all event responses with all values that user can access
|
||||||
|
*
|
||||||
|
* @return array With all table values
|
||||||
|
*/
|
||||||
|
function event_responses_get_responses() {
|
||||||
|
global $config;
|
||||||
|
$filter = array();
|
||||||
|
|
||||||
|
// Apply a filter if user cannot see all groups
|
||||||
|
if (!users_can_manage_group_all()) {
|
||||||
|
$id_groups = array_keys(users_get_groups(false, "PM"));
|
||||||
|
$filter = array('id_group' => $id_groups);
|
||||||
|
}
|
||||||
|
return db_get_all_rows_filter('tevent_response', $filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
x
Reference in New Issue
Block a user