2012-12-05 Sergio Martin <sergio.martin@artica.es>

* godmode/agentes/module_manager_editor_common.php
	godmode/agentes/configurar_agente.php
	godmode/agentes/module_manager_editor.php
	godmode/menu.php
	godmode/category
	godmode/category/category.php
	godmode/category/edit_category.php: Add categories editor
	and the category combo in the modules editor



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7231 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2012-12-05 17:02:47 +00:00
parent fbdc052f00
commit a973eec629
7 changed files with 297 additions and 1 deletions

View File

@ -1,3 +1,14 @@
2012-12-05 Sergio Martin <sergio.martin@artica.es>
* godmode/agentes/module_manager_editor_common.php
godmode/agentes/configurar_agente.php
godmode/agentes/module_manager_editor.php
godmode/menu.php
godmode/category
godmode/category/category.php
godmode/category/edit_category.php: Add categories editor
and the category combo in the modules editor
2012-12-05 Miguel de Dios <miguel.dedios@artica.es>
* extensions/update_manager/lib/libupdate_manager_client.php,

View File

@ -790,6 +790,8 @@ if ($update_module || $create_module) {
$critical_inverse = (int) get_parameter('critical_inverse');
$warning_inverse = (int) get_parameter('warning_inverse');
$id_category = (int) get_parameter('id_category');
$hour = get_parameter('hour');
$minute = get_parameter('minute');
$mday = get_parameter('mday');
@ -863,7 +865,8 @@ if ($update_module) {
'unknown_instructions' => $unknown_instructions,
'critical_inverse' => $critical_inverse,
'warning_inverse' => $warning_inverse,
'cron_interval' => $cron_interval);
'cron_interval' => $cron_interval,
'id_category' => $id_category);
if ($prediction_module == 3 && $serialize_ops == '') {
$result = false;

View File

@ -210,6 +210,8 @@ if ($id_agent_module) {
$critical_inverse = $module['critical_inverse'];
$warning_inverse = $module['warning_inverse'];
$id_category = $module['id_category'];
$cron_interval = explode (" ", $module['cron_interval']);
if (isset ($cron_interval[4])) {
$minute = $cron_interval[0];
@ -285,6 +287,8 @@ else {
$critical_inverse = '';
$warning_inverse = '';
$id_category = 0;
$cron_interval = '* * * * *';
$hour = '*';
$minute = '*';

View File

@ -15,6 +15,7 @@
// GNU General Public License for more details.
include_once("include/functions_modules.php");
include_once("include/functions_categories.php");
function prepend_table_simple ($row, $id = false) {
global $table_simple;
@ -379,6 +380,11 @@ $table_advanced->data[12][2] = '';
$table_advanced->data[12][3] = __('Retries');
$table_advanced->data[12][4] = html_print_input_text ('max_retries', $max_retries, '', 5, 10, true);
if (check_acl ($config['id_user'], 0, "PM")) {
$table_advanced->data[13][0] = __('Category');
$table_advanced->data[13][1] = html_print_select(categories_get_all_categories('forselect'), 'id_category', $id_category, '', __('None'), 0, true);
$table_advanced->colspan[13][1] = 4;
}
?>
<script type="text/javascript">

View File

@ -0,0 +1,128 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config;
// Check login and ACLs
check_login ();
if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_user'])) {
db_pandora_audit("ACL Violation", "Trying to access Categories Management");
require ("general/noaccess.php");
return;
}
//Include functions code
require_once ($config['homedir'].'/include/functions_categories.php');
// Get parameters
$delete = (int) get_parameter ("delete_category", 0);
$search = (int) get_parameter ("search_category", 0);
$category_name = (string) get_parameter ("category_name","");
$tab = (string) get_parameter ("tab", "list");
$buttons = array(
'list' => array(
'active' => false,
'text' => '<a href="index.php?sec=galertas&sec2=godmode/category/category&tab=list">' .
html_print_image ("images/god6.png", true, array ("title" => __('List categories'))) .'</a>'));
$buttons[$tab]['active'] = true;
// Header
ui_print_page_header (__('Categories configuration'), "images/setup.png", false, "", true, $buttons);
// Two actions can performed in this page: search and delete categories
// Delete action: This will delete a category
if ($delete != 0) {
$return_delete = categories_delete_category ($delete);
if (!$return_delete) {
db_pandora_audit("Category management", "Fail try to delete category #$delete");
ui_print_error_message(__('Error deleting category'));
}
else {
db_pandora_audit("Category management", "Delete category #$delete");
ui_print_success_message(__('Successfully deleted category'));
}
}
// statements for pagination
$url = ui_get_url_refresh ();
$total_categories = categories_get_category_count();
$filter['offset'] = (int) get_parameter ('offset');
$filter['limit'] = (int) $config['block_size'];
// Search action: This will filter the display category view
$result = false;
$result = categories_get_all_categories ();
// Form to add new categories or search categories
echo "<table border=0 cellpadding=4 cellspacing=4 class=databox width=98%>";
echo "<tr>";
echo "<td align=right>";
echo '<form method="post" action="index.php?sec=gmodules&sec2=godmode/category/edit_category&action=new">';
html_print_input_hidden ("create_category", "1", true);
html_print_submit_button (__('Create category'), 'create_button', false, 'class="sub next"');
echo "</form>";
echo "</td>";
echo "</tr>";
echo "</table>";
// Prepare pagination
ui_pagination ($total_categories, $url);
// Display categories previously filtered or not
$rowPair = true;
$iterator = 0;
if (!empty($result)) {
$table->width = '98%';
$table->data = array ();
$table->head = array ();
$table->align = array ();
$table->style = array ();
$table->style[0] = 'font-weight: bold; text-align:left';
$table->style[1] = 'text-align:center; width: 100px;';
$table->head[0] = __('Category name');
$table->head[1] = __('Actions');
foreach ($result as $category) {
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
$table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair;
$iterator++;
$data = array ();
$data[0] = "<a href='index.php?sec=gmodules&sec2=godmode/category/edit_category&action=update&id_category=" . $category["id"] . "'>" . $category["name"] . "</a>";
$data[1] = "<a href='index.php?sec=gmodules&sec2=godmode/category/edit_category&action=update&id_category=".$category["id"] . "'>" . html_print_image("images/config.png", true, array("title" => "Edit")) . "</a>&nbsp;&nbsp;";
$data[1] .= '<a href="index.php?sec=gmodules&sec2=godmode/category/category&delete_category='.$category["id"] . '"onclick="if (! confirm (\''.__('Are you sure?').'\')) return false">' . html_print_image("images/cross.png", true, array("title" => "Delete")) . '</a>';
array_push ($table->data, $data);
}
html_print_table ($table);
}
else {
// No categories available or selected
echo "<div class='nf'>".__('No categories found')."</div>";
}
?>

View File

@ -0,0 +1,140 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
check_login ();
//Include functions code
require_once ($config['homedir'].'/include/functions_categories.php');
if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_user'])) {
db_pandora_audit("ACL Violation", "Trying to access Edit Category");
require ("general/noaccess.php");
return;
}
// Get parameters
$action = (string) get_parameter ("action", "");
$id_category = (int) get_parameter ("id_category", 0);
$update_category = (int) get_parameter ("update_category", 0);
$create_category = (int) get_parameter ("create_category", 0);
$name_category = (string) get_parameter ("name_category", "");
$tab = (string) get_parameter ("tab", "list");
$buttons = array(
'list' => array(
'active' => false,
'text' => '<a href="index.php?sec=gmodules&sec2=godmode/category/category&tab=list">' .
html_print_image ("images/god6.png", true, array ("title" => __('List categories'))) .'</a>'));
$buttons[$tab]['active'] = true;
// Header
ui_print_page_header (__('Categories configuration'), "images/setup.png", false, "", true, $buttons);
// Two actions can performed in this page: update and create categories
// Update category: update an existing category
if ($update_category && $id_category != 0) {
$values = array();
$values['name'] = $name_category;
$result = false;
if ($values['name'] != '')
$result = db_process_sql_update('tcategory', $values, array('id' => $id_category));
if ($result === false) {
db_pandora_audit("Category management", "Fail try to update category #$id_category");
ui_print_error_message(__('Error updating category'));
}
else {
db_pandora_audit("Category management", "Update category #$id_category");
ui_print_success_message(__('Successfully updated category'));
}
}
// Create category: creates a new category
if ($create_category) {
$return_create = true;
$values = array();
$values['name'] = $name_category;
// DB insert
$return_create = false;
if ($values['name'] != '')
$return_create = db_process_sql_insert('tcategory', $values);
if ($return_create === false) {
db_pandora_audit("Category management", "Fail try to create category");
ui_print_error_message(__('Error creating category'));
$action = "new";
// If create action ends successfully then current action is update
}
else {
db_pandora_audit("Category management", "Create category #$return_create");
ui_print_success_message(__('Successfully created category'));
$id_category = $return_create;
$action = "update";
}
}
// Form fields are filled here
// Get results when update action is performed
if ($action == "update" && $id_category != 0){
$result_category = db_get_row_filter('tcategory', array('id' => $id_category));
$name_category = $result_category["name"];
} // If current action is create (new) or somethig goes wrong fields are filled with void value
else {
$name_category = "";
}
// Create/Update category form
echo '<form method="post" action="index.php?sec=gmodules&sec2=godmode/category/edit_category&action=' . $action . '&id_category=' . $id_category . '" enctype="multipart/form-data">';
echo '<div align=left style="width: 98%" class="pandora_form">';
echo "<table border=0 cellpadding=4 cellspacing=4 class=databox width=98%>";
echo "<tr>";
echo "<td align=center>";
html_print_label (__("Name"),'name');
echo "</td>";
echo "<td align=center>";
html_print_input_text ('name_category', $name_category);
echo "</td>";
echo "</tr>";
echo "<tr>";
if ($action == "update"){
echo "<td align=center>";
html_print_input_hidden ('update_category', 1);
echo "</td>";
echo "<td align=right>";
html_print_submit_button (__('Update'), 'update_button', false, 'class="sub next"');
echo "</td>";
}
if ($action == "new"){
echo "<td align=center>";
html_print_input_hidden ('create_category', 1);
echo "</td>";
echo "<td align=right>";
html_print_submit_button (__('Create'), 'create_button', false, 'class="sub next"');
echo "</td>";
}
echo "</tr>";
echo "</table>";
echo '</div>';
echo '</form>';
?>

View File

@ -86,6 +86,10 @@ if (check_acl ($config['id_user'], 0, "PM")) {
$sub["godmode/tag/tag"]["text"] = __('Manage tags');
$sub["godmode/tag/tag"]["subsecs"] = "godmode/tag/edit_tag";
// Category
$sub["godmode/category/category"]["text"] = __('Manage categories');
$sub["godmode/category/category"]["subsecs"] = "godmode/category/edit_category";
$sub["godmode/modules/module_list"]["text"] = __('Module types');
$menu_godmode["gmodules"]["sub"] = $sub;