From af509742e6a16910f55b9e95e21527dc1726a0b3 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 1 Jun 2021 16:34:39 +0200 Subject: [PATCH] Fix #17726 : holliday with advanced perms works --- htdocs/holiday/card.php | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index bab0655b4c2..97a70782e36 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -163,19 +163,23 @@ if (empty($reshook)) { $description = trim(GETPOST('description', 'restricthtml')); // Check that leave is for a user inside the hierarchy or advanced permission for all is set - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->holiday->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->id == $fuserid && empty($user->rights->holiday->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->id != $fuserid && empty($user->rights->holiday->writeall_advance)) - ) { - $error++; - setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors'); + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { + if (empty($user->rights->holiday->write)) { + $error++; + setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors'); + } elseif (!in_array($fuserid, $childids)) { + $error++; + setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors'); + $action = 'create'; + } } else { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance)) { - if (!in_array($fuserid, $childids)) { - $error++; - setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors'); - $action = 'create'; - } + if (empty($user->rights->holiday->write) && empty($user->rights->holiday->writeall_advance)) { + $error++; + setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors'); + } elseif (empty($user->rights->holiday->writeall_advance) && !in_array($fuserid, $childids)) { + $error++; + setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors'); + $action = 'create'; } } @@ -1136,7 +1140,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { } // On vérifie si l'utilisateur à le droit de lire cette demande - if ($cancreate) { + if ($canread) { $head = holiday_prepare_head($object); if (($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) || ($action == 'editvalidator')) {