Permissions for Custom Module

Author Message

Erik Weinmaster

Monday 03 May 2010 11:05:02 am

I have a custom module where I define links to custom functionality. I have the module file set up where user roles match the functions list, and thus if someone doesn't have the correct permissions, they can't access the custom view.

However, the only way to tell if you can access the link is by clicking on it. All functions that I have found to inform the system before accessing belong to ezcontentobjecttreenode (can_edit, can_hide, etc.). This doesn't help me since my custom view doesn't have a content object.

Is there any way to see if a particular user has access to a custom module/function before they click on the link?

thanks,

erik

Håvard Bergersen

Monday 17 May 2010 12:27:59 pm

Maybe you can use this? Documented here http://ez.no/doc/ez_publish/technical_manual/4_x/reference/modules/user/fetch_functions/has_access_to

{def $access=fetch( 'user', 'has_access_to',                    
hash( 'module',   'yourModule',                          
      'function', 'yourFunction' ) )}

{if $access}    
<a href="#">Your link...</a>
{/if}

Jérôme Vieilledent

Monday 17 May 2010 1:45:27 pm

Hi Erik

eZJSCore extension has a very handy template operator (has_access_to_limitation). You can find details on the extension repository.

Besides, I've written a tutorial about permissions and policy limitation for custom modules. It will be published on share.ez.no very soon ;)

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.