|
dolibarr 25.0.0-alpha
|
Text engine for the BEGIN/END MODULEBUILDER PERMISSIONS section of a module descriptor. More...
Go to the source code of this file.
Classes | |
| class | PermissionsBlock |
| Text engine for the BEGIN/END MODULEBUILDER PERMISSIONS section of a module descriptor. More... | |
Functions | |
| detectRightsShapeWarnings (array $permissions) | |
| List the rights carrying indexes the renderer will drop. | |
| render (array $permissions) | |
| Render a rights array as the new content of the permissions block. | |
| assignOffsets (array $group) | |
| Give each right of one object its numbering offset. | |
| escapeForPhpSingleQuotedString (string $value) | |
| Escape a value for inclusion in a single-quoted PHP string literal. | |
| write (string $newInnerBlock) | |
| Replace the whole permissions block, markers included, in a single write. | |
Text engine for the BEGIN/END MODULEBUILDER PERMISSIONS section of a module descriptor.
Definition in file PermissionsBlock.class.php.
|
private |
Give each right of one object its numbering offset.
The three standard crud codes keep their canonical offset. Any other code — or a duplicate standard one — takes the next free offset from 3 upwards, so two rights of the same object can never collide on the same permission id.
| array<int,array<int,string>> | $group Rights of a single object |
| array{offset:int,right:array<int,string>} | $a First entry to compare |
| array{offset:int,right:array<int,string>} | $b Second entry to compare |
Definition at line 287 of file PermissionsBlock.class.php.
References string.
Referenced by render().
| detectRightsShapeWarnings | ( | array | $permissions | ) |
List the rights carrying indexes the renderer will drop.
Indexes 2 and 3 are obsolete in modern Dolibarr. Dropping them is the correct migration, so this is reported as a warning and does not prevent the write.
| array<int,array<int,string>> | $permissions Rights array to inspect |
Definition at line 222 of file PermissionsBlock.class.php.
|
private |
Escape a value for inclusion in a single-quoted PHP string literal.
GETPOST(..., 'alpha') keeps the single quote, the semicolon, the dollar sign and parentheses, so a label reaches this class able to close the literal it is written into.
| string | $value | Raw value |
Definition at line 331 of file PermissionsBlock.class.php.
Referenced by render().
| render | ( | array | $permissions | ) |
Render a rights array as the new content of the permissions block.
Only indexes 0, 1, 4 and 5 are emitted: the historical code rewrote those four but imploded the whole row, so a right carrying the obsolete index 2 or 3 had its raw value written into the descriptor, which then no longer parsed.
| array<int,array<int,string>> | $permissions Rights array to render |
Definition at line 248 of file PermissionsBlock.class.php.
References $id, assignOffsets(), escapeForPhpSingleQuotedString(), and string.
| write | ( | string | $newInnerBlock | ) |
Replace the whole permissions block, markers included, in a single write.
dolReplaceInFile() already writes to a .tmp file and dol_move()s it into place, so the write itself is atomic. What matters here is that there is exactly ONE of them: the historical code deleted the block and then inserted the new one, leaving the descriptor without any permissions block whenever the second write failed.
Regex mode is mandatory, not a style choice: in plain mode dolReplaceInFile() runs the whole file through make_substitutions(), which expands __(Key)__ and [class:method:id] patterns anywhere in the descriptor and even instantiates classes to do so.
| string | $newInnerBlock | New block content, markers excluded |
Definition at line 351 of file PermissionsBlock.class.php.
References dol_syslog(), and dolReplaceInFile().
Referenced by dolReceiptPrinter\sendToPrinter().