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

Trying to extend XenForo_Permission

Discussion in 'XenForo Development Discussions' started by Jake B., Nov 18, 2014.

  1. Jake B.

    Jake B. Well-Known Member

    I am trying to extend XenForo_Permission, more specifically the 'hasPermission' function in it, however it does not seem to be working, What I have is below:

    Permission.php:
    Code:
    <?php
    class XXX_Permission extends XFCP_XXX_Permission
    {
    public static function hasPermission(array $permissions, $group, $permission)
    {
    die;
    }
    }
    
    So the page shouldn't load after the first time a permission is checked, though it does not seem to be working. I was just wondering if for some reason it is not possible to extend this class, as I do not have issues with any of the other classes being extended in the same manner using the same loadClass function. Help would be greatly appreciated.

    Also, my code loadClass function is similar to the following:

    Code:
    public static function loadClass($class, array &$extend)
    {
    switch ($class)
    {
    case 'XenForo_Permission':
    $extend[] = 'XXX_Permission';
    break;}
    }
    
    If this is not possible, do you happen to have any idea of how to extend this functionality?
     
  2. Jake B.

    Jake B. Well-Known Member

    Looks like the only classes that are loaded (on the index page by default) are
    Odd. Guess I can extend the hasPermission in XenForo_Visitor, that *should* be all that I need.
     
  3. tyteen4a03

    tyteen4a03 Well-Known Member

    XenForo_Permission is a core class; it cannot be extended. (There's no point either; it's a bunch of helper functions)

    You may want to instead modify the permission array itself.
     
  4. Jake B.

    Jake B. Well-Known Member

    It's not feasible to do that, due to the number of calls to hasPermission. It works fine for my needs by extending XenForo_Visitor::hasPermission()
     
  5. tyteen4a03

    tyteen4a03 Well-Known Member

    Can't you extend XenForo_Model_Permission?
     

Share This Page