pandorafms/pandora_console/include/functions_event_responses.php

89 lines
2.2 KiB
PHP
Raw Normal View History

2018-10-25 11:49:39 +02:00
<?php
2023-06-08 13:19:01 +02:00
// Pandora FMS - https://pandorafms.com
2018-10-25 11:49:39 +02:00
// ==================================================
2023-06-08 11:53:13 +02:00
// Copyright (c) 2005-2023 Pandora FMS
2023-06-08 13:19:01 +02:00
// Please see https://pandorafms.com/community/ for full contribution list
2018-10-25 11:49:39 +02:00
// 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
2018-10-25 11:49:39 +02:00
* @subpackage Event Responses
*/
2018-10-25 11:49:39 +02:00
/**
* 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 = [];
2018-10-25 11:49:39 +02:00
// 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 = ['id_group' => $id_groups];
}
return db_get_all_rows_filter('tevent_response', $filter);
2018-10-25 11:49:39 +02:00
}
2018-10-25 15:03:07 +02:00
/**
* Validate the responses data to store in database
*
* @param array (by reference) Array with values to validate and modify
*/
function event_responses_validate_data(&$values)
{
if ($values['type'] != 'command' || !enterprise_installed()) {
$values['server_to_exec'] = 0;
}
if ($values['new_window'] == 1) {
$values['modal_width'] = 0;
$values['modal_height'] = 0;
}
2018-10-25 15:03:07 +02:00
}
2018-10-25 15:03:07 +02:00
/**
* Create an event response
*
* @param array With all event response data
*
* @return True if successful insertion
*/
function event_responses_create_response($values)
{
event_responses_validate_data($values);
return db_process_sql_insert('tevent_response', $values);
2018-10-25 15:03:07 +02:00
}
2018-10-25 15:25:27 +02:00
/**
* Update an event response
*
* @param array With all event response data
*
* @return True if successful insertion
*/
function event_responses_update_response($response_id, $values)
{
event_responses_validate_data($values);
return db_process_sql_update(
'tevent_response',
$values,
['id' => $response_id]
);
2018-10-25 15:25:27 +02:00
}