Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

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

NameTypeDescriptionRequired
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'

    I figured this while hacking on the owner change extension, it seems to work.