Merge branch 'ent-6574-mensaje-borrado-agentes-meta' into 'develop'
Fixed api agent delete and show correct message when called by meta wizard See merge request artica/pandorafms!3892
This commit is contained in:
commit
c2f297c26a
|
@ -1864,10 +1864,14 @@ function api_get_custom_field_id($t1, $t2, $other, $returnType)
|
||||||
* @param $thrast2 Don't use.
|
* @param $thrast2 Don't use.
|
||||||
* @param $thrash3 Don't use.
|
* @param $thrash3 Don't use.
|
||||||
*/
|
*/
|
||||||
function api_set_delete_agent($id, $thrash1, $other, $thrash3)
|
function api_set_delete_agent($id, $thrash1, $other, $returnType)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
if (empty($returnType)) {
|
||||||
|
$returnType = 'string';
|
||||||
|
}
|
||||||
|
|
||||||
$agent_by_alias = false;
|
$agent_by_alias = false;
|
||||||
|
|
||||||
if ($other['data'][0] === '1') {
|
if ($other['data'][0] === '1') {
|
||||||
|
@ -1910,7 +1914,7 @@ function api_set_delete_agent($id, $thrash1, $other, $thrash3)
|
||||||
} else {
|
} else {
|
||||||
// Delete only if the centralised mode is disabled.
|
// Delete only if the centralised mode is disabled.
|
||||||
$headers = getallheaders();
|
$headers = getallheaders();
|
||||||
if (isset($headers['idk']) === false || is_management_allowed($headers['idk']) === false) {
|
if (isset($headers['idk']) === false && is_management_allowed($headers['idk']) === false) {
|
||||||
returnError('centralized');
|
returnError('centralized');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -1934,19 +1938,27 @@ function api_set_delete_agent($id, $thrash1, $other, $thrash3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$idAgent = agents_get_agent_id($id, true);
|
$idAgent = agents_get_agent_id($id, false);
|
||||||
if (!util_api_check_agent_and_print_error($idAgent, 'string', 'AD')) {
|
if (!util_api_check_agent_and_print_error($idAgent, 'string', 'AD')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = agents_delete_agent($idAgent, true);
|
$result = agents_delete_agent($idAgent, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$result) {
|
if ($result === false) {
|
||||||
returnError('The agent could not be deleted');
|
if ($returnType !== 'string') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
returnError('The agent could not be deleted', $returnType);
|
||||||
} else {
|
} else {
|
||||||
returnData('string', ['type' => 'string', 'data' => __('The agent was successfully deleted')]);
|
if ($returnType !== 'string') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
returnData($returnType, ['type' => 'string', 'data' => __('The agent was successfully deleted')]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue