2010-09-09 14:19:11 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2010 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 ();
|
|
|
|
|
|
|
|
if (! give_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_user'])) {
|
|
|
|
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation", "Trying to access Setup Management");
|
|
|
|
require ("general/noaccess.php");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$action = get_parameter('action', 'new');
|
|
|
|
$idOS = get_parameter('id_os', 0);
|
2010-09-09 16:07:21 +02:00
|
|
|
$tab = get_parameter('tab', 'builder');
|
2010-09-09 14:19:11 +02:00
|
|
|
|
|
|
|
if ($idOS) {
|
|
|
|
$os = get_db_row_filter('tconfig_os', array('id_os' => $idOS));
|
|
|
|
$name = $os['name'];
|
|
|
|
$description = $os['description'];
|
|
|
|
$icon = $os['icon_name'];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$name = get_parameter('name', '');
|
|
|
|
$description = get_parameter('description', '');
|
|
|
|
$icon = get_parameter('icon',0);
|
|
|
|
}
|
|
|
|
|
2010-09-09 16:07:21 +02:00
|
|
|
$message = '';
|
2010-09-09 14:19:11 +02:00
|
|
|
|
|
|
|
switch ($action) {
|
|
|
|
default:
|
|
|
|
case 'new':
|
|
|
|
$actionHidden = 'save';
|
|
|
|
$textButton = __('Create');
|
|
|
|
$classButton = 'class="sub next"';
|
|
|
|
break;
|
|
|
|
case 'edit':
|
|
|
|
$actionHidden = 'update';
|
|
|
|
$textButton = __('Update');
|
|
|
|
$classButton = 'class="sub upd"';
|
|
|
|
break;
|
|
|
|
case 'save':
|
|
|
|
$values = array();
|
|
|
|
$values['name'] = $name;
|
|
|
|
$values['description'] = $description;
|
|
|
|
|
|
|
|
if (($icon !== 0) && ($icon != '')) {
|
|
|
|
$values['icon_name'] = $icon;
|
|
|
|
}
|
|
|
|
$resultOrId = process_sql_insert('tconfig_os', $values);
|
|
|
|
|
|
|
|
if ($resultOrId === false) {
|
2010-09-09 16:07:21 +02:00
|
|
|
$message = print_error_message(__('Fail to create OS'), '', true);
|
|
|
|
$tab = 'builder';
|
2010-09-09 14:19:11 +02:00
|
|
|
$actionHidden = 'save';
|
|
|
|
$textButton = __('Create');
|
|
|
|
$classButton = 'class="sub next"';
|
|
|
|
}
|
|
|
|
else {
|
2010-09-09 16:07:21 +02:00
|
|
|
$message = print_success_message(__('Success to create OS'), '', true);
|
|
|
|
$tab = 'list';
|
2010-09-09 14:19:11 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'update':
|
|
|
|
$name = get_parameter('name', '');
|
|
|
|
$description = get_parameter('description', '');
|
|
|
|
$icon = get_parameter('icon',0);
|
|
|
|
|
|
|
|
$values = array();
|
|
|
|
$values['name'] = $name;
|
|
|
|
$values['description'] = $description;
|
|
|
|
|
|
|
|
if (($icon !== 0) && ($icon != '')) {
|
|
|
|
$values['icon_name'] = $icon;
|
|
|
|
}
|
|
|
|
$result = process_sql_update('tconfig_os', $values, array('id_os' => $idOS));
|
|
|
|
|
2010-09-09 16:07:21 +02:00
|
|
|
$message = print_result_message($result, __('Success to update OS'), __('Error to update OS'), '', true);
|
|
|
|
if ($result !== false) {
|
|
|
|
$tab = 'list';
|
|
|
|
}
|
2010-09-09 14:19:11 +02:00
|
|
|
|
|
|
|
$actionHidden = 'update';
|
|
|
|
$textButton = __('Update');
|
|
|
|
$classButton = 'class="sub upd"';
|
|
|
|
break;
|
|
|
|
case 'delete':
|
|
|
|
$sql = 'SELECT COUNT(id_os) AS count FROM tagente WHERE id_os = ' . $idOS;
|
|
|
|
$count = get_db_all_rows_sql($sql);
|
|
|
|
$count = $count[0]['count'];
|
|
|
|
|
|
|
|
if ($count > 0) {
|
2010-09-09 16:07:21 +02:00
|
|
|
$message = print_error_message(__('There are agents with this OS.'), '', true);
|
2010-09-09 14:19:11 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$result = (bool)process_sql_delete('tconfig_os', array('id_os' => $idOS));
|
|
|
|
|
2010-09-09 16:07:21 +02:00
|
|
|
$message = print_result_message($result, __('Success to delete'), __('Error to delete'), '', true);
|
2010-09-09 14:19:11 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-09-09 16:07:21 +02:00
|
|
|
$buttons = array(
|
|
|
|
'list' => array(
|
|
|
|
'active' => false,
|
|
|
|
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=list">' .
|
|
|
|
print_image ("images/god6.png", true, array ("title" => __('List OS'))) .'</a>'),
|
|
|
|
'builder' => array(
|
|
|
|
'active' => false,
|
|
|
|
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=builder">' .
|
|
|
|
print_image ("images/config.png", true, array ("title" => __('Builder OS'))) .'</a>'));
|
2010-09-09 14:19:11 +02:00
|
|
|
|
2010-09-09 16:07:21 +02:00
|
|
|
|
|
|
|
$buttons[$tab]['active'] = true;
|
2010-09-09 14:19:11 +02:00
|
|
|
|
2010-09-09 16:07:21 +02:00
|
|
|
// Header
|
|
|
|
print_page_header(__('Edit OS'), "", false, "", true, $buttons);
|
2010-09-09 14:19:11 +02:00
|
|
|
|
2010-09-09 16:07:21 +02:00
|
|
|
echo $message;
|
2010-09-09 14:19:11 +02:00
|
|
|
|
2010-09-09 16:07:21 +02:00
|
|
|
switch ($tab) {
|
|
|
|
case 'list':
|
|
|
|
require_once('godmode/setup/os.list.php');
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case 'builder':
|
|
|
|
require_once('godmode/setup/os.builder.php');
|
|
|
|
return;
|
|
|
|
break;
|
2010-09-09 14:19:11 +02:00
|
|
|
}
|
2010-09-09 16:07:21 +02:00
|
|
|
?>
|