2013-03-11 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_tags.php: fixed the function "tags_get_acl_tags_module_condition" when the user profile is in the all group. * include/functions_reporting.php, include/functions_alerts.php, operation/agentes/estado_monitores.php: improve the code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7826 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
3bd61d3c01
commit
c715ec8231
|
@ -1,3 +1,12 @@
|
|||
2013-03-11 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_tags.php: fixed the function
|
||||
"tags_get_acl_tags_module_condition" when the user profile is in
|
||||
the all group.
|
||||
|
||||
* include/functions_reporting.php, include/functions_alerts.php,
|
||||
operation/agentes/estado_monitores.php: improve the code style.
|
||||
|
||||
2013-03-11 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/agentes/module_manager_editor_common.php: show only the
|
||||
|
|
|
@ -1167,7 +1167,7 @@ function alerts_validate_alert_agent_module ($id_alert_agent_module, $noACLs = f
|
|||
$warning_instructions = db_get_value('warning_instructions', 'tagente_modulo', 'id_agente_modulo', $agent_id);
|
||||
$unknown_instructions = db_get_value('unknown_instructions', 'tagente_modulo', 'id_agente_modulo', $agent_id);
|
||||
|
||||
if (!$noACLs){
|
||||
if (!$noACLs) {
|
||||
if (! check_acl ($config['id_user'], $group_id, "AW")) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1176,12 +1176,12 @@ function alerts_validate_alert_agent_module ($id_alert_agent_module, $noACLs = f
|
|||
array ('times_fired' => 0,
|
||||
'internal_counter' => 0),
|
||||
array ('id' => $id));
|
||||
|
||||
|
||||
|
||||
if ($result > 0) {
|
||||
// Update fired alert count on the agent
|
||||
db_process_sql(sprintf('UPDATE tagente SET fired_count=fired_count-1 WHERE id_agente = %d', $agent_id));
|
||||
|
||||
|
||||
events_create_event ("Manual validation of alert for ".
|
||||
alerts_get_alert_template_description ($alert["id_alert_template"]),
|
||||
$group_id, $agent_id, 1, $config["id_user"],
|
||||
|
|
|
@ -5382,7 +5382,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
foreach ($data_exceptions as $dex) {
|
||||
$data_hbar[$agent_name[$j]]['g'] = $dex;
|
||||
$data_pie_graph[$agent_name[$j]] = $dex;
|
||||
if ($show_graph == 0 || $show_graph == 1) {
|
||||
if ($show_graph == 0 || $show_graph == 1) {
|
||||
$data = array();
|
||||
$data[0] = $agent_name[$j];
|
||||
$data[1] = $module_name[$j];
|
||||
|
|
|
@ -647,6 +647,7 @@ function tags_get_tags_formatted ($tags_array, $get_url = true) {
|
|||
|
||||
function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = 'module_condition', $query_prefix = '', $query_table = '') {
|
||||
global $config;
|
||||
|
||||
if($id_user == false) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
@ -663,49 +664,49 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = '
|
|||
}
|
||||
}
|
||||
|
||||
if((string)$id_group === "0") {
|
||||
if ((string)$id_group === "0") {
|
||||
$id_group = array_keys(users_get_groups($id_user, $access, false));
|
||||
|
||||
if(empty($id_group)) {
|
||||
|
||||
if (empty($id_group)) {
|
||||
return ERR_WRONG_PARAMETERS;
|
||||
}
|
||||
}
|
||||
elseif(empty($id_group)) {
|
||||
elseif (empty($id_group)) {
|
||||
return ERR_WRONG_PARAMETERS;
|
||||
}
|
||||
elseif(!is_array($id_group)) {
|
||||
elseif (!is_array($id_group)) {
|
||||
$id_group = (array) $id_group;
|
||||
}
|
||||
|
||||
|
||||
$acl_column = get_acl_column($access);
|
||||
|
||||
if(empty($acl_column)) {
|
||||
if (empty($acl_column)) {
|
||||
return ERR_WRONG_PARAMETERS;
|
||||
}
|
||||
|
||||
$query = sprintf("SELECT tags, id_grupo
|
||||
FROM tusuario_perfil, tperfil
|
||||
WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND
|
||||
tusuario_perfil.id_usuario = '%s' AND
|
||||
tperfil.%s = 1 AND
|
||||
tusuario_perfil.id_usuario = '%s' AND
|
||||
tperfil.%s = 1 AND
|
||||
(tusuario_perfil.id_grupo IN (%s) OR tusuario_perfil.id_grupo = 0)
|
||||
ORDER BY id_grupo", $id_user, $acl_column, implode(',',$id_group));
|
||||
$tags = db_get_all_rows_sql($query);
|
||||
|
||||
// If not profiles returned, the user havent acl permissions
|
||||
if(empty($tags)) {
|
||||
if (empty($tags)) {
|
||||
return ERR_ACL;
|
||||
}
|
||||
|
||||
// Array to store groups where there arent tags restriction
|
||||
$non_restriction_groups = array();
|
||||
|
||||
|
||||
$acltags = array();
|
||||
foreach($tags as $tagsone) {
|
||||
if(empty($tagsone['tags'])) {
|
||||
foreach ($tags as $tagsone) {
|
||||
if (empty($tagsone['tags'])) {
|
||||
// If there arent tags restriction in all groups (group 0), return no condition
|
||||
if($tagsone['id_grupo'] == 0) {
|
||||
switch($return_mode) {
|
||||
if ($tagsone['id_grupo'] == 0) {
|
||||
switch ($return_mode) {
|
||||
case 'data':
|
||||
return array();
|
||||
break;
|
||||
|
@ -722,7 +723,7 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = '
|
|||
|
||||
$tags_array = explode(',',$tagsone['tags']);
|
||||
|
||||
if(!isset($acltags[$tagsone['id_grupo']])) {
|
||||
if (!isset($acltags[$tagsone['id_grupo']])) {
|
||||
$acltags[$tagsone['id_grupo']] = $tags_array;
|
||||
}
|
||||
else {
|
||||
|
@ -731,13 +732,13 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = '
|
|||
}
|
||||
|
||||
// Delete the groups without tag restrictions from the acl tags array
|
||||
foreach($non_restriction_groups as $nrgroup) {
|
||||
if(isset($acltags[$nrgroup])) {
|
||||
foreach ($non_restriction_groups as $nrgroup) {
|
||||
if (isset($acltags[$nrgroup])) {
|
||||
unset($acltags[$nrgroup]);
|
||||
}
|
||||
}
|
||||
|
||||
switch($return_mode) {
|
||||
|
||||
switch ($return_mode) {
|
||||
case 'data':
|
||||
// Stop here and return the array
|
||||
return $acltags;
|
||||
|
@ -745,7 +746,7 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = '
|
|||
case 'module_condition':
|
||||
// Return the condition of the tags for tagente_modulo table
|
||||
$condition = tags_get_acl_tags_module_condition($acltags, $query_table);
|
||||
if(!empty($condition)) {
|
||||
if (!empty($condition)) {
|
||||
return " $query_prefix ".$condition;
|
||||
}
|
||||
break;
|
||||
|
@ -771,28 +772,37 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = '
|
|||
*/
|
||||
|
||||
function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
|
||||
if(!empty($modules_table)) {
|
||||
if (!empty($modules_table)) {
|
||||
$modules_table .= '.';
|
||||
}
|
||||
|
||||
$condition = '';
|
||||
foreach($acltags as $group_id => $group_tags) {
|
||||
if($condition != '') {
|
||||
foreach ($acltags as $group_id => $group_tags) {
|
||||
if ($condition != '') {
|
||||
$condition .= ' OR ';
|
||||
}
|
||||
|
||||
// Group condition (The module belongs to an agent of the group X)
|
||||
$group_condition = sprintf('%sid_agente IN (SELECT id_agente FROM tagente WHERE id_grupo = %d)', $modules_table, $group_id);
|
||||
if (!array_key_exists(0, array_keys($acltags))) {
|
||||
$group_condition = sprintf('%sid_agente IN (SELECT id_agente FROM tagente WHERE id_grupo = %d)', $modules_table, $group_id);
|
||||
}
|
||||
else {
|
||||
//Avoid the user profiles with all group access.
|
||||
$group_condition = " 1 = 1 ";
|
||||
}
|
||||
// Tags condition (The module has at least one of the restricted tags)
|
||||
$tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, implode(',',$group_tags));
|
||||
|
||||
$condition .= "($group_condition AND \n$tags_condition)\n";
|
||||
}
|
||||
|
||||
if(!empty($condition)) {
|
||||
|
||||
//Avoid the user profiles with all group access.
|
||||
//if (!empty($condition)) {
|
||||
if (!empty($condition) &&
|
||||
!array_key_exists(0, array_keys($acltags))) {
|
||||
$condition = sprintf("\n((%s) OR %sid_agente NOT IN (SELECT id_agente FROM tagente WHERE id_grupo IN (%s)))", $condition, $modules_table, implode(',',array_keys($acltags)));
|
||||
}
|
||||
|
||||
|
||||
return $condition;
|
||||
}
|
||||
|
||||
|
|
|
@ -152,7 +152,8 @@ switch ($config["dbtype"]) {
|
|||
break;
|
||||
}
|
||||
|
||||
$tags_sql = tags_get_acl_tags($config['id_user'], $agent['id_grupo'], 'AR', 'module_condition', 'AND', 'tagente_modulo');
|
||||
$tags_sql = tags_get_acl_tags($config['id_user'],
|
||||
$agent['id_grupo'], 'AR', 'module_condition', 'AND', 'tagente_modulo');
|
||||
|
||||
$status_filter_monitor = (int)get_parameter('status_filter_monitor', -1);
|
||||
$status_text_monitor = get_parameter('status_text_monitor', '');
|
||||
|
@ -565,7 +566,8 @@ foreach ($modules as $module) {
|
|||
</script>
|
||||
<?php
|
||||
|
||||
echo "<h4 style='padding-top:0px !important;'>".__('Full list of monitors')."</h4>";
|
||||
echo "<h4 style='padding-top:0px !important;'>" .
|
||||
__('Full list of monitors') . "</h4>";
|
||||
|
||||
print_form_filter_monitors($status_filter_monitor, $status_text_monitor);
|
||||
if (empty ($table->data)) {
|
||||
|
|
Loading…
Reference in New Issue