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

User Group Permissions: Administrative

Discussion in 'XenForo Development Discussions' started by AndyB, Aug 8, 2014.

  1. AndyB

    AndyB Well-Known Member

    Hello,

    I would like to change the sorting of this template.

    pic001.jpg

    The reason is that XenForo sets the Interface Group/Display Order between 1 and 205. So I have set my Group/Display Order add-ons all set to 300. This way they all fall after the default XenForo Permission Groups.

    What I would like to do is add a secondary sort to the Model.

    Could someone please point me to the correct Model that is used get the values which this template uses.

    Thank you.
     
    Floyd R Turbo likes this.
  2. Chris D

    Chris D XenForo Developer Staff Member

    You might have to elaborate somewhat. For what purpose do you need a secondary sorting criteria?

    Is the secondary criteria sorting an add-on in itself or part of some other add on you are releasing?
     
  3. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    I would LOVE to be able to change the display sorting order of permissions. @AndyB when you develop this addon, I'd be happy to test it for you!! :D
     
  4. AndyB

    AndyB Well-Known Member

    Hi Chris,

    When I want to change a User Group Permission for one of my add-ons, this is what I see:

    (scrolled all way down to show there is no secondary sorting)

    pic001.jpg

    Amazon should show before the other add-ons.
     
  5. AndyB

    AndyB Well-Known Member

    Got it.

    library/XenForo/Model/Permission.php

    Line 399 original code
    PHP:
        /**
         * Gets all permission interface groups in order.
         *
         * @return array Format: [interface group id] => interface group info
         */
        
    public function getAllPermissionInterfaceGroups()
        {
            return 
    $this->fetchAllKeyed('
                SELECT *
                FROM xf_permission_interface_group
                ORDER BY display_order
            '
    'interface_group_id');
        }
    Line 399 modified code
    PHP:
        /**
         * Gets all permission interface groups in order.
         *
         * @return array Format: [interface group id] => interface group info
         */
        
    public function getAllPermissionInterfaceGroups()
        {
            return 
    $this->fetchAllKeyed('
                SELECT *
                FROM xf_permission_interface_group
                ORDER BY display_order, addon_id
            '
    'interface_group_id');
        }
     
    Valhalla likes this.
  6. AndyB

    AndyB Well-Known Member

  7. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    Done!
     
    AndyB likes this.
  8. Rutger

    Rutger Member

    Liked!
     
  9. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    @AndyB in ACP, Debug mode on > Dev tab > Permissions Definitions you can edit each permissions interface group and change the display order.

    my question is, does this get overridden on an upgrade? Maybe a question for @Chris D.

    My purpose is just wanting to sort the permissions to my liking. I'm assuming that "Display Order" is just that, and not a priority order of any kind. I know that sounds kind stupid but better to ask...just dabbling with debug mode
     
  10. Chris D

    Chris D XenForo Developer Staff Member

    It is indeed harmless to change the display order, but pretty pointless as they will get reset.

    If the permissions belong to an add-on, the display orders will be reset on upgrade (to the values defined by the add-on developer. If the permissions belong to XenForo, then the same happens when XF is upgraded (to the values defined by us).
     
    Floyd R Turbo likes this.
  11. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    Nice to know that I can do it though...thanks!
     

Share This Page