2011-12-02 Sergio Martin <sergio.martin@artica.es>

* include/functions_modules.php
	include/functions.php
	extensions/snmp_explorer.php
	godmode/agentes/configurar_agente.php
	godmode/massive/massive_edit_modules.php: Check if a module 
	name exists in the agent when you edit the module and
	improve the errors feedback



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5229 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2011-12-02 10:08:07 +00:00
parent 534787d360
commit 8591c8b25c
6 changed files with 78 additions and 27 deletions

View File

@ -1,3 +1,13 @@
2011-12-02 Sergio Martin <sergio.martin@artica.es>
* include/functions_modules.php
include/functions.php
extensions/snmp_explorer.php
godmode/agentes/configurar_agente.php
godmode/massive/massive_edit_modules.php: Check if a module
name exists in the agent when you edit the module and
improve the errors feedback
2011-12-02 Sergio Martin <sergio.martin@artica.es>
* include/functions_modules.php

View File

@ -240,7 +240,7 @@ function snmp_explorer() {
case ERR_DB:
case ERR_GENERIC:
default:
$msg .= '<br>'.__('Processing errors')." ($number)";
$msg .= '<br>'.__('Processing error')." ($number)";
break;
}

View File

@ -742,8 +742,28 @@ if ($update_module) {
$values, false, $id_tag);
}
if ($result === false) {
echo '<h3 class="error">'.__('There was a problem updating module').'</h3>';
if (is_error($result)) {
$msg = __('There was a problem updating module').'. ';
switch($result) {
case ERR_EXIST:
$msg .= __('Another module already exists with the same name').'.';
break;
case ERR_INCOMPLETE:
$msg .= __('Some required fields are missed').': ('.__('name').')';
break;
case ERR_NOCHANGES:
$msg .= __('"No change"');
break;
case ERR_DB:
case ERR_GENERIC:
default:
$msg .= __('Processing error');
break;
}
$result = false;
echo '<h3 class="error">'.$msg.'</h3>';
$edit_module = true;
db_pandora_audit("Agent management",
@ -841,7 +861,7 @@ if ($create_module) {
case ERR_DB:
case ERR_GENERIC:
default:
// No more info
$msg .= __('Processing error');
break;
}
$id_agent_module = false;

View File

@ -73,7 +73,7 @@ else {
foreach ($modules as $module) {
$result = modules_update_agent_module ($module['id_agente_modulo'], $values, true, $update_tags);
if ($result === false) {
if (is_error($result)) {
db_process_sql_rollback ();
return false;

View File

@ -48,6 +48,8 @@ define ('ERR_DB', -40000);
define ('ERR_FILE', -50000);
define ('ERR_NOCHANGES', -60000);
/* Visual console constants */
define("MIN_WIDTH",300);
define("MIN_HEIGHT",120);
@ -1119,7 +1121,7 @@ function is_ajax () {
* @return bool true if a result code is an error or false otherwise
*/
function is_error($code) {
if($code <= ERR_GENERIC) {
if($code !== true AND ($code <= ERR_GENERIC || $code === false)) {
return true;
}
else {

View File

@ -194,28 +194,47 @@ function modules_delete_agent_module ($id_agent_module) {
*
* @return True if the module was updated. False if not.
*/
function modules_update_agent_module ($id, $values, $onlyNoDeletePending = false,
$tags = false) {
if (! is_array ($values) || empty ($values))
return false;
if (isset ($values['nombre']) && empty ($values['nombre']))
return false;
if ($tags !== false)
$return_tag = tags_update_module_tag ($id, $tags);
// if ($return_tag === false){
// return false;
// }
if ($onlyNoDeletePending) {
return (@db_process_sql_update ('tagente_modulo', $values,
array ('id_agente_modulo' => (int) $id, 'delete_pending' => 0)) !== false);
function modules_update_agent_module ($id, $values, $onlyNoDeletePending = false, $tags = false) {
if (!is_array ($values) || empty ($values)) {
return ERR_GENERIC;
}
else {
return (@db_process_sql_update ('tagente_modulo', $values,
array ('id_agente_modulo' => (int) $id)) !== false);
if (isset ($values['nombre'])) {
if(empty ($values['nombre'])) {
return ERR_INCOMPLETE;
}
$id_agent = modules_get_agentmodule_agent($id);
$exists = (bool)db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('nombre' => $values['nombre'], 'id_agente' => $id_agent, 'id_agente_modulo' => "<>$id"));
if($exists) {
return ERR_EXIST;
}
}
$return_tag = true;
if ($tags !== false) {
$return_tag = tags_update_module_tag ($id, $tags);
}
if ($return_tag === false){
return ERR_DB;
}
$where = array();
$where['id_agente_modulo'] = $id;
if ($onlyNoDeletePending) {
$where['delete_pending'] = 0;
}
$result = @db_process_sql_update ('tagente_modulo', $values, $where);
if($result === false) {
return ERR_DB;
}
else {
return true;
}
}