has_access_to
Summary
Checks if a user has access to a certain function of a module.
Usage
fetch( 'user', 'has_access_to',
hash( 'module', module
'function', function,
[ 'user_id', user_id ] ) )Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| module | string | The name of the module. | Yes. |
| function | string | The name of the function. | Yes. |
| user_id | integer | The ID number of the user. | No. |
Returns
TRUE if access is allowed, FALSE otherwise.
Description
This function checks if the current user has access to a certain function of a module. The name of the module and the function must be provided using the "module" and the "function" parameters. The optional "user_id" parameter can be used to check access for other users than the current user. The function returns TRUE if access is allowed, otherwise FALSE will be returned.
Examples
Example 1
{def $access=fetch( 'user', 'has_access_to',
hash( 'module', 'content',
'function', 'read',
'user_id', 128 ) )}
{if $access}
Access is allowed.
{else}
Access is denied.
{/if}Reveals if user number 128 has access to the read function of the content module.
Contributors
- Balazs Halasy Updated
- Gabriel Ambuehl Commenter
Comments (1 historical)
Written by readers of the earlier documentation sites, kept as they were.
In case of modules without per function access level use 'function', 'all'
Gabriel Ambuehl ·
I figured this while hacking on the owner change extension, it seems to work.