MyBB Support

[Plugin Help] Making available to certain usergroups

Submitted by Tropical, , Thread ID: 3944

Thread Closed

RE: [Plugin Help] Making available to certain usergroups

Akay
We are!
Level:
0
Reputation:
28
Posts:
946
Likes:
109
Credits:
2.05K
18-05-2015, 07:45 AM
#2
PHP Code:
function PLUGIN_install()
{
global 
$db$lang;

$insertarray = array(
'name' => 'PLUGIN - SETTINGS'
'title' => 'IDK'
'description' => "IDK"
'disporder' => 100
'isdefault' => 0
);
$gid $db->insert_query("settinggroups"$insertarray);

$setting = array(
"sid"=> NULL,
"name"=> "PLUGIN_usergroups",
"title"=> "Allowed Usergroups",
"description"=> "Enter the IDs (GIDS) of the groups allowed to use this feature. (use \'all\' to allow everyone)",
"optionscode"=> "text",
"value"=> 'all',
"disporder"=> 1,
"gid"=> $gid
);

$db->insert_query("settings"$setting);

rebuild_settings();
}

function 
PLUGIN_uninstall()
{
global 
$db$mybb;

// This deletes the setting group
$db->delete_query("settinggroups""name = 'PLUGIN'");

// And this removes the settings
$db->delete_query('settings''name IN (\'PLUGIN_usergroups\')');

rebuild_settings();
}

function 
PLUGIN_check_permissions($groups_comma)
{
global 
$mybb;

if (
$groups_comma == '')
return 
false;

if (
$groups_comma == 'all')
return 
true;

$groups explode(","$groups_comma);

$ourgroups explode(","$mybb->user['additionalgroups']);
$ourgroups[] = $mybb->user['usergroup'];

if(
count(array_intersect($ourgroups$groups)) == 0)
return 
false;
else
return 
true;
}

function 
PLUGIN_page()
{
global 
$mybb$lang$cache$db$templates$header$headerinclude$footer$theme$usercpnav;

$lang->load("PLUGIN");

if(
$mybb->input['action'] != 'PLUGIN')
return;

if (!
$mybb->user['uid'])
error_no_permission();

if (!
PLUGIN_check_permissions($mybb->settings['PLUGIN_usergroups']))
error_no_permission();

if(
$mybb->request_method == "post")
{
// Verify incoming POST request
verify_post_check($mybb->input['my_post_key']);

$errors = array();

if(
count($errors) > 0)
{
$errors inline_error($errors);
}
}




Users browsing this thread: 1 Guest(s)