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

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

 

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

Usergoup Permissions are being controlled through XML files, you don't have to edit usergroup.php anymore

To create your own usergroup permissions, the first thing to do is to modify table usergroup (keep table prefixes in mind!):

[sql]ALTER TABLE usergroup ADD myhackpermissions INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL ;[/sql]

If your hack does need some integer settings as well (and not just On/Off-Options):

[sql]ALTER TABLE usergroup ADD myhackintset INT( 10 ) DEFAULT '100' NOT NULL ;[/sql]

Then you must create a an XML-File bitfield_myhack.xml and place it in includes/xml:

HTML Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<bitfields product="vbulletin">
	<bitfielddefs>
		<group name="ugp">
			<group name="myhackpermissions">
				<bitfield name="canfoo" group="my_hack_permissions"  phrase="can_foo_forum" install="1,2,3,4,5,6,7">1</bitfield>
				<bitfield name="canbaa" group="my_hack_permissions"  phrase="can_baa_forum" install="">2</bitfield>
				<bitfield intperm="true" name="myhackintset" group="my_hack_permissions"  phrase="myhack_int_desc"></bitfield>
			</group>
		</group>
	</bitfielddefs>
</bitfields>
As you can see, you must create a new permission group below group ugp (short for usergroup permissions).

Parameter product of Tag bitfields should be the identifier of your Product

Paramater name of Tag group must match the column name in table usergroup.

The Parameters for Tag bitfield are:
  • name is the identifier you can use in your hack code (eg. $permissions['myhackpermissions'] & $vbulletin->bf_ugp['myhackpermissions']['canfoo'])
    In case of integer options this name must match the column name in table usergroup.
  • intperm indicates that this Option is a integer value
  • group is the varname for the Phrase that should be displayed as Permission Group Title.
    This is also being used to set up different Groups for your permissions.
  • phrase is the varname of the Phrase that should be displayed for this option in Usergroup Manager
  • install is a comma-separated list of the usergroups where this permission should be visible
    If this parameter is empty or omitted, this Option will be used for all Usergroups

The value of <bitfield> is the decimal value of the bit (eg. 1 for the first, 2 for the second, 4 for the third, and so on).
In case of an Integer Option this is the default value.

If you want to hide certain permission groups for some usergroups, for example from Guests as they don't make sense for them:

HTML Code:
<ignoregroups>
        <group name="myhackpermissions" ignoregroups="1" />
</ignoregroups>
Parameter name is the name of the permission group you want to hide, ignoregroups is a comma seperated list of usergoup IDs where this permission group should not show up.
Place this section below the <bitfielddefs>-Section.

Now create the necessary phrases (in Phrasegroup Permissions) at this point.

As vBulletin caches Bitfields in Datastore, you must rebuild this cache before the new usergroup permissions can be actually used (They will already show up in Usergroup Manager, but cannot be saved - you will get an error).
To do so, point your browser to admincp/index.php?do=buildbitfields.

You can also use the following Code (in a Custom Installer or Install-Code of a Product) to update the Bitfield Cache:
PHP Code:
if (is_newer_version('3.5.1'$vbulletin->options['templateversion']))
{
    
// Rebuild Bitfields
    // Do this for vBulletin < 3.5.1 *ONLY*; later versions rebuild
    // automatically and calling the builder in install code causes
    // the bitfields NOT to be rebuild correctly
    
require_once(DIR '/includes/class_bitfield_builder.php');
    
vB_Bitfield_Builder::save($db);
    
build_forum_permissions();

If you install/upgrade vBulletin and custom bitfield_xxx.xml files are already in place, they will be used - you don't have to update the Bitfield Cache in this case.

This How-To is (C) 2005 by KirbyDE and you are not allowed to redistribute it in any way without my explicit consent.
Reply With Quote
  #22  
Old 06-25-2005, 11:33 AM
HakkieDEV HakkieDEV is offline
 
Join Date: Jun 2004
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've had a look and I see that it also adds a field in the usergroup permissions area.

However, I'd like to know how I could add some extra permission fields in the forum area (admincp/forum.php).
Reply With Quote
  #23  
Old 06-25-2005, 07:39 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Not possible without editing the File.
Reply With Quote
  #24  
Old 06-26-2005, 06:13 AM
HakkieDEV HakkieDEV is offline
 
Join Date: Jun 2004
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah, okay, thanks.

It was driving me crazy.
Reply With Quote
  #25  
Old 07-12-2005, 07:11 AM
TitanKing TitanKing is offline
 
Join Date: Mar 2005
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can anyone please explain to me the forumpermissions bits, how will I get the permissions out of there... thank you...
Reply With Quote
  #26  
Old 07-27-2005, 05:06 PM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's my bitfield_vbgarage.xml and here's the error I get once my custom permissions are in place:


HTML Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<bitfields product="vBulletin">
	<bitfielddefs>
		<group name="ugp">
			<group name="canvbgarage">
			<bitfield name="canenter" group="canvbgarage" phrase="can_enter_vbgarage" install="">1</bitfield>
			</group>
		</group>
	</bitfielddefs>
</bitfields>

If the file is there and active I get this error when I try to save the permissions. The newly added permissions are not saved and they remain 'no'..
Attached Images
File Type: jpg bitfield-error.jpg (45.4 KB, 0 views)
Reply With Quote
  #27  
Old 07-27-2005, 05:27 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Make sure you don't have any Plugins enabled and try again.

Edit: install="" might also cause this error
Reply With Quote
  #28  
Old 07-27-2005, 05:33 PM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's a fresh install without any plugins.. I also removed install="" with no success

I added another group and here's the sql error I get now:

HTML Code:
### UPDATE QUERY GENERATED BY fetch_query_sql() ###
	`title` = 'Administrators',
	`description` = '',
	`usertitle` = 'Administrator',
	`opentag` = '',
	`closetag` = '',
	`passwordexpires` = '180',
	`passwordhistory` = '360',
	`canvbgarage` = '',
	`canvbgarage2` = '',
	`forumpermissions` = '1048575',
	`attachlimit` = '0',
	`pmquota` = '50',
	`pmpermissions` = '3',
	`pmsendmax` = '5',
	`calendarpermissions` = '63',
	`wolpermissions` = '31',
	`adminpermissions` = '3',
	`genericpermissions` = '205520831',
	`genericoptions` = '31',
	`profilepicmaxwidth` = '100',
	`profilepicmaxheight` = '100',
	`profilepicmaxsize` = '65535',
	`avatarmaxwidth` = '80',
	`avatarmaxheight` = '80',
	`avatarmaxsize` = '20000'
WHERE usergroupid=6;
You can see that canvbgarage is empty but it shouldn't..

I edited the usergroup #6 via phpmyadmin and changed canvbgarage to 1 and the usergroup manager still says no and my scripts are still not working
Reply With Quote
  #29  
Old 07-27-2005, 05:41 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you rebuild the Bitfield Cache?

Btw:

I'd use a XML like
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<bitfields product="garage">
	<bitfielddefs>
		<group name="ugp">
			<group name="vbgaragepermissions">
			<bitfield name="canenter" group="vbgarage_permissions" phrase="can_enter_vbgarage" install="">1</bitfield>
			</group>
		</group>
	</bitfielddefs>
</bitfields>
Reply With Quote
  #30  
Old 07-27-2005, 05:47 PM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Verdammt, ich wusste doch das ich was vergessen hatte *vordenkopfschlag*

No I didn't

Next question: If Iam using the XML like you suggested, what does this has to look like:
PHP Code:
if ($permissions['canvbgarage'] & $vbulletin->bf_ugp['canvbgarage']['canenter']) 
Reply With Quote
  #31  
Old 07-27-2005, 05:54 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, it's just variable Names so it's not really important, but IMHO it makes Code more readable

PHP Code:
if ($permissions['vbgaragepermissions'] & $vbulletin->bf_ugp['vbgaragepermissions']['canenter']) 
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 01:45 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.05192 seconds
  • Memory Usage 2,341KB
  • Queries Executed 26 (?)
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
  • (1)bbcode_code
  • (4)bbcode_html
  • (3)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
  • (2)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete