![]() |
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:
|
Great function, very usefull indeed. Thanks.
|
Wow...very useful I agree. Thank you!
|
I should mention that the function only issues 3 queries, one of which VERY fast. :)
|
I seem to be having some problems with this.
I've added the entire function to functions.php. I added it as the second-to-last function, above doshutdown. I tried to use the function from global.php (the forums, not the admin). Right above the part of global.php that parses the css (headinclude), header, and footer. I've tried $jjr512=get_allowed_forums();. I've tried $jjr512=get_allowed_forums('canview',-1,',');. I've tried a lot of things. But whenever I try to use the function, I get this error: "Warning: Bad arguments to implode() in /home/jjr512/public_html/testvb/admin/functions.php on line 2289" Now as I have it in my functions.php, Line 2289 is: Code:
SELECT forumid, '.iif(is_array($checkfor), implode(', ', $checkfor), $checkfor)." |
Try the new version.
|
great, thank you!
|
This is a great function, and i'm using it right now for some custom statistics.
Thing is though, Guests and normal members and stuff get permissions returned that they don't have "canview" permissions to. Any thoughts? |
I think what is happening, is if a forum is using permissions from it's parent forum, then it doesn't get taken into account.
If you know what I mean? |
very usefull, as lesane said before. thanks for posting it.
|
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. |
... 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.
|
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:
|
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 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. |
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 I really appreciate your help on this. I am totally lost when it comes to the permissions checking. :) |
After calling my function, you can use these two queries :
PHP Code:
... and i've also taken out the : PHP Code:
PHP Code:
|
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?
|
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:
|
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:
|
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> |
dwh, i've had a go at your request in this thread.
https://vborg.vbsupport.ru/showthrea...732#post311732 |
All times are GMT. The time now is 08:16 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|