2011-07-11 Junichi Satoh <junichi@rworks.jp>

* operation/agentes/estado_agente.php,
	godmode/agentes/modificar_agente.php: Improved group selection, it
	allows group recursion.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4540 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
jsatoh 2011-07-11 04:28:21 +00:00
parent e67eae02ec
commit dbc7ecb2e8
3 changed files with 50 additions and 39 deletions

View File

@ -1,3 +1,9 @@
2011-07-11 Junichi Satoh <junichi@rworks.jp>
* operation/agentes/estado_agente.php,
godmode/agentes/modificar_agente.php: Improved group selection, it
allows group recursion.
2011-07-08 Miguel de Dios <miguel.dedios@artica.es>
* images/minimap_open_arrow.png, images/minimap_close_arrow.png: added the

View File

@ -22,6 +22,7 @@ $group_id = (int) get_parameter ("group_id");
$ag_group = get_parameter ("ag_group_refresh", -1);
$sortField = get_parameter('sort_field');
$sort = get_parameter('sort', 'none');
$recursion = get_parameter('recursion');
if ($ag_group == -1 )
$ag_group = (int) get_parameter ("ag_group", -1);
@ -95,19 +96,15 @@ echo "<td valign='top'>
</td>
</form>
<td valign='top'>";
echo __('Group recursion') . ': ';
html_print_checkbox ("recursion", 1, $recursion, false, false, 'this.form.submit()');
echo "</td><td valign='top'>";
echo __('Free text for search (*)');
echo "</td><td>";
// Show group selector
if (isset($_POST["ag_group"])) {
$group_mod = "&ag_group_refresh=".get_parameter_post ("ag_group");
}
else {
$group_mod ="";
}
echo "<form method='post' action='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&refr=60$group_mod'>";
echo "<form method='post' action='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&refr=60&ag_group_refresh=$ag_group&recursion=$recursion'>";
echo "<input type=text name='search' size='15' value='$search' >";
echo "</td><td valign='top'>";
echo "<input name='srcbutton' type='submit' class='sub search' value='".__('Search')."'>";
@ -189,23 +186,29 @@ if ($ag_group > 0) {
%s',
$ag_group, $search_sql);
$total_agents = db_get_sql ($sql);
$ag_groups = array();
$ag_groups = (array)$ag_group;
if ($recursion) {
$ag_groups = groups_get_id_recursive($ag_group, true);
}
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo = %d
WHERE id_grupo IN (%s)
%s
ORDER BY %s %s LIMIT %d, %d',
$ag_group, $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]);
implode (",", $ag_groups), $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]);
break;
case "postgresql":
$sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo = %d
WHERE id_grupo IN (%s)
%s
ORDER BY %s %s LIMIT %d OFFSET %d',
$ag_group, $search_sql, $order['field'], $order['order'], $config["block_size"], $offset);
implode (",", $ag_groups), $search_sql, $order['field'], $order['order'], $config["block_size"], $offset);
break;
case "oracle":
$set = array ();
@ -213,10 +216,10 @@ if ($ag_group > 0) {
$set['offset'] = $offset;
$sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo = %d
WHERE id_grupo IN (%s)
%s
ORDER BY %s %s',
$ag_group, $search_sql, $order['field'], $order['order']);
implode (",", $ag_groups), $search_sql, $order['field'], $order['order']);
$sql = oracle_recode_query ($sql, $set);
break;
}
@ -319,24 +322,24 @@ if (($config['dbtype'] == 'oracle') && ($agents !== false)) {
}
// Prepare pagination
ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset);
ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort", $offset);
echo "<div style='height: 20px'> </div>";
if ($agents !== false) {
echo "<table cellpadding='4' id='agent_list' cellspacing='4' width='98%' class='databox'>";
echo "<th>".__('Agent name') . ' ' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&search='.$search .'&offset='.$offset.'&sort_field=name&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '</a>' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&search='.$search .'&offset='.$offset.'&sort_field=name&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . '</a>';
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=name&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '</a>' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=name&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . '</a>';
echo "</th>";
echo "<th title='".__('Remote agent configuration')."'>".__('R')."</th>";
echo "<th>".__('OS'). ' ' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&search='.$search .'&offset='.$offset.'&sort_field=os&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectOsUp)) . '</a>' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&search='.$search .'&offset='.$offset.'&sort_field=os&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectOsDown)) . '</a>';
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=os&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectOsUp)) . '</a>' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=os&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectOsDown)) . '</a>';
echo "</th>";
echo "<th>".__('Group'). ' ' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&search='.$search .'&offset='.$offset.'&sort_field=group&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp)) . '</a>' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&search='.$search .'&offset='.$offset.'&sort_field=group&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . '</a>';
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=group&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp)) . '</a>' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=group&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . '</a>';
echo "</th>";
echo "<th>".__('Description')."</th>";
echo "<th>".__('Delete')."</th>";

View File

@ -119,15 +119,11 @@ $group_id = (int) get_parameter ("group_id", 0);
$search = io_safe_output(get_parameter ("search", ""));
$offset = get_parameter('offset', 0);
$refr = get_parameter('refr', 0);
$recursion = get_parameter('recursion', 0);
ui_print_page_header ( __("Agent detail"), "images/bricks.png", false, "agent_status");
if ($group_id > 1) {
echo '<form method="post" action="' . ui_get_url_refresh (array ('group_id' => $group_id, 'offset' => 0)).'">';
}
else {
echo '<form method="post" action="' . ui_get_url_refresh (array('offset' => 0)).'">';
}
echo '<form method="post" action="?sec=estado&sec2=operation/agentes/estado_agente&group_id=' . $group_id . '&offset=' . $offset . '">';
echo '<table cellpadding="4" cellspacing="4" class="databox" width="98%">';
echo '<tr><td style="white-space:nowrap;">'.__('Group').': ';
@ -135,6 +131,9 @@ echo '<tr><td style="white-space:nowrap;">'.__('Group').': ';
$groups = users_get_groups ();
html_print_select_groups(false, "AR", true, 'group_id', $group_id, 'this.form.submit()', '', '', false, false, true, '', false, 'width:180px');
echo '</td><td style="white-space:nowrap;">'.__('Group recursion').': ';
html_print_checkbox ("recursion", 1, $recursion, false, false, 'this.form.submit()');
echo '</td><td style="white-space:nowrap;">';
echo __('Free text for search').' (*): ';
@ -254,7 +253,10 @@ if ($search != ""){
// Show only selected groups
if ($group_id > 0) {
$groups = $group_id;
$agent_names = agents_get_group_agents ($group_id, $filter, "upper");
$agent_names = agents_get_group_agents ($group_id, $filter, "upper", false, $recursion);
if ($recursion) {
$groups = groups_get_id_recursive($group_id, true);
}
}
else {
$groups = array();
@ -295,7 +297,7 @@ if (empty ($agents)) {
}
// Prepare pagination
ui_pagination ($total_agents, ui_get_url_refresh (array ('group_id' => $group_id, 'search' => $search, 'sort_field' => $sortField, 'sort' => $sort)));
ui_pagination ($total_agents, ui_get_url_refresh (array ('group_id' => $group_id, 'recursion' => $recursion, 'search' => $search, 'sort_field' => $sortField, 'sort' => $sort)));
// Show data.
$table->cellpadding = 4;
@ -305,23 +307,23 @@ $table->class = "databox";
$table->head = array ();
$table->head[0] = __('Agent'). ' ' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;search=' . $search . '&amp;sort_field=name&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;search=' . $search . '&amp;sort_field=name&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;recursion=' . $recursion . '&amp;search=' . $search . '&amp;sort_field=name&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;recursion=' . $recursion . '&amp;search=' . $search . '&amp;sort_field=name&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
$table->head[1] = __('OS'). ' ' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;search=' . $search . '&amp;sort_field=os&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectOsUp, "alt" => "up")) . '</a>' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;search=' . $search . '&amp;sort_field=os&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectOsDown, "alt" => "down")) . '</a>';
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;recursion=' . $recursion . '&amp;search=' . $search . '&amp;sort_field=os&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectOsUp, "alt" => "up")) . '</a>' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;recursion=' . $recursion . '&amp;search=' . $search . '&amp;sort_field=os&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectOsDown, "alt" => "down")) . '</a>';
$table->head[2] = __('Interval'). ' ' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;search=' . $search . '&amp;sort_field=interval&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '</a>' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;search=' . $search . '&amp;sort_field=interval&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectIntervalDown, "alt" => "down")) . '</a>';
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;recursion=' . $recursion . '&amp;search=' . $search . '&amp;sort_field=interval&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '</a>' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;recursion=' . $recursion . '&amp;search=' . $search . '&amp;sort_field=interval&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectIntervalDown, "alt" => "down")) . '</a>';
$table->head[3] = __('Group'). ' ' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;search=' . $search . '&amp;sort_field=group&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp, "alt" => "up")) . '</a>' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;search=' . $search . '&amp;sort_field=group&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown, "alt" => "down")) . '</a>';
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;recursion=' . $recursion . '&amp;search=' . $search . '&amp;sort_field=group&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp, "alt" => "up")) . '</a>' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;recursion=' . $recursion . '&amp;search=' . $search . '&amp;sort_field=group&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown, "alt" => "down")) . '</a>';
$table->head[4] = __('Modules');
$table->head[5] = __('Status');
$table->head[6] = __('Alerts');
$table->head[7] = __('Last contact'). ' ' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;search=' . $search . '&amp;sort_field=last_contact&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectLastContactUp, "alt" => "up")) . '</a>' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;search=' . $search . '&amp;sort_field=last_contact&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectLastContactDown, "alt" => "down")) . '</a>';
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;recursion=' . $recursion . '&amp;search=' . $search . '&amp;sort_field=last_contact&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectLastContactUp, "alt" => "up")) . '</a>' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;group_id=' . $group_id . '&amp;recursion=' . $recursion . '&amp;search=' . $search . '&amp;sort_field=last_contact&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectLastContactDown, "alt" => "down")) . '</a>';
$table->align = array ();
$table->align[1] = "center";