Custom Administrator Permissions
by
09 Sep 2005
Your Hack has an Admin Backend? Then you should consider protecting it with custom Admin Permissions - not every Admin has to be able to control everything. First of all, you have to decide on a uniqe Key for your Admin Permission, just like your Product ID. In this example I will use canadminmyhack. Go to your ACP File(s) and place the following Code below the Back-End requirement: PHP Code:
// ######################## CHECK ADMIN PERMISSIONS #######################
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <navgroups product="myhack"> <navgroup phrase="myhack_settings" hr="true" permissions="canadminmyhack"> <navoption> <phrase>demohack_foo</phrase> <link>demohack.php?do=foo</link> </navoption> <navoption> <phrase>demohack_modcp</phrase> <link>../{$vbulletin->config[Misc][modcpdir]}/foobar.php</link> </navoption> </navgroup> </navgroups> Code:
Varname: can_administer_myhack Text: Can Administer Myhack As the Permissions Editor only takes care of standard Permissions, you must create 4 Plugins: admin_permissions_form PHP Code:
print_yes_no_row($vbphrase['can_administer_myhack'], 'customadminperms[canadminmyhack]', ($user['customadminperms'] & $vbulletin->bf_misc_customadminperms['canadminmyhack']));
You must also create a Plugin for the Administrator Datamanager admindata_start PHP Code:
$this->validfields['customadminperms'] = array(TYPE_UINT, REQ_NO);
admin_permissions_process PHP Code:
$vbulletin->input->clean_gpc('p', 'customadminperms', TYPE_ARRAY_INT);
can_administer PHP Code:
foreach($do AS $field)
As you can see, I used customadminperms as the Bitfield. This is the Bitfield I will use for my Hacks, Bit 1 is already in use. If others want to use it too (to avoid having to create there own (Bit)fields) - feel free to do so. But please, first post here and state which Bit you are going to use and wait for an Okay so there won't be conflicts. To use it, create an appropriate Bitfield XML File. The following Install Code should be used then: PHP Code:
require_once(DIR . '/includes/class_dbalter.php');
PHP Code:
unset($vbulletin->bf_misc_customadminperms['canadminmyhack']);
1 - KirbyDE |