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)

deathemperor 09-22-2005 03:48 PM

thanks, glad to hear that, I'll try it

Alan @ CIT 09-23-2005 12:52 AM

Hi Kirby, just 1 quick question if I may.

Quote:

To use it, create an appropriate Bitfield XML File.
What is an "appropriate Bitfield XML file"? Do you have a template of what one should look like?

Thanks,
Alan.

Dark_Wizard 10-03-2005 05:18 PM

Therer was an apparent restructuring of the file class_dbalter.php changing the class and functions used in Kirby's uninstall example.

fetch_table_info has now changed to fetchTableInfo and drop_field has changed to dropField and lastly table_field_data has changed to fetchFieldInfo.


new coding
PHP Code:

unset($vbulletin->bf_misc_customadminperms['canadminmyhack']);
if (empty(
$vbulletin->bf_misc_customadminperms))
{
    require_once(
DIR '/includes/class_dbalter.php');
    
$dbalter = new vB_Database_Alter_MySQL($db);
    
$dbalter->fetchTableInfo('administrator');
    if (!
$dbalter->fetchFieldInfo['customadminperms'])
    {
        
$dbalter->dropField('customadminperms');
    }


Lastly TABLE_PREFIX is no longer needed...

harmor19 01-04-2006 04:57 PM

I did everything the tutorial said and I can see the radio button in the admin permissions but when I click "yes" and save it, it goes back to "no".

Do I change customadminperms?

Kurisu 02-09-2006 09:22 PM

Quote:

Originally Posted by harmor19
I did everything the tutorial said and I can see the radio button in the admin permissions but when I click "yes" and save it, it goes back to "no".

Yes, same problem for me...

Revan 02-21-2006 12:38 AM

This thing doesn't actually work. (3.5.3)
After the first check of permissions, the static $adminpermissions; takes over, to which the custom permissions are not added.

Therefore an alternative solution is required.
I will look deeper into it tomorrow.

Andreas 02-21-2006 05:36 AM

You're right. Must have missed that issue as I only had one custom navgroup - and it was the first one.

I tweaked the code a bit to get around this.

Revan 02-21-2006 09:59 AM

Allow me to point out two facts:
  1. static doesn't work through eval(). Believe me, I tried. I worked with this for 3 hours straight yesterday XD
  2. You might not actually have to run a new query:
    PHP Code:

    global $admin;

    if (isset(
    $getperms['customadminperms']))
    {
        
    $admin $getperms['customadminperms'];
    }

    if (!isset(
    $admin))
    {
        
    // must get our perms
        
    $getperms $vbulletin->db->query_first("
            SELECT `customadminperms`
            FROM " 
    TABLE_PREFIX "administrator
            WHERE userid = " 
    $vbulletin->userinfo['userid']
        ); 
        
        
    $admin $getperms['customadminperms'];
    }

    foreach (
    $do AS $field)
    {
        if (
    $admin $vbulletin->bf_misc_customadminperms["$field"])
        {
            
    $return_value true;
        }


    I tested this code on localhost yesterday, and it works like a charm, no extra queries involved unless for some reason it won't work like it should without :)

EDIT: This randomly doesn't seem to work for OLD administrators, and only in the ACP menu.
In my custom menu it works fine, it just doesn't work in the cpnav_ menu.
EDIT #2: I fixed it now. Made it so it doesn't query unless for some reason it didn't fetch the permissions properly. Also I replaced the * in the query for a slight load decrease =P

Andreas 02-21-2006 02:58 PM

Well ... as of vBulletin 3.5.4 $admin is there by default :)

The following code might work cross-version?

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['customadminperms'] & $vbulletin->bf_misc_customadminperms["$field"])
    {
        
$return_value true;
    }



Revan 02-21-2006 04:27 PM

It might, but due to the fact that I don't actually use the $admin variable, I don't know if I need to change the code.
I don't really see how changing the variable name would help in solving the original problem, though. I just tested the new plugin with some slight alterations and it works.
I cba to "remake" it into your "customadminperms" format so Ill just give it like I use it:
PHP Code:

global $rpgpermissions;

if (!isset(
$admin))
{
    
// this is not vBulletin 3.5.4+
    
$admin $getperms;
}

if (isset(
$admin['rpgadminperms']))
{
    
$rpgpermissions $admin['rpgadminperms'];
}

if (!isset(
$rpgpermissions))
{
    
// must get our perms
    
$getperms $vbulletin->db->query_first("
        SELECT *
        FROM " 
TABLE_PREFIX "administrator
        WHERE userid = " 
$vbulletin->userinfo['userid']
    ); 
    
    
$rpgpermissions $getperms['rpgadminperms'];
}

foreach (
$do AS $field)
{
    if (
$rpgpermissions  $vbulletin->bf_misc_rpgadminperms["$field"])
    {
        
$return_value true;
    }


Tested to work on 3.5.3 and 3.5.4.
I think that's a pretty efficient way of doing it, as it only runs 1 additional query for ONE admin (out of the ~10 I tested it on, non-superadmins that is).
So yeah, tis odd, but meh =P


All times are GMT. The time now is 01:47 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.01245 seconds
  • Memory Usage 1,765KB
  • 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
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)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