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

Display user who has permission

Discussion in 'XenForo Development Discussions' started by Walky, Sep 7, 2014.

  1. Walky

    Walky Member

    Hi !

    I would to display all users who have a permission But didn't get it :(

    Route class code :
    PHP:
    <?php

    class Test_Route_PrefixAdmin_Test implements XenForo_Route_Interface
    {
           public function 
    match($routePathZend_Controller_Request_Http $requestXenForo_Router $router)
           {
                     return 
    $router->getRouteMatch('Test_ControllerAdmin_Test'$routePath);
           }
    }
    ControllerAdmin
    PHP:
    <?php

    class Test_ControllerAdmin_Test extends XenForo_ControllerAdmin_Abstract
    {
           public function 
    actionIndex()
           {
                   
    $visitor XenForo_Visitor::getInstance();
                   
    $usersCanViewPop $visitor->hasPermission('general''canViewPop');

                   
    $viewParams = array('usersCanViewPop' => $usersCanViewPop);
                   return 
    $this->responseView('Test_ViewAdmin_Test''test_permissions'$viewParams);
            }
    }
    Template test_permissions

    HTML:
    {$usersCanViewPop}
    
    Didn't display users who have the permissions (canViewPop)

    Thanks
     
    Last edited: Sep 7, 2014
  2. NinjaFox

    NinjaFox New Member

    Looks like you are querying the current visitor and not the user model?
     
  3. Walky

    Walky Member

    Mmmh possible :(
    How can i query the user model ?
     
  4. Adam K M

    Adam K M Active Member

    I believe this code is what you would do. I used this a while back to display all users who are a part of a certain usergroup. At any rate, here you are :)

    PHP:
                $criteria = array(
                    
    'secondary_group_ids' => $AvailableGroups
                
    );
                
    $options = array(
                    
    'join' => XenForo_Model_User::FETCH_USER_FULL,
                    
    'order' => 'username'
                
    );
                
    $finalUsers $this->getModelFromCache('XenForo_Model_User')->getUsers($criteria$options);
    The $criteria and $options variables are just what I used, and obviously, the $criteria array is what you want to filter for. Mind you, if you're looking for a specific permission given to users individually, then it will change in your case.
     
  5. Walky

    Walky Member

    Thanks you !
    But yes I'm looking for a specific permissions given to users individually :)
     
  6. Adam K M

    Adam K M Active Member

    Hmmm...

    There's probably a certain query you could use with your $criteria, but I'm not sure what it is.
     
  7. Walky

    Walky Member

    Mmhh I will see :)

    But I have only a ControllerAdmin and a Route Prefix so How can I insert the Model ?
     

Share This Page