diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 1151ef4abb9..4b12e54dc97 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -79,6 +79,11 @@ if ($action == 'set' && $user->admin) { $result=activateModule($value); if ($result) setEventMessages($result, null, 'errors'); + else + { + $msg = $langs->trans('ModuleEnabledAdminMustCheckRights'); + setEventMessages($msg, null, 'warnings'); + } header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); exit; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index c57c01dfc36..6dad591cf0a 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1752,3 +1752,5 @@ AddSubstitutions=Add keys substitutions DetectionNotPossible=Detection not possible UrlToGetKeyToUseAPIs=Url to get token to use API (once token has been received it is saved on database user table and will be checked on each future access) ListOfAvailableAPIs=List of available APIs +ModuleEnabledAdminMustCheckRights=Module has been activated. All permissions were given to admin users only. +UserHasNoPermissions=This user has no permission defined \ No newline at end of file diff --git a/htdocs/user/card.php b/htdocs/user/card.php index acfe1c85cd7..319e4880efa 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1129,6 +1129,10 @@ else $object->fetch($id); if ($res < 0) { dol_print_error($db,$object->error); exit; } $res=$object->fetch_optionals($object->id,$extralabels); + + // Check if user has rights + $object->getrights(); + if(empty($object->nb_rights)) setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings'); // Connexion ldap // pour recuperer passDoNotExpire et userChangePassNextLogon diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 51945677694..f35356a9f81 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -107,6 +107,7 @@ class User extends CommonObject var $rights; // Array of permissions user->rights->permx var $all_permissions_are_loaded; /**< \private all_permissions_are_loaded */ private $_tab_loaded=array(); // Array of cache of already loaded permissions + var $nb_rights; // Number of rights granted to the user var $conf; // To store personal config var $oldcopy; // To contains a clone of this when we need to save old properties of object @@ -138,6 +139,7 @@ class User extends CommonObject // For cache usage $this->all_permissions_are_loaded = 0; + $this->nb_rights = 0; // Force some default values $this->admin = 0; @@ -629,10 +631,12 @@ class User extends CommonObject if ($subperms) { if (! isset($this->rights->$module->$perms) || ! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = new stdClass(); + if(empty($this->rights->$module->$perms->$subperms)) $this->nb_rights++; $this->rights->$module->$perms->$subperms = 1; } else { + if(empty($this->rights->$module->$perms)) $this->nb_rights++; $this->rights->$module->$perms = 1; } @@ -679,10 +683,12 @@ class User extends CommonObject if ($subperms) { if (! isset($this->rights->$module->$perms) || ! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = new stdClass(); + if(empty($this->rights->$module->$perms->$subperms)) $this->nb_rights++; $this->rights->$module->$perms->$subperms = 1; } else { + if(empty($this->rights->$module->$perms)) $this->nb_rights++; $this->rights->$module->$perms = 1; }