2009-05-25 Esteban Sanchez <estebans@artica.es>

* general/ui/agents_list.php: Fixed pagination javascript selector
	to avoid collisions.

	* godmode/modules/manage_nc_groups.php,
	godmode/modules/manage_nc_groups_form.php: Rewritten to use pandora
	functions. Code cleanup.

	* godmode/modules/manage_network_components.php: Fixed string search
	query.

	* include/functions_network_components.php: Added
	get_network_component_group().



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1705 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2009-05-25 13:29:48 +00:00
parent bfb03549a9
commit d4b2f7863d
6 changed files with 119 additions and 65 deletions

View File

@ -1,3 +1,18 @@
2009-05-25 Esteban Sanchez <estebans@artica.es>
* general/ui/agents_list.php: Fixed pagination javascript selector
to avoid collisions.
* godmode/modules/manage_nc_groups.php,
godmode/modules/manage_nc_groups_form.php: Rewritten to use pandora
functions. Code cleanup.
* godmode/modules/manage_network_components.php: Fixed string search
query.
* include/functions_network_components.php: Added
get_network_component_group().
2009-05-25 Jorge Gonzalez <jorgegonz@artica.es> 2009-05-25 Jorge Gonzalez <jorgegonz@artica.es>
* include/languages/es.po, include/languages/es.mo: Updated Spanish * include/languages/es.po, include/languages/es.mo: Updated Spanish

View File

@ -189,7 +189,7 @@ function send_search_form (offset) {
function (data, status) { function (data, status) {
$("#agents_loading").hide ().after (data); $("#agents_loading").hide ().after (data);
$("#agents_list, table#agents_table").show (); $("#agents_list, table#agents_table").show ();
$("a.pagination").click (function () { $("#agents a.pagination").click (function () {
offset = this.href.split ("=").pop (); offset = this.href.split ("=").pop ();
send_search_form (offset); send_search_form (offset);
return false; return false;
@ -206,7 +206,7 @@ $(document).ready (function () {
return false; return false;
}); });
$("a.pagination").click (function () { $("#agents a.pagination").click (function () {
offset = this.href.split ("=").pop (); offset = this.href.split ("=").pop ();
send_search_form (offset); send_search_form (offset);
return false; return false;

View File

@ -25,14 +25,16 @@ if (! give_acl ($config['id_user'], 0, "PM")) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
"Trying to access SNMP Group Management"); "Trying to access SNMP Group Management");
require ("general/noaccess.php"); require ("general/noaccess.php");
exit; return;
} }
require_once ('include/functions_network_components.php');
$create = (bool) get_parameter ('create'); $create = (bool) get_parameter ('create');
$update = (bool) get_parameter ('update'); $update = (bool) get_parameter ('update');
$delete = (bool) get_parameter ('delete'); $delete = (bool) get_parameter ('delete');
$new = (bool) get_parameter ('new');
echo '<h2>'.__('Module management').' &raquo; '. __('Component group management').'</h2>'; $id = (int) get_parameter ('id');
if ($create) { if ($create) {
$name = (string) get_parameter ('name'); $name = (string) get_parameter ('name');
@ -47,7 +49,6 @@ if ($create) {
} }
if ($update) { if ($update) {
$id = (int) get_parameter ('id_sg');
$name = (string) get_parameter ('name'); $name = (string) get_parameter ('name');
$parent = (int) get_parameter ('parent'); $parent = (int) get_parameter ('parent');
@ -60,9 +61,7 @@ if ($update) {
__('Not updated. Error updating data')); __('Not updated. Error updating data'));
} }
if ($delete) { // if delete if ($delete) {
$id = (int) get_parameter ('id_sg');
$result = process_sql_delete ('tnetwork_component_group', $result = process_sql_delete ('tnetwork_component_group',
array ('id_sg' => $id)); array ('id_sg' => $id));
print_result_message ($result, print_result_message ($result,
@ -70,40 +69,72 @@ if ($delete) { // if delete
__('Not deleted. Error deleting data')); __('Not deleted. Error deleting data'));
} }
if ($id || $new) {
require_once ('manage_nc_groups_form.php');
return;
}
echo '<h2>'.__('Module management').' &raquo; '. __('Component group management').'</h2>';
$url = get_url_refresh (array ('offset' => false,
'create' => false,
'update' => false,
'delete' => false,
'new' => false,
'crt' => false,
'upd' => false,
'id_sg' => false));
$table->width = '90%'; $table->width = '90%';
$table->head = array (); $table->head = array ();
$table->head[0] = __('Name'); $table->head[0] = __('Name');
$table->head[1] = __('Parent'); $table->head[1] = __('Parent');
$table->head[2] = __('Delete'); $table->head[2] = '';
$table->style = array (); $table->style = array ();
$table->style[0] = 'font-weight: bold'; $table->style[0] = 'font-weight: bold';
$table->align = array (); $table->align = array ();
$table->align[2] = 'center'; $table->align[2] = 'center';
$table->size = array ();
$table->size[0] = '50%';
$table->size[1] = '50%';
$table->size[2] = '40px';
$table->data = array (); $table->data = array ();
$groups = get_db_all_rows_filter ('tnetwork_component_group', $total_groups = get_db_all_rows_filter ('tnetwork_component_group', false, 'COUNT(*) AS total');
array ('order' => 'parent')); $total_groups = $total_groups[0]['total'];
$filter = array ();
$filter['offset'] = (int) get_parameter ('offset');
$filter['limit'] = (int) $config['block_size'];
$groups = get_db_all_rows_filter ('tnetwork_component_group', $filter);
if ($groups === false) if ($groups === false)
$groups = array (); $groups = array ();
pagination ($total_groups, $url);
foreach ($groups as $group) { foreach ($groups as $group) {
$data = array (); $data = array ();
$data[0] = '<a href="index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups_form&edit=1&id_sg='.$group["id_sg"].'">'.$group["name"].'</a>'; $data[0] = '<a href="index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups&id='.$group['id_sg'].'">'.$group['name'].'</a>';
$data[1] = get_network_component_group_name ($group["parent"]); $data[1] = get_network_component_group_name ($group['parent']);
$data[2] = '<a href="index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups&delete=1&id_sg='.$group["id_sg"].'"
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;"> $data[2] = '<form method="post" onsubmit="if (! confirm (\''.__('Are you sure?').'\')) return false">';
<img src="images/cross.png"></a>'; $data[2] .= print_input_hidden ('delete', 1, true);
$data[2] .= print_input_hidden ('id', $group['id_sg'], true);
$data[2] .= print_input_image ('del', 'images/cross.png', 1, '', true,
array ('title' => __('Delete')));
$data[2] .= '</form>';
array_push ($table->data, $data); array_push ($table->data, $data);
} }
print_table ($table); print_table ($table);
echo '<form method="post" action="index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups_form">'; echo '<form method="post">';
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
print_input_hidden ('create', 1); print_input_hidden ('new', 1);
print_submit_button (__('Create'), 'crt', false, 'class="sub next"'); print_submit_button (__('Create'), 'crt', false, 'class="sub next"');
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';

View File

@ -28,55 +28,44 @@ if (! give_acl ($config['id_user'], 0, "PM")) {
exit; exit;
} }
$create = (bool) get_parameter ('create'); require_once ('include/functions_network_components.php');
$edit = (bool) get_parameter ('edit');
if ($edit) { // Edit mode $id = (int) get_parameter ('id');
$id_sg = entrada_limpia ($_GET["id_sg"]);
$sql1 = "SELECT * FROM tnetwork_component_group where id_sg = $id_sg"; if ($id) {
$result=mysql_query($sql1); $group = get_network_component_group ($id);
$row=mysql_fetch_array($result); $name = $group['name'];
$name = $row["name"]; $parent = $group['parent'];
$parent = $row["parent"]; } else {
} elseif ($create) { $name = '';
$id_sg = -1; $parent = '';
$name = "";
$parent = "";
} }
echo "<h2>".__('Component group management')."</h2>"; echo '<h2>'.__('Component group management').'</h2>';
echo '<table width="50%" cellspacing="4" cellpadding="4" class="databox">';
// Different Form url if it's a create or if it's a update form $table->width = '50%';
if ($id_sg != -1) $table->style = array ();
echo "<form name='snmp_c' method='post' action='index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups&update=1&id_sg=$id_sg'>"; $table->style[0] = 'font-weight: bold';
else $table->data = array ();
echo "<form name='snmp_c' method='post' action='index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups&create=1'>";
echo "<tr>"; $table->data[0][0] = __('Name');
echo "<td class='datos'>".__('Name')."</td>"; $table->data[0][1] = print_input_text ('name', $name, '', 15, 255, true);
echo "<td class='datos'><input type='text' name='name' size=30 value='$name'></td>";
echo "<tr>"; $table->data[1][0] = __('Parent');
echo "<td class='datos2'>".__('Parent')."</td>"; $table->data[1][1] = print_select (get_network_component_groups (),
echo "<td class='datos2'>"; 'parent', $parent, false, __('None'), 0, true, false, false);
echo "<select name='parent'>";
echo "<option value='$parent'>".get_network_component_group_name($parent);
$sql1 = "SELECT * FROM tnetwork_component_group where id_sg != '$parent'";
$result=mysql_query($sql1);
while ($row=mysql_fetch_array($result))
echo "<option value='".$row["id_sg"]."'>".get_network_component_group_name($row["id_sg"]);
echo "</select>";
echo "</td></tr><table>";
echo '<table width="500">';
echo '<tr><td align="right">';
if ($id_sg == -1)
echo "<input name='crtbutton' type='submit' class='sub wand' value='".__('Create')."'>";
else
echo "<input name='uptbutton' type='submit' class='sub upd' value='".__('Update')."'>";
echo "</form></td></tr></table>";
echo '<form method="post" action="index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups">';
print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) {
print_input_hidden ('update', 1);
print_input_hidden ('id', $id);
print_submit_button (__('Update'), 'crt', false, 'class="sub upd"');
} else {
print_input_hidden ('create', 1);
print_submit_button (__('Create'), 'crt', false, 'class="sub next"');
}
echo '</div>';
echo '</form>';
?> ?>

View File

@ -216,7 +216,7 @@ $filter = array ();
if ($search_id_group) if ($search_id_group)
$filter['id_group'] = $search_id_group; $filter['id_group'] = $search_id_group;
if ($search_string != '') if ($search_string != '')
$filter[] = '(nombre LIKE "%'.$search_id_group.'%" OR description LIKE "%'.$search_id_group.'%" OR tcp_send LIKE "%'.$search_id_group.'%" OR tcp_rcv LIKE "%'.$search_id_group.'%")'; $filter[] = '(name LIKE "%'.$search_string.'%" OR description LIKE "%'.$search_string.'%" OR tcp_send LIKE "%'.$search_string.'%" OR tcp_rcv LIKE "%'.$search_stringg.'%")';
$total_components = get_network_components (false, $filter, 'COUNT(*) AS total'); $total_components = get_network_components (false, $filter, 'COUNT(*) AS total');
$total_components = $total_components[0]['total']; $total_components = $total_components[0]['total'];

View File

@ -64,6 +64,25 @@ function get_network_component_group_name ($id_network_component_group) {
return @get_db_value ('name', 'tnetwork_component_group', 'id_sg', $id_network_component_group); return @get_db_value ('name', 'tnetwork_component_group', 'id_sg', $id_network_component_group);
} }
/**
* Get a network component group.
*
* @param int Group id to be fetched.
* @param array Extra filter.
* @param array Fields to be fetched.
*
* @return array A network component group matching id and filter.
*/
function get_network_component_group ($id_network_component_group, $filter = false, $fields = false) {
if (empty ($id_network_component_group))
return false;
if (! is_array ($filter))
$filter = array ();
$filter['id_sg'] = (int) $id_network_component_group;
return get_db_row_filter ('tnetwork_component_group', $filter, $fields);
}
/** /**
* Get a list of network component groups. * Get a list of network component groups.
* *