fixed error in ACL
This commit is contained in:
parent
638d7ced30
commit
5d61ff5056
|
@ -53,7 +53,7 @@ class Tree {
|
|||
|
||||
$this->strictACL = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
|
||||
|
||||
$this->acltags = tags_get_user_module_and_tags($config['id_user'], $this->access);
|
||||
$this->acltags = tags_get_user_groups_and_tags($config['id_user'], $this->access);
|
||||
}
|
||||
|
||||
public function setFilter($filter) {
|
||||
|
|
|
@ -1645,10 +1645,19 @@ function config_process_config () {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($config['id_user']))
|
||||
$relative_path = enterprise_hook('skins_set_image_skin_path',array($config['id_user']));
|
||||
else
|
||||
$relative_path = enterprise_hook('skins_set_image_skin_path',array(get_parameter('nick')));
|
||||
if(!is_metaconsole()) {
|
||||
// Skins are available only in console mode
|
||||
|
||||
if (isset($config['id_user'])){
|
||||
$relative_path = enterprise_hook('skins_set_image_skin_path',array($config['id_user']));
|
||||
}
|
||||
else{
|
||||
$relative_path = enterprise_hook('skins_set_image_skin_path',array(get_parameter('nick')));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$relative_path = '';
|
||||
}
|
||||
$config['relative_path'] = $relative_path;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -573,7 +573,7 @@ function groups_get_status ($id_group = 0, $strict_user = false) {
|
|||
require_once ($config['homedir'].'/include/functions_reporting.php');
|
||||
|
||||
if ($strict_user) {
|
||||
$acltags = tags_get_user_module_and_tags ($config['id_user'], 'AR', $strict_user);
|
||||
$acltags = tags_get_user_groups_and_tags ($config['id_user'], 'AR', $strict_user);
|
||||
$group_status = group_get_data ($config['id_user'], $strict_user, $acltags, false, 'group');
|
||||
$data['monitor_alerts_fired'] = $groups_status['_monitors_alerts_fired_'];
|
||||
$data['agent_critical'] = $groups_status['_agents_critical_'];
|
||||
|
@ -3010,7 +3010,7 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access =
|
|||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
$acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict);
|
||||
$acltags = tags_get_user_groups_and_tags ($id_user, $access, $user_strict);
|
||||
|
||||
// If using metaconsole, the strict users will use the agent table of every node
|
||||
if (is_metaconsole() && $user_strict) {
|
||||
|
|
|
@ -24,14 +24,13 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||
}
|
||||
|
||||
$user_groups = array();
|
||||
$groups_without_tags = array();
|
||||
foreach ($acltags as $group => $tags) {
|
||||
if ($user_strict) { //Remove groups with tags
|
||||
$groups_without_tags[$group] = $group;
|
||||
}
|
||||
$user_groups[$group] = groups_get_name($group);
|
||||
if ($tags != '') {
|
||||
$tags_group = explode(',', $tags);
|
||||
$user_tags = array();
|
||||
|
||||
foreach ($acltags as $item) {
|
||||
$user_groups[$item["id_grupo"]] = $item["nombre"];
|
||||
|
||||
if ($item["tags"] != '') {
|
||||
$tags_group = explode(',', $item["tags"]);
|
||||
|
||||
foreach ($tags_group as $tag) {
|
||||
$user_tags[$tag] = tags_get_name($tag);
|
||||
|
@ -39,12 +38,7 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||
}
|
||||
}
|
||||
|
||||
if ($user_strict) {
|
||||
$user_groups_ids = implode(',', array_keys($groups_without_tags));
|
||||
}
|
||||
else {
|
||||
$user_groups_ids = implode(',', array_keys($acltags));
|
||||
}
|
||||
$user_groups_ids = implode(',', array_keys($acltags));
|
||||
|
||||
if (!empty($user_groups_ids)) {
|
||||
if (is_metaconsole() && (!$user_strict)) {
|
||||
|
@ -380,7 +374,8 @@ function groupview_status_modules_agents($id_user = false, $user_strict = false,
|
|||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
$acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict);
|
||||
//$acltags = tags_get_user_groups_and_tags ($id_user, $access, $user_strict);
|
||||
$acltags = users_get_groups ($id_user, $access, true, true);
|
||||
|
||||
// If using metaconsole, the strict users will use the agent table of every node
|
||||
if (is_metaconsole() && $user_strict) {
|
||||
|
@ -526,7 +521,11 @@ function groupview_get_groups_list($id_user = false, $user_strict = false, $acce
|
|||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
$acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict);
|
||||
//$acltags = tags_get_user_groups_and_tags ($id_user, $access, $user_strict);
|
||||
//
|
||||
|
||||
|
||||
$acltags = users_get_groups($id_user, $access, true, true);
|
||||
|
||||
// If using metaconsole, the strict users will use the agent table of every node
|
||||
if (is_metaconsole() && $user_strict) {
|
||||
|
@ -575,19 +574,15 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
if ($id_user == false) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
$groups_with_privileges = users_get_groups($id_user, $access);
|
||||
$groups_with_privileges = implode('","', $groups_with_privileges);
|
||||
|
||||
|
||||
$user_groups = array();
|
||||
$user_tags = array();
|
||||
$groups_without_tags = array();
|
||||
foreach ($acltags as $group => $tags) {
|
||||
if ($user_strict) { //Remove groups with tags
|
||||
$groups_without_tags[$group] = $group;
|
||||
}
|
||||
$user_groups[$group] = groups_get_name($group);
|
||||
if ($tags != '') {
|
||||
$tags_group = explode(',', $tags);
|
||||
$user_tags = array();
|
||||
|
||||
foreach ($acltags as $item) {
|
||||
$user_groups[$item["id_grupo"]] = $item["nombre"];
|
||||
|
||||
if ($item["tags"] != '') {
|
||||
$tags_group = explode(',', $item["tags"]);
|
||||
|
||||
foreach ($tags_group as $tag) {
|
||||
$user_tags[$tag] = tags_get_name($tag);
|
||||
|
@ -595,15 +590,12 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
}
|
||||
}
|
||||
|
||||
$groups_with_privileges = implode(',', array_keys($acltags));
|
||||
|
||||
if (!$user_strict)
|
||||
$acltags[0] = 0;
|
||||
|
||||
if ($user_strict) {
|
||||
$user_groups_ids = implode(',', array_keys($groups_without_tags));
|
||||
}
|
||||
else {
|
||||
$user_groups_ids = implode(',', array_keys($acltags));
|
||||
}
|
||||
$user_groups_ids = implode(',', array_keys($acltags));
|
||||
|
||||
if (!empty($user_groups_ids)) {
|
||||
if (is_metaconsole() && (!$user_strict)) {
|
||||
|
@ -700,7 +692,7 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $fathers_id . ")
|
||||
AND nombre IN (\"". $groups_with_privileges ."\")
|
||||
AND id_grupo IN (" . $groups_with_privileges . ")
|
||||
ORDER BY nombre COLLATE utf8_general_ci ASC");
|
||||
if (!empty($list_father_groups)) {
|
||||
//Merges the arrays and eliminates the duplicates groups
|
||||
|
@ -763,17 +755,20 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
COUNT(*) AS _total_agents_, id_grupo, intervalo,
|
||||
ultimo_contacto, disabled
|
||||
FROM tmetaconsole_agent WHERE id_grupo = " . $group['id_grupo'] . " AND disabled = 0 GROUP BY id_grupo");
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = (int)$group_agents['_monitors_critical_'];
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = (int)$group_agents['_monitors_warning_'];
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = (int)$group_agents['_monitors_unknown_'];
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = (int)$group_agents['_monitors_not_init_'];
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = (int)$group_agents['_monitors_ok_'];
|
||||
|
||||
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = (int)$group_agents['_monitors_critical_'];
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = (int)$group_agents['_monitors_warning_'];
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = (int)$group_agents['_monitors_unknown_'];
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = (int)$group_agents['_monitors_not_init_'];
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = (int)$group_agents['_monitors_ok_'];
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = (int)$group_agents['_monitors_alerts_fired_'];
|
||||
|
||||
$list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_'];
|
||||
|
||||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
$list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_'];
|
||||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"]
|
||||
+ $list[$group['id_grupo']]["_monitors_unknown_"]
|
||||
+ $list[$group['id_grupo']]["_monitors_warning_"]
|
||||
+ $list[$group['id_grupo']]["_monitors_critical_"]
|
||||
+ $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
|
||||
if ($group['icon'])
|
||||
$list[$group['id_grupo']]["_iconImg_"] = html_print_image ("images/".$group['icon'].".png", true, array ("style" => 'vertical-align: middle;'));
|
||||
|
|
|
@ -317,7 +317,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||
$fields = array ('tagente.id_grupo, tagente.nombre, tagente.id_os, tagente.id_parent, tagente.id_agente,
|
||||
tagente.normal_count, tagente.warning_count, tagente.critical_count,
|
||||
tagente.unknown_count, tagente.total_count, tagente.notinit_count');
|
||||
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
|
||||
$acltags = tags_get_user_groups_and_tags ($config['id_user'],'AR', $strict_user);
|
||||
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
|
||||
}
|
||||
else {
|
||||
|
@ -343,7 +343,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||
$fields = array ('tagente.id_grupo, tagente.nombre, tagente.id_os, tagente.id_parent, tagente.id_agente,
|
||||
tagente.normal_count, tagente.warning_count, tagente.critical_count,
|
||||
tagente.unknown_count, tagente.total_count, tagente.notinit_count');
|
||||
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
|
||||
$acltags = tags_get_user_groups_and_tags ($config['id_user'],'AR', $strict_user);
|
||||
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
|
||||
}
|
||||
else {
|
||||
|
@ -625,7 +625,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0,
|
|||
global $config;
|
||||
|
||||
if ($strict_user) {
|
||||
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
|
||||
$acltags = tags_get_user_groups_and_tags ($config['id_user'],'AR', $strict_user);
|
||||
}
|
||||
$parents = array();
|
||||
$orphans = array();
|
||||
|
@ -1003,7 +1003,7 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu
|
|||
|
||||
if ($strict_user) {
|
||||
require_once($config['homedir']."/include/functions_tags.php");
|
||||
$acltags = tags_get_user_module_and_tags ($config["id_user"], 'AR', $strict_user);
|
||||
$acltags = tags_get_user_groups_and_tags ($config["id_user"], 'AR', $strict_user);
|
||||
|
||||
$agent_filter = array("id" => $agent["id_agente"]);
|
||||
$strict_data['normal_count'] = (int) groups_get_normal_monitors ($agent['id_grupo'], $agent_filter, array(), $strict_user, $acltags);
|
||||
|
@ -1798,7 +1798,7 @@ function networkmap_get_new_nodes_from_ip_mask($ip_mask,
|
|||
if ($strict_user) {
|
||||
$filter['group_by'] = 'tagente.id_agente';
|
||||
$fields = array ('tagente.id_agente');
|
||||
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
|
||||
$acltags = tags_get_user_groups_and_tags ($config['id_user'],'AR', $strict_user);
|
||||
$user_agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
|
||||
|
||||
foreach ($all_user_agents as $agent) {
|
||||
|
|
|
@ -8713,7 +8713,7 @@ function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent', $
|
|||
|
||||
if ($strict_user && $type == 'agent') {
|
||||
|
||||
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
|
||||
$acltags = tags_get_user_groups_and_tags ($config['id_user'],'AR', $strict_user);
|
||||
$filter['disabled'] = 0;
|
||||
$id_agent = $counts_info['id_agente'];
|
||||
|
||||
|
|
|
@ -427,7 +427,7 @@ function tactical_status_modules_agents($id_user = false, $user_strict = false,
|
|||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
$acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict);
|
||||
$acltags = tags_get_user_groups_and_tags ($id_user, $access, $user_strict);
|
||||
|
||||
// If using metaconsole, the strict users will use the agent table of every node
|
||||
if (is_metaconsole() && $user_strict) {
|
||||
|
|
|
@ -670,30 +670,19 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR',
|
|||
return ERR_WRONG_PARAMETERS;
|
||||
}
|
||||
|
||||
$acltags = tags_get_user_module_and_tags($id_user, $access);
|
||||
|
||||
// Delete the groups without tag restrictions from the acl tags array if $force_group_and_tag == false
|
||||
// Delete the groups that aren't in the received groups id
|
||||
$acltags_aux = array();
|
||||
|
||||
if (!empty($groups) && in_array(0, $groups)) {
|
||||
$acltags_aux[0] = "";
|
||||
}
|
||||
foreach ($acltags as $group_id => $tags) {
|
||||
if (!empty($groups) && array_search($group_id, $groups) === false) {
|
||||
unset($acltags[$group_id]);
|
||||
$raw_acltags = tags_get_user_groups_and_tags($id_user, $access);
|
||||
|
||||
$acltags = array();
|
||||
foreach ($raw_acltags as $group => $taglist) {
|
||||
if (!empty($taglist)) {
|
||||
$acltags[$group] = explode(',', $taglist);
|
||||
}
|
||||
else {
|
||||
if (!empty($tags))
|
||||
$tags = explode(",", $tags);
|
||||
$acltags_aux[$group_id] = $tags;
|
||||
$acltags[$group] = '';
|
||||
}
|
||||
}
|
||||
// Clean the possible empty elements
|
||||
if (!$force_group_and_tag)
|
||||
$acltags_aux = array_filter($acltags_aux);
|
||||
$acltags = $acltags_aux;
|
||||
|
||||
|
||||
switch ($return_mode) {
|
||||
case 'data':
|
||||
// Stop here and return the array
|
||||
|
@ -711,6 +700,7 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR',
|
|||
case 'event_condition':
|
||||
// Return the condition of the tags for tevento table
|
||||
$condition = tags_get_acl_tags_event_condition($acltags, $meta, $force_group_and_tag);
|
||||
|
||||
if (!empty($condition)) {
|
||||
return " $query_prefix " . "(" . $condition . ")";
|
||||
}
|
||||
|
@ -735,7 +725,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
|
|||
$group_conditions = array();
|
||||
|
||||
// The acltags array contains the groups with the acl propagation applied
|
||||
// after the changes done into the 'tags_get_user_module_and_tags' function.
|
||||
// after the changes done into the 'tags_get_user_groups_and_tags' function.
|
||||
foreach ($acltags as $group_id => $group_tags) {
|
||||
$tag_join = '';
|
||||
if (!empty($group_tags)) {
|
||||
|
@ -859,83 +849,84 @@ function tags_get_acl_tags_event_condition($acltags, $meta = false, $force_group
|
|||
|
||||
// Juanma (08/05/2014) Fix : Will have all groups retrieved (also propagated ones)
|
||||
$_groups_not_in = '';
|
||||
|
||||
foreach ($acltags as $group_id => $group_tags) {
|
||||
// Group condition (The module belongs to an agent of the group X)
|
||||
// Juanma (08/05/2014) Fix : Get all groups (children also, Propagate ACL func!)
|
||||
$group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_id_recursive($group_id, true))));
|
||||
$_groups_not_in .= implode(',', array_values(groups_get_id_recursive($group_id))) . ',';
|
||||
|
||||
// Tags condition (The module has at least one of the restricted tags)
|
||||
$tags_condition = '';
|
||||
if (empty($group_tags)) {
|
||||
$tags_condition = "id_grupo = ".$group_id;
|
||||
}
|
||||
else {
|
||||
if (!is_array($group_tags)) {
|
||||
$group_tags = explode(',', $group_tags);
|
||||
|
||||
if($acltags[0]){
|
||||
foreach ($acltags as $group_id => $group_tags) {
|
||||
// Group condition (The module belongs to an agent of the group X)
|
||||
$group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_id_recursive($group_id, true))));
|
||||
//$_groups_not_in .= implode(',', array_values(groups_get_id_recursive($group_id))) . ',';
|
||||
|
||||
// Tags condition (The module has at least one of the restricted tags)
|
||||
$tags_condition = '';
|
||||
if (empty($group_tags)) {
|
||||
$tags_condition = "id_grupo = ".$group_id;
|
||||
}
|
||||
else {
|
||||
if (!is_array($group_tags)) {
|
||||
$group_tags = explode(',', $group_tags);
|
||||
}
|
||||
|
||||
foreach ($group_tags as $tag) {
|
||||
// If the tag ID doesnt exist, ignore
|
||||
if (!isset($all_tags[$tag])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($tags_condition != '') {
|
||||
$tags_condition .= " OR \n";
|
||||
}
|
||||
|
||||
//~ // Add as condition all the posibilities of the serialized tags
|
||||
//~ $tags_condition .= sprintf('tags LIKE "%s,%%"',io_safe_input($all_tags[$tag]));
|
||||
//~ $tags_condition .= sprintf(' OR tags LIKE "%%,%s,%%"',io_safe_input($all_tags[$tag]));
|
||||
//~ $tags_condition .= sprintf(' OR tags LIKE "%%,%s"',io_safe_input($all_tags[$tag]));
|
||||
//~ $tags_condition .= sprintf(' OR tags LIKE "%s %%"',io_safe_input($all_tags[$tag]));
|
||||
//~ $tags_condition .= sprintf(' OR tags LIKE "%%,%s %%"',io_safe_input($all_tags[$tag]));
|
||||
|
||||
if ($force_group_and_tag) {
|
||||
if (!empty($all_tags[$tag])) {
|
||||
if ($force_equal) {
|
||||
$tags_condition .= sprintf('(tags = "%s"',io_safe_input($all_tags[$tag]));
|
||||
} else {
|
||||
$tags_condition .= "(tags LIKE '%".io_safe_input($all_tags[$tag])."%'";
|
||||
}
|
||||
$childrens = groups_get_childrens($group_id, null, true);
|
||||
|
||||
if (empty($childrens)) {
|
||||
$tags_condition .= sprintf(' AND id_grupo = %d )', $group_id);
|
||||
} else {
|
||||
$childrens_ids[] = $group_id;
|
||||
foreach ($childrens as $child) {
|
||||
$childrens_ids[] = (int)$child['id_grupo'];
|
||||
}
|
||||
$ids_str = implode(',', $childrens_ids);
|
||||
|
||||
$tags_condition .= sprintf(' AND id_grupo IN (%s) )', $ids_str);
|
||||
}
|
||||
} else {
|
||||
$tags_condition .= "id_grupo = ".$group_id;
|
||||
}
|
||||
} else {
|
||||
if ($force_equal) {
|
||||
$tags_condition .= sprintf('tags = "%s"',io_safe_input($all_tags[$tag]));
|
||||
} else {
|
||||
$tags_condition .= "tags LIKE '%".io_safe_input($all_tags[$tag])."%'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($group_tags as $tag) {
|
||||
// If the tag ID doesnt exist, ignore
|
||||
if (!isset($all_tags[$tag])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($tags_condition != '') {
|
||||
$tags_condition .= " OR \n";
|
||||
}
|
||||
|
||||
//~ // Add as condition all the posibilities of the serialized tags
|
||||
//~ $tags_condition .= sprintf('tags LIKE "%s,%%"',io_safe_input($all_tags[$tag]));
|
||||
//~ $tags_condition .= sprintf(' OR tags LIKE "%%,%s,%%"',io_safe_input($all_tags[$tag]));
|
||||
//~ $tags_condition .= sprintf(' OR tags LIKE "%%,%s"',io_safe_input($all_tags[$tag]));
|
||||
//~ $tags_condition .= sprintf(' OR tags LIKE "%s %%"',io_safe_input($all_tags[$tag]));
|
||||
//~ $tags_condition .= sprintf(' OR tags LIKE "%%,%s %%"',io_safe_input($all_tags[$tag]));
|
||||
|
||||
if ($force_group_and_tag) {
|
||||
if (!empty($all_tags[$tag])) {
|
||||
if ($force_equal) {
|
||||
$tags_condition .= sprintf('(tags = "%s"',io_safe_input($all_tags[$tag]));
|
||||
} else {
|
||||
$tags_condition .= "(tags LIKE '%".io_safe_input($all_tags[$tag])."%'";
|
||||
}
|
||||
$childrens = groups_get_childrens($group_id, null, true);
|
||||
|
||||
if (empty($childrens)) {
|
||||
$tags_condition .= sprintf(' AND id_grupo = %d )', $group_id);
|
||||
} else {
|
||||
$childrens_ids[] = $group_id;
|
||||
foreach ($childrens as $child) {
|
||||
$childrens_ids[] = (int)$child['id_grupo'];
|
||||
}
|
||||
$ids_str = implode(',', $childrens_ids);
|
||||
|
||||
$tags_condition .= sprintf(' AND id_grupo IN (%s) )', $ids_str);
|
||||
}
|
||||
} else {
|
||||
$tags_condition .= "id_grupo = ".$group_id;
|
||||
}
|
||||
} else {
|
||||
if ($force_equal) {
|
||||
$tags_condition .= sprintf('tags = "%s"',io_safe_input($all_tags[$tag]));
|
||||
} else {
|
||||
$tags_condition .= "tags LIKE '%".io_safe_input($all_tags[$tag])."%'";
|
||||
}
|
||||
}
|
||||
// If there is not tag condition ignore
|
||||
if (empty($tags_condition)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($condition != '') {
|
||||
$condition .= ' OR ';
|
||||
}
|
||||
|
||||
$condition .= "($tags_condition)\n";
|
||||
}
|
||||
|
||||
// If there is not tag condition ignore
|
||||
if (empty($tags_condition)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($condition != '') {
|
||||
$condition .= ' OR ';
|
||||
}
|
||||
|
||||
$condition .= "($tags_condition)\n";
|
||||
}
|
||||
|
||||
//Commented because ACLs propagation don't work
|
||||
|
@ -2402,76 +2393,22 @@ function __add_acltags (&$acltags, $group_id, $tags_str) {
|
|||
}
|
||||
|
||||
/* Return array with groups and their tags */
|
||||
function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $strict_user = false) {
|
||||
function tags_get_user_groups_and_tags ($id_user = false, $access = 'AR', $strict_user = false) {
|
||||
global $config;
|
||||
|
||||
|
||||
if ($id_user == false) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
$acl_column = get_acl_column($access);
|
||||
|
||||
$sql = 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
|
||||
ORDER BY id_grupo", $id_user, $acl_column);
|
||||
$tags_and_groups = db_get_all_rows_sql($sql);
|
||||
|
||||
if ($tags_and_groups === false)
|
||||
$tags_and_groups = array();
|
||||
|
||||
$acltags = array();
|
||||
|
||||
// Change the 'All' group with all groups
|
||||
$user_groups = users_get_groups($id_user, $access, false);
|
||||
$user_groups_ids = array();
|
||||
if (!empty($user_groups) && is_array($user_groups)) {
|
||||
$user_groups_ids = array_keys($user_groups);
|
||||
|
||||
$acls = users_get_groups ($id_user, $access, false, true);
|
||||
|
||||
$return = array();
|
||||
foreach ($acls as $acl) {
|
||||
$return[$acl["id_grupo"]] = $acl["tags"];
|
||||
|
||||
}
|
||||
|
||||
// If the user is admin, he should have access to the all group with the required permission
|
||||
if (is_user_admin($id_user))
|
||||
array_unshift($tags_and_groups, array('id_grupo' => 0, 'tags' => ''));
|
||||
|
||||
$tags_and_groups_aux = array();
|
||||
foreach ($tags_and_groups as $data) {
|
||||
// All group
|
||||
if ((int)$data['id_grupo'] === 0) {
|
||||
// All group with empty tags. All groups without tags permission!
|
||||
if (empty($data['tags'])) {
|
||||
foreach ($user_groups_ids as $group_id) {
|
||||
$acltags[$group_id] = '';
|
||||
}
|
||||
|
||||
return $acltags; // End of the function
|
||||
}
|
||||
// Create a new element for every group with the tags
|
||||
else {
|
||||
foreach ($user_groups_ids as $group_id) {
|
||||
$tags_and_groups_aux[] = array(
|
||||
'id_grupo' => $group_id,
|
||||
'tags' => $data['tags']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Specific group
|
||||
else {
|
||||
$tags_and_groups_aux[] = $data;
|
||||
}
|
||||
}
|
||||
$tags_and_groups = $tags_and_groups_aux;
|
||||
unset($tags_and_groups_aux);
|
||||
|
||||
|
||||
foreach ($tags_and_groups as $group_tag) {
|
||||
__add_acltags($acltags, $group_tag['id_grupo'], $group_tag['tags']);
|
||||
}
|
||||
|
||||
|
||||
return $acltags;
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -139,7 +139,7 @@ function users_get_groups_for_select($id_user, $privilege = "AR", $returnAllGro
|
|||
return $fields;
|
||||
}
|
||||
|
||||
function get_group_ancestors($group_id,$groups, $debug = 0) {
|
||||
function get_group_ancestors($group_id, $groups) {
|
||||
|
||||
if (!isset($groups[$group_id])) {
|
||||
return null;
|
||||
|
@ -155,7 +155,7 @@ function get_group_ancestors($group_id,$groups, $debug = 0) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
$r = get_group_ancestors($parent, $groups, $debug);
|
||||
$r = get_group_ancestors($parent, $groups);
|
||||
|
||||
if (is_array($r)) {
|
||||
$r = array_merge(array($parent), $r);
|
||||
|
@ -206,9 +206,26 @@ function groups_combine_acl($acl_group_a, $acl_group_b){
|
|||
"vconsole_view" => 1,
|
||||
"vconsole_edit" => 1,
|
||||
"vconsole_management" => 1,
|
||||
"tags" => 1,
|
||||
);
|
||||
|
||||
foreach ($acl_list as $acl => $aux) {
|
||||
|
||||
if($acl == "tags") {
|
||||
// Mix tags
|
||||
|
||||
if (isset($acl_group_a[$acl]) && ($acl_group_a[$acl] != "")) {
|
||||
if (isset($acl_group_b[$acl]) && ($acl_group_b[$acl] != "")) {
|
||||
if ($acl_group_b[$acl] != ($acl_group_a[$acl])) {
|
||||
$acl_group_b[$acl] = $acl_group_a[$acl] . "," . $acl_group_b[$acl];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$acl_group_b[$acl] = $acl_group_a[$acl];
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// propagate ACL
|
||||
$acl_group_b[$acl] = $acl_group_a[$acl] || $acl_group_b[$acl];
|
||||
}
|
||||
|
|
|
@ -465,7 +465,7 @@ if ($strict_user) {
|
|||
$fields = array ('tagente.id_agente','tagente.id_grupo','tagente.id_os','tagente.ultimo_contacto','tagente.intervalo','tagente.comentarios description','tagente.quiet',
|
||||
'tagente.normal_count','tagente.warning_count','tagente.critical_count','tagente.unknown_count','tagente.notinit_count','tagente.total_count','tagente.fired_count', 'tagente.nombre', 'tagente.alias');
|
||||
|
||||
$acltags = tags_get_user_module_and_tags ($config['id_user'], $access, $strict_user);
|
||||
$acltags = tags_get_user_groups_and_tags ($config['id_user'], $access, $strict_user);
|
||||
|
||||
$total_agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $count_filter, $fields, false, $strict_user, true);
|
||||
$total_agents = count($total_agents);
|
||||
|
|
|
@ -178,7 +178,7 @@ echo '<td style="vertical-align: top; width: 75%; padding-top: 0px;" id="rightco
|
|||
// Last events information
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
$acltags = tags_get_user_module_and_tags ($config['id_user'], 'ER', $user_strict);
|
||||
$acltags = tags_get_user_groups_and_tags ($config['id_user'], 'ER', $user_strict);
|
||||
|
||||
if (!empty($acltags)) {
|
||||
$tags_condition = tags_get_acl_tags_event_condition($acltags, false, $user_strict);
|
||||
|
|
|
@ -805,7 +805,7 @@ enterprise_hook('print_event_tags_active_filters',
|
|||
if (!empty($result)) {
|
||||
//~ Checking the event tags exactly. The event query filters approximated tags to keep events
|
||||
//~ with several tags
|
||||
$acltags = tags_get_user_module_and_tags ($config['id_user'], $access, true);
|
||||
$acltags = tags_get_user_groups_and_tags ($config['id_user'], $access, true);
|
||||
|
||||
foreach ($result as $key=>$event_data) {
|
||||
$has_tags = events_checks_event_tags($event_data, $acltags);
|
||||
|
|
Loading…
Reference in New Issue