e107help.org Q&A
0 like 0 dislike
Build an awards plugin, in the admin area I want to create a dropdown menu like the one user's have for user classes - any idea on how to do that?
e107 version e107 2.1.6
closed
in Plugins by (459 points) 17 37 50

2 Answers

0 like 0 dislike
Best answer
After doing some digging in the e107_admin/users.php I found the line of code I can use.

 

$e_userclass = e107::getUserClass();

$temp = $e_userclass->vetted_tree('class', array($e_userclass, 'checkbox_desc'), $user_data['user_class'], 'classes, no-excludes');

        if ($temp)
        {
            $text .= "<tr style='vertical-align:top'>
            <td>
                ".USRLAN_120."
            </td>
            <td>
                <a href='#set_class' class='btn btn-default e-expandit'>".USRLAN_120."</a>
                <div class='e-hideme' id='set_class'>
                {$temp}
                </div>
            </td>
            </tr>\n";
        }

 

But modify it to do what I wanted to do (somewhat - i need to select 1 user class, and not many).

This is what I did in admin_config.php

'userclass_id' => array ( 'title' => 'User Class', 'type' => 'method', 'data' => 'int', 'width' => '5%', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',  )  <-- added Method as type, added custom method userclass_id and added this code to the fucntion.

case 'write': // Edit Page
                $temp = $e_userclass->vetted_tree('class', array($e_userclass, 'checkbox_desc'), $this->userclass_id['userclass_id'], 'classes, no-excludes');

                if ($temp)
                {
                    $text .= "<tr style='vertical-align:top'>
                    <td>
                        User Class (Select Only One):
                    </td>
                    <td>
                        <a href='#set_class' class='btn btn-default e-expandit'>User Class</a>
                        <div class='e-hideme' id='set_class'>
                            {$temp}
                        </div>
                    </td>
                    </tr>\n";
                }
                return $text;        
            break;
by (459 points) 17 37 50
0 like 0 dislike
Just as idea (do not know if it works in v2) take a look at Clan Members Basic v1.0  (maybe needs a rewrite???  https://e107.org/plugins/?id=476
by (3.4k points) 8 9 11
If a rewrite is needed, then I might as well make one - plus this one is more for a military style unit, so it would need more than what that plugin offers.
996 questions
1,389 answers
2,527 comments
2,512 users