Changes

m
no edit summary
Line 10: Line 10:  
It contains all informations of the current user.
 
It contains all informations of the current user.
 
Its permissions can be tested by a test
 
Its permissions can be tested by a test
if ($user->rights->module->codestringlevel1->codestringlevel1)
+
<source lang="php">
 +
if ($user->rights->module->codestringlevel1->codestringlevel1)
 +
</source>
    
To know list of groups in which a user is, you can use the following code (Dolibarr 2.5 or more):
 
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);
+
<source lang="php">
$listofgroups=$usergroup->listGroupsForUser($fuser);
+
$usergroup=new UserGroup($db);
print $listofgroups[0]->nom;
+
$listofgroups=$usergroup->listGroupsForUser($fuser);
 +
print $listofgroups[0]->nom;
 +
</source>
 
$listofgroups is an array of all objects UserGroups (the groups) where the user $fuser belongs to
 
$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
 
and $fuser is the object User loaded with code
$fuser=new User($db);
+
<source lang="php">
$fuser->fetch('login');
+
$fuser=new User($db);
 +
$fuser->fetch('login');
 +
</source>
    
= Array of available permissions =
 
= Array of available permissions =