Merge branch 'ent-6148-new-report-permissions' into 'develop'
Ent 6148 new report permissions See merge request artica/pandorafms!3490
This commit is contained in:
commit
a24bc6d15c
|
@ -156,6 +156,11 @@ $agent_max_value = true;
|
|||
$agent_min_value = true;
|
||||
$uncompressed_module = true;
|
||||
|
||||
// Users.
|
||||
$id_users = [];
|
||||
$users_groups = [];
|
||||
$select_by_group = false;
|
||||
|
||||
$nothing = __('Local metaconsole');
|
||||
$nothing_value = 0;
|
||||
|
||||
|
@ -752,6 +757,22 @@ switch ($action) {
|
|||
$top_n_value = $item['top_n_value'];
|
||||
break;
|
||||
|
||||
case 'permissions_report':
|
||||
$description = $item['description'];
|
||||
$es = json_decode($item['external_source'], true);
|
||||
$id_users = array_combine(
|
||||
array_values($es['id_users']),
|
||||
array_values($es['id_users'])
|
||||
);
|
||||
|
||||
if (isset($id_users[0]) && $id_users[0] == 0) {
|
||||
$id_users[0] = __('None');
|
||||
}
|
||||
|
||||
$users_groups = $es['users_groups'];
|
||||
$select_by_group = $es['select_by_group'];
|
||||
break;
|
||||
|
||||
default:
|
||||
// It's not possible.
|
||||
break;
|
||||
|
@ -1046,23 +1067,6 @@ $class = 'databox filters';
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_resolution" style="" class="datos">
|
||||
<td style="font-weight:bold;">
|
||||
<?php
|
||||
echo __('Resolution');
|
||||
?>
|
||||
</td>
|
||||
<td style="">
|
||||
<?php
|
||||
html_print_select(
|
||||
netflow_resolution_select_params(),
|
||||
'resolution',
|
||||
$resolution
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_period1" style="" class="datos">
|
||||
<td style="font-weight:bold;">
|
||||
<?php
|
||||
|
@ -2851,7 +2855,102 @@ $class = 'databox filters';
|
|||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_profiles_group" style="" class="datos">
|
||||
<td style="font-weight:bold;">
|
||||
<?php
|
||||
echo __('Group');
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
$user_groups = users_get_groups();
|
||||
|
||||
// Add a selector for users without assigned group.
|
||||
$user_groups[''] = __('Unassigned group');
|
||||
|
||||
html_print_select(
|
||||
$user_groups,
|
||||
'users_groups[]',
|
||||
$users_groups,
|
||||
'',
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
'min-width: 180px'
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_users" style="" class="datos">
|
||||
<td style="font-weight:bold;">
|
||||
<?php
|
||||
echo __('User');
|
||||
?>
|
||||
</td>
|
||||
<td style="">
|
||||
<?php
|
||||
$tmp_users = db_get_all_rows_filter('tusuario', [], 'id_user');
|
||||
foreach ($tmp_users as $key => $user) {
|
||||
$select_users[$user['id_user']] = $user['id_user'];
|
||||
}
|
||||
|
||||
$input_data = [
|
||||
'type' => 'select_multiple_filtered',
|
||||
'class' => 'w80p mw600px',
|
||||
'name' => 'id_users',
|
||||
'return' => 0,
|
||||
'available' => array_diff(
|
||||
$select_users,
|
||||
$id_users
|
||||
),
|
||||
'selected' => $id_users,
|
||||
'group_filter' => [
|
||||
'page' => 'godmode/users/user_list',
|
||||
'method' => 'get_users_by_group',
|
||||
'nothing' => __('Unnasigned group'),
|
||||
'nothing_value' => -1,
|
||||
'id' => $id_users,
|
||||
],
|
||||
'texts' => [
|
||||
'title-left' => 'Available users',
|
||||
'title-right' => 'Selected users',
|
||||
'filter-item' => 'Filter user name',
|
||||
],
|
||||
'sections' => [
|
||||
'filters' => 1,
|
||||
'item-selected-filters' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
html_print_input($input_data, 'div', true);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_select_by_group" style="" class="datos">
|
||||
<td style="font-weight:bold;">
|
||||
<?php
|
||||
echo __('Select by group');
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
html_print_checkbox_switch(
|
||||
'select_by_group',
|
||||
1,
|
||||
$select_by_group,
|
||||
false
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_landscape" style="" class="datos">
|
||||
<td style="font-weight:bold;">
|
||||
<?php
|
||||
|
@ -3712,6 +3811,14 @@ echo "<div id='message_no_interval_option' title='".__('Item Editor Information
|
|||
echo "<p style='text-align: center;font-weight: bold;'>".__('Please checked a custom interval option.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_no_user' title='".__('Item Editor Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('Please select a user.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_no_group' title='".__('Item Editor Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('Please select a group.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
ui_require_javascript_file(
|
||||
'pandora_inventory',
|
||||
ENTERPRISE_DIR.'/include/javascript/'
|
||||
|
@ -3936,6 +4043,20 @@ $(document).ready (function () {
|
|||
});
|
||||
});
|
||||
|
||||
$("#checkbox-select_by_group").change(function () {
|
||||
var select_by_group = $('#checkbox-select_by_group').prop('checked');
|
||||
|
||||
if(select_by_group == true) {
|
||||
$("#row_users").hide();
|
||||
$("#row_profiles_group").show();
|
||||
|
||||
} else {
|
||||
$("#row_users").show();
|
||||
$("#row_profiles_group").hide();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$("#checkbox-fullscale").change(function(e){
|
||||
if(e.target.checked === true) {
|
||||
$("#graph_render").prop('disabled', 'disabled');
|
||||
|
@ -3999,6 +4120,16 @@ $(document).ready (function () {
|
|||
return false;
|
||||
}
|
||||
break;
|
||||
case 'permissions_report':
|
||||
if ($("#checkbox-select_by_group").prop("checked") && $("select#users_groups>option:selected").val() == undefined) {
|
||||
dialog_message('#message_no_group');
|
||||
return false;
|
||||
}
|
||||
if ($("#checkbox-select_by_group").prop("checked") == false && $("select#selected-select-id_users>option:selected").val() == 0) {
|
||||
dialog_message('#message_no_user');
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -4120,6 +4251,18 @@ $(document).ready (function () {
|
|||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'permissions_report':
|
||||
if ($("#checkbox-select_by_group").prop("checked") && $("select#users_groups>option:selected").val() == undefined) {
|
||||
dialog_message('#message_no_group');
|
||||
return false;
|
||||
}
|
||||
if ($("#checkbox-select_by_group").prop("checked") == false && $("select#selected-select-id_users>option:selected").val() == 0) {
|
||||
dialog_message('#message_no_user');
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -5006,6 +5149,10 @@ function chooseType() {
|
|||
$("#row_select_fields2").hide();
|
||||
$("#row_select_fields3").hide();
|
||||
$("#row_uncompressed_module").hide();
|
||||
$("#row_users").hide();
|
||||
$("#row_profiles_group").hide();
|
||||
$("#row_select_by_group").hide();
|
||||
|
||||
|
||||
// SLA list default state.
|
||||
$("#sla_list").hide();
|
||||
|
@ -5690,7 +5837,21 @@ function chooseType() {
|
|||
$("#row_period").show();
|
||||
$("#row_quantity").show();
|
||||
break;
|
||||
|
||||
case 'permissions_report':
|
||||
$("#row_description").show();
|
||||
$("#row_users").show();
|
||||
$("#row_profiles_group").show();
|
||||
$("#row_select_by_group").show();
|
||||
|
||||
if($("#checkbox-select_by_group").prop("checked")) {
|
||||
$("#row_users").hide();
|
||||
} else {
|
||||
$("#row_profiles_group").hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 'event_report_agent':
|
||||
case 'simple_graph':
|
||||
|
@ -5779,4 +5940,5 @@ function dialog_message(message_id) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
|
@ -2054,6 +2054,14 @@ switch ($action) {
|
|||
}
|
||||
break;
|
||||
|
||||
case 'permissions_report':
|
||||
$es['id_users'] = get_parameter('selected-select-id_users', 0);
|
||||
$es['users_groups'] = get_parameter('users_groups', 0);
|
||||
$es['select_by_group'] = get_parameter('select_by_group', 0);
|
||||
$description = get_parameter('description');
|
||||
$values['external_source'] = json_encode($es);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
|
@ -2669,6 +2677,14 @@ switch ($action) {
|
|||
}
|
||||
break;
|
||||
|
||||
case 'permissions_report':
|
||||
$es['id_users'] = get_parameter('selected-select-id_users');
|
||||
$es['users_groups'] = get_parameter('users_groups', 0);
|
||||
$es['select_by_group'] = get_parameter('select_by_group', 0);
|
||||
$description = get_parameter('description');
|
||||
$values['external_source'] = json_encode($es);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
|
|
|
@ -196,6 +196,8 @@ if (is_ajax()) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$tab = get_parameter('tab', 'user');
|
||||
|
||||
if ($id) {
|
||||
|
|
|
@ -33,6 +33,53 @@ if (! check_acl($config['id_user'], 0, 'UM')) {
|
|||
exit;
|
||||
}
|
||||
|
||||
if (is_ajax()) {
|
||||
$method = get_parameter('method');
|
||||
$group_id = get_parameter('group_id');
|
||||
$group_recursion = (bool) get_parameter('group_recursion', 0);
|
||||
$return_all = false;
|
||||
|
||||
if ($group_id == -1) {
|
||||
$sql = 'SELECT tusuario.id_user FROM tusuario
|
||||
LEFT OUTER JOIN tusuario_perfil
|
||||
ON tusuario.id_user = tusuario_perfil.id_usuario
|
||||
WHERE tusuario_perfil.id_usuario IS NULL';
|
||||
|
||||
$users = io_safe_output(db_get_all_rows_sql($sql));
|
||||
|
||||
foreach ($users as $key => $user) {
|
||||
$ret_user[$user['id_user']] = $user['id_user'];
|
||||
}
|
||||
|
||||
echo json_encode($ret_user);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($group_id == 0) {
|
||||
$users = io_safe_output(db_get_all_rows_filter('tusuario', [], 'id_user'));
|
||||
foreach ($users as $key => $user) {
|
||||
$ret_user[$user['id_user']] = $user['id_user'];
|
||||
}
|
||||
|
||||
echo json_encode($ret_user);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($method === 'get_users_by_group') {
|
||||
if ($group_recursion === true) {
|
||||
$group_id = groups_get_children_ids($group_id);
|
||||
}
|
||||
|
||||
$users_id = io_safe_output(users_get_user_users(false, 'AR', false, null, $group_id));
|
||||
foreach ($users_id as $key => $user_id) {
|
||||
$ret_id[$user_id] = $user_id;
|
||||
}
|
||||
|
||||
echo json_encode($ret_id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$sortField = get_parameter('sort_field');
|
||||
$sort = get_parameter('sort', 'none');
|
||||
$tab = get_parameter('tab', 'user');
|
||||
|
|
|
@ -457,6 +457,9 @@ define('REPORT_OLD_TYPE_SUMATORY', 10);
|
|||
define('REPORT_GENERAL_NOT_GROUP_BY_AGENT', 0);
|
||||
define('REPORT_GENERAL_GROUP_BY_AGENT', 1);
|
||||
|
||||
define('REPORT_PERMISSIONS_NOT_GROUP_BY_GROUP', 0);
|
||||
define('REPORT_PERMISSIONS_GROUP_BY_GROUP', 1);
|
||||
|
||||
define('REPORTING_CUSTOM_GRAPH_LEGEND_EACH_MODULE_VERTICAL_SIZE', 15);
|
||||
|
||||
// POLICIES.
|
||||
|
|
|
@ -913,28 +913,45 @@ function html_print_select_multiple_filtered(
|
|||
$sections = [];
|
||||
}
|
||||
|
||||
if (empty($sections['filters']) === true) {
|
||||
if (isset($sections['filters']) === false) {
|
||||
$sections['filters'] = 1;
|
||||
}
|
||||
|
||||
if (empty($sections['group-filter']) === true) {
|
||||
// Show/hide all left/rigth sfilters.
|
||||
if (isset($sections['item-selected-filters']) === false) {
|
||||
$sections['item-selected-filters'] = 1;
|
||||
}
|
||||
|
||||
if (isset($sections['item-available-filters']) === false) {
|
||||
$sections['item-available-filters'] = 1;
|
||||
}
|
||||
|
||||
if (isset($sections['group-filter']) == false) {
|
||||
$sections['group-filter'] = 1;
|
||||
}
|
||||
|
||||
if (empty($sections['item-available-filter']) === true) {
|
||||
if (isset($sections['item-available-filter']) === false) {
|
||||
$sections['item-available-filter'] = 1;
|
||||
}
|
||||
|
||||
if (empty($sections['item-selected-filter']) === true) {
|
||||
if (isset($sections['item-selected-filter']) === false) {
|
||||
$sections['item-selected-filter'] = 1;
|
||||
}
|
||||
|
||||
if (empty($group_filter) === true) {
|
||||
if (isset($group_filter) === false) {
|
||||
$sections['group-filter'] = 0;
|
||||
}
|
||||
|
||||
if (isset($group_filter['nothing']) === false) {
|
||||
$group_filter['nothing'] = '';
|
||||
}
|
||||
|
||||
if (isset($group_filter['nothing_value']) === false) {
|
||||
$group_filter['nothing_value'] = 0;
|
||||
}
|
||||
|
||||
// Main container.
|
||||
$output = '<div class="multi-select flex-row-vcenter '.$class.'">';
|
||||
$output = '<div class="multi-select flex-row-end '.$class.'">';
|
||||
|
||||
// Left box.
|
||||
$output .= '<div class="multi-select-container flex-column">';
|
||||
|
@ -943,6 +960,7 @@ function html_print_select_multiple_filtered(
|
|||
// Filtering.
|
||||
if (isset($sections['filters']) === true
|
||||
&& $sections['filters'] === 1
|
||||
&& $sections['item-available-filters'] === 1
|
||||
) {
|
||||
// Filtering.
|
||||
if (isset($sections['group-filter']) === true
|
||||
|
@ -962,6 +980,7 @@ function html_print_select_multiple_filtered(
|
|||
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'input_class' => 'flex-row-vcenter',
|
||||
'label' => __('Filter group'),
|
||||
'name' => 'id-group-available-select-'.$rid,
|
||||
'returnAllGroup' => true,
|
||||
|
@ -969,16 +988,20 @@ function html_print_select_multiple_filtered(
|
|||
'type' => 'select_groups',
|
||||
'return' => true,
|
||||
'script' => $reload_content,
|
||||
'nothing' => $group_filter['nothing'],
|
||||
'nothing_value' => $group_filter['nothing_value'],
|
||||
]
|
||||
);
|
||||
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'label' => __('Group recursion'),
|
||||
'name' => 'id-group-recursion-available-select-'.$rid,
|
||||
'type' => 'checkbox',
|
||||
'script' => $reload_content,
|
||||
'return' => true,
|
||||
'label' => __('Group recursion'),
|
||||
'input_class' => 'flex-row-vcenter',
|
||||
'name' => 'id-group-recursion-available-select-'.$rid,
|
||||
'id' => 'checkbox-id-group-recursion-available-select-'.$rid,
|
||||
'type' => 'switch',
|
||||
'onchange' => $reload_content,
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -1087,6 +1110,7 @@ function html_print_select_multiple_filtered(
|
|||
// Filtering.
|
||||
if (isset($sections['filters']) === true
|
||||
&& $sections['filters'] === 1
|
||||
&& $sections['item-selected-filters']
|
||||
) {
|
||||
if (isset($sections['group-filter']) === true
|
||||
&& $sections['group-filter'] === 1
|
||||
|
@ -1105,6 +1129,7 @@ function html_print_select_multiple_filtered(
|
|||
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'input_class' => 'flex-row-vcenter',
|
||||
'label' => __('Filter group'),
|
||||
'name' => 'id-group-selected-select-'.$rid,
|
||||
'returnAllGroup' => true,
|
||||
|
@ -1117,11 +1142,12 @@ function html_print_select_multiple_filtered(
|
|||
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'label' => __('Group recursion'),
|
||||
'name' => 'id-group-recursion-selected-select-'.$rid,
|
||||
'type' => 'checkbox',
|
||||
'script' => $reload_content,
|
||||
'return' => true,
|
||||
'input_class' => 'flex-row-vcenter',
|
||||
'label' => __('Group recursion'),
|
||||
'name' => 'id-group-recursion-selected-select-'.$rid,
|
||||
'type' => 'checkbox',
|
||||
'script' => $reload_content,
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -1152,7 +1178,7 @@ function html_print_select_multiple_filtered(
|
|||
'label' => __($texts['filter-item']),
|
||||
'name' => 'filter-item-selected-'.$rid,
|
||||
'onKeyUp' => $f,
|
||||
'input_class' => 'filter w100p',
|
||||
'input_class' => 'flex-row-vcenter filter w100p',
|
||||
'size' => 20,
|
||||
'type' => 'text',
|
||||
'return' => true,
|
||||
|
|
|
@ -694,6 +694,13 @@ function reporting_make_reporting_data(
|
|||
);
|
||||
break;
|
||||
|
||||
case 'permissions_report':
|
||||
$report['contents'][] = reporting_permissions(
|
||||
$report,
|
||||
$content
|
||||
);
|
||||
break;
|
||||
|
||||
case 'group_report':
|
||||
$report['contents'][] = reporting_group_report(
|
||||
$report,
|
||||
|
@ -3577,6 +3584,128 @@ function reporting_last_value($report, $content)
|
|||
}
|
||||
|
||||
|
||||
function reporting_permissions($report, $content)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$return['type'] = 'permissions_report';
|
||||
|
||||
if (empty($content['name'])) {
|
||||
$content['name'] = __('Permissions report');
|
||||
}
|
||||
|
||||
$return['title'] = $content['name'];
|
||||
$return['landscape'] = $content['landscape'];
|
||||
$return['pagebreak'] = $content['pagebreak'];
|
||||
$return['description'] = $content['description'];
|
||||
$return['date'] = reporting_get_date_text($report, $content);
|
||||
|
||||
$external_source = io_safe_input(json_decode($content['external_source'], true));
|
||||
$id_users = $external_source['id_users'];
|
||||
$id_groups = $external_source['users_groups'];
|
||||
|
||||
// Select subtype: group by user or by group.
|
||||
$select_by_group = $external_source['select_by_group'];
|
||||
$return['subtype'] = (int) $select_by_group;
|
||||
|
||||
if ($select_by_group === REPORT_PERMISSIONS_NOT_GROUP_BY_GROUP) {
|
||||
foreach ($id_users as $id_user) {
|
||||
$user_name = db_get_value_filter('fullname', 'tusuario', ['id_user' => $id_user]);
|
||||
|
||||
$sql = sprintf(
|
||||
"SELECT name, id_grupo FROM tusuario_perfil
|
||||
INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil
|
||||
WHERE tusuario_perfil.id_usuario like '%s'",
|
||||
$id_user
|
||||
);
|
||||
|
||||
$profiles = db_get_all_rows_sql($sql);
|
||||
|
||||
$user_profiles = [];
|
||||
if (empty($profiles)) {
|
||||
$user_profiles[] = __('The user doesn\'t have any assigned profile/group');
|
||||
} else {
|
||||
foreach ($profiles as $user_profile) {
|
||||
$user_profiles[] = $user_profile['name'].' / '.groups_get_name($user_profile['id_grupo'], true);
|
||||
}
|
||||
}
|
||||
|
||||
$data[] = [
|
||||
'user_id' => io_safe_output($id_user),
|
||||
'user_name' => io_safe_output($user_name),
|
||||
'user_profiles' => io_safe_output($user_profiles),
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$group_users = [];
|
||||
foreach ($id_groups as $id_group) {
|
||||
if ($id_group === '') {
|
||||
$group_name = __('Unnasigned group');
|
||||
$sql = 'SELECT tusuario.id_user, tusuario.fullname FROM tusuario
|
||||
LEFT OUTER JOIN tusuario_perfil
|
||||
ON tusuario.id_user = tusuario_perfil.id_usuario
|
||||
WHERE tusuario_perfil.id_usuario IS NULL';
|
||||
$group_users = db_get_all_rows_sql($sql);
|
||||
$group_name = __('Unassigned group');
|
||||
} else {
|
||||
$group_name = groups_get_name($id_group, true);
|
||||
$group_users = users_get_user_users(
|
||||
$id_group,
|
||||
'AR',
|
||||
false,
|
||||
[
|
||||
'id_user',
|
||||
'fullname',
|
||||
|
||||
],
|
||||
[$id_group]
|
||||
);
|
||||
}
|
||||
|
||||
$row['users'] = [];
|
||||
foreach ($group_users as $user) {
|
||||
$id_user = $user['id_user'];
|
||||
|
||||
// Get user fullanme.
|
||||
$row['users'][$id_user]['fullname'] = $user['fullname'];
|
||||
|
||||
if ($id_group === '') {
|
||||
$row['users'][$id_user]['profiles'][] = __('The user doesn\'t have any assigned profile/group');
|
||||
} else {
|
||||
// Incluide id group = 0 for 'All' profile.
|
||||
$sql = sprintf(
|
||||
"SELECT id_perfil FROM tusuario_perfil
|
||||
WHERE id_usuario LIKE '%s'
|
||||
AND (
|
||||
id_grupo LIKE '%s'
|
||||
OR id_grupo LIKE '0'
|
||||
)",
|
||||
$id_user,
|
||||
$id_group
|
||||
);
|
||||
|
||||
$user_profiles_id = db_get_all_rows_sql($sql);
|
||||
|
||||
foreach ($user_profiles_id as $profile_id) {
|
||||
$row['users'][$id_user]['profiles'][] = profile_get_name($profile_id['id_perfil']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data[] = [
|
||||
'group_name' => $group_name,
|
||||
'users' => $row['users'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$return['data'] = [];
|
||||
$return['data'] = $data;
|
||||
|
||||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
|
||||
function reporting_group_configuration($report, $content)
|
||||
{
|
||||
global $config;
|
||||
|
|
|
@ -236,6 +236,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
|
|||
reporting_html_log($table, $item);
|
||||
break;
|
||||
|
||||
case 'permissions_report':
|
||||
reporting_html_permissions($table, $item);
|
||||
break;
|
||||
|
||||
case 'availability_graph':
|
||||
reporting_html_availability_graph($table, $item);
|
||||
break;
|
||||
|
@ -5649,3 +5653,117 @@ function reporting_html_planned_downtimes_table($planned_downtimes)
|
|||
|
||||
return $downtimes_table;
|
||||
}
|
||||
|
||||
|
||||
function reporting_html_permissions($table, $item, $pdf=0)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$table1 = new stdClass();
|
||||
$table1->width = '100%';
|
||||
|
||||
$table1->style[0] = 'text-align: left;vertical-align: top;min-width: 100px;';
|
||||
$table1->class = 'databox data';
|
||||
$table1->cellpadding = 1;
|
||||
$table1->cellspacing = 1;
|
||||
$table1->styleTable = 'overflow: wrap; table-layout: fixed;';
|
||||
|
||||
if ($item['subtype'] === REPORT_PERMISSIONS_NOT_GROUP_BY_GROUP) {
|
||||
$table1->style[0] = 'text-align: left;vertical-align: top;min-width: 100px;';
|
||||
$table1->style[1] = 'text-align: left;vertical-align: top;min-width: 100px;';
|
||||
$table1->style[2] = 'text-align: left;vertical-align: top; min-width: 100px';
|
||||
|
||||
$table1->head = [
|
||||
__('User ID'),
|
||||
__('Full name'),
|
||||
__('Permissions'),
|
||||
];
|
||||
|
||||
$table1->headstyle[0] = 'text-align: left';
|
||||
$table1->headstyle[1] = 'text-align: left';
|
||||
$table1->headstyle[2] = 'text-align: left';
|
||||
}
|
||||
|
||||
if ($item['subtype'] === REPORT_PERMISSIONS_GROUP_BY_GROUP) {
|
||||
$table1->style[0] = 'text-align: left;vertical-align: top;min-width: 150px;';
|
||||
$table1->style[1] = 'text-align: left;vertical-align: top;min-width: 150px;';
|
||||
$table1->style[2] = 'text-align: left;vertical-align: top;min-width: 150px;';
|
||||
$table1->style[3] = 'text-align: left;vertical-align: top;min-width: 150px;';
|
||||
|
||||
$table1->headstyle[0] = 'text-align: left';
|
||||
$table1->headstyle[1] = 'text-align: left';
|
||||
$table1->headstyle[2] = 'text-align: left';
|
||||
$table1->headstyle[3] = 'text-align: left';
|
||||
|
||||
$table1->head = [
|
||||
__('Group'),
|
||||
__('User ID'),
|
||||
__('Full name'),
|
||||
__('Permissions'),
|
||||
];
|
||||
}
|
||||
|
||||
$table1->data = [];
|
||||
|
||||
foreach ($item['data'] as $data) {
|
||||
if ($item['subtype'] === REPORT_PERMISSIONS_NOT_GROUP_BY_GROUP) {
|
||||
$profile_group_name = '';
|
||||
foreach ($data['user_profiles'] as $user_profile) {
|
||||
$profile_group_name .= $user_profile.'<br />';
|
||||
}
|
||||
|
||||
$row = [
|
||||
$data['user_id'],
|
||||
$data['user_name'],
|
||||
$profile_group_name,
|
||||
];
|
||||
}
|
||||
|
||||
if ($item['subtype'] === REPORT_PERMISSIONS_GROUP_BY_GROUP) {
|
||||
$user_profile_id_users = '';
|
||||
$user_profile_name = '';
|
||||
$user_profile_users_name = '';
|
||||
$group_name = $data['group_name'].'<br />';
|
||||
|
||||
foreach ($data['users'] as $user => $user_data) {
|
||||
$user_profile_id_users .= $user.'<br />';
|
||||
$user_profile_users_name .= $user_data['fullname'].'<br />';
|
||||
|
||||
foreach ($user_data['profiles'] as $profile) {
|
||||
$user_profile_id_users .= '<br />';
|
||||
$user_profile_users_name .= '<br />';
|
||||
$user_profile_name .= $profile.'<br />';
|
||||
}
|
||||
|
||||
$user_profile_name .= '<br />';
|
||||
}
|
||||
|
||||
$row = [
|
||||
$group_name,
|
||||
$user_profile_id_users,
|
||||
$user_profile_users_name,
|
||||
$user_profile_name,
|
||||
];
|
||||
}
|
||||
|
||||
$table1->data[] = $row;
|
||||
|
||||
if ($pdf !== 0) {
|
||||
$table1->data[] = '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if ($pdf === 0) {
|
||||
$table->colspan['permissions']['cell'] = 3;
|
||||
$table->cellstyle['permissions']['cell'] = 'text-align: center;';
|
||||
$table->data['permissions']['cell'] = html_print_table(
|
||||
$table1,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
return html_print_table(
|
||||
$table1,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ function reports_get_report($id_report, $filter=false, $fields=false)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (! is_array($filter)) {
|
||||
if (!is_array($filter)) {
|
||||
$filter = [];
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ function reports_get_report($id_report, $filter=false, $fields=false)
|
|||
|
||||
$report = db_get_row_filter('treport', $filter, $fields);
|
||||
|
||||
if (! check_acl($config['id_user'], $report['id_group'], 'RR')) {
|
||||
if (!check_acl($config['id_user'], $report['id_group'], 'RR')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -104,16 +104,16 @@ function reports_get_reports(
|
|||
) {
|
||||
global $config;
|
||||
|
||||
if (! is_array($filter)) {
|
||||
if (!is_array($filter)) {
|
||||
$filter = [];
|
||||
}
|
||||
|
||||
/*
|
||||
if (!is_user_admin ($config["id_user"]))
|
||||
/*
|
||||
if (!is_user_admin ($config["id_user"]))
|
||||
$filter[] = sprintf ('private = 0 OR (private = 1 AND id_user = "%s")',
|
||||
$config['id_user']);
|
||||
*/
|
||||
$filter['hidden'] = 0;
|
||||
*/
|
||||
$filter['hidden'] = 0;
|
||||
if (is_array($fields)) {
|
||||
$fields[] = 'id_group';
|
||||
$fields[] = 'id_user';
|
||||
|
@ -146,7 +146,7 @@ function reports_get_reports(
|
|||
}
|
||||
|
||||
if ($config['id_user'] != $report['id_user']
|
||||
&& ! check_acl($config['id_user'], $report['id_group'], $privileges)
|
||||
&& !check_acl($config['id_user'], $report['id_group'], $privileges)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ function reports_create_report($name, $id_group, $values=false)
|
|||
{
|
||||
global $config;
|
||||
|
||||
if (! is_array($values)) {
|
||||
if (!is_array($values)) {
|
||||
$values = [];
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ function reports_get_content($id_report_content, $filter=false, $fields=false)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (! is_array($filter)) {
|
||||
if (!is_array($filter)) {
|
||||
$filter = [];
|
||||
}
|
||||
|
||||
|
@ -293,7 +293,7 @@ function reports_create_content($id_report, $values)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (! is_array($values)) {
|
||||
if (!is_array($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ function reports_get_contents($id_report, $filter=false, $fields=false)
|
|||
return [];
|
||||
}
|
||||
|
||||
if (! is_array($filter)) {
|
||||
if (!is_array($filter)) {
|
||||
$filter = [];
|
||||
}
|
||||
|
||||
|
@ -546,7 +546,7 @@ function reports_delete_content($id_report_content)
|
|||
function get_report_name($type, $template=false)
|
||||
{
|
||||
$types = reports_get_report_types($template);
|
||||
if (! isset($types[$type])) {
|
||||
if (!isset($types[$type])) {
|
||||
return __('Unknown');
|
||||
}
|
||||
|
||||
|
@ -890,5 +890,10 @@ function reports_get_report_types($template=false, $not_editor=false)
|
|||
];
|
||||
}
|
||||
|
||||
$types['permissions_report'] = [
|
||||
'optgroup' => __('Permissions report'),
|
||||
'name' => __('Permissions report'),
|
||||
];
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
|
|
@ -616,7 +616,8 @@ function users_get_user_users(
|
|||
$id_user=false,
|
||||
$privilege='AR',
|
||||
$returnAllGroup=true,
|
||||
$fields=null
|
||||
$fields=null,
|
||||
$filter_group=[]
|
||||
) {
|
||||
global $config;
|
||||
|
||||
|
@ -625,8 +626,12 @@ function users_get_user_users(
|
|||
$user_users = [];
|
||||
$array_user_group = [];
|
||||
|
||||
foreach ($user_groups as $id_user_group => $name_user_group) {
|
||||
$array_user_group[] = $id_user_group;
|
||||
if (empty($filter_group)) {
|
||||
foreach ($user_groups as $id_user_group => $name_user_group) {
|
||||
$array_user_group[] = $id_user_group;
|
||||
}
|
||||
} else {
|
||||
$array_user_group = $filter_group;
|
||||
}
|
||||
|
||||
$group_users = groups_get_users($array_user_group, false, $returnAllGroup);
|
||||
|
@ -831,3 +836,25 @@ function users_get_user_profile($id_user)
|
|||
|
||||
return $user_profiles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtiene una matriz con la informacion de cada usuario que pertenece a un grupo
|
||||
*
|
||||
* @param string User id
|
||||
* @return array Return .
|
||||
*/
|
||||
function users_get_users_group_by_group($id_group)
|
||||
{
|
||||
$sql = sprintf(
|
||||
"SELECT tusuario.* FROM tusuario
|
||||
LEFT JOIN tusuario_perfil ON tusuario_perfil.id_usuario = tusuario.id_user
|
||||
AND tusuario_perfil.id_grupo = '%s'
|
||||
GROUP BY tusuario_perfil.id_usuario",
|
||||
$id_group
|
||||
);
|
||||
|
||||
$users = db_get_all_rows_sql($sql);
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,9 @@ function reloadContent(id, url, options, side, noneStr) {
|
|||
data.side = side;
|
||||
data.group_recursion = $("#checkbox-id-group-recursion-" + current).prop(
|
||||
"checked"
|
||||
);
|
||||
)
|
||||
? 1
|
||||
: 0;
|
||||
data.group_id = $("#id-group-" + current).val();
|
||||
|
||||
$.ajax({
|
||||
|
@ -139,8 +141,8 @@ function reloadContent(id, url, options, side, noneStr) {
|
|||
|
||||
for (var [value, label] of items) {
|
||||
if (
|
||||
$("#" + opposite + " option[value=" + value + "]").length == 0 &&
|
||||
$("#tmp-" + current + " option[value=" + value + "]").length == 0
|
||||
$("#" + opposite + " option[value='" + value + "']").length == 0 &&
|
||||
$("#tmp-" + current + " option[value='" + value + "']").length == 0
|
||||
) {
|
||||
// Does not exist in opposite box nor is filtered.
|
||||
$("#" + current).append(new Option(label, value));
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
flex: 1 1 200px;
|
||||
min-width: 200px;
|
||||
}
|
||||
.multi-select-container * {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.multi-select.flex-column {
|
||||
justify-content: space-between;
|
||||
|
@ -16,10 +13,12 @@
|
|||
|
||||
.multi-select-container.flex-column {
|
||||
flex-wrap: nowrap;
|
||||
align-self: flex-end;
|
||||
}
|
||||
|
||||
.arrows-container {
|
||||
width: 50px;
|
||||
margin-bottom: 65px;
|
||||
}
|
||||
|
||||
.multi-select-container .filter input,
|
||||
|
@ -40,8 +39,11 @@
|
|||
|
||||
.group-filter.flex-row-vcenter div,
|
||||
.item-filter.flex-row-vcenter div {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.multi-select-container .title {
|
||||
|
@ -58,3 +60,14 @@
|
|||
.multi-select-container.flex-column div input {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.multi-select-container
|
||||
.select2-container--default
|
||||
.select2-selection--single
|
||||
.select2-selection__rendered {
|
||||
line-height: inherit !important;
|
||||
}
|
||||
|
||||
.p-slider {
|
||||
margin: auto !important;
|
||||
}
|
||||
|
|
|
@ -612,6 +612,13 @@ select:-internal-list-box {
|
|||
align-items: center;
|
||||
}
|
||||
|
||||
.flex-row-end {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.flex-space-around {
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue