Added get event_responses to API

This commit is contained in:
fermin831 2018-10-25 11:49:39 +02:00
parent cab90a4fd3
commit c0afbf0b6f
3 changed files with 61 additions and 8 deletions

View File

@ -16,6 +16,8 @@
global $config;
include_once($config['homedir'] . "/include/functions_event_responses.php");
check_login ();
if (! check_acl($config['id_user'], 0, "PM")) {
@ -25,14 +27,7 @@ if (! check_acl($config['id_user'], 0, "PM")) {
return;
}
if (!is_user_admin($config['id_user'])) {
$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');
}
$event_responses = event_responses_get_responses();
if(empty($event_responses)) {
ui_print_info_message ( array('no_close'=>true, 'message'=> __('No responses found') ) );

View File

@ -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_planned_downtimes.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_events.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){
global $config;

View 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);
}
?>