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.
Balazs Halasy (02/04/2005 9:32 pm)
Balazs Halasy (29/04/2005 9:29 am)
Comments
In case of modules without per function access level use 'function', 'all'
Saturday 06 August 2005 7:13:00 pm
Gabriel Ambuehl