Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
Permission check to return highest level?
  • Posted: 26.05.2007, 01:35
     
    uheweb
    rank:
    Professional Professional
    registered:
     September 2004
    Status:
    offline
    last visit:
    10.11.08
    Posts:
    815
    Is there a way to return the highest permission level for a user?

    Purpose:

    Return highest level permission and carry this through the function call, pass to Smarty templates, etc.

    Rather than iterate through all the permission levels (ie, have to start at admin which is the LEAST likely permission for general users, and iterate down until a TRUE is recieved) a function call that would return the highest level found would be preferred.

    Then, by assigning this "level" for the current function, all main, item read/overview, Smarty permissions (of assigned to the template) could run off this rather than having several calls to pnSecAuthAction.

    Perfect function would be say:

    pnSecAuthLevel(Realm, Component, Instance) that returns the numerical permission levels - 400 for moderate, 800 for admin, etc.

    Then, subsequent code could use a >= or <= to branch into the correct code for each permission.

    As is, a module function, say MODIFY, checks to see if user has EDIT permissions. Then, in the smarty template permission levels are often checked again for items like EDIT / DELETE / NEW links (based on ADD, EDIT, ADMIN or whatever permissions).

    I know I can create an iteration to do this, but that defeats the purpose of making the call once, and passing that to smarty. Might was well just call it once in the function, and more in the template if you're going to have to call it several times in the iteration.

    So, long story short - is there a minimalist way to get a users highest permission for the module/component/instance at hand?

    NCM
    UHEweb



    edited by: uheweb, May 25, 2007 - 01:52 PM

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula