mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
[Tags performance] Improve monitor detail (aka status_monitor)
This commit is contained in:
parent
79961b91d0
commit
631c38ca84
@ -723,47 +723,26 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
|
|||||||
$condition = '';
|
$condition = '';
|
||||||
$group_conditions = array();
|
$group_conditions = array();
|
||||||
|
|
||||||
|
$has_secondary = enterprise_hook('agents_is_using_secondary_groups');
|
||||||
// The acltags array contains the groups with the acl propagation applied
|
// The acltags array contains the groups with the acl propagation applied
|
||||||
// after the changes done into the 'tags_get_user_groups_and_tags' function.
|
// after the changes done into the 'tags_get_user_groups_and_tags' function.
|
||||||
foreach ($acltags as $group_id => $group_tags) {
|
foreach ($acltags as $group_id => $group_tags) {
|
||||||
$tag_join = '';
|
$tag_join = '';
|
||||||
if (!empty($group_tags)) {
|
if (!empty($group_tags)) {
|
||||||
$tag_join = sprintf('INNER JOIN ttag_module ttmc
|
$tag_join = sprintf('AND ttag_module.id_tag IN (%s)',is_array($group_tags) ? implode(',', $group_tags) : $group_tags);
|
||||||
ON tamc.id_agente_modulo = ttmc.id_agente_modulo
|
if($has_secondary){
|
||||||
AND ttmc.id_tag IN (%s)',
|
$agent_condition = sprintf('((tagente.id_grupo = %d OR tasg.id_group = %d) %s)',$group_id,$group_id,$tag_join);
|
||||||
is_array($group_tags) ? implode(',', $group_tags) : $group_tags);
|
} else {
|
||||||
|
$agent_condition = sprintf('((tagente.id_grupo = %d %s)',$group_id,$tag_join);
|
||||||
|
}
|
||||||
|
$group_conditions[] = $agent_condition;
|
||||||
}
|
}
|
||||||
// FIXME: Not properly way to increse performance
|
|
||||||
if(enterprise_hook('agents_is_using_secondary_groups')){
|
|
||||||
$agent_condition = sprintf('SELECT tamc.id_agente_modulo
|
|
||||||
FROM tagente_modulo tamc
|
|
||||||
%s
|
|
||||||
INNER JOIN tagente tac
|
|
||||||
ON tamc.id_agente = tac.id_agente
|
|
||||||
LEFT JOIN tagent_secondary_group tasg
|
|
||||||
ON tasg.id_agent = tac.id_agente
|
|
||||||
WHERE (tac.id_grupo = %d OR tasg.id_group = %d)',
|
|
||||||
$tag_join, $group_id, $group_id);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$agent_condition = sprintf('SELECT tamc.id_agente_modulo
|
|
||||||
FROM tagente_modulo tamc
|
|
||||||
%s
|
|
||||||
INNER JOIN tagente tac
|
|
||||||
ON tamc.id_agente = tac.id_agente
|
|
||||||
AND tac.id_grupo = %d',
|
|
||||||
$tag_join, $group_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql_condition = sprintf('(%sid_agente_modulo IN (%s))', $modules_table, $agent_condition);
|
|
||||||
|
|
||||||
$group_conditions[] = $sql_condition;
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($group_conditions))
|
if (!empty($group_conditions)) {
|
||||||
$condition = implode(' OR ', $group_conditions);
|
$condition = implode(' OR ', $group_conditions);
|
||||||
|
}
|
||||||
$condition = !empty($condition) ? "($condition)" : '';
|
$condition = !empty($condition) ? "($condition)" : '';
|
||||||
|
|
||||||
return $condition;
|
return $condition;
|
||||||
@ -2446,7 +2425,7 @@ function tags_get_user_groups_and_tags ($id_user = false, $access = 'AR', $stric
|
|||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach ($acls as $acl) {
|
foreach ($acls as $acl) {
|
||||||
$return[$acl["id_grupo"]] = $acl["tags"];
|
$return[$acl["id_grupo"]] = $acl["tags"][get_acl_column($access)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
@ -207,24 +207,27 @@ function groups_combine_acl($acl_group_a, $acl_group_b){
|
|||||||
"vconsole_management" => 1,
|
"vconsole_management" => 1,
|
||||||
"tags" => 1,
|
"tags" => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($acl_group_a['tags']) users_get_explode_tags($acl_group_a);
|
||||||
|
if ($acl_group_b['tags']) users_get_explode_tags($acl_group_b);
|
||||||
|
|
||||||
|
if (is_array($acl_group_a['tags']) && is_array($acl_group_b['tags'])) {
|
||||||
|
foreach ($acl_group_a['tags'] as $key => $value) {
|
||||||
|
$acl_group_b['tags'][$key] = implode(
|
||||||
|
',',
|
||||||
|
array_merge(
|
||||||
|
$value,
|
||||||
|
$acl_group_b['tags'][$key]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (is_array($acl_group_a['tags'])) {
|
||||||
|
$acl_group_b['tags'] = $acl_group_a['tags'];
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($acl_list as $acl => $aux) {
|
foreach ($acl_list as $acl => $aux) {
|
||||||
|
|
||||||
if($acl == "tags") {
|
if($acl == "tags") continue;
|
||||||
// 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
|
// propagate ACL
|
||||||
$acl_group_b[$acl] = $acl_group_a[$acl] || $acl_group_b[$acl];
|
$acl_group_b[$acl] = $acl_group_a[$acl] || $acl_group_b[$acl];
|
||||||
}
|
}
|
||||||
@ -1069,4 +1072,17 @@ function users_get_strict_mode_groups($id_user, $return_group_all) {
|
|||||||
return $return_user_groups;
|
return $return_user_groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function users_get_explode_tags(&$group) {
|
||||||
|
if (is_array($group['tags'])) return;
|
||||||
|
|
||||||
|
$aux = explode(',', $group['tags']);
|
||||||
|
$group['tags'] = array();
|
||||||
|
$group['tags']['agent_view'] = ($group['agent_view']) ? $aux : array();
|
||||||
|
$group['tags']['agent_edit'] = ($group['agent_edit']) ? $aux : array();
|
||||||
|
$group['tags']['agent_disable'] = ($group['agent_disable']) ? $aux : array();
|
||||||
|
$group['tags']['event_view'] = ($group['event_view']) ? $aux : array();
|
||||||
|
$group['tags']['event_edit'] = ($group['event_edit']) ? $aux : array();
|
||||||
|
$group['tags']['event_management'] = ($group['event_management']) ? $aux : array();
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -87,16 +87,25 @@ if ($id_module) {
|
|||||||
enterprise_hook('open_meta_frame');
|
enterprise_hook('open_meta_frame');
|
||||||
|
|
||||||
// Get Groups and profiles from user
|
// Get Groups and profiles from user
|
||||||
$user_groups = implode (',', array_keys (users_get_groups ()));
|
$user_groups = implode (',', array_keys (users_get_groups (false,'AR',false)));
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
// Begin Build SQL sentences
|
// Begin Build SQL sentences
|
||||||
$sql_from = ' FROM ttipo_modulo,tagente LEFT JOIN tagent_secondary_group tasg ON tagente.id_agente = tasg.id_agent, tagente_modulo, tagente_estado,tmodule ';
|
$sql_from = " FROM tagente_modulo
|
||||||
|
INNER JOIN tagente
|
||||||
|
ON tagente_modulo.id_agente = tagente.id_agente
|
||||||
|
LEFT JOIN tagent_secondary_group tasg
|
||||||
|
ON tagente.id_agente = tasg.id_agent
|
||||||
|
INNER JOIN tagente_estado
|
||||||
|
ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||||
|
INNER JOIN tmodule
|
||||||
|
ON tmodule.id_module = tagente_modulo.id_modulo
|
||||||
|
INNER JOIN ttipo_modulo
|
||||||
|
ON tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo
|
||||||
|
LEFT JOIN ttag_module
|
||||||
|
ON tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo";
|
||||||
|
|
||||||
$sql_conditions_base = ' WHERE tagente.id_agente = tagente_modulo.id_agente
|
$sql_conditions = ' WHERE tagente.disabled = 0';
|
||||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo AND tmodule.id_module = tagente_modulo.id_modulo';
|
|
||||||
|
|
||||||
$sql_conditions = ' AND tagente.disabled = 0';
|
|
||||||
|
|
||||||
if (is_numeric($ag_group)) {
|
if (is_numeric($ag_group)) {
|
||||||
$id_ag_group = 0;
|
$id_ag_group = 0;
|
||||||
@ -261,8 +270,7 @@ if (!users_is_admin()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Two modes of filter. All the filters and only ACLs filter
|
// Two modes of filter. All the filters and only ACLs filter
|
||||||
$sql_conditions_all = $sql_conditions_base . $sql_conditions . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields;
|
$sql_conditions_all = $sql_conditions . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields;
|
||||||
$sql_conditions_acl = $sql_conditions_base . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields;
|
|
||||||
|
|
||||||
// Get count to paginate
|
// Get count to paginate
|
||||||
if (!defined('METACONSOLE'))
|
if (!defined('METACONSOLE'))
|
||||||
@ -337,8 +345,7 @@ $table->rowspan[0][6] = 2;
|
|||||||
$table->data[0][6] = html_print_submit_button (__('Show'), 'uptbutton',
|
$table->data[0][6] = html_print_submit_button (__('Show'), 'uptbutton',
|
||||||
false, 'class="sub search" style="margin-top:0px;"',true);
|
false, 'class="sub search" style="margin-top:0px;"',true);
|
||||||
$modules = array();
|
$modules = array();
|
||||||
$modules = modules_get_modules_name ($sql_from , $sql_conditions_acl, is_metaconsole());
|
// TODO change for input text
|
||||||
|
|
||||||
$table->data[1][0] = __('Module name');
|
$table->data[1][0] = __('Module name');
|
||||||
$table->data[1][1] = html_print_select (index_array ($modules, 'nombre', 'nombre'), 'ag_modulename',
|
$table->data[1][1] = html_print_select (index_array ($modules, 'nombre', 'nombre'), 'ag_modulename',
|
||||||
$ag_modulename, '', __('All'), '', true, false, true, '', false, 'width: 150px;');
|
$ag_modulename, '', __('All'), '', true, false, true, '', false, 'width: 150px;');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user