• 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"

#1
Hey,
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
[X]Registered

Moderator: [ ]Administrative
[ ]Moderator
[X]Registered

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?
 

Aayush

Well-known member
#2
Maybe this would help you

Code:
<?php
/*                                                                        *
* 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.