';
@@ -1464,7 +1471,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
print ''.$langs->trans("ActionRefuseCP").'';
// Button Cancel (because we can't approve)
- if (in_array($object->fk_user, $childids) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))) {
+ if ($cancreate || $cancreateall) {
if (($object->date_debut > dol_now()) || !empty($user->admin)) {
print 'id.'&action=cancel&token='.newToken().'" class="butAction">'.$langs->trans("ActionCancelCP").'';
} else {
@@ -1473,17 +1480,15 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
}
}
}
- if ($object->statut == Holiday::STATUS_APPROVED) { // If validated or approved
- if ($user->id == $object->fk_validator
- || in_array($object->fk_user, $childids)
- || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))) {
+ if ($object->statut == Holiday::STATUS_APPROVED) { // If validated and approved
+ if ($user->id == $object->fk_validator || $cancreate || $cancreateall) {
if (($object->date_debut > dol_now()) || !empty($user->admin)) {
print 'id.'&action=cancel&token='.newToken().'" class="butAction">'.$langs->trans("ActionCancelCP").'';
} else {
print 'trans("NotAllowed").'">'.$langs->trans("ActionCancelCP").'';
}
} else { // I have no rights on the user of the holiday.
- if (!empty($user->admin)) { // If current validator can't cancel an approved leave, we allow admin user
+ if (!empty($user->admin)) { // If current approver can't cancel an approved leave, we allow admin user
print 'id.'&action=cancel&token='.newToken().'" class="butAction">'.$langs->trans("ActionCancelCP").'';
} else {
print ''.$langs->trans("ActionCancelCP").'';
@@ -1491,7 +1496,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
}
}
- if ($cancreate && $object->statut == Holiday::STATUS_CANCELED) {
+ if (($cancreate || $cancreateall) && $object->statut == Holiday::STATUS_CANCELED) {
print 'id.'&action=backtodraft" class="butAction">'.$langs->trans("SetToDraft").'';
}
if ($candelete && ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED)) { // If draft or canceled or refused
diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php
index b11b795723c..1e9c5602704 100644
--- a/htdocs/holiday/document.php
+++ b/htdocs/holiday/document.php
@@ -93,23 +93,6 @@ if (($id > 0) || $ref) {
}
}
-/*$cancreate = 0;
-
-if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)) {
- $cancreate = 1;
-}
-if (!empty($user->rights->holiday->write) && in_array($fuserid, $childids)) {
- $cancreate = 1;
-}
-
-$candelete = 0;
-if (!empty($user->rights->holiday->delete)) {
- $candelete = 1;
-}
-if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) {
- $candelete = 1;
-}
-*/
$upload_dir = $conf->holiday->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, '');
$modulepart = 'holiday';
diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php
index 207c7c31707..b4985100e44 100644
--- a/htdocs/holiday/list.php
+++ b/htdocs/holiday/list.php
@@ -488,9 +488,15 @@ if ($resql) {
print '
';
- $canedit = (($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))));
+ $cancreate = 0;
+ if (!empty($user->rights->holiday->writeall)) {
+ $cancreate = 1;
+ }
+ if (!empty($user->rights->holiday->write) && in_array($user_id, $childids)) {
+ $cancreate = 1;
+ }
- if ($canedit) {
+ if ($cancreate) {
print ''.$langs->trans("AddCP").'';
}
diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
index c062b57c482..e60208cf56d 100644
--- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
+++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
@@ -482,3 +482,5 @@ ALTER TABLE llx_inventorydet ADD COLUMN fk_movement integer NULL;
ALTER TABLE llx_stock_mouvement MODIFY COLUMN origintype varchar(64);
ALTER TABLE llx_intracommreport CHANGE COLUMN period periods varchar(32);
+
+UPDATE llx_rights_def SET perms = 'writeall' WHERE perms = 'writeall_advance' AND module = 'holiday';
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 94e21f076e3..02a88e8a453 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -893,12 +893,11 @@ Permission701=Read donations
Permission702=Create/modify donations
Permission703=Delete donations
Permission771=Read expense reports (yours and your subordinates)
-Permission772=Create/modify expense reports
+Permission772=Create/modify expense reports (for you and your subordinates)
Permission773=Delete expense reports
-Permission774=Read all expense reports (even for user not subordinates)
Permission775=Approve expense reports
Permission776=Pay expense reports
-Permission777=Read expense reports of everybody
+Permission777=Read all expense reports (even those of user not subordinates)
Permission778=Create/modify expense reports of everybody
Permission779=Export expense reports
Permission1001=Read stocks
@@ -977,9 +976,9 @@ Permission10005=Delete website content
Permission20001=Read leave requests (your leave and those of your subordinates)
Permission20002=Create/modify your leave requests (your leave and those of your subordinates)
Permission20003=Delete leave requests
-Permission20004=Read all leave requests (even of user not subordinates)
-Permission20005=Create/modify leave requests for everybody (even of user not subordinates)
-Permission20006=Admin leave requests (setup and update balance)
+Permission20004=Read all leave requests (even those of user not subordinates)
+Permission20005=Create/modify leave requests for everybody (even those of user not subordinates)
+Permission20006=Administer leave requests (setup and update balance)
Permission20007=Approve leave requests
Permission23001=Read Scheduled job
Permission23002=Create/update Scheduled job
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index d9d8f5dd6da..f4c7a7352ea 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -1080,11 +1080,12 @@ class User extends CommonObject
$sql .= " ".MAIN_DB_PREFIX."rights_def as r";
$sql .= " WHERE r.id = ur.fk_id";
if (!empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY)) {
- // on old version, we use entity defined into table r
+ // on old version, we use entity defined into table r only
$sql .= " AND r.entity IN (0,".(!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? "1," : "").$conf->entity.")";
} else {
- // we must now use entity into table ur
- $sql .= " AND ur.entity = ".((int) $conf->entity);
+ // On table r=rights_def, the unique key is (id, entity) because id is hard coded into module descriptor and insert during module activation.
+ // So we must include the filter on entity on both table r. and ur.
+ $sql .= " AND r.entity = ".((int) $conf->entity)." AND ur.entity = ".((int) $conf->entity);
}
$sql .= " AND ur.fk_user= ".((int) $this->id);
$sql .= " AND r.perms IS NOT NULL";