The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Function to retrieve the forums a user can access
This is something I once wrote for someone (think it was merk?), and kept it in a file, and finally got around to clean it up and wrap it in a function. Very useful for some hacks, hope this helps at least some of you. Here is the full function, along with some basic instructions: PHP Code:
|
#12
|
||||
|
||||
As I posted before in this thread - the above function does not return results of forums a user cannot "view", if the forum is using default permissions from it's parent forum.
Our board uses only forum default permissions, inherited from it's parent forum - we rely on usergroup permissions, and this does us absolutely fine. The other night, I really really needed to make sure I could restrict some queries from returning data that comes from forums any certain usergroup cannot view, so I made the following function - it's a little sloppy in places, but it's not that bad - the main thing is, it works : PHP Code:
As an example, we can take the last 12 posts made, from forums that only the viewers usergroup has 'canview' access to : PHP Code:
I find this very handy for some of our non-vB pages.... and I post it simply in-case sombody likes the concept. |
#13
|
||||
|
||||
... actually, I think the 2nd query in the example can be left out, cleaning up the example code a little.... basically, the 'else {}' bit in the example (containing the alternate query) can be left out.
|
#14
|
||||
|
||||
How could I sue this to get the Top thread by replies and the Top Thread by views and only have the right thread show up according to what the user is able to view?
Quote:
|
#15
|
||||
|
||||
You could use this :
PHP Code:
As far as i've tested, this only works (and only intended) for forums that have parent forum permissions - it doesn't cater for access masks... I believe that forums using their parent forum permissions show up in BLUE, in the forum permissions panel in the Admin CP... like this : Code:
Example Forums (COPPA) Users Awaiting Moderation Administrators .... etc .... .... etc .... Registered .... etc .... Example Sub Forum, Of Above Category (COPPA) Users Awaiting Moderation Administrators .... etc .... .... etc .... Registered .... etc .... Best to test it out yourself though, to be sure in your own mind. You can simply echo out the returned string list, like this : PHP Code:
Play about with forum permissions, and log-in and out as different member groups, and see if the forums that get returned are the only ones viewable by that group. |
#16
|
||||
|
||||
I don't mean to sound stupid here, but you are way over my head on this one.
The two queries I need to check permissions for are: Code:
//Most Popular Thread by Replies $popularreply=$DB_site->query_first("SELECT * FROM thread ORDER by replycount DESC LIMIT 1"); //Most Popular Thread by Views $popularview=$DB_site->query_first("SELECT * FROM thread ORDER by views DESC LIMIT 1"); I really appreciate your help on this. I am totally lost when it comes to the permissions checking. |
#17
|
||||
|
||||
After calling my function, you can use these two queries :
PHP Code:
... and i've also taken out the : PHP Code:
PHP Code:
|
#18
|
||||
|
||||
Ok, I think I understand what you are doing here. Where do put the function? In functions.php? And how do I call it in the index.php for the 2 queries?
|
#19
|
||||
|
||||
I'm going out in a few hours to get p***ed as a fart, but tomorrow, i'll start a new thread for this function, i'll clean up the code and give easy instruction.
But to answer your question here, yeah, you can place it in 'functions.php' if you wish, and you call it like this : PHP Code:
|
#20
|
||||
|
||||
Thanks for taking the time and patience with me on this. I really appreciate it. I'll be looking forward to the new thread and your instructions tomorrow then. Have one for me tonight (today, actually for me). I'm home watching the little one.
Quote:
|
#21
|
||||
|
||||
So how could I use this to build a drop down box with a list of forums that the current user has permission to see? Would need the forum name as well as forum id. Here's the part that would have to be built:
Code:
<option value="$forumid">$forumname</option> |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|