12400 getPermission

This commit is contained in:
Fred Tempez 2023-05-11 19:31:20 +02:00
parent b4f5546a5f
commit 4af57f42b7
1 changed files with 8 additions and 1 deletions

View File

@ -908,25 +908,32 @@ class common
*/
public function getPermission($key1, $key2 = null)
{
// User n'existe pas
if (is_array($this->user) === false) {
return false;
// Administrateur, toutes les permissions
} elseif ($this->getUser('group') === self::GROUP_ADMIN) {
return true;
// Groupe sans autorisation
} elseif ($this->getUser('group') < 1) {
return false;
// Groupe avec profil, consultation des autorisations sur deux clés
} elseif (
$key2
&& $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1])
&& array_key_exists($key2, $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1]))
) {
return $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1, $key2]);
// Groupe avec profil, consultation des autorisations sur une seule clé
} elseif (
$this->getData(['profil', $this->user['group'], $this->user['profil']])
&& array_key_exists($key1, $this->getData(['profil', $this->user['group'], $this->user['profil']]))
) {
return $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1]);
} else {
return false;
// Permission non spécifiée dans le profil est autorisée par défaut pour le fonctionnement de $action
return true;
//return false;
}
}