Merge branch 'ent-11930-16108-16130-se-han-borrado-los-elementos-de-los-dashboards-773' into 'develop'

Ent 11930 16108 16130 se han borrado los elementos de los dashboards 773

See merge request artica/pandorafms!6353
This commit is contained in:
Rafael Ameijeiras 2023-08-23 13:40:53 +00:00
commit ec14abd9ca
2 changed files with 0 additions and 119 deletions

View File

@ -2760,79 +2760,6 @@ function agents_delete_agent($id_agents, $disableACL=false)
enterprise_include_once('include/functions_agents.php');
enterprise_hook('agent_delete_from_cache', [$id_agent]);
// Delete agent from visual console.
db_process_sql_delete(
'tlayout_data',
['id_agent' => $id_agent]
);
// Delete agent from visual dashboards.
db_process_sql(
'UPDATE twidget_dashboard
SET options = NULL
WHERE options LIKE ("%\"agentid\":\"'.$id_agent.'\"%")'
);
// Delete agent from treport.
db_process_sql_delete(
'treport_content',
['id_agent' => $id_agent]
);
// Delete rules from tevent alerts (correlative alerts)
db_process_sql_delete(
'tevent_rule',
[
'agent' => $id_agent,
'operator_agent' => '==',
]
);
db_process_sql_delete(
'tevent_rule',
[
'log_agent' => $id_agent,
'operator_log_agent' => '==',
]
);
// Delete from gis maps history
db_process_sql_delete(
'tgis_data_history',
['tagente_id_agente' => $id_agent]
);
// Delete from policies.
db_process_sql_delete(
'tpolicy_agents',
['id_agent' => $id_agent]
);
// Delete from tnetwork maps
db_process_sql_delete(
'titem',
['source_data' => $id_agent]
);
db_process_sql_delete(
'trel_item',
[
'id_parent_source_data' => $id_agent,
'id_child_source_data' => $id_agent,
],
'OR'
);
// Delete agent from fav menu.
db_process_sql_delete(
'tfavmenu_user',
[
'id_element' => $id_agent,
'section' => 'Agents',
'id_user' => $config['id_user'],
]
);
// Break the loop on error.
if ((bool) $error === true) {
break;

View File

@ -767,52 +767,6 @@ sub pandora_checkdb_integrity {
# Delete orphan data_inc reference records
db_do ($dbh, 'DELETE FROM tagente_datos_inc WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM tagente_modulo)');
# Delete orphan data from visual console.
log_message ('INTEGRITY', "Deleting orphan visual console items.");
db_do ($dbh, 'DELETE FROM tlayout_data WHERE id_agent <> 0 AND id_agent NOT IN (SELECT id_agente FROM tagente)');
db_do ($dbh, 'DELETE FROM tlayout_data WHERE id_agente_modulo <> 0 AND id_agente_modulo NOT IN (SELECT id_agente_modulo FROM tagente_modulo)');
# Delete orphan data form deleted agents.
# Clearl orphan data from dashboards
log_message ('INTEGRITY', "Deleting orphan dahsboard items.");
my @agents_ids = get_db_rows($dbh, 'SELECT id_agente FROM tagente');
my $where_condition;
foreach my $agent_id (@agents_ids) {
$where_condition .= 'options NOT LIKE ("%\\"agentid\\":\\"'.$agent_id->{'id_agente'}.'\\"%")';
if($agent_id == $agents_ids[-1]) {
last;
}
$where_condition .= ' AND ';
}
db_do ($dbh, 'UPDATE twidget_dashboard set options = NULL WHERE '.$where_condition);
$where_condition = '';
my @modules = get_db_rows($dbh, 'SELECT id_agente_modulo FROM tagente_modulo');
foreach my $id_agente_modulo (@modules) {
$where_condition .= 'options NOT LIKE ("%\\"moduleId\\":\\"'.$id_agente_modulo->{'id_agente_modulo'}.'\\"%")';
if($id_agente_modulo == $modules[-1]) {
last;
}
$where_condition .= ' AND ';
}
db_do ($dbh, 'UPDATE twidget_dashboard set options = NULL WHERE '.$where_condition);
# Delete orphan data from favorite agents
log_message ('INTEGRITY', "Deleting orphan favories items.");
db_do ($dbh, 'DELETE FROM tfavmenu_user WHERE section = "Agents" AND id_element NOT IN (SELECT id_agente FROM tagente)');
# Delete orphan data from gis maps
log_message ('INTEGRITY', "Deleting orphan GIS data.");
db_do ($dbh, 'DELETE FROM tgis_data_history WHERE tagente_id_agente NOT IN (SELECT id_agente FROM tagente)');
# Delete orphan tnetwork maps data
log_message ('INTEGRITY', "Deleting orphan networkmaps data.");
db_do ($dbh, 'DELETE FROM titem WHERE source_data NOT IN (SELECT id_agente FROM tagente)');
db_do ($dbh, 'DELETE FROM trel_item WHERE id_parent_source_data NOT IN (SELECT id_agente FROM tagente) OR id_child_source_data NOT IN (SELECT id_agente FROM tagente)');
# Check enterprise tables
enterprise_hook ('pandora_checkdb_integrity_enterprise', [$conf, $dbh]);
}