2013-06-04 Miguel de Dios <miguel.dedios@artica.es>
* godmode/massive/massive_delete_alerts.php: fixed the delete alerts with same module. Fixes: #2272 * include/functions_agents.php: erased unused function. MERGED FROM THE BRANCH PANDORA_4 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8253 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
756a889d15
commit
bf3dbc3836
|
@ -1,3 +1,14 @@
|
||||||
|
2013-06-04 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* godmode/massive/massive_delete_alerts.php: fixed the delete
|
||||||
|
alerts with same module.
|
||||||
|
|
||||||
|
Fixes: #2272
|
||||||
|
|
||||||
|
* include/functions_agents.php: erased unused function.
|
||||||
|
|
||||||
|
MERGED FROM THE BRANCH PANDORA_4
|
||||||
|
|
||||||
2013-06-04 Sergio Martin <sergio.martin@artica.es>
|
2013-06-04 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
* include/styles/pandora.css
|
* include/styles/pandora.css
|
||||||
|
|
|
@ -47,7 +47,7 @@ if (is_ajax ()) {
|
||||||
$agents_alerts = array();
|
$agents_alerts = array();
|
||||||
foreach( $groups as $group ) {
|
foreach( $groups as $group ) {
|
||||||
$agents_alerts_one_group = alerts_get_agents_with_alert_template ($id_alert_template, $group,
|
$agents_alerts_one_group = alerts_get_agents_with_alert_template ($id_alert_template, $group,
|
||||||
false, array ('tagente.nombre', 'tagente.id_agente'));
|
false, array ('tagente.nombre', 'tagente.id_agente'));
|
||||||
if (is_array($agents_alerts_one_group)) {
|
if (is_array($agents_alerts_one_group)) {
|
||||||
$agents_alerts = array_merge($agents_alerts, $agents_alerts_one_group);
|
$agents_alerts = array_merge($agents_alerts, $agents_alerts_one_group);
|
||||||
}
|
}
|
||||||
|
@ -79,22 +79,39 @@ function process_manage_delete ($id_alert_template, $id_agents, $module_names) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If is selected "ANY" option then we need the module selection mode: common or all modules
|
// If is selected "ANY" option then we need the module selection
|
||||||
|
// mode: common or all modules
|
||||||
if (count($module_names) == 1 && $module_names[0] == '0') {
|
if (count($module_names) == 1 && $module_names[0] == '0') {
|
||||||
|
if ($module_selection_mode == 'common') {
|
||||||
if ($module_selection_mode == 'common')
|
$sql = 'SELECT t1.id_agente_modulo
|
||||||
$modules_id = agents_common_modules_with_alerts ($id_agents, false, true);
|
FROM tagente_modulo AS t1
|
||||||
|
WHERE t1.id_agente_modulo IN (
|
||||||
|
SELECT t2.id_agent_module
|
||||||
|
FROM talert_template_modules AS t2
|
||||||
|
WHERE
|
||||||
|
t2.id_alert_template = ' . $id_alert_template . ')
|
||||||
|
AND t1.id_agente IN (' . implode(',', $id_agents) . ');';
|
||||||
|
$modules = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
|
if (empty($modules)) {
|
||||||
|
$modules = array();
|
||||||
|
}
|
||||||
|
$modules_id = array();
|
||||||
|
foreach ($modules as $module) {
|
||||||
|
$modules_id[$module['id_agente_modulo']] = $module['id_agente_modulo'];
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// For agents selected
|
// For agents selected
|
||||||
$modules_id = array();
|
$modules_id = array();
|
||||||
|
|
||||||
foreach ($id_agents as $id_agent) {
|
foreach ($id_agents as $id_agent) {
|
||||||
$current_modules_agent = agents_get_modules($id_agent, 'id_agente_modulo', array ('disabled' => 0));
|
$current_modules_agent = agents_get_modules($id_agent, 'id_agente_modulo', array ('disabled' => 0));
|
||||||
|
|
||||||
if ($current_modules_agent != false) {
|
if ($current_modules_agent != false) {
|
||||||
// And their modules
|
// And their modules
|
||||||
foreach ($current_modules_agent as $current_module) {
|
foreach ($current_modules_agent as $current_module) {
|
||||||
$module_alerts = alerts_get_alerts_agent_module($current_module);
|
$module_alerts = alerts_get_alerts_agent_module($current_module);
|
||||||
|
|
||||||
if ($module_alerts != false) {
|
if ($module_alerts != false) {
|
||||||
// And for all alert in modules
|
// And for all alert in modules
|
||||||
foreach ($module_alerts as $module_alert) {
|
foreach ($module_alerts as $module_alert) {
|
||||||
|
@ -113,8 +130,8 @@ function process_manage_delete ($id_alert_template, $id_agents, $module_names) {
|
||||||
$contsuccess = 0;
|
$contsuccess = 0;
|
||||||
foreach ($modules_id as $module) {
|
foreach ($modules_id as $module) {
|
||||||
$success = alerts_delete_alert_agent_module (false,
|
$success = alerts_delete_alert_agent_module (false,
|
||||||
array ('id_agent_module' => $module,
|
array ('id_agent_module' => $module,
|
||||||
'id_alert_template' => $id_alert_template));
|
'id_alert_template' => $id_alert_template));
|
||||||
|
|
||||||
if ($success)
|
if ($success)
|
||||||
$contsuccess ++;
|
$contsuccess ++;
|
||||||
|
|
|
@ -169,9 +169,9 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
|
||||||
$subQuery .= $where_tags;
|
$subQuery .= $where_tags;
|
||||||
}
|
}
|
||||||
else if ($id_agent === false) {
|
else if ($id_agent === false) {
|
||||||
if ($allModules)
|
if ($allModules)
|
||||||
$disabled = '';
|
$disabled = '';
|
||||||
else
|
else
|
||||||
$disabled = 'WHERE disabled = 0';
|
$disabled = 'WHERE disabled = 0';
|
||||||
|
|
||||||
$subQuery = 'SELECT id_agente_modulo
|
$subQuery = 'SELECT id_agente_modulo
|
||||||
|
@ -645,120 +645,6 @@ function agents_get_next_contact($idAgent, $maxModules = false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all the modules common in various agents that have associated alerts. If an empty list is passed it will select all
|
|
||||||
*
|
|
||||||
* @param mixed Agent id to get modules. It can also be an array of agent id's.
|
|
||||||
* @param mixed Array, comma delimited list or singular value of rows to
|
|
||||||
* select. If nothing is specified, nombre will be selected. A special
|
|
||||||
* character "*" will select all the values.
|
|
||||||
* @param mixed Aditional filters to the modules. It can be an indexed array
|
|
||||||
* (keys would be the field name and value the expected value, and would be
|
|
||||||
* joined with an AND operator) or a string, including any SQL clause (without
|
|
||||||
* the WHERE keyword).
|
|
||||||
* @param bool Wheter to return the modules indexed by the id_agente_modulo or
|
|
||||||
* not. Default is indexed.
|
|
||||||
* Example:
|
|
||||||
<code>
|
|
||||||
Both are similars:
|
|
||||||
$modules = agents_get_modules ($id_agent, false, array ('disabled' => 0));
|
|
||||||
$modules = agents_get_modules ($id_agent, false, 'disabled = 0');
|
|
||||||
|
|
||||||
Both are similars:
|
|
||||||
$modules = agents_get_modules ($id_agent, '*', array ('disabled' => 0, 'history_data' => 0));
|
|
||||||
$modules = agents_get_modules ($id_agent, '*', 'disabled = 0 AND history_data = 0');
|
|
||||||
</code>
|
|
||||||
*
|
|
||||||
* @return array An array with all modules in the agent.
|
|
||||||
* If multiple rows are selected, they will be in an array
|
|
||||||
*/
|
|
||||||
function agents_common_modules_with_alerts ($id_agent, $filter = false, $indexed = true, $get_not_init_modules = true) {
|
|
||||||
$id_agent = safe_int ($id_agent, 1);
|
|
||||||
|
|
||||||
$where = '';
|
|
||||||
|
|
||||||
if (! empty ($filter)) {
|
|
||||||
$where .= ' AND ';
|
|
||||||
if (is_array ($filter)) {
|
|
||||||
$fields = array ();
|
|
||||||
foreach ($filter as $field => $value) {
|
|
||||||
array_push ($fields, $field.'="'.$value.'"');
|
|
||||||
}
|
|
||||||
$where .= implode (' AND ', $fields);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$where .= $filter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! empty ($id_agent)) {
|
|
||||||
// Get module_name-template repetitions over agents selected
|
|
||||||
// Group by if there is more than one agent
|
|
||||||
$group_by = '';
|
|
||||||
if (count((array)$id_agent) > 1)
|
|
||||||
$group_by = 'having count(*) > 1';
|
|
||||||
|
|
||||||
$sql = sprintf ('SELECT t1.nombre, t2.id_alert_template, count(*)
|
|
||||||
FROM tagente_modulo t1, talert_template_modules t2
|
|
||||||
WHERE t2.id_agent_module = t1.id_agente_modulo
|
|
||||||
AND delete_pending = 0
|
|
||||||
AND id_agente IN (%s) %s group by nombre, id_alert_template %s'
|
|
||||||
, implode (",", (array) $id_agent)
|
|
||||||
, $where
|
|
||||||
,$group_by);
|
|
||||||
|
|
||||||
$result_tmp = db_get_all_rows_sql ($sql);
|
|
||||||
|
|
||||||
$result = array();
|
|
||||||
if ($result_tmp != false) {
|
|
||||||
|
|
||||||
foreach ($result_tmp as $module_template) {
|
|
||||||
|
|
||||||
$sql_modules = sprintf ('
|
|
||||||
SELECT t1.id_agente_modulo
|
|
||||||
FROM tagente_modulo t1, talert_template_modules t2
|
|
||||||
WHERE t1.id_agente_modulo = t2.id_agent_module
|
|
||||||
AND delete_pending = 0
|
|
||||||
AND t1.nombre = \'%s\' AND t2.id_alert_template = %s',
|
|
||||||
$module_template['nombre'], $module_template['id_alert_template']);
|
|
||||||
|
|
||||||
$id_modules_template = db_get_all_rows_sql ($sql_modules);
|
|
||||||
|
|
||||||
if ($id_modules_template != false)
|
|
||||||
foreach ($id_modules_template as $id_module_template)
|
|
||||||
$result[] = $id_module_template;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
$sql = sprintf ('SELECT DISTINCT(t1.id_agente_modulo)
|
|
||||||
FROM tagente_modulo t1, talert_template_modules t2
|
|
||||||
%s
|
|
||||||
ORDER BY nombre',
|
|
||||||
$where);
|
|
||||||
$result = db_get_all_rows_sql ($sql);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty ($result)) {
|
|
||||||
return array ();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $indexed)
|
|
||||||
return $result;
|
|
||||||
|
|
||||||
$modules = array ();
|
|
||||||
foreach ($result as $module) {
|
|
||||||
if ($get_not_init_modules || modules_get_agentmodule_is_init($module['id_agente_modulo'])) {
|
|
||||||
$modules[$module['id_agente_modulo']] = $module['id_agente_modulo'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $modules;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the modules common in various agents. If an empty list is passed it will select all
|
* Get all the modules common in various agents. If an empty list is passed it will select all
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue