fixed errors in policies metaconsole

This commit is contained in:
daniel 2018-07-26 12:41:09 +02:00
parent fb73a0b8b2
commit 3985316a9b
3 changed files with 72 additions and 38 deletions

View File

@ -832,19 +832,36 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f
$data = array ();
if (!defined('METACONSOLE')) {
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
if(is_metaconsole()){
$node = metaconsole_get_connection_by_id($alert['server_data']['id']);
if (metaconsole_load_external_db($node) !== NOERR) {
// Restore the default connection.
metaconsole_restore_db();
$errors++;
break;
}
}
$policyInfo = policies_is_alert_in_policy2($alert['id'], false);
if ($policyInfo === false)
$data[$index['policy']] = '';
else {
$img = 'images/policies.png';
if(!is_metaconsole()){
$data[$index['policy']] = '<a href="?sec=gmodules&amp;sec2=enterprise/godmode/policies/policies&amp;id=' . $policyInfo['id'] . '">' .
html_print_image($img,true, array('title' => $policyInfo['name'])) .
'</a>';
}else{
$data[$index['policy']] = '<a href="?sec=gmodules&amp;sec2=advanced/policymanager&amp;id=' . $policyInfo['id'] . '">' .
html_print_image($img,true, array('title' => $policyInfo['name'])) .
'</a>';
}
}
if(is_metaconsole()){
metaconsole_restore_db();
}
}
// Standby
@ -882,7 +899,7 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f
$id_agent = modules_get_agentmodule_agent ($alert["id_agent_module"]);
}
if (defined('METACONSOLE') && !can_user_access_node ()) {
if (defined('METACONSOLE') || !can_user_access_node ()) {
$data[$index['agent_name']] = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '[&hellip;]', 'font-size:7.5pt;');
}
else {

View File

@ -449,10 +449,8 @@ $table->align = array ();
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
if ($print_agent) {
if (!is_metaconsole()) {
$table->head[0] = "<span title='" . __('Policy') . "'>" .
__('P.') . "</span>";
}
$table->head[0] = "<span title='" . __('Policy') . "'>" . __('P.') . "</span>";
$table->head[1] = "<span title='" . __('Standby') . "'>" .
__('S.') . "</span>";
@ -496,9 +494,7 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
}
}
else {
if (!is_metaconsole()) {
$table->head[0] = "<span title='" . __('Policy') . "'>" . __('P.') . "</span>";
}
$table->head[1] = "<span title='" . __('Standby') . "'>" . __('S.') . "</span>";

View File

@ -1043,7 +1043,18 @@ if (!empty($result)) {
$data = array ();
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
if(is_metaconsole()){
$node = metaconsole_get_connection_by_id($row['server_id']);
if (metaconsole_load_external_db($node) !== NOERR) {
// Restore the default connection.
metaconsole_restore_db();
$errors++;
break;
}
}
$policyInfo = policies_info_module_policy($row['id_agente_modulo']);
if ($policyInfo === false)
$data[0] = '';
else {
@ -1074,13 +1085,23 @@ if (!empty($result)) {
$title = __('(Unlinked) ') . $policyInfo['name_policy'];
}
}
if(is_metaconsole()){
$data[0] = '<a href="?sec=gmodules&amp;sec2=advanced/policymanager&amp;id=' . $policyInfo['id_policy'] . '">' .
html_print_image($img,true, array('title' => $title)) .
'</a>';
}
else{
$data[0] = '<a href="?sec=gmodules&amp;sec2=enterprise/godmode/policies/policies&amp;id=' . $policyInfo['id_policy'] . '">' .
html_print_image($img,true, array('title' => $title)) .
'</a>';
}
}
if(is_metaconsole()){
metaconsole_restore_db();
}
}
$agent_alias = !empty($row['agent_alias']) ? $row['agent_alias'] : $row['agent_name'];
// TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view