Added set create_event_response to API
This commit is contained in:
parent
c0afbf0b6f
commit
6b93cba119
|
@ -40,24 +40,9 @@ switch($action) {
|
||||||
$values['modal_height'] = get_parameter('modal_height');
|
$values['modal_height'] = get_parameter('modal_height');
|
||||||
$values['new_window'] = get_parameter('new_window');
|
$values['new_window'] = get_parameter('new_window');
|
||||||
$values['params'] = get_parameter('params');
|
$values['params'] = get_parameter('params');
|
||||||
if (enterprise_installed()) {
|
|
||||||
if ($values['type'] == 'command') {
|
|
||||||
$values['server_to_exec'] = get_parameter('server_to_exec');
|
$values['server_to_exec'] = get_parameter('server_to_exec');
|
||||||
}
|
|
||||||
else {
|
|
||||||
$values['server_to_exec'] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$values['server_to_exec'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($values['new_window'] == 1) {
|
$result = event_responses_create_responses($values);
|
||||||
$values['modal_width'] = 0;
|
|
||||||
$values['modal_height'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = db_process_sql_insert('tevent_response', $values);
|
|
||||||
|
|
||||||
if($result) {
|
if($result) {
|
||||||
ui_print_success_message(__('Response added succesfully'));
|
ui_print_success_message(__('Response added succesfully'));
|
||||||
|
|
|
@ -11457,7 +11457,7 @@ function api_get_modules_id_name_by_cluster_name ($cluster_name){
|
||||||
function api_get_event_responses($trash1, $trash2, $trash3, $returnType) {
|
function api_get_event_responses($trash1, $trash2, $trash3, $returnType) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// Error if user cannot read agents.
|
// Error if user cannot read event responses.
|
||||||
if (!check_acl($config['id_user'], 0, "PM")) {
|
if (!check_acl($config['id_user'], 0, "PM")) {
|
||||||
returnError('forbidden', $returnType);
|
returnError('forbidden', $returnType);
|
||||||
return;
|
return;
|
||||||
|
@ -11472,6 +11472,38 @@ function api_get_event_responses($trash1, $trash2, $trash3, $returnType) {
|
||||||
returnData ($returnType, array('type' => 'array', 'data' => $responses));
|
returnData ($returnType, array('type' => 'array', 'data' => $responses));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function api_set_create_event_response($trash1, $trash2, $other, $returnType) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
// Error if user cannot read event responses.
|
||||||
|
if (!check_acl($config['id_user'], 0, "PM")) {
|
||||||
|
returnError('forbidden', $returnType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$values = array();
|
||||||
|
$values['name'] = $other['data'][0];
|
||||||
|
$values['description'] = $other['data'][1];
|
||||||
|
$values['target'] = $other['data'][2];
|
||||||
|
$values['type'] = $other['data'][3];
|
||||||
|
$values['id_group'] = $other['data'][4];
|
||||||
|
$values['modal_width'] = $other['data'][5];
|
||||||
|
$values['modal_height'] = $other['data'][6];
|
||||||
|
$values['new_window'] = $other['data'][7];
|
||||||
|
$values['params'] = $other['data'][8];
|
||||||
|
$values['server_to_exec'] = $other['data'][9];
|
||||||
|
|
||||||
|
// Error if user has not permission for the group.
|
||||||
|
if (!check_acl($config['id_user'], $values['id_group'], "PM")) {
|
||||||
|
returnError('forbidden', $returnType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$return = event_responses_create_responses($values) ? 1 : 0;
|
||||||
|
|
||||||
|
returnData ($returnType, array('type' => 'string', 'data' => $return));
|
||||||
|
}
|
||||||
|
|
||||||
function api_get_cluster_items ($cluster_id){
|
function api_get_cluster_items ($cluster_id){
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
|
|
@ -36,4 +36,31 @@ function event_responses_get_responses() {
|
||||||
return db_get_all_rows_filter('tevent_response', $filter);
|
return db_get_all_rows_filter('tevent_response', $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an event response
|
||||||
|
*
|
||||||
|
* @param array With all event response data
|
||||||
|
*
|
||||||
|
* @return True if successful insertion
|
||||||
|
*/
|
||||||
|
function event_responses_create_responses($values) {
|
||||||
|
event_responses_validate_data($values);
|
||||||
|
return db_process_sql_insert('tevent_response', $values);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue