Merge branch 'ent-13291-Varios-problemas-en-Workspace-con-usuario-limitado-por-perfil-y-por-ACL-Ent' into 'develop'

Ent 13291 varios problemas en workspace con usuario limitado por perfil y por acl ent

See merge request artica/pandorafms!7279
This commit is contained in:
Jose Martin 2024-05-09 09:30:16 +00:00
commit ba5ed7b2cd
4 changed files with 70 additions and 43 deletions

View File

@ -37,7 +37,7 @@ if ($change_label === '1') {
$label = get_parameter('label', '');
$source = get_parameter('source', 0);
$user = get_parameter('user', '');
$value = get_parameter('value', 0) ? 1 : 0;
$value = get_parameter('value', 0);
$user_info = get_user_info($config['id_user']);
if ((bool) $user_info['is_admin'] === false && $config['id_user'] !== $user) {
return false;

View File

@ -680,7 +680,7 @@ function notifications_set_user_label_status($source, $user, $label, $value)
}
$exists = db_process_sql(sprintf('SELECT * FROM tnotification_source_user WHERE id_user = "%s" AND id_source = "%s"', $user, $source));
if (empty($exists['enabled']) && empty($exists['also_mail'])) {
if (empty($exists[0]['enabled']) && empty($exists[0]['also_mail'])) {
$sql = sprintf('DELETE FROM tnotification_source_user WHERE id_user = "%s" AND id_source = "%s"', $user, $source);
db_process_sql($sql);
$exists = false;

View File

@ -79,30 +79,49 @@ if (is_metaconsole()) {
} else {
$urls['main'] = 'index.php?sec=gusuarios&sec2=godmode/users/user_list';
$urls['notifications'] = 'index.php?sec=workspace&sec2=operation/users/user_edit_notifications';
$buttons = [
'main' => [
'active' => $_GET['sec2'] === 'godmode/users/user_list&tab=user&pure=0',
'text' => "<a href='{$urls['main']}'>".html_print_image(
'images/user.svg',
true,
[
'title' => __('User management'),
'class' => 'main_menu_icon invert_filter',
]
).'</a>',
],
'notifications' => [
'active' => $_GET['sec2'] === 'operation/users/user_edit_notifications',
'text' => "<a href='{$urls['notifications']}'>".html_print_image(
'images/alert@svg.svg',
true,
[
'title' => __('User notifications'),
'class' => 'main_menu_icon invert_filter',
]
).'</a>',
],
];
$buttons = [];
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
$buttons = [
'main' => [
'active' => $_GET['sec2'] === 'godmode/users/user_list&tab=user&pure=0',
'text' => "<a href='{$urls['main']}'>".html_print_image(
'images/user.svg',
true,
[
'title' => __('User management'),
'class' => 'main_menu_icon invert_filter',
]
).'</a>',
],
'notifications' => [
'active' => $_GET['sec2'] === 'operation/users/user_edit_notifications',
'text' => "<a href='{$urls['notifications']}'>".html_print_image(
'images/alert@svg.svg',
true,
[
'title' => __('User notifications'),
'class' => 'main_menu_icon invert_filter',
]
).'</a>',
],
];
} else {
$buttons = [
'notifications' => [
'active' => $_GET['sec2'] === 'operation/users/user_edit_notifications',
'text' => "<a href='{$urls['notifications']}'>".html_print_image(
'images/alert@svg.svg',
true,
[
'title' => __('User notifications'),
'class' => 'main_menu_icon invert_filter',
]
).'</a>',
],
];
}
$tab_name = 'User Management';
$helpers = '';

View File

@ -45,30 +45,38 @@ echo '<div id="user-notifications-wrapper" class="white_box table_div table_thre
$sources = notifications_get_all_sources();
$disabled_flag = false;
$disabled_flag = [];
$user_login = $config['id_user'];
foreach ($sources as $source) {
echo '<div class="table_tbody">';
$table_content = [
$source['description'],
notifications_print_user_switch($source, $id, 'enabled'),
notifications_print_user_switch($source, $id, 'also_mail'),
];
// Enabled notification user.
$users_notification = notifications_get_user_sources(
[
'id_source' => $source['id'],
'id_user' => $user_login,
],
['id_user']
);
$notifications_enabled = notifications_print_user_switch($source, $id, 'enabled');
$notifications_also_mail = notifications_print_user_switch($source, $id, 'also_mail');
if ((boolean) $source['enabled'] === true && $users_notification[0]['id_user'] === $user_login) {
echo '<div class="table_tbody">';
$table_content = [
notifications_print_user_switch($source, $id, 'enabled'),
notifications_print_user_switch($source, $id, 'also_mail'),
];
$notifications_enabled = notifications_print_user_switch($source, $id, 'enabled');
$notifications_also_mail = notifications_print_user_switch($source, $id, 'also_mail');
if ($notifications_enabled['disabled'] == 1 || $notifications_also_mail['disabled'] == 1) {
$disabled_flag = true;
$disabled_flag[] = true;
echo '<div class="table_td">'.$source['description'].'</div>';
echo '<div class="table_td">'.$notifications_enabled['switch'].'</div>';
echo '<div class="table_td">'.$notifications_also_mail['switch'].'</div>';
echo '</div>';
}
echo '<div class="table_td">'.$source['description'].'</div>';
echo '<div class="table_td">'.$notifications_enabled['switch'].'</div>';
echo '<div class="table_td">'.$notifications_also_mail['switch'].'</div>';
echo '</div>';
}
if ((bool) $disabled_flag === true) {
if (count($disabled_flag) === 0) {
ui_print_warning_message(
__('Controls have been disabled by the system administrator')
);