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:
parent
bfb03549a9
commit
d4b2f7863d
|
@ -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>
|
||||
|
||||
* include/languages/es.po, include/languages/es.mo: Updated Spanish
|
||||
|
|
|
@ -189,7 +189,7 @@ function send_search_form (offset) {
|
|||
function (data, status) {
|
||||
$("#agents_loading").hide ().after (data);
|
||||
$("#agents_list, table#agents_table").show ();
|
||||
$("a.pagination").click (function () {
|
||||
$("#agents a.pagination").click (function () {
|
||||
offset = this.href.split ("=").pop ();
|
||||
send_search_form (offset);
|
||||
return false;
|
||||
|
@ -206,7 +206,7 @@ $(document).ready (function () {
|
|||
return false;
|
||||
});
|
||||
|
||||
$("a.pagination").click (function () {
|
||||
$("#agents a.pagination").click (function () {
|
||||
offset = this.href.split ("=").pop ();
|
||||
send_search_form (offset);
|
||||
return false;
|
||||
|
|
|
@ -25,15 +25,17 @@ if (! give_acl ($config['id_user'], 0, "PM")) {
|
|||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access SNMP Group Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
return;
|
||||
}
|
||||
|
||||
require_once ('include/functions_network_components.php');
|
||||
|
||||
$create = (bool) get_parameter ('create');
|
||||
$update = (bool) get_parameter ('update');
|
||||
$delete = (bool) get_parameter ('delete');
|
||||
|
||||
echo '<h2>'.__('Module management').' » '. __('Component group management').'</h2>';
|
||||
|
||||
$new = (bool) get_parameter ('new');
|
||||
$id = (int) get_parameter ('id');
|
||||
|
||||
if ($create) {
|
||||
$name = (string) get_parameter ('name');
|
||||
$parent = (int) get_parameter ('parent');
|
||||
|
@ -47,7 +49,6 @@ if ($create) {
|
|||
}
|
||||
|
||||
if ($update) {
|
||||
$id = (int) get_parameter ('id_sg');
|
||||
$name = (string) get_parameter ('name');
|
||||
$parent = (int) get_parameter ('parent');
|
||||
|
||||
|
@ -60,9 +61,7 @@ if ($update) {
|
|||
__('Not updated. Error updating data'));
|
||||
}
|
||||
|
||||
if ($delete) { // if delete
|
||||
$id = (int) get_parameter ('id_sg');
|
||||
|
||||
if ($delete) {
|
||||
$result = process_sql_delete ('tnetwork_component_group',
|
||||
array ('id_sg' => $id));
|
||||
print_result_message ($result,
|
||||
|
@ -70,40 +69,72 @@ if ($delete) { // if delete
|
|||
__('Not deleted. Error deleting data'));
|
||||
}
|
||||
|
||||
if ($id || $new) {
|
||||
require_once ('manage_nc_groups_form.php');
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<h2>'.__('Module management').' » '. __('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->head = array ();
|
||||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('Parent');
|
||||
$table->head[2] = __('Delete');
|
||||
$table->head[2] = '';
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->align = array ();
|
||||
$table->align[2] = 'center';
|
||||
$table->size = array ();
|
||||
$table->size[0] = '50%';
|
||||
$table->size[1] = '50%';
|
||||
$table->size[2] = '40px';
|
||||
$table->data = array ();
|
||||
|
||||
$groups = get_db_all_rows_filter ('tnetwork_component_group',
|
||||
array ('order' => 'parent'));
|
||||
$total_groups = get_db_all_rows_filter ('tnetwork_component_group', false, 'COUNT(*) AS total');
|
||||
$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)
|
||||
$groups = array ();
|
||||
|
||||
pagination ($total_groups, $url);
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$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[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;">
|
||||
<img src="images/cross.png"></a>';
|
||||
$data[1] = get_network_component_group_name ($group['parent']);
|
||||
|
||||
$data[2] = '<form method="post" onsubmit="if (! confirm (\''.__('Are you sure?').'\')) return false">';
|
||||
$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);
|
||||
}
|
||||
|
||||
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.'">';
|
||||
print_input_hidden ('create', 1);
|
||||
print_input_hidden ('new', 1);
|
||||
print_submit_button (__('Create'), 'crt', false, 'class="sub next"');
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
|
|
@ -28,55 +28,44 @@ if (! give_acl ($config['id_user'], 0, "PM")) {
|
|||
exit;
|
||||
}
|
||||
|
||||
$create = (bool) get_parameter ('create');
|
||||
$edit = (bool) get_parameter ('edit');
|
||||
require_once ('include/functions_network_components.php');
|
||||
|
||||
if ($edit) { // Edit mode
|
||||
$id_sg = entrada_limpia ($_GET["id_sg"]);
|
||||
$sql1 = "SELECT * FROM tnetwork_component_group where id_sg = $id_sg";
|
||||
$result=mysql_query($sql1);
|
||||
$row=mysql_fetch_array($result);
|
||||
$name = $row["name"];
|
||||
$parent = $row["parent"];
|
||||
} elseif ($create) {
|
||||
$id_sg = -1;
|
||||
$name = "";
|
||||
$parent = "";
|
||||
$id = (int) get_parameter ('id');
|
||||
|
||||
if ($id) {
|
||||
$group = get_network_component_group ($id);
|
||||
$name = $group['name'];
|
||||
$parent = $group['parent'];
|
||||
} else {
|
||||
$name = '';
|
||||
$parent = '';
|
||||
}
|
||||
|
||||
echo "<h2>".__('Component group management')."</h2>";
|
||||
echo '<table width="50%" cellspacing="4" cellpadding="4" class="databox">';
|
||||
echo '<h2>'.__('Component group management').'</h2>';
|
||||
|
||||
// Different Form url if it's a create or if it's a update form
|
||||
if ($id_sg != -1)
|
||||
echo "<form name='snmp_c' method='post' action='index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups&update=1&id_sg=$id_sg'>";
|
||||
else
|
||||
echo "<form name='snmp_c' method='post' action='index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups&create=1'>";
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'>".__('Name')."</td>";
|
||||
echo "<td class='datos'><input type='text' name='name' size=30 value='$name'></td>";
|
||||
$table->width = '50%';
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->data = array ();
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class='datos2'>".__('Parent')."</td>";
|
||||
echo "<td class='datos2'>";
|
||||
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>";
|
||||
$table->data[0][0] = __('Name');
|
||||
$table->data[0][1] = print_input_text ('name', $name, '', 15, 255, true);
|
||||
|
||||
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>";
|
||||
$table->data[1][0] = __('Parent');
|
||||
$table->data[1][1] = print_select (get_network_component_groups (),
|
||||
'parent', $parent, false, __('None'), 0, true, false, false);
|
||||
|
||||
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>';
|
||||
?>
|
||||
|
|
|
@ -216,7 +216,7 @@ $filter = array ();
|
|||
if ($search_id_group)
|
||||
$filter['id_group'] = $search_id_group;
|
||||
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 = $total_components[0]['total'];
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue