Difference between revisions of "Permissions En"

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search
m
Line 7: Line 7:
 
= Get permission and groups of a user =
 
= Get permission and groups of a user =
 
{{ToTranslate}}
 
{{ToTranslate}}
Dans une page de code Dolibarr, l'objet global $user est automatiquement défini.
+
In the source code of a Dolibarr page, the global object $user is automatically defined.
Il contient les informations sur l'utilisateur courant.
+
It contains all informations of the current user.
Ces droits sont accessibles par un test
+
Its permissions can be tested by a test
  if ($user->rights->module->droit)
+
  if ($user->rights->module->codestringlevel1->codestringlevel1)
  
Pour connaitre les groupes auxquels un utilisateur appartient, on peut utiliser le code suivant (Dolibarr 2.5 ou plus):
+
To know list of groups in which a user is, you can use the following code (Dolibarr 2.5 or more):
 
  $usergroup=new UserGroup($db);
 
  $usergroup=new UserGroup($db);
 
  $listofgroups=$usergroup->listGroupsForUser($fuser);
 
  $listofgroups=$usergroup->listGroupsForUser($fuser);
 
  print $listofgroups[0]->nom;
 
  print $listofgroups[0]->nom;
$listofgroups étant un tableau de tous les objets UserGroups (les groupes) auxquels appartient l'utilisateur $fuser
+
$listofgroups is an array of all objects UserGroups (the groups) where the user $fuser belongs to
et $fuser étant un objet User chargé par
+
and $fuser is the object User loaded with code
 
  $fuser=new User($db);
 
  $fuser=new User($db);
 
  $fuser->fetch('login');
 
  $fuser->fetch('login');

Revision as of 14:26, 12 August 2009

Each permission has a unique ID. All permissions managed by Dolibarr are saved into Table llx_rights_def and has its own ID. This id is used to make link between a user and the permission (links are saved into Table llx_user_rights or to make link between groupe and the permission (links are saved into the Table llx_usergroup_rights).

Get permission and groups of a user

En verysmall.png Page waiting for translation. To translate, create an account, go back and clic on "Modify".
Fr verysmall.png Page en attente de traduction. Pour traduire, créez un compte, revenez et cliquez sur "Modifier".
Es verysmall.png Página a traducir. Para traducirla, cree una cuenta, vuelva a la página y haga clic en "editar".
It verysmall.png Pagina da tradurre. Per tradurla, crea un utente, torna indietro e clicca su "modifica".
Pt verysmall.png Página a aguardar por tradução. Para traduzir, crie uma conta, volte atrás e clique em "Modificar".
De verysmall.png Seite wartet auf Übersetzung. Um Übersetzung zu erstellen, richte einen Account ein, geh zurück und klicke auf "bearbeiten".
Zh verysmall.png 页面等待翻译。若要翻译本页,先创建一个帐户、登录并返回本页后单击“编辑”。

In the source code of a Dolibarr page, the global object $user is automatically defined. It contains all informations of the current user. Its permissions can be tested by a test

if ($user->rights->module->codestringlevel1->codestringlevel1)

To know list of groups in which a user is, you can use the following code (Dolibarr 2.5 or more):

$usergroup=new UserGroup($db);
$listofgroups=$usergroup->listGroupsForUser($fuser);
print $listofgroups[0]->nom;

$listofgroups is an array of all objects UserGroups (the groups) where the user $fuser belongs to and $fuser is the object User loaded with code

$fuser=new User($db);
$fuser->fetch('login');

Array of available permissions

Each module has its code string to use the $user->rights array to get its related permissions for user. List of code to use to read permissions are available of module developer documentation.

Click here to get full list of modules.