2012-04-12 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_ui.php: standariced the messages and added one more for
	info.
	
	* include/functions.php: added function "enterprise_installed".
	
	* extensions/update_manager/update_pandora.php: removed file, because it is
	into update_manager.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5958 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-04-12 12:20:38 +00:00
parent d73b391e16
commit f927caa9c8
4 changed files with 135 additions and 205 deletions

View File

@ -1,3 +1,13 @@
2012-04-12 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_ui.php: standariced the messages and added one more for
info.
* include/functions.php: added function "enterprise_installed".
* extensions/update_manager/update_pandora.php: removed file, because it is
into update_manager.
2012-04-12 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_config.php, extensions/update_manager.php,

View File

@ -1,194 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 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; 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.
require_once('lib/functions.php');
if (is_ajax ()) {
global $config;
check_login ();
if (! check_acl ($config["id_user"], 0, "PM")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
require_once('lib/functions.ajax.php');
$get_packages_online = (bool) get_parameter('get_packages_online');
$download_package = (bool) get_parameter('download_package');
$check_download_package = (bool) get_parameter('check_download_package');
$install_package = (bool) get_parameter('install_package');
$check_install_package = (bool) get_parameter('check_install_package');
if ($get_packages_online)
update_pandora_get_packages_online_ajax();
if ($download_package)
update_pandora_download_package();
if ($check_download_package)
update_pandora_check_download_package();
if ($install_package)
update_pandora_install_package();
if ($check_install_package)
update_pandora_check_install_package();
return;
}
function update_pandora_administration($settings, $user_key) {
global $config;
global $conf_update_pandora;
check_login ();
if (! check_acl ($config["id_user"], 0, "PM")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
if (!update_pandora_check_installation()) {
ui_print_error_message(__('First execution of Update Pandora'));
update_pandora_installation();
}
$delete_package = (bool)get_parameter('delete_package');
if ($delete_package) {
$package = get_parameter('package');
$dir = $config['attachment_store'] . '/update_pandora/';
$result = unlink($dir . $package);
}
$conf_update_pandora = update_pandora_get_conf();
$table = null;
$table->width = '98%';
$table->style = array();
$table->style[0] = 'font-weight: bolder; font-size: 20px;';
$table->data = array();
$table->data[0][0] = __('Your Pandora FMS open source package installed is') .
' ' . $conf_update_pandora['last_installed'];
html_print_table($table);
ui_print_info_message(
'<p>' .
__('This is a automatilly update Pandora Console only. Be careful if you have changed any php file of console, please make a backup this modified files php. Because the update action ovewrite all php files in Pandora console.') .
'</p>' .
'<p>' .
__('Update Manager sends anonymous information about Pandora FMS usage (number of agents and modules running). To disable it, just delete extension or remove remote server address from Update Manager plugin setup.') .
'</p>'
);
$table = null;
$table->width = '98%';
$table->data = array();
$table->data[0][0] = '<h4>' . __('Online') . '</h4>';
$table->data[1][0] =
'<table id="online_packages" class="databox" width="80%" cellspacing="4" cellpadding="4" border="0" style="">' .
'<tbody>
<tr id="online_packages-0" class="spinner_row" style="">
<td id="online_packages-0-0" style=" text-align:left; width:80%;">' .
__('Get list online Package') . " " . html_print_image('images/spinner.gif', true) .
'</td>
<td id="online_packages-0-1" style=" text-align:center; width:50px;"></td>
</tr>
</tbody>' .
'</table>';
html_print_table($table);
?>
<div id="dialog_download" title="<?php echo __('Process packge'); ?>"
style="display:none;">
<div style="position:absolute; top:20%; text-align: center; left:0%; right:0%; width:600px;">
<?php
echo '<h2 id="title_downloading_update_pandora">' . __('Downloading <span class="package_name">package</span> in progress') . " ";
html_print_image('images/spinner.gif');
echo '</h2>';
echo '<h2 style="display: none;" id="title_downloaded_update_pandora">' . __('Downloaded <span class="package_name">package</span>') . '</h2>';
echo '<h2 style="display: none;" id="title_installing_update_pandora">' . __('Installing <span class="package_name">package</span> in progress') . " ";
html_print_image('images/spinner.gif');
echo '</h2>';
echo '<h2 style="display: none;" id="title_installed_update_pandora">' . __('Installed <span class="package_name">package</span> in progress') . '</h2>';
echo '<h2 style="display: none;" id="title_error_update_pandora">' . __('Fail download <span class="package_name">package</span>') . '</h2>';
echo '<br /><br />';
echo "<div id='progress_bar_img'>";
echo progress_bar(0, 300, 20, 0 . '%', 1, false, "#00ff00");
echo "</div>";
echo "<div style='padding-top: 10px; display: none;' id='info_text'>
<b>Size:</b> 666/666 kbytes <b>Speed:</b> 666 bytes/second
</div>";
?>
<div id="button_close_download" style="display: none; position: absolute; top:280px; right:43%;">
<?php
html_print_submit_button(__("Close"), 'hide_download_dialog', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only" style="width:100px;"');
?>
</div>
</div>
</div>
<?php
$tableMain = null;
$tableMain->width = '98%';
$tableMain->data = array();
$tableMain->data[0][0] = '<h4>' . __('Downloaded Packages') . '</h4>';
$list_downloaded_packages = update_pandora_get_list_downloaded_packages('administration');
$table = null;
$table->width = '100%';
$table->size = array('50%', '25%', '25%');
$table->align = array('left', 'center');
$table->data = array();
foreach ($list_downloaded_packages as $package) {
$actions = '';
if (!isset($package['empty'])) {
if (!$package['current']) {
$actions = html_print_button(__('Install'),
'install_' . uniqid(), false,
'ajax_start_install_package(\'' . $package['name'] . '\');',
'class="sub next" style="width: 40%;"', true);
}
else {
$actions = html_print_button(__('Reinstall'),
'reinstall_' . uniqid(), false,
'ajax_start_install_package(\'' . $package['name'] . '\');',
'class="sub upd" style="width: 40%;"', true);
}
$actions .= ' ' . html_print_button(__('Delete'),
'delete' . uniqid(), false,
'delete_package(\'' . $package['name'] . '\');',
'class="sub delete" style="width: 40%;"', true);
}
$table->data[] = array($package['name'], $package['time'], $actions);
}
$tableMain->data[1][0] = html_print_table($table, true);
html_print_table($tableMain);
ui_require_css_file ('dialog');
ui_require_jquery_file ('ui.core');
ui_require_jquery_file ('ui.dialog');
update_pandora_print_javascript_admin();
}
?>

View File

@ -310,7 +310,7 @@ function human_time_comparation ($timestamp, $units = 'large') {
*/
function get_system_time () {
global $config;
switch ($config["dbtype"]) {
case "mysql":
return mysql_get_system_time();
@ -906,7 +906,24 @@ function get_priority_class($priority) {
break;
}
}
/**
* Check if the enterprise version is installed.
*
* @return boolean If it is installed return true, otherwise return false.
*/
function enterprise_installed() {
$return = false;
if (defined('PANDORA_ENTERPRISE')) {
if (PANDORA_ENTERPRISE) {
$return = true;
}
}
return $return;
}
/**
* TODO: Document enterprise functions
*/
@ -970,12 +987,12 @@ if (!function_exists ("mb_strtoupper")) {
function mb_strtoupper ($string, $encoding = false) {
return strtoupper ($string);
}
/**
* @ignore
*/
*/
function mb_strtolower ($string, $encoding = false) {
return strtoupper ($string);
return strtoupper ($string);
}
/**
@ -991,7 +1008,7 @@ if (!function_exists ("mb_strtoupper")) {
function mb_strlen ($string, $encoding = false) {
return strlen ($string);
}
/**
* @ignore
*/

View File

@ -135,7 +135,7 @@ function printSmallFont ($string, $return = true) {
/**
* Prints a generic message between tags.
*
* @param string The message string to be displayed
* @param mixed The string message or array ('title', 'message', 'icon', 'no_close') to be displayed
* @param string the class to user
* @param string Any other attributes to be set for the tag.
* @param bool Whether to output the string or return it
@ -145,7 +145,89 @@ function printSmallFont ($string, $return = true) {
* @return string HTML code if return parameter is true.
*/
function ui_print_message ($message, $class = '', $attributes = '', $return = false, $tag = 'h3') {
$output = '<'.$tag.(empty ($class) ? '' : ' class="'.$class.'" ').$attributes.'>'.$message.'</'.$tag.'>';
static $first_execution = true;
$text_title = '';
$text_message = '';
$icon_image = '';
$no_close_bool = false;
if (is_array($message)) {
if (!empty($message['title']))
$text_title = $message['title'];
if (!empty($message['message']))
$text_message = $message['message'];
if (!empty($message['icon']))
$icon_image = $message['icon'];
if (!empty($message['no_close']))
$no_close_bool = $message['no_close'];
}
else {
$text_message = $message;
}
if (empty($text_title)) {
switch ($class) {
default:
case 'info':
$text_title = __('Information');
break;
case 'error':
$text_title = __('Error');
break;
case 'suc':
$text_title = __('Success');
break;
}
}
if (empty($icon_image)) {
switch ($class) {
default:
case 'info':
$icon_image = 'images/information.png';
break;
case 'error':
$icon_image = 'images/err.png';
break;
case 'suc':
$icon_image = 'images/suc.png';
break;
}
}
$id = 'info_box_' . uniqid();
$output = '<table cellspacing="0" cellpadding="0" id="' . $id . '" ' . $attributes . '
class="info_box ' . $class . '" >
<tr>
<td class="icon">' . html_print_image($icon_image, true) . '</td>
<td class="title"><b>' . $text_title . '</b></td>
<td class="icon">';
if (!$no_close_bool) {
$output .= '<a href="javascript: close_info_box(\'' . $id . '\')">' .
html_print_image('images/cross.disabled.png', true) . '</a>';
}
$output .= '</td>
</tr>
<tr>
<td></td>
<td>' . $text_message . '</td>
<td></td>
</tr>
</table>';
if ($first_execution) {
$first_execution = false;
$output .= '
<script type="text/javascript">
function close_info_box(id) {
$("#" + id).hide();
}
</script>
';
}
if ($return)
return $output;
@ -155,7 +237,7 @@ function ui_print_message ($message, $class = '', $attributes = '', $return = fa
/**
* Prints an error message.
*
* @param string The error message to be displayed
* @param mixed The string error message or array ('title', 'message', 'icon', 'no_close') to be displayed
* @param string Any other attributes to be set for the tag.
* @param bool Whether to output the string or return it
* @param string What tag to use (you could specify something else than
@ -170,7 +252,7 @@ function ui_print_error_message ($message, $attributes = '', $return = false, $t
/**
* Prints an operation success message.
*
* @param string The message to be displayed
* @param mixed The string message or array ('title', 'message', 'icon', 'no_close') to be displayed
* @param string Any other attributes to be set for the tag.
* @param bool Whether to output the string or return it
* @param string What tag to use (you could specify something else than
@ -182,13 +264,28 @@ function ui_print_success_message ($message, $attributes = '', $return = false,
return ui_print_message ($message, 'suc', $attributes, $return, $tag);
}
/**
* Prints an operation info message.
*
* @param mixed The string message or array ('title', 'message', 'icon', 'no_close') to be displayed
* @param string Any other attributes to be set for the tag.
* @param bool Whether to output the string or return it
* @param string What tag to use (you could specify something else than
* h3 like div or h2)
*
* @return string HTML code if return parameter is true.
*/
function ui_print_info_message ($message, $attributes = '', $return = false, $tag = 'h3') {
return ui_print_message ($message, 'info', $attributes, $return, $tag);
}
/**
* Evaluates a result using empty() and then prints an error or success message
*
* @param mixed The results to evaluate. 0, NULL, false, '' or
* array() is bad, the rest is good
* @param string The string to be displayed if the result was good
* @param string The string to be displayed if the result was bad
* @param mixed The string or array ('title', 'message') to be displayed if the result was good
* @param mixed The string or array ('title', 'message') to be displayed if the result was bad
* @param string Any other attributes to be set for the h3
* @param bool Whether to output the string or return it
* @param string What tag to use (you could specify something else than