HowTo Create Custom Usergroup Permissions
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"?> 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:
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> 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:
This How-To is (C) 2005 by KirbyDE and you are not allowed to redistribute it in any way without my explicit consent. |
Very nice, no more chances of stepping on toes. :)
I think the field add for a custom permission, bitfield, may need to look like this instead... PHP Code:
|
Good tut, I hope Administrator Permissions is next... *hint* ;)
|
@noppid
Right. Should have been UNSIGNED of course, corrected :) |
very very nice, this will boost the learning of vb3.5, no one wrote something like this for vb3.0
|
Yay! This is what I was going to ask for! :up: :up:
|
I think I love you KirbyDE :)
|
Question: Is there something similar for forum permissions?
|
Im with amykhar I tried to apply this to forumperms but with no effect.
I want simple yes/no option. I even tried editing the bitfield_vbulletin.xml directly and no effect any help appreciated. *edit * Got it to work. Note to self read full post before asking for help |
Update: Simplified instructions to rebuild Bitfield Cache.
@amykhar You can extend the forumpermissions bitfield, however I fear this will cause problems sooner or later - 20 of 32 Bits are already being used. To do so: Code:
<?xml version="1.0" encoding="ISO-8859-1"?> |
Why cant this be added to bitfield_vbulletin.xml? I have tried, but it doesnt work.
|
It can ... but you shouldn't do that, as bitfield_vbulletin.xml will be overwritten during an upgrade, which means you would have to redo the changes.
If you use your own XML file it will still be there and used after an upgrade. |
how does one go about putting a title on the grey table header? I tried phrase="_phrase_var_" and text="phrase text" but neither worked.
|
Quoting myself to answer your question:
Quote:
|
yea, i read that but figured I also needed another param because it wasnt (and isnt) working
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> I'll try looking over everything to see if there are errors, but I dont see how I could have messed up. |
Have you tried phrase="download_permissions" instead of name=?
|
Kirby - Any way to make this work with Forum Options? :)
Rather than editing forum.php ;) Satan |
there're optional ways to use the permission:
along with $permissions['myhackpermissions'] & $vbulletin->bf_ugp['myhackpermissions']['canfoo'] you can use $permissions['myhackpermissions'] & $vbulletin->bf_ugp_myhackpermissions['canfoo'] or $permissions['myhackpermissions'] & 1 the last one is the shortest one but then you won't understand what it does, 1 is the value of <bitfield> tag, just similar as the old permission settings. I found that the 'canfoo' is case sensitive, this took me almost a day to figure out lol |
I still don't understand how I could add forumpermissions?
I've tried to play with it, I've added an xml file with the content of kirbyDE, but it didn't work. |
Take a look at my recent Get New Posts Hack and you'll see :)
|
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). |
Not possible without editing the File.
|
Ah, okay, thanks.
It was driving me crazy. :) |
Can anyone please explain to me the forumpermissions bits, how will I get the permissions out of there... thank you...
|
1 Attachment(s)
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"?> 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'.. |
Make sure you don't have any Plugins enabled and try again.
Edit: install="" might also cause this error |
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() ### 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 :( |
Did you rebuild the Bitfield Cache?
Btw: I'd use a XML like Code:
<?xml version="1.0" encoding="ISO-8859-1"?> |
Verdammt, ich wusste doch das ich was vergessen hatte *vordenkopfschlag* :D
No I didn't :D Next question: If Iam using the XML like you suggested, what does this has to look like: PHP Code:
|
Well, it's just variable Names so it's not really important, but IMHO it makes Code more readable :)
PHP Code:
|
very nice,
thank you! :D |
KirbyDE .... Great How-To!!
One thing I would like to point out to everyone which I think is extremely relevant to this thread is the install="X" field will not be recognized during a product installation script ... at least not without extra code which I haven't figured out how to write yet. Simply rebuilding the bitfields (while it will allow the new permissions to begin functioning) will result in all zero's as default for all groups. http://www.vbulletin.com/forum/bugs3...iew&bugid=1054 This is the vBulletin response. Quote:
Maybe someone else will have better luck than me. |
Untested, but
PHP Code:
|
You were close Kirby
You only forgot the WHERE usergroupid=$usergroupid in the query. Works like a charm!!! Thank you, Sir!! PHP Code:
|
I knew there was a reason why I specified a Variable for the Key in foreach() :p
|
lol... Kirby, might I ask why I'm in your signature?
|
Yes. I've read this Post you made and found it very amusing :)
|
Can anyone verify or deny for certain if two of the same "canfoo" bitfield names can exist as long as they are each under a different groupname?
For example, something like "canview" under groupname "bluntswhodlpermissions". I could see almost every hack using a "canview", LOL, but the groupname is very unique. I ask because I do see a lot of vbulletin code which checks for clashes, but the code gets a little too deep for me to fully understand so far. I ask in this thread to help reinforce this how-to. I mean if we must all diversify this variable as well, then maybe the how-to should reflect that we should put part of our myhack name in this too somehow .... or maybe we are all good with real simple short vars here if duplicate canfoo's are ok as long as the groupname is unique. I suspect the latter, but I leave it as a question. Just trying to help avert potential problems down the road while we are all learning the vb350 ways. |
You can have "canfoo" in myperms1, myperms2, mypers3, doesntmatterperms and so on - doesn't cause Problems, as they are different Bitfields and those Names are just Shortcuts for the Bits :)
|
3 thumbs up for Kirby!!
Appreciate the time!! |
All times are GMT. The time now is 06:35 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 | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|