Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles

Reply
 
Thread Tools
Custom Administrator Permissions
Andreas's Avatar
Andreas
Join Date: Jan 2004
Posts: 6,863

 

Germany
Show Printable Version Email this Page Subscription
Andreas Andreas is offline 09-08-2005, 10:00 PM

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 #######################
if (!can_administer('canadminmyhack'))
{
    
print_cp_no_permission();

In your ACP Navigation XML Files, add the Parameter permissions to your Navgroup:
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>
In order to display Text in the Admin Permissions Editor, you must create a Phrase in Phrasegroup Permissions:
Code:
Varname: can_administer_myhack
Text: Can Administer Myhack
Make sure that it is attached to your Product and inserted into GLOBAL Language!

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'])); 
customadminperms[canadminmyhack] must the Name of the Bit(field) you want to use, $vbulletin->bf_misc_customadminperms['canadminmyhack'] the Value of the Bit

You must also create a Plugin for the Administrator Datamanager
admindata_start
PHP Code:
$this->validfields['customadminperms'] = array(TYPE_UINTREQ_NO);
$this->bitfields['customadminperms'] = $this->registry->bf_misc_customadminperms
Now we need a Plugin to save our Permission setting after editing it:

admin_permissions_process
PHP Code:
$vbulletin->input->clean_gpc('p''customadminperms'TYPE_ARRAY_INT);
$admindm->set_bitfield('customadminperms''canadminmyhack'$vbulletin->GPC['customadminperms']['canadminmyhack']); 
Now, finally, we need a Plugin to actually check this Permission

can_administer
PHP Code:
foreach($do AS $field)
{
    if (
$admin['customadminperms']  & $vbulletin->bf_misc_customadminperms["$field"])
    {
        
$return_value true;
        return;
    }

Here again, $vbulletin->bf_misc_customadminperms['canadminmyhack'] must be the Value of your Bit.

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');
$dbalter = new vB_Database_Alter_MySQL($db);
$dbalter->fetch_table_info('administrator');
if (!
$dbalter->fetch_field_info('customadminperms'))
{
    
$dbalter->add_field(array('name' => 'customadminperms''type' => 'INT''length' => '10''attributes' => 'UNSIGNED''null' => false'default' => '0'));
    }

And this Uninstall-Code
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);
    
// Using 3.5.1+ calls
    
$dbalter->fetch_table_info('administrator');
    if (
$dbalter->fetch_field_info('customadminperms'))
    {
        
$dbalter->drop_field('customadminperms');
    }

Bitfield Usage customadminperms (this will be updated if other Authors use it too)
1 - KirbyDE
Reply With Quote
  #42  
Old 10-30-2006, 05:02 PM
Gerakus's Avatar
Gerakus Gerakus is offline
 
Join Date: Apr 2005
Location: Illinois
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks so much Surviver! your input resolve my problem!

And Kirby for this wonderful "plugin/product".
Reply With Quote
  #43  
Old 12-10-2006, 05:18 AM
ReadOrDie ReadOrDie is offline
 
Join Date: Sep 2005
Posts: 258
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

how would one get this working on a mod that has already been installed on a forum?
Reply With Quote
  #44  
Old 04-05-2007, 09:12 PM
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Posts: 3,832
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I was wondering if this going to work just fine on vB 3.6.5?
Reply With Quote
  #45  
Old 06-13-2007, 03:14 PM
Mistah Roth's Avatar
Mistah Roth Mistah Roth is offline
 
Join Date: Jul 2003
Location: Ottawa, Ontario
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So yea, this doesn't work on the latest vB lol (3.6.7 PL1)

I believe the addition of Dismissed News to the admin permissions screwed it up, I get this error if I try to edit any admin permission (or even if I don't)

Fatal error: Field dismissednews is not defined in $validfields in class vb_datamanager_admin in /includes/class_dm.php on line 485

Looks like an array is being populated with all the admin permission fields, but our addition bumps the last one (dismissednews) out of the array.
Reply With Quote
  #46  
Old 06-15-2007, 01:56 PM
Mistah Roth's Avatar
Mistah Roth Mistah Roth is offline
 
Join Date: Jul 2003
Location: Ottawa, Ontario
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$10 to anyone that can get this working.
Reply With Quote
  #47  
Old 06-15-2007, 02:36 PM
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Posts: 3,832
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, I'm looking forward to this as well. Please anyone?
Reply With Quote
  #48  
Old 06-21-2007, 02:54 PM
Mistah Roth's Avatar
Mistah Roth Mistah Roth is offline
 
Join Date: Jul 2003
Location: Ottawa, Ontario
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$25 for a working version of this
Reply With Quote
  #49  
Old 06-22-2007, 05:00 PM
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Posts: 3,832
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$50 for someone who can take over this, create it as a product and support it.
Reply With Quote
  #50  
Old 06-23-2007, 05:14 AM
LightScribe's Avatar
LightScribe LightScribe is offline
 
Join Date: Jun 2006
Location: Australia
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

as a product would be nice.
Reply With Quote
  #51  
Old 08-30-2007, 04:14 AM
CarlitoBrigante's Avatar
CarlitoBrigante CarlitoBrigante is offline
 
Join Date: Nov 2002
Location: Iceland
Posts: 182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello -

what do you guys need exactly? I have been creating custom Admin permission in all of my clients' scripts (when needed, of course!), and I am not having any issue with the latest vBulletin versions. The steps are exactly the same Andreas gave you. You may just want to replace the install code with a straightforward ALTER TABLE query, and you must remember to create your bitfield xml file correctly, but other than that there is nothing more to it, really.

If it's not working, it is because you missed some step. Let me know, and I will package this into an xml product tomorrow, if you still need this. And no money needed, of course.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:52 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.06730 seconds
  • Memory Usage 2,319KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (7)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete