2009-03-17 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/manage_config.php: Select dependant modules when an alert is selected. * include/functions_agents.php: Copy selected alerts on process_manage_config(). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1540 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
5d69e0d636
commit
635898e459
|
@ -1,3 +1,11 @@
|
|||
2009-03-17 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* godmode/agentes/manage_config.php: Select dependant modules when an
|
||||
alert is selected.
|
||||
|
||||
* include/functions_agents.php: Copy selected alerts on
|
||||
process_manage_config().
|
||||
|
||||
2009-03-16 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||
|
||||
* general/logoff.php: Cleaned up invalid html
|
||||
|
|
|
@ -30,7 +30,7 @@ require_once ('include/functions_agents.php');
|
|||
require_once ('include/functions_alerts.php');
|
||||
require_once ('include/functions_modules.php');
|
||||
|
||||
echo '<h2>'.__('Agent configuration'). ' » '. __('Configuration Management').'</h2>';
|
||||
echo '<h3>'.__('Configuration Management').'</h3>';
|
||||
|
||||
$source_id_group = (int) get_parameter ('source_id_group');
|
||||
$source_id_agent = (int) get_parameter ('source_id_agent');
|
||||
|
@ -69,7 +69,7 @@ $table->data[0][2] .= '</span>';
|
|||
$table->data[0][3] = print_select (get_group_agents ($source_id_group, false, "none"),
|
||||
'source_id_agent', $source_id_agent, false, __('Select'), 0, true);
|
||||
|
||||
echo '<form id="manage_config_form" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/manage_config">';
|
||||
echo '<form id="manage_config_form" method="post">';
|
||||
|
||||
echo '<fieldset id="fieldset_source">';
|
||||
echo '<legend><span>'.__('Source');
|
||||
|
@ -167,6 +167,7 @@ require_jquery_file ('pandora.controls');
|
|||
?>
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
var module_alerts;
|
||||
$(document).ready (function () {
|
||||
$("#source_id_group").pandoraSelectGroup ({
|
||||
agentSelect: "select#source_id_agent",
|
||||
|
@ -224,6 +225,7 @@ $(document).ready (function () {
|
|||
"id_agent" : id_agent
|
||||
},
|
||||
function (data, status) {
|
||||
module_alerts = Array ();
|
||||
if (! data) {
|
||||
no_alerts = true;
|
||||
} else {
|
||||
|
@ -236,6 +238,7 @@ $(document).ready (function () {
|
|||
.append (module_name)
|
||||
.append (")");
|
||||
$("#target_alerts").append (option);
|
||||
module_alerts[val["id"]] = val["id_agent_module"];
|
||||
});
|
||||
no_alerts = false;
|
||||
}
|
||||
|
@ -279,6 +282,14 @@ $(document).ready (function () {
|
|||
);
|
||||
});
|
||||
|
||||
$("#target_alerts").change (function () {
|
||||
jQuery.each ($(this).fieldValue (), function () {
|
||||
if (module_alerts[this] != undefined)
|
||||
$("#target_modules option[value="+module_alerts[this]+"]")
|
||||
.attr ("selected", "selected");
|
||||
});
|
||||
});
|
||||
|
||||
$("#manage_config_form").submit (function () {
|
||||
$("h3:not([id=message])").remove ();
|
||||
if ($("#source_id_agent").attr ("value") == 0) {
|
||||
|
|
|
@ -127,15 +127,16 @@ function get_agent_alerts ($id_agent, $filter = false, $options = false) {
|
|||
/**
|
||||
* Copy the agents config from one agent to the other
|
||||
*
|
||||
* @param int $source_id_agent Agent id
|
||||
* @param mixed $destiny_id_agents Agent id or id's (array) to copy to
|
||||
* @param bool $modules Whether to copy modules as well (defaults to get_parameter ('copy_modules'))
|
||||
* @param bool $alerts Whether to copy alerts as well
|
||||
* @param array $target_modules Which modules to copy
|
||||
* @param int Agent id
|
||||
* @param mixed Agent id or id's (array) to copy to
|
||||
* @param bool Whether to copy modules as well (defaults to $_REQUEST['copy_modules'])
|
||||
* @param bool Whether to copy alerts as well
|
||||
* @param array Which modules to copy.
|
||||
* @param array Which alerts to copy. Only will be used if target_modules is empty.
|
||||
*
|
||||
* @return bool True in case of good, false in case of bad
|
||||
*/
|
||||
function process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modules = false, $copy_alerts = false, $target_modules = false) {
|
||||
function process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modules = false, $copy_alerts = false, $target_modules = false, $target_alerts = false) {
|
||||
if (empty ($source_id_agent)) {
|
||||
echo '<h3 class="error">'.__('No source agent to copy').'</h3>';
|
||||
return false;
|
||||
|
@ -149,24 +150,44 @@ function process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modu
|
|||
if ($copy_modules == false) {
|
||||
$copy_modules = (bool) get_parameter ('copy_modules', $copy_modules);
|
||||
}
|
||||
|
||||
if ($copy_alerts == false) {
|
||||
$copy_alerts = (bool) get_parameter ('copy_alerts', $copy_alerts);
|
||||
}
|
||||
|
||||
if ($copy_modules) {
|
||||
if (! $copy_modules && ! $copy_alerts)
|
||||
return;
|
||||
|
||||
if (empty ($target_modules)) {
|
||||
$target_modules = (array) get_parameter ('target_modules', $target_modules);
|
||||
$target_modules = (array) get_parameter ('target_modules', array ());
|
||||
}
|
||||
|
||||
if (empty ($target_alerts)) {
|
||||
$target_alerts = (array) get_parameter ('target_alerts', array ());
|
||||
}
|
||||
|
||||
if (empty ($target_modules)) {
|
||||
if (! $copy_alerts) {
|
||||
echo '<h3 class="error">'.__('No modules have been selected').'</h3>';
|
||||
return false;
|
||||
}
|
||||
$target_modules = array ();
|
||||
|
||||
foreach ($target_alerts as $id_alert) {
|
||||
$alert = get_alert_agent_module ($id_alert);
|
||||
if ($alert === false)
|
||||
continue;
|
||||
/* Check if some alerts which doesn't belong to the agent was given */
|
||||
if (get_agentmodule_agent ($alert['id_agent_module']) != $source_id_agent)
|
||||
continue;
|
||||
array_push ($target_modules, $alert['id_agent_module']);
|
||||
}
|
||||
}
|
||||
|
||||
process_sql ('SET AUTOCOMMIT = 0');
|
||||
process_sql ('START TRANSACTION');
|
||||
$error = false;
|
||||
$alerts = array ();
|
||||
|
||||
foreach ($destiny_id_agents as $id_destiny_agent) {
|
||||
foreach ($target_modules as $id_agent_module) {
|
||||
$result = copy_agent_module_to_agent ($id_agent_module,
|
||||
|
@ -178,17 +199,35 @@ function process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modu
|
|||
}
|
||||
|
||||
$id_destiny_module = $result;
|
||||
if (! isset ($alerts[$id_agent_module]))
|
||||
$alerts[$id_agent_module] = get_alerts_agent_module ($id_agent_module,
|
||||
true);
|
||||
|
||||
if ($alerts[$id_agent_module] === false)
|
||||
continue;
|
||||
|
||||
if (! $copy_alerts)
|
||||
continue;
|
||||
|
||||
foreach ($alerts[$id_agent_module] as $alert) {
|
||||
/* If the alerts were given, copy afterwards. Otherwise, all the
|
||||
alerts for the module will be copied */
|
||||
if (! empty ($target_alerts)) {
|
||||
foreach ($target_alerts as $id_alert) {
|
||||
$alert = get_alert_agent_module ($id_alert);
|
||||
if ($alert === false)
|
||||
continue;
|
||||
if ($alert['id_agent_module'] != $id_agent_module)
|
||||
continue;
|
||||
$result = copy_alert_agent_module_to_agent_module ($alert['id'],
|
||||
$id_destiny_module);
|
||||
if ($result === false) {
|
||||
$error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$alerts = get_alerts_agent_module ($id_agent_module, true);
|
||||
|
||||
if ($alerts === false)
|
||||
continue;
|
||||
|
||||
foreach ($alerts as $alert) {
|
||||
$result = copy_alert_agent_module_to_agent_module ($alert['id'],
|
||||
$id_destiny_module);
|
||||
if ($result === false) {
|
||||
|
@ -209,7 +248,5 @@ function process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modu
|
|||
process_sql ('COMMIT');
|
||||
}
|
||||
process_sql ('SET AUTOCOMMIT = 1');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue