Reformuled users_can_manage_group_all Tickets #3680
This commit is contained in:
parent
1c53126a4c
commit
417b3faba5
|
@ -277,7 +277,7 @@ if ($strict_user) {
|
|||
}
|
||||
else {
|
||||
$users = users_get_user_users($config['id_user'], "ER",
|
||||
users_can_manage_group_all(0));
|
||||
users_can_manage_group_all());
|
||||
}
|
||||
|
||||
$table->data[10][1] = html_print_select($users, "id_user_ack",
|
||||
|
|
|
@ -69,7 +69,7 @@ $table->data['name'][1] = html_print_input_text('name', $reportName,
|
|||
$table->data['group'][0] = __('Group');
|
||||
|
||||
$write_groups = users_get_groups_for_select(false, "RW",
|
||||
users_can_manage_group_all(0, "RW"), true, false, 'id_grupo');
|
||||
users_can_manage_group_all("RW"), true, false, 'id_grupo');
|
||||
|
||||
// If the report group is not among the RW groups (special permission) we add it
|
||||
if (!isset($write_groups[$idGroupReport]) && $idGroupReport) {
|
||||
|
|
|
@ -373,9 +373,7 @@ switch ($action) {
|
|||
$delete = true; //owner can delete
|
||||
} else {
|
||||
$delete = check_acl($config['id_user'],
|
||||
$report['id_group'], "RM")
|
||||
&&
|
||||
users_can_manage_group_all($report["id_group"], "RM");
|
||||
$report['id_group'], "RM");
|
||||
}
|
||||
break;
|
||||
case 'group_edit':
|
||||
|
@ -383,9 +381,7 @@ switch ($action) {
|
|||
$delete = true; //owner can delete
|
||||
} else {
|
||||
$delete = check_acl($config['id_user'],
|
||||
$report['id_group'], "RM")
|
||||
&&
|
||||
users_can_manage_group_all($report["id_group"], "RM");
|
||||
$report['id_group'], "RM");
|
||||
}
|
||||
break;
|
||||
case 'user_edit':
|
||||
|
@ -591,7 +587,7 @@ switch ($action) {
|
|||
|
||||
$data = array ();
|
||||
|
||||
if (check_acl ($config["id_user"], $report["id_group"], "RW") && users_can_manage_group_all($report["id_group"])) {
|
||||
if (check_acl ($config["id_user"], $report["id_group"], "RW")) {
|
||||
$data[0] = '<a href="' . $config['homeurl'] . 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&action=edit&id_report='.
|
||||
$report['id_report'].'&pure='.$pure.'">'.$report['name'].'</a>';
|
||||
}
|
||||
|
@ -652,9 +648,7 @@ switch ($action) {
|
|||
switch ($type_access_selected) {
|
||||
case 'group_view':
|
||||
$edit = check_acl($config['id_user'],
|
||||
$report['id_group'], "RW")
|
||||
&&
|
||||
users_can_manage_group_all($report["id_group"], "RW");
|
||||
$report['id_group'], "RW");
|
||||
|
||||
if ($config['id_user'] == $report['id_user'] || is_user_admin ($config["id_user"])) {
|
||||
$delete = true; //owner can delete
|
||||
|
@ -664,17 +658,13 @@ switch ($action) {
|
|||
break;
|
||||
case 'group_edit':
|
||||
$edit = check_acl($config['id_user'],
|
||||
$report['id_group_edit'], "RW")
|
||||
&&
|
||||
users_can_manage_group_all($report["id_group_edit"], "RW");
|
||||
$report['id_group_edit'], "RW");
|
||||
|
||||
if ($config['id_user'] == $report['id_user'] || is_user_admin ($config["id_user"])) {
|
||||
$delete = true; //owner can delete
|
||||
} else {
|
||||
$delete = check_acl($config['id_user'],
|
||||
$report['id_group'], "RM")
|
||||
&&
|
||||
users_can_manage_group_all($report["id_group"], "RM");
|
||||
$report['id_group'], "RM");
|
||||
}
|
||||
break;
|
||||
case 'user_edit':
|
||||
|
|
|
@ -821,13 +821,9 @@ function users_check_users() {
|
|||
// Check if a user can manage a group when group is all
|
||||
// This function dont check acls of the group, only if the
|
||||
// user is admin or pandora manager and the group is all
|
||||
function users_can_manage_group_all($id_group = 0, $access = "PM") {
|
||||
function users_can_manage_group_all($access = "PM") {
|
||||
global $config;
|
||||
|
||||
if ($id_group != 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$is_admin = db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']);
|
||||
|
||||
if (check_acl ($config['id_user'], 0, $access) || $is_admin) {
|
||||
|
|
|
@ -427,7 +427,7 @@ $data[0] = __('User ack.') . $jump;
|
|||
if ($strict_user) {
|
||||
$user_users = array($config['id_user']=>$config['id_user']);
|
||||
} else {
|
||||
$user_users = users_get_user_users($config['id_user'], "ER", users_can_manage_group_all(0));
|
||||
$user_users = users_get_user_users($config['id_user'], "ER", users_can_manage_group_all());
|
||||
}
|
||||
|
||||
$data[0] .= html_print_select($user_users, "id_user_ack", $id_user_ack, '',
|
||||
|
@ -467,7 +467,7 @@ $table_advanced->rowclass[] = '';
|
|||
$data = array();
|
||||
$data[0] = __('Date from') . $jump;
|
||||
|
||||
$user_users = users_get_user_users($config['id_user'], "ER", users_can_manage_group_all(0));
|
||||
$user_users = users_get_user_users($config['id_user'], "ER", users_can_manage_group_all());
|
||||
|
||||
$data[0] .= html_print_input_text ('date_from', $date_from, '', 15, 10, true);
|
||||
|
||||
|
@ -494,13 +494,13 @@ if (defined('METACONSOLE'))
|
|||
'</fieldset>';
|
||||
}
|
||||
else {
|
||||
$data[0] = '<fieldset class="databox" style="padding:0px; width: 30%; ">' .
|
||||
$data[0] = '<fieldset class="databox" style="padding:0px; width: 510px; ">' .
|
||||
'<legend>' .
|
||||
__('Events with following tags') .
|
||||
'</legend>' .
|
||||
html_print_table($tabletags_with, true) .
|
||||
'</fieldset>';
|
||||
$data[1] = '<fieldset class="databox" style="padding:0px; width: 30%;">' .
|
||||
$data[1] = '<fieldset class="databox" style="padding:0px; width: 310px;">' .
|
||||
'<legend>' .
|
||||
__('Events without following tags') .
|
||||
'</legend>' .
|
||||
|
@ -560,7 +560,6 @@ $data[1] .= html_print_input_text ('event_view_hr', $event_view_hr, '', 5, 255,
|
|||
$data[2] = __("Repeated") . $jump;
|
||||
$repeated_sel[0] = __("All events");
|
||||
$repeated_sel[1] = __("Group events");
|
||||
$repeated_sel[2] = __("Group agents");
|
||||
$data[2] .= html_print_select ($repeated_sel, "group_rep", $group_rep, '', '', 0, true);
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
|
@ -681,7 +680,7 @@ if ($group_rep == 0) {
|
|||
//Extract the events by filter (or not) from db
|
||||
$result = db_get_all_rows_sql ($sql);
|
||||
}
|
||||
elseif ($group_rep == 1) {
|
||||
else {
|
||||
$result = events_get_events_grouped(
|
||||
$sql_post,
|
||||
$offset,
|
||||
|
@ -689,14 +688,6 @@ elseif ($group_rep == 1) {
|
|||
$meta,
|
||||
$history);
|
||||
}
|
||||
elseif ($group_rep == 2) {
|
||||
$result = events_get_events_grouped_by_agent(
|
||||
$sql_post,
|
||||
$offset,
|
||||
$pagination,
|
||||
$meta,
|
||||
$history);
|
||||
}
|
||||
|
||||
if (!empty($result)) {
|
||||
if ($group_rep == 0) {
|
||||
|
@ -704,7 +695,7 @@ if (!empty($result)) {
|
|||
FROM $event_table
|
||||
WHERE 1=1 " . $sql_post;
|
||||
}
|
||||
elseif ($group_rep == 1) {
|
||||
else {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
|
@ -722,10 +713,6 @@ if (!empty($result)) {
|
|||
GROUP BY to_char(evento), id_agentmodule) t";
|
||||
break;
|
||||
}
|
||||
}
|
||||
elseif ($group_rep == 2) {
|
||||
|
||||
|
||||
}
|
||||
$limit = (int) db_get_sql ($sql);
|
||||
|
||||
|
@ -758,26 +745,20 @@ if (!empty($result)) {
|
|||
//Extract the events by filter (or not) from db
|
||||
$results_graph = db_get_all_rows_sql ($sql);
|
||||
}
|
||||
elseif ($group_rep == 1) {
|
||||
else {
|
||||
$results_graph = events_get_events_grouped($sql_post,
|
||||
0,
|
||||
$limit,
|
||||
$meta,
|
||||
$history);
|
||||
}
|
||||
elseif ($group_rep == 2) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (($group_rep == 1) OR ($group_rep == 0)) {
|
||||
$graph = '<div style="width: 350px; margin: 0 auto;">' .
|
||||
grafico_eventos_agente(350, 185,
|
||||
$results_graph, $meta, $history, $tags_acls_condition,$limit) .
|
||||
'</div>';
|
||||
html_print_div(array('id' => 'events_graph',
|
||||
'hidden' => true, 'content' => $graph));
|
||||
}
|
||||
|
||||
$graph = '<div style="width: 350px; margin: 0 auto;">' .
|
||||
grafico_eventos_agente(350, 185,
|
||||
$results_graph, $meta, $history, $tags_acls_condition,$limit) .
|
||||
'</div>';
|
||||
html_print_div(array('id' => 'events_graph',
|
||||
'hidden' => true, 'content' => $graph));
|
||||
}
|
||||
|
||||
|
||||
|
@ -808,7 +789,7 @@ if ($group_rep == 0) {
|
|||
FROM $event_table
|
||||
WHERE 1=1 $sql_post";
|
||||
}
|
||||
elseif ($group_rep == 1) {
|
||||
else {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
|
@ -827,13 +808,9 @@ elseif ($group_rep == 1) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
elseif ($group_rep == 2) {
|
||||
$sql = "SELECT COUNT(*) FROM (select id_agente as total from $event_table WHERE id_agente > 0
|
||||
$sql_post GROUP BY id_agente ORDER BY id_agente ) AS t";
|
||||
}
|
||||
|
||||
|
||||
$total_events = (int) db_get_sql ($sql);
|
||||
|
||||
if (empty ($result)) {
|
||||
$result = array ();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue