Added API function set update_user_profile_info
This commit is contained in:
parent
4f02d72630
commit
bf7cdcc7ff
|
@ -8723,6 +8723,11 @@ function api_set_delete_user_profile($id, $thrash1, $other, $thrash2) {
|
|||
/**
|
||||
* List all user profiles.
|
||||
*
|
||||
* @param Reserved $thrash1
|
||||
* @param Reserved $thrash2
|
||||
* @param Reserved $thrash3
|
||||
* @param string Return type (csv, json, string...)
|
||||
*
|
||||
* api.php?op=get&op2=user_profiles_info&return_type=json&apipass=1234&user=admin&pass=pandora
|
||||
*/
|
||||
function api_get_user_profiles_info ($thrash1, $thrash2, $thrash3, $returnType) {
|
||||
|
@ -8775,7 +8780,10 @@ function api_get_user_profiles_info ($thrash1, $thrash2, $thrash3, $returnType)
|
|||
/**
|
||||
* Create an user profile.
|
||||
*
|
||||
* @param array Serialized parameters: name|IR|IW|IM|AR|AW|AD|LW|LM|UM|DM|ER|EW|EM|RR|RW|RM|MR|MW|MM|VR|VW|VM|PM
|
||||
* @param Reserved $thrash1
|
||||
* @param Reserved $thrash2
|
||||
* @param array parameters in array: name|IR|IW|IM|AR|AW|AD|LW|LM|UM|DM|ER|EW|EM|RR|RW|RM|MR|MW|MM|VR|VW|VM|PM
|
||||
* @param string Return type (csv, json, string...)
|
||||
*
|
||||
* api.php?op=set&op2=create_user_profile_info&return_type=json&other=API_profile%7C1%7C0%7C0%7C1%7C0%7C0%7C0%7C0%7C0%7C0%7C1%7C0%7C0%7C1%7C0%7C0%7C1%7C0%7C0%7C1%7C0%7C0%7C0&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
|
||||
*/
|
||||
|
@ -8823,6 +8831,66 @@ function api_set_create_user_profile_info ($thrash1, $thrash2, $other, $returnTy
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an user profile.
|
||||
*
|
||||
* @param int Profile id
|
||||
* @param Reserved $thrash2
|
||||
* @param array parameters in array: name|IR|IW|IM|AR|AW|AD|LW|LM|UM|DM|ER|EW|EM|RR|RW|RM|MR|MW|MM|VR|VW|VM|PM
|
||||
* @param string Return type (csv, json, string...)
|
||||
*
|
||||
* api.php?op=set&op2=create_user_profile_info&return_type=json&other=API_profile%7C1%7C0%7C0%7C1%7C0%7C0%7C0%7C0%7C0%7C0%7C1%7C0%7C0%7C1%7C0%7C0%7C1%7C0%7C0%7C1%7C0%7C0%7C0&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
|
||||
*/
|
||||
function api_set_update_user_profile_info ($id_profile, $thrash2, $other, $returnType) {
|
||||
global $config;
|
||||
|
||||
if (!check_acl($config['id_user'], 0, "PM")){
|
||||
returnError('forbidden', 'string');
|
||||
return;
|
||||
}
|
||||
|
||||
$profile = db_get_row ('tperfil', 'id_perfil', $id_profile);
|
||||
if ($profile === false) {
|
||||
returnError('id_not_found', 'string');
|
||||
return;
|
||||
}
|
||||
|
||||
$values = array(
|
||||
'name' => $other['data'][0] == '' ? $profile['name'] : (string)$other['data'][0],
|
||||
'incident_view' => $other['data'][1] == '' ? $profile['incident_view'] : (bool)$other['data'][1] ? 1 : 0,
|
||||
'incident_edit' => $other['data'][2] == '' ? $profile['incident_edit'] : (bool)$other['data'][2] ? 1 : 0,
|
||||
'incident_management' => $other['data'][3] == '' ? $profile['incident_management'] : (bool)$other['data'][3] ? 1 : 0,
|
||||
'agent_view' => $other['data'][4] == '' ? $profile['agent_view'] : (bool)$other['data'][4] ? 1 : 0,
|
||||
'agent_edit' => $other['data'][5] == '' ? $profile['agent_edit'] : (bool)$other['data'][5] ? 1 : 0,
|
||||
'agent_disable' => $other['data'][6] == '' ? $profile['agent_disable'] : (bool)$other['data'][6] ? 1 : 0,
|
||||
'alert_edit' => $other['data'][7] == '' ? $profile['alert_edit'] : (bool)$other['data'][7] ? 1 : 0,
|
||||
'alert_management' => $other['data'][8] == '' ? $profile['alert_management'] : (bool)$other['data'][8] ? 1 : 0,
|
||||
'user_management' => $other['data'][9] == '' ? $profile['user_management'] : (bool)$other['data'][9] ? 1 : 0,
|
||||
'db_management' => $other['data'][10] == '' ? $profile['db_management'] : (bool)$other['data'][10] ? 1 : 0,
|
||||
'event_view' => $other['data'][11] == '' ? $profile['event_view'] : (bool)$other['data'][11] ? 1 : 0,
|
||||
'event_edit' => $other['data'][12] == '' ? $profile['event_edit'] : (bool)$other['data'][12] ? 1 : 0,
|
||||
'event_management' => $other['data'][13] == '' ? $profile['event_management'] : (bool)$other['data'][13] ? 1 : 0,
|
||||
'report_view' => $other['data'][14] == '' ? $profile['report_view'] : (bool)$other['data'][14] ? 1 : 0,
|
||||
'report_edit' => $other['data'][15] == '' ? $profile['report_edit'] : (bool)$other['data'][15] ? 1 : 0,
|
||||
'report_management' => $other['data'][16] == '' ? $profile['report_management'] : (bool)$other['data'][16] ? 1 : 0,
|
||||
'map_view' => $other['data'][17] == '' ? $profile['map_view'] : (bool)$other['data'][17] ? 1 : 0,
|
||||
'map_edit' => $other['data'][18] == '' ? $profile['map_edit'] : (bool)$other['data'][18] ? 1 : 0,
|
||||
'map_management' => $other['data'][19] == '' ? $profile['map_management'] : (bool)$other['data'][19] ? 1 : 0,
|
||||
'vconsole_view' => $other['data'][20] == '' ? $profile['vconsole_view'] : (bool)$other['data'][20] ? 1 : 0,
|
||||
'vconsole_edit' => $other['data'][21] == '' ? $profile['vconsole_edit'] : (bool)$other['data'][21] ? 1 : 0,
|
||||
'vconsole_management' => $other['data'][22] == '' ? $profile['vconsole_management'] : (bool)$other['data'][22] ? 1 : 0,
|
||||
'pandora_management' => $other['data'][23] == '' ? $profile['pandora_management'] : (bool)$other['data'][23] ? 1 : 0
|
||||
);
|
||||
|
||||
$return = db_process_sql_update('tperfil', $values, array('id_perfil' => $id_profile));
|
||||
|
||||
if ($return === false) {
|
||||
returnError('error_update_user_profile_info', __('Error updating user profile'));
|
||||
} else {
|
||||
returnData($returnType, array('type' => 'array', 'data' => 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new incident in Pandora.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue