vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Custom Administrator Permissions (https://vborg.vbsupport.ru/showthread.php?t=95918)

Alan @ CIT 07-28-2006 04:11 PM

It is at the bottom of "vBulletin : General Administration"

Thanks,
Alan.

harmor19 08-02-2006 04:03 PM

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_UINTREQ_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).

Dilmah 08-04-2006 06:12 AM

I have this in my custom XML file - the canadminnetwork option works fine, however the canadminrankings part (using your code) returns a value of 2 when Yes, or 0 when No.
Code:

    <bitfielddefs>
        <group name="misc">
            <group name="customadminperms">
                <bitfield name="canadminnetwork">1</bitfield>
                <bitfield name="canadminrankings">2</bitfield>                                                               
            </group>
        </group>
    </bitfielddefs>

Do I have to somehow put things into an array first or something? I tried a few things, but couldn't work it out.

harmor19 08-04-2006 07:21 AM

Quote:

Originally Posted by Dilmah
I have this in my custom XML file - the canadminnetwork option works fine, however the canadminrankings part (using your code) returns a value of 2 when Yes, or 0 when No.
Code:

    <bitfielddefs>
        <group name="misc">
            <group name="customadminperms">
                <bitfield name="canadminnetwork">1</bitfield>
                <bitfield name="canadminrankings">2</bitfield>                                                               
            </group>
        </group>
    </bitfielddefs>

Do I have to somehow put things into an array first or something? I tried a few things, but couldn't work it out.

It's supposed to return a value of 2 when you select "Yes".

Dilmah 08-04-2006 07:23 AM

Yes, but how do I put that into a print_yes_no_row for use in adminpermissions.php

harmor19 08-04-2006 07:26 AM

I have no idea. I need help with it as well.

Buraq 08-07-2006 04:35 PM

This is somewhat unrelated, but where can I get info on how to give my plugin an admincp back-end? I'm working on a small plugin for my forum and this would be very useful.

Surviver 10-27-2006 12:48 PM

Hello, Andreas, I've a problem: The permissions are not stored. When I click save and return to the Permission Overview, The Right i snot saved. (No is ever selected)

I dont know, where the problem is.

Thanks for Help !!!

Surviver

Because of my bed English: http://surviver.bokuv.de/ablage/admi...dminperms.html :D



//All ok, thanx Andreas :)

Gerakus 10-30-2006 04:08 PM

Same problem here.

First, Does this works with 3.6.0? If so what are the right steps to make it work.

Second, Any particular reason why doesnt save the permissions? it just don't do it, I have try in so many ways, but it appears vbulletin for some reason doesnt store the changes.

I am using vbulletin 3.6.0+

Also could you make this hack works with more than one custom permissions?

Thanks on advance.

Surviver 10-30-2006 04:25 PM

Quote:

Originally Posted by Gerakus
Same problem here.

First, Does this works with 3.6.0? If so what are the right steps to make it work.

Second, Any particular reason why doesnt save the permissions? it just don't do it, I have try in so many ways, but it appears vbulletin for some reason doesnt store the changes.


I am using vbulletin 3.6.0+

Also could you make this hack works with more than one custom permissions?

Thanks on advance.

have you created the Bitfield ? :)

Example:
Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<bitfields>
        <bitfielddefs>
                <group name="misc">
                        <group name="customadminperms">
                                <bitfield name="canadminmyhack">1</bitfield>
                        </group>
                </group>
        </bitfielddefs>
</bitfields>

Then it will work ;)


All times are GMT. The time now is 06:23 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01196 seconds
  • Memory Usage 1,773KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (7)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete