31,003
edits
| Line 276: | Line 276: | ||
with correct value for mymodule. | with correct value for mymodule. | ||
Then you must fill the array $this->rights with as many entries than different permissions you need to manage. | |||
<source lang="php"> | <source lang="php"> | ||
$this->rights[$r][0] = 10001; | $this->rights[$r][0] = 10001; | ||
$this->rights[$r][1] = ' | $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] = ' | $this->rights[$r][5] = 'subaction'; | ||
$r++; | $r++; | ||
</source> | </source> | ||
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. | |||
Into $this->rights[$r][3], put 1 if this permission must be granted automatically by default to any new created user. | |||
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'''). | |||
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-> | if ($user->rights->mymodule->action->subaction) ... | ||
</source> | </source> | ||