Added link to MC place where user must manage the stuff when in centralised environment and ui_get_meta_url

This commit is contained in:
fbsanchez 2021-06-24 19:48:07 +02:00
parent 4c2ac234b8
commit eec373e896
26 changed files with 278 additions and 71 deletions

View File

@ -1082,8 +1082,15 @@ function resource_registration_extension_main()
if (is_management_allowed() === false) {
ui_print_warning_message(
__('This node is configured with centralized mode. Go to metaconsole to create a policy.')
__(
'This node is configured with centralized mode. Go to %s to create a policy.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/policymanager'
).'">'.__('metaconsole').'</a>'
)
);
return;
}
echo '<div class=notify>';

View File

@ -112,7 +112,12 @@ ui_print_standard_header(
if (is_management_allowed() === false) {
ui_print_warning_message(
__('This node is configured with centralized mode. To delete an agent go to metaconsole.')
__(
'This node is configured with centralized mode. Go to %s to delete an agent',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=monitoring&sec2=monitoring/wizard/wizard'
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -216,7 +216,12 @@ if ($delete_action) {
$is_management_allowed = is_management_allowed();
if ($is_management_allowed === false) {
ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All alert actions information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/alerts/alert_actions&tab=action&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -617,7 +617,12 @@ if ($copy_command) {
$is_management_allowed = is_management_allowed();
if ($is_management_allowed === false) {
ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All alert commands information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/alerts/alert_commands&tab=command&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -261,7 +261,12 @@ if ($delete_template) {
if (is_management_allowed() === false) {
ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All alert templates information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/alerts/alert_templates&tab=template'
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -105,7 +105,12 @@ $is_management_allowed = is_management_allowed();
if ($is_management_allowed === false) {
ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All alert actions information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/alerts/configure_alert_action&tab=action&pure=0&id='.$id
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -159,7 +159,12 @@ $is_management_allowed = is_management_allowed();
if ($is_management_allowed === false) {
ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All alert commands information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/alerts/configure_alert_command&pure=0&id='.$id
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -36,7 +36,9 @@ $id = (int) get_parameter('id');
$pure = get_parameter('pure', 0);
$step = (int) get_parameter('step', 1);
// We set here the number of steps.
define('LAST_STEP', 3);
if (defined('LAST_STEP') === false) {
define('LAST_STEP', 3);
}
if ($duplicate_template) {
$source_id = (int) get_parameter('source_id');
@ -372,13 +374,15 @@ $is_management_allowed = is_management_allowed();
if ($is_management_allowed === false) {
ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All alerts templates information is read only. Go to Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/alerts/configure_alert_template&pure=0&id='.$id.'&step='.$step
).'">'.__('metaconsole').'</a>'
)
);
}
// We set here the number of steps.
define('LAST_STEP', 3);
$step = (int) get_parameter('step', 1);
$create_alert = (bool) get_parameter('create_alert');

View File

@ -93,7 +93,12 @@ $is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
ui_print_warning_message(
__('This node is configured with centralized mode. All categories information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All categories information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/category/category&tab=list&pure='.(int) $config['pure']
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -383,7 +383,12 @@ $is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
ui_print_warning_message(
__('This node is configured with centralized mode. All groups information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All groups information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/groups/group_list&tab=groups'
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -80,7 +80,12 @@ $is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
ui_print_warning_message(
__('This node is configured with centralized mode. All module groups information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All module groups information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/component_management'
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -40,7 +40,12 @@ if (!check_acl($config['id_user'], 0, 'UM')) {
if (is_management_allowed() === false) {
ui_print_warning_message(
__('This node is configured with centralized mode. All profiles user information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All profiles user information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/users_setup&tab=profile&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
return;

View File

@ -40,7 +40,12 @@ if (! check_acl($config['id_user'], 0, 'UM')) {
if (is_management_allowed() === false) {
ui_print_warning_message(
__('This node is configured with centralized mode. All profiles user information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All profiles user information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/users_setup&tab=profile&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
return;

View File

@ -334,7 +334,14 @@ $agentstab = [
}
if ($tab == 'massive_policies' && is_management_allowed() === false) {
ui_print_warning_message(__('This node is configured with centralized mode. All policies information is read only. Go to metaconsole to manage it.'));
ui_print_warning_message(
__(
'This node is configured with centralized mode. All policies information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/policymanager'
).'">'.__('metaconsole').'</a>'
)
);
return;
}
@ -394,7 +401,14 @@ $agentstab = [
<?php
if (is_management_allowed() === false && $option == 'delete_agents') {
ui_print_warning_message(__('This node is configured with centralized mode. To delete an agent go to metaconsole.'));
ui_print_warning_message(
__(
'This node is configured with centralized mode. To delete agents go to %s',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=monitoring&sec2=monitoring/wizard/wizard'
).'">'.__('metaconsole').'</a>'
)
);
}
echo '<br />';

View File

@ -255,7 +255,7 @@ foreach ($groups as $group) {
$tabulation = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $group['deep']);
if (defined('METACONSOLE')) {
if (is_metaconsole() === true) {
$data[0] = $tabulation.'<a href="index.php?sec=advanced&sec2=godmode/modules/manage_nc_groups&id='.$group['id_sg'].'">'.$group['name'].'</a>';
} else {
$data[0] = $tabulation.'<a href="index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups&id='.$group['id_sg'].'">'.$group['name'].'</a>';
@ -270,8 +270,15 @@ foreach ($groups as $group) {
array_push($table->data, $data);
}
if (is_management_allowed() === false && !is_metaconsole()) {
ui_print_warning_message(__('This node is configured with centralized mode. This page is for read only. Go to metaconsole to manage the component groups.'));
if (is_management_allowed() === false && is_metaconsole() === false) {
ui_print_warning_message(
__(
'This node is configured with centralized mode. Component groups are read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/modules/manage_nc_groups'
).'">'.__('metaconsole').'</a>'
)
);
}
if (isset($data)) {

View File

@ -298,7 +298,12 @@ if (is_metaconsole() === true) {
if ($is_management_allowed === false) {
ui_print_warning_message(
__('This node is configured with centralized mode. All Remote components information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All remote components are read only. Go to %s to manage them.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/modules/manage_network_components&tab=network&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -41,7 +41,12 @@ $is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
ui_print_warning_message(
__('This node is configured with centralized mode. All Os information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All OS definitions are read only. Go to %s to manage them.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2=list&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -172,7 +172,12 @@ if ($delete !== 0) {
$is_management_allowed = is_management_allowed();
if ($is_management_allowed === false) {
ui_print_warning_message(
__('This node is configured with centralized mode. All tags information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All tags information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/component_management'
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -103,7 +103,12 @@ $is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
ui_print_warning_message(
__('This node is configured with centralized mode. All profiles information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All profiles information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/users_setup&tab=profile&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -398,7 +398,12 @@ $is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
ui_print_warning_message(
__('This node is configured with centralized mode. All users information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All users information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/users_setup&tab=user&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -160,15 +160,23 @@ function mysql_db_get_all_rows_sql($sql, $search_history_db=false, $cache=true,
/**
* Get the first value of the first row of a table in the database.
*
* @param string Field name to get
* @param string Table to retrieve the data
* @param string Field to filter elements
* @param string Condition the field must have
* @param string $field Field name to get.
* @param string $table Table to retrieve the data.
* @param string $field_search Field to filter elements.
* @param string $condition Condition the field must have.
* @param boolean $search_history_db Search in historical db.
* @param boolean $cache Enable cache or not.
*
* @return mixed Value of first column of the first row. False if there were no row.
*/
function mysql_db_get_value($field, $table, $field_search=1, $condition=1, $search_history_db=false)
{
function mysql_db_get_value(
$field,
$table,
$field_search=1,
$condition=1,
$search_history_db=false,
$cache=true
) {
if (is_int($condition)) {
$sql = sprintf(
'SELECT %s FROM %s WHERE %s = %d LIMIT 1',
@ -195,7 +203,7 @@ function mysql_db_get_value($field, $table, $field_search=1, $condition=1, $sear
);
}
$result = db_get_all_rows_sql($sql, $search_history_db);
$result = db_get_all_rows_sql($sql, $search_history_db, $cache);
if ($result === false) {
return false;

View File

@ -72,15 +72,23 @@ function oracle_connect_db($host=null, $db=null, $user=null, $pass=null, $port=n
/**
* Get the first value of the first row of a table in the database.
*
* @param string Field name to get
* @param string Table to retrieve the data
* @param string Field to filter elements
* @param string Condition the field must have
* @param string $field Field name to get.
* @param string $table Table to retrieve the data.
* @param string $field_search Field to filter elements.
* @param string $condition Condition the field must have.
* @param boolean $search_history_db Search in historical db.
* @param boolean $cache Enable cache or not.
*
* @return mixed Value of first column of the first row. False if there were no row.
*/
function oracle_db_get_value($field, $table, $field_search=1, $condition=1, $search_history_db=false)
{
function oracle_db_get_value(
$field,
$table,
$field_search=1,
$condition=1,
$search_history_db=false,
$cache=false
) {
if (is_int($condition)) {
$sql = sprintf(
'SELECT *
@ -113,7 +121,7 @@ function oracle_db_get_value($field, $table, $field_search=1, $condition=1, $sea
);
}
$result = db_get_all_rows_sql($sql, $search_history_db);
$result = db_get_all_rows_sql($sql, $search_history_db, $cache);
if ($result === false) {
return false;

View File

@ -53,15 +53,23 @@ function postgresql_connect_db($host=null, $db=null, $user=null, $pass=null, $po
/**
* Get the first value of the first row of a table in the database.
*
* @param string Field name to get
* @param string Table to retrieve the data
* @param string Field to filter elements
* @param string Condition the field must have
* @param string $field Field name to get.
* @param string $table Table to retrieve the data.
* @param string $field_search Field to filter elements.
* @param string $condition Condition the field must have.
* @param boolean $search_history_db Search in historical db.
* @param boolean $cache Enable cache or not.
*
* @return mixed Value of first column of the first row. False if there were no row.
*/
function postgresql_db_get_value($field, $table, $field_search=1, $condition=1, $search_history_db=false)
{
function postgresql_db_get_value(
$field,
$table,
$field_search=1,
$condition=1,
$search_history_db=false,
$cache=true
) {
if ($field_search[0] == '`') {
$field_search = str_replace('`', '', $field_search);
}
@ -92,7 +100,7 @@ function postgresql_db_get_value($field, $table, $field_search=1, $condition=1,
);
}
$result = db_get_all_rows_sql($sql, $search_history_db);
$result = db_get_all_rows_sql($sql, $search_history_db, $cache);
if ($result === false) {
return false;

View File

@ -328,30 +328,35 @@ $sql_cache = ['saved' => []];
/**
* Get the first value of the first row of a table in the database.
*
* @param string Field name to get
* @param string Table to retrieve the data
* @param string Field to filter elements
* @param string Condition the field must have
* @param string $field Field name to get.
* @param string $table Table to retrieve the data.
* @param string $field_search Field to filter elements.
* @param string $condition Condition the field must have.
* @param boolean $search_history_db Search in historical db.
* @param boolean $cache Enable cache or not.
*
* @return mixed Value of first column of the first row. False if there were no row.
*/
function db_get_value($field, $table, $field_search=1, $condition=1, $search_history_db=false)
{
function db_get_value(
$field,
$table,
$field_search=1,
$condition=1,
$search_history_db=false,
$cache=true
) {
global $config;
switch ($config['dbtype']) {
case 'mysql':
return mysql_db_get_value($field, $table, $field_search, $condition, $search_history_db);
default:
return mysql_db_get_value($field, $table, $field_search, $condition, $search_history_db, $cache);
break;
case 'postgresql':
return postgresql_db_get_value($field, $table, $field_search, $condition, $search_history_db);
return postgresql_db_get_value($field, $table, $field_search, $condition, $search_history_db, $cache);
break;
case 'oracle':
return oracle_db_get_value($field, $table, $field_search, $condition, $search_history_db);
break;
return oracle_db_get_value($field, $table, $field_search, $condition, $search_history_db, $cache);
}
}
@ -567,30 +572,32 @@ function db_get_sql($sql, $field=0, $search_history_db=false)
/**
* Get all the result rows using an SQL statement.
*
* @param string SQL statement to execute.
* @param bool If want to search in history database also
* @param bool If want to use cache (true by default)
* @param string $sql SQL statement to execute.
* @param boolean $search_history_db If want to search in history database also.
* @param boolean $cache If want to use cache (true by default).
* @param mixed $dbconnection Use custom database connection (false default).
*
* @return mixed A matrix with all the values returned from the SQL statement or
* false in case of empty result
*/
function db_get_all_rows_sql($sql, $search_history_db=false, $cache=true, $dbconnection=false)
{
function db_get_all_rows_sql(
$sql,
$search_history_db=false,
$cache=true,
$dbconnection=false
) {
global $config;
switch ($config['dbtype']) {
case 'mysql':
default:
return mysql_db_get_all_rows_sql($sql, $search_history_db, $cache, $dbconnection);
break;
case 'postgresql':
return postgresql_db_get_all_rows_sql($sql, $search_history_db, $cache, $dbconnection);
break;
case 'oracle':
return oracle_db_get_all_rows_sql($sql, $search_history_db, $cache, $dbconnection);
break;
}
}

View File

@ -4170,6 +4170,65 @@ function ui_forced_public_url()
}
/**
* Returns a full built url for given section.
*
* @param string $url
* @return void
*/
function ui_get_meta_url($url)
{
global $config;
if (is_metaconsole() === true) {
return ui_get_full_url($url);
}
$mc_db_conn = \enterprise_hook(
'metaconsole_load_external_db',
[
[
'dbhost' => $config['replication_dbhost'],
'dbuser' => $config['replication_dbuser'],
'dbpass' => \io_output_password(
$config['replication_dbpass']
),
'dbname' => $config['replication_dbname'],
],
]
);
if ($mc_db_conn === NOERR) {
$public_url_meta = \db_get_value(
'value',
'tconfig',
'token',
'public_url',
false,
false
);
// Restore the default connection.
\enterprise_hook('metaconsole_restore_db');
if (empty($public_url_meta) === false
&& $public_url_meta !== $config['metaconsole_base_url']
) {
config_update_value(
'metaconsole_base_url',
$public_url_meta
);
}
}
if (isset($config['metaconsole_base_url']) === true) {
return $config['metaconsole_base_url'].'enterprise/meta/'.$url;
}
return $url;
}
/**
* Returns a full URL in Pandora. (with the port and https in some systems)
*

View File

@ -238,7 +238,12 @@ $is_management_allowed = true;
if (is_management_allowed() === false) {
$is_management_allowed = false;
ui_print_warning_message(
__('This node is configured with centralized mode. All users information is read only. Go to metaconsole to manage it.')
__(
'This node is configured with centralized mode. All users information is read only. Go to %s to manage it.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/users_setup&tab=user&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
}