Added documentation and minor fixes related with API event responses functions

This commit is contained in:
fermin831 2018-10-25 15:42:45 +02:00
parent 8cc68185d9
commit f831e59ac3
3 changed files with 40 additions and 8 deletions

View File

@ -42,7 +42,7 @@ switch($action) {
$values['params'] = get_parameter('params'); $values['params'] = get_parameter('params');
$values['server_to_exec'] = get_parameter('server_to_exec'); $values['server_to_exec'] = get_parameter('server_to_exec');
$result = event_responses_create_responses($values); $result = event_responses_create_response($values);
if($result) { if($result) {
ui_print_success_message(__('Response added succesfully')); ui_print_success_message(__('Response added succesfully'));
@ -66,7 +66,7 @@ switch($action) {
$values['server_to_exec'] = get_parameter('server_to_exec'); $values['server_to_exec'] = get_parameter('server_to_exec');
$response_id = get_parameter('id_response',0); $response_id = get_parameter('id_response',0);
$result = event_responses_update_responses($response_id, $values); $result = event_responses_update_response($response_id, $values);
if($result) { if($result) {
ui_print_success_message(__('Response updated succesfully')); ui_print_success_message(__('Response updated succesfully'));

View File

@ -11454,6 +11454,14 @@ function api_get_modules_id_name_by_cluster_name ($cluster_name){
} }
/**
* @param $trash1
* @param $trash2
* @param mixed $trash3
* @param $returnType
* Example:
* api.php?op=get&op2=event_responses&return_type=csv&apipass=1234&user=admin&pass=pandora
*/
function api_get_event_responses($trash1, $trash2, $trash3, $returnType) { function api_get_event_responses($trash1, $trash2, $trash3, $returnType) {
global $config; global $config;
@ -11472,7 +11480,15 @@ 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_delete_event_response($id_response, $trash2, $trash3, $returnType) { /**
* @param $id_response
* @param $trash2
* @param mixed $trash3
* @param $returnType
* Example:
* api.php?op=set&op2=delete_event_response&id=7&apipass=1234&user=admin&pass=pandora
*/
function api_set_delete_event_response($id_response, $trash1, $trash2, $returnType) {
global $config; global $config;
// Error if user cannot read event responses. // Error if user cannot read event responses.
@ -11498,6 +11514,14 @@ function api_set_delete_event_response($id_response, $trash2, $trash3, $returnTy
returnData ($returnType, array('type' => 'string', 'data' => $result)); returnData ($returnType, array('type' => 'string', 'data' => $result));
} }
/**
* @param $trash1
* @param $trash2
* @param mixed $other. Serialized params
* @param $returnType
* Example:
* api.php?op=set&op2=create_event_response&other=response%7Cdescription%20response%7Ctouch%7Ccommand%7C0%7C650%7C400%7C0%7Cresponse%7C0&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
*/
function api_set_create_event_response($trash1, $trash2, $other, $returnType) { function api_set_create_event_response($trash1, $trash2, $other, $returnType) {
global $config; global $config;
@ -11525,12 +11549,20 @@ function api_set_create_event_response($trash1, $trash2, $other, $returnType) {
return; return;
} }
$return = event_responses_create_responses($values) ? 1 : 0; $return = event_responses_create_response($values) ? 1 : 0;
returnData ($returnType, array('type' => 'string', 'data' => $return)); returnData ($returnType, array('type' => 'string', 'data' => $return));
} }
function api_set_update_event_response($id_response, $trash2, $other, $returnType) { /**
* @param $id_response
* @param $trash2
* @param mixed $other. Serialized params
* @param $returnType
* Example:
* api.php?op=set&op2=update_event_response&id=7&other=response%7Cdescription%20response%7Ctouch%7Ccommand%7C0%7C650%7C400%7C0%7Cresponse%7C0&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
*/
function api_set_update_event_response($id_response, $trash1, $other, $returnType) {
global $config; global $config;
// Error if user cannot read event responses. // Error if user cannot read event responses.
@ -11570,7 +11602,7 @@ function api_set_update_event_response($id_response, $trash2, $other, $returnTyp
return; return;
} }
$return = event_responses_update_responses($id_response, $values) ? 1 : 0; $return = event_responses_update_response($id_response, $values) ? 1 : 0;
returnData ($returnType, array('type' => 'string', 'data' => $return)); returnData ($returnType, array('type' => 'string', 'data' => $return));
} }

View File

@ -58,7 +58,7 @@ function event_responses_validate_data (&$values) {
* *
* @return True if successful insertion * @return True if successful insertion
*/ */
function event_responses_create_responses($values) { function event_responses_create_response($values) {
event_responses_validate_data($values); event_responses_validate_data($values);
return db_process_sql_insert('tevent_response', $values); return db_process_sql_insert('tevent_response', $values);
} }
@ -70,7 +70,7 @@ function event_responses_create_responses($values) {
* *
* @return True if successful insertion * @return True if successful insertion
*/ */
function event_responses_update_responses($response_id, $values) { function event_responses_update_response($response_id, $values) {
event_responses_validate_data($values); event_responses_validate_data($values);
return db_process_sql_update( return db_process_sql_update(
'tevent_response', $values, array('id' => $response_id) 'tevent_response', $values, array('id' => $response_id)