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

Unsure of how to setup this "option"

Discussion in 'XenForo Development Discussions' started by XoO, Mar 1, 2014.

  1. XoO

    XoO Member

    For he plugin I'm working on, currently each usergroup can only interact with 1 other usergroup and that group is set through a permission for that usergroup
    So when your setting permissions for a Usergroup, you can either set "0" to interact with all other usergroups or an ID to interact with a specific usergroup.
    What I would like is to be able to setup an option that would let me make a usergroup selector for each usergroup
    So for example:

    Administrative: [X]Administrative
    [ ]Moderator

    Moderator: [ ]Administrative
    [ ]Moderator

    Registered: [ ]Administrative
    [ ]Moderator
    [ ]Registered

    So from the example above, Administrative can interact with Administrative and Registered
    Moderator can interact with only Registered
    Registered cannot interact with any groups

    I've coded the above with a php callback
    The problem i'm running into is the Array sub-options
    Ideally i'd like the sub options to be the usergroup IDs

    Any suggestions on how to do this or any other approaches that would work?
  2. Aayush

    Aayush Well-Known Member

    Maybe this would help you

    /*                                                                        *
    * Top Poster of The Month                                                   *
    * Top poster leaderboard which automatically gets the top posters each   *
    * month and displays them in a leaderboard.                              *
    * Also includes a sidebar leaderboard option and previous Winner          *
    *                                                                          *
    * Addon - Xenforo                                                          *
    *                                                                           *
    * Aayush Ranaut                                                          *
    * Copyright (c) LiquidServe.com. All rights reserved.                      *
    *                                                                        */
    class PosterOfMonth_Options extends XenForo_Option_UserGroupChooser
         * Renders the Checkbox with the list of all the User Groups Available
         * @param XenForo_View $view
         * @param              $fieldPrefix
         * @param array        $preparedOption
         * @param              $canEdit
         * @return Rendered HTML    Checkboxes with User Groups
        public static function renderCheckbox(XenForo_View $view, $fieldPrefix, array $preparedOption, $canEdit)
            return self::_render('option_list_option_checkbox', $view, $fieldPrefix, $preparedOption, $canEdit);
    I callback this PHP function which lets me show the usergroup options available.
    Sadik B likes this.
  3. XoO

    XoO Member

    I managed to figure it out
  4. HotCopper

    HotCopper Member

    Aayush, Mine shows the list and saves to db, but its not showing the saved values (checked) when the option is reloaded

Share This Page