Function To Retrieve Usergroup Forum CANVIEW Permissions
This is a new, cleaner thread, holding my input to the following thread :
https://vborg.vbsupport.ru/showthrea...threadid=41934 I noticed that with the function in the above mentioned thread, though an excellent routine, if you use usergroup permissions inherited from parent forum permissions, inside the Forum Permissions in your AdminCP, that function can return false results. I needed a function to tell my scripts which forums any usergroup has CANVIEW access to, and this is my solution. This function handles forum CANVIEW permissions that are set in the Forum Permissions screen of the AdminCP, it does not cater for AccessMasks or anything, because we don't use accessmasks on our forums. This function also shouldn't be relied upon if you have several tiers of forums/sub-forums... this should only cater for those who have forum categories, and sub-forums of the category.... if your setup has sub-forums of sub-forums, do not rely on this function. The restrictions of this function, as just mentioned, should not cause a problem to perhaps the majority of forum setups, as it's very rare that I see sub-forums of sub-forums (etc.) at vB boards. Ok, i've cleaned this code up, and have done some more testing, so let's get on with the good stuff... here is the function : PHP Code:
Right, that's the function - you may place that in your 'admin/functions.php' file, if you wish. Then, in any script that you intend to use the function, place this : PHP Code:
PHP Code:
What those two lines do, is get a string list of all forums that the current visitor has CANVIEW permissions to, and then generates a WHERE clause for you, ready for easy inclusion into an SQL query. Unless you will need the string list for other reasons, you'll only be interested in this $whereClause_forumPermissions variable... which holds the WHERE clause. Here is an example of how forums using permissions inherited from it's parent forum might look inside your AdminCP : Code:
Example Forums This function will cater for this. The following is also allowable by this function : Code:
Example Forums Only one thing to be carful of, is not setting any permissions for a forum.... this function will not include that forum. A forum must have either custom permissions, or inherited permissions, (show in either RED or BLUE) or the forum will be classed as "viewable". So, your "viewable by all" forums can be left without special permissions set, if you wish. You only need to set permissions for those forums where certain usergroups should not have CANVIEW access. Right, the next thing to do, is show some examples of usage. We've already called the function, and setup the WHERE clause, so let's execute a query.... the following example, is so that you can test this out - it will display the list of forums which a usergroup can access : PHP Code:
During testing, you can subsitute the $bbuserinfo[usergroupid] in the calling of the function, for any usergroup number, if you wish... but be sure to put it back before going "live" with the function... example : PHP Code:
Another test, would be to return the most viewed thread stored in your database, but only threads in forums that are viewable by the current usergroup will be counted : PHP Code:
That's the jist, it does the job for me, and I hope you may find it usfull too. Our forums only use usergroup permissions, inherited from parent forums, and occasionally some custom permissions for usergroups, but, we don't use accessmasks, and we don't have sub-forums of sub-forums... this function works for us, and maybe for alot you too. Biggup the "open source / community source".... it's saved me alot of time and headache at times.... as i'm sure i've saved others from the same.... again.... big it up. :cool: :cool: :) :cool: :cool: |
I'm back again to share some more. Sombody wanted a list of forums that a user can view, based on their usergroup permissions.
I'm doing exactly the same thing at our site, but, i'm outputting formatted links. The request was for a dropdown box... so, here is the gumph for a DD box. Again, here is the function... you can place this in your 'functions.php' or 'global.php' if you wish : PHP Code:
PHP Code:
PHP Code:
Then using all the collected data, you can create a drop down box, with this : PHP Code:
Do remember that this does not support permissions where Access Masks are used. I reckon the majority of boards don't use Access Masks anyway. Also, i'm using a multi database connection system on our site, where this thing is used, and I have changed the SQL object to a different name. Just replace all occurances of '$DB_forum' with '$DB_site', and you'll be ok. Hope it helps you, and I hope you can get it working. |
Execue me, is there an updated version for vbb 3.0.7 :nervous:
|
All times are GMT. The time now is 06:55 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:
|