Merge branch 'ent-12783-errores-al-borrar-modulos-que-se-usan-en-safe-operation-mode' into 'develop'

Ent 12783 Errores al borrar módulos que se usan en Safe operation mode

See merge request artica/pandorafms!6921
This commit is contained in:
Matias Didier 2024-02-22 14:03:32 +00:00
commit 9e312890bd
2 changed files with 42 additions and 0 deletions

View File

@ -2334,6 +2334,23 @@ if ($delete_module) {
exit; exit;
} }
// Check if module is used by agent for Safe mode.
$is_safe_mode_module = modules_check_safe_mode($id_borrar_modulo);
if ($is_safe_mode_module === true && isset($id_agente) === true) {
db_process_sql_update('tagente', ['safe_mode_module' => '0'], ['id_agente' => $id_agente]);
db_process_sql_update(
'tagente_modulo',
[
'disabled' => 0,
'disabled_by_safe_mode' => 0,
],
[
'id_agente' => $id_agente,
'disabled_by_safe_mode' => 1,
]
);
}
// Before delete the main module, check and delete the childrens from the original module. // Before delete the main module, check and delete the childrens from the original module.
module_check_childrens_and_delete($id_borrar_modulo); module_check_childrens_and_delete($id_borrar_modulo);

View File

@ -5074,3 +5074,28 @@ function modules_made_compatible($id_tipo_modulo)
return true; return true;
} }
} }
/**
* Check if module is used by agent for Safe mode.
*
* @param integer $id_module Id for module to check
*
* @return boolean
*/
function modules_check_safe_mode($id_module)
{
$id_agent = modules_give_agent_id_from_module_id($id_module);
if ($id_agent === 0) {
// No exist agent with this id.
return false;
}
$agent = agents_get_agent($id_agent);
if (isset($agent['safe_mode_module']) === true && (int) $agent['safe_mode_module'] === (int) $id_module) {
return true;
} else {
return false;
}
}