I'm getting frustrated because I can't get it to work.
This is for vBulletin 3.6.0 RC 3
Install Code
PHP Code:
require_once(DIR . '/includes/class_dbalter.php');
$dbalter = new vB_Database_Alter_MySQL($db);
$dbalter->fetch_table_info('administrator');
if (!$dbalter->fetch_field_info('hostingadminperms'))
{
$dbalter->add_field(array('name' => 'hostingadminperms', 'type' => 'INT', 'length' => '10', 'attributes' => 'UNSIGNED', 'null' => 'NOT_NULL', 'default' => '0'));
}
Uninstall Code
PHP Code:
unset($vbulletin->bf_misc_hostingadminperms['canadminhosting']);
if (empty($vbulletin->bf_misc_hostingadminperms))
{
require_once(DIR . '/includes/class_dbalter.php');
$dbalter = new vB_Database_Alter_MySQL($db);
$dbalter->fetch_table_info('administrator');
if (!$dbalter->fetch_field_info['hostingadminperms'])
{
$dbalter->drop_field('hostingadminperms');
}
}
--Hooks--
admindata_start
PHP Code:
$this->validfields['hostingadminperms'] = array(TYPE_UINT, REQ_NO);
$this->bitfields['hostingadminperms'] = $this->registry->bf_misc_hostingadminperms;
admin_permissions_form
PHP Code:
print_yes_no_row($vbphrase['can_administer_hosting'], 'hostingadminperms[canadminhosting]', ($user['hostingadminperms'] & $vbulletin->bf_misc_hostingadminperms['canadminhosting']));
admin_permissions_process
PHP Code:
$vbulletin->input->clean_gpc('p', 'hostingadminperms', TYPE_ARRAY_INT);
$admindm->set_bitfield('hostingadminperms', 'canadminhosting', $vbulletin->GPC['hostingadminperms']['canadminhosting']);
can_administer
PHP Code:
if (!isset($admin))
{
// this is not vBulletin 3.5.4+
global $admin;
}
if (!isset($admin))
{
// must get our perms
$getperms = $vbulletin->db->query_first("
SELECT *
FROM " . TABLE_PREFIX . "administrator
WHERE userid = " . $vbulletin->userinfo['userid']
);
$admin = $getperms;
}
foreach ($do AS $field)
{
if ($admin['hostingadminperms'] & $vbulletin->bf_misc_hostingadminperms["$field"])
{
$return_value = true;
}
}
I create a bitfield XML with
PHP Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<bitfields product="Hosting">
<bitfielddefs>
<group name="misc">
<group name="hostingadminperms">
<bitfield name="canadminhosting" phrase="can_administer_hosting">1</bitfield>
</group>
</group>
</bitfielddefs>
</bitfields>
I didn't know what to make bitfield number so I just did the date I created it (m/d/yy).