1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Unset Permission in Template

Discussion in 'XenForo Development Discussions' started by Deek, Sep 9, 2014.

  1. Deek

    Deek Member

    I've created a permission ['developers']['canDownload'] and I'd like to check the permission in templates.

    I check for the permission by using
    <xen:if is="{$visitor.permissions.developer.canDownload} == 'allow'">
    This will work if the permission is set to allow or never but the check does not get run properly in the default state, not set. Is there a template syntax that will check if a viewParam is unset so I can apply logic to it?
  2. Deek

    Deek Member

    When I change a permission from Never to No Set and dump out XenForo_Visitor::getInstance()->getPermissions(); ['developer']['canDownload'] will still show as True. Do non-node permission only have 'allow' and 'never' states but no way to check unset?
  3. Snog

    Snog Well-Known Member

    I believe it's 'allow', 'deny', 'unset' and 'use_int'. (could be wrong though)

    deny = never
    unset = no
  4. Deek

    Deek Member

    So I set the permission in 'User Permission' section for the user I'm testing in the admin section and here are the outputs:

    XenForo_Visitor::getInstance()->hasPermission('developer', 'canDownload')
    Not Set (No) => true
    Allow => true
    Never => false

    Why does Not Set return true?
    EDIT: Tried this with another user and didn't have the issue. Not sure what was causing it...
    Last edited: Sep 9, 2014

Share This Page