Module development: Difference between revisions

Jump to navigation Jump to search
m
Line 276: Line 276:
with correct value for mymodule.
with correct value for mymodule.


{{ToTranslate}}
Then you must fill the array $this->rights with as many entries than different permissions you need to manage.
Ensuite remplissez le tableau $this->rights avec autant d'entrée que de permissions différentes à gérer.


<source lang="php">
<source lang="php">
$this->rights[$r][0] = 10001;
$this->rights[$r][0] = 10001;
$this->rights[$r][1] = 'Libelle par défaut de ma permission';
$this->rights[$r][1] = 'Label by default of permission';
$this->rights[$r][3] = 1;
$this->rights[$r][3] = 1;
$this->rights[$r][4] = 'action';
$this->rights[$r][4] = 'action';
$this->rights[$r][5] = 'sousaction';
$this->rights[$r][5] = 'subaction';
$r++;
$r++;
</source>
</source>


Dans $this->rights[$r][0], mettre un id de permission non déjà pris (Voir dans le menu '''Infos Système''' sur une installation de Dolibarr opérationnelle pour connaitre les id déjà utilisés.
Into $this->rights[$r][0], put a permission id not already used (See into menu '''System info''' on a working installation of Dolibarr to know list of id already used by standard modules.
Dans $this->rights[$r][3], mettre 1 si cette permission est attribué d'office par défaut quand un utilisateur est créé.
Into $this->rights[$r][3], put 1 if this permission must be granted automatically by default to any new created user.
Dans $this->rights[$r][1], mettre un libellé par défaut (il sera affiché si aucune traduction n'est trouvé pour votre permission dans le fichier '''admin.lang''').
Into $this->rights[$r][1], put a label by default for permission (This label will be used if no translation can be found into the file '''admin.lang''').
Dans $this->rights[$r][4] et $this->rights[$r][5], mettre une chaine action et sousaction sans espaces. Vous pourrez alors tester dans le code PHP si un utilisateurs a bien les droits par la séquence suivante:
Into $this->rights[$r][4] and $this->rights[$r][5], put an action and subaction string without spaces. You will be able to test if a user has the permission in your PHP source code with the sequence:


<source lang="php">
<source lang="php">
if ($user->rights->monmodule->action->sousaction) ...
if ($user->rights->mymodule->action->subaction) ...
</source>
</source>


Navigation menu