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

access

Summary

Checks if the current user has access to a given function.

Usage

fetch( 'content', 'access',
       hash( 'access',                 access,
             'contentobject',          contentobject,
           [ 'contentclass_id',        contentclass_id,       ]
           [ 'parent_contentclass_id', parent_contentclass_id ] ) )

Parameters

NameTypeDescriptionRequired
access string The desired access method (see below). Yes.
contentobject object The target/location (either an object or a node). Yes.
contentclass_id integer, string The ID number or identifier of the class that should be included in the check. No.
parent_contentclass_id integer, string The parent node's class ID number or identifier that should be included in the check. No.

Returns

TRUE if access is allowed, FALSE otherwise.

Description

This function makes it possible to find out if the current user has access (read, edit, create, remove, etc.) to a given content object or a content node. The optional parameters "contentclass_id" and "parent_content_class_id" can be used to finetune the checking. These parameters are compatible with both class ID numbers and class identifier strings. The function supports checking for the following access methods:

  • bookmark
  • create
  • edit
  • move
  • read
  • remove
  • pdf (deprecated)
  • restore
  • translate
  • versionread

When checking "create" access and the "contentclass_id" is not specified, the function will return TRUE as long as there is a create access for the given object. However, the user could still not be allowed to create a specific class.

Examples

Example 1

{def $test=fetch( 'content', 'access',
                  hash( 'access', 'read',
                        'contentobject', $node ) )}
 
{if $test}
    The current user has read access to the given node.
{else}
    The current user does not have read access to the given node.
{/if}

Checks if the content node represented by $node is can be read by the current user.

Example 2

{def $test=fetch( 'content', 'access',
                  hash( 'access', 'create',
                        'contentobject', $node,
                        'contentclass_id', 'folder' ) )}
 
{if $test}
    The current user can create a folder below the given node.
{else}
    The current user can not create a folder below the given node.
{/if}

Checks if the current user can create an instance of a given class below the specified node.

Balazs Halasy (01/06/2004 4:52 pm)

Julia Shymova (18/01/2008 1:25 pm)

Balazs Halasy, Julia Shymova


Comments

There are no comments.