bbPress

Simple, Fast, Elegant

bbPress plugin browser »

Private Forums (5.0)

Download

Version: 5.0

Other Versions

Last Updated: 2007-7-17

Requires bbPress Version: 0.74 or higher

Compatible up to: 0.74

Author Homepage »

Plugin Homepage »

Donate to this plugin »

Average Rating

5 stars
4 stars
3 stars
2 stars
1 star
(9)

Your Rating

Author: Aditya Naik

Tags: , ,

  1. I found a simple solution to the whole issue..

    i will update the plugin in the evening.

    Posted: 1 year ago #
  2. Is 5.0 the new update?
    Did you actually find a fix for search without patching the core?!

    Wow it works... I have no idea how you did that.
    I have a lot to learn about the bbpress filter system!

    Many thanks for the updates. This is one very powerful plugin!

    Posted: 1 year ago #
  3. Ah now I see you filtered the results the exact way I was trying to avoid in my technique.

    The way you do it, all results are returned for every kind of list, feed, search, etc. THEN you filter out the bad ones.

    The problem with that is it tampers with the result count and it makes the database work harder than it should. The first issue is much bigger than the second obviously.

    For example let's say there are 100 recent posts in a moderator's only forum. A regular user then triggers a search that gives those 100 results plus five more. If bbpress ever has a proper result count header and proper pagination for results, it needs that total result count to be proper.

    If the pagination thinks there are 105 results it will make a mess if there are actually only 5.

    My method lets it know there are really only five.

    Your method also reduces the total displayed post count on the front page, the feeds, etc. If there are supposed to be 25 displayed but 15 of them are moderator private posts, a regular end user will only see 10 items on the front page and rss. My method will show the proper 25.

    You might want to use a hybrid of my method for regular things and then your method for the search results which cannot be filtered otherwise.

    For now I am just being lazy and appending my WHERE filter routine to the end of your plugin to get proper counts/pagination (everywhere except search of course)

    function private_forums_filter_private($where,$prefix=''){
    $private_forums = private_forums_custom_get_options('private_forums');
    foreach($private_forums as $forum => $role) {
    	if(!private_forums_check_user_access_to_forum($role)) {
    		$where.=" AND ".$prefix."forum_id != ".$forum."  ";
    	}
    }
      return  $where;
    }
    add_filter( 'get_latest_topics_where', 'private_forums_filter_private');
    add_filter( 'get_latest_posts_where', 'private_forums_filter_private');
    Posted: 1 year ago #
  4. true.. i understand the concern.
    the only issue is the query with multiple forum_id != is inefficient. specially if the there are ten fifteen forums.

    but i do see that there can be a better way to do it. version 6.0? :)

    Posted: 1 year ago #
  5. I have found a bug that I can't seem to trace the source.

    There is a sub-forum (forum under a main forum) which when the plugin is active will not appear for logged-out visitors. However both it and the parent are marked as "open for all". I looked at the serialized data and it's fine too. Disable the plugin and it's back.

    This leads me to believe it's in the code but I am having a darn hard time tracing it. Maybe you can find it faster?

    See if you can replicate the results by creating a new sub-forum and then logging out and see if it disappears when you browse it's parent?

    Posted: 1 year ago #
  6. Oh and this is probably a better idea than to constantly check the version for upgrade on every bbpress execute:

    // private_forums_upgrade();
    add_action('activate_private-forums.php', 'private_forums_upgrade');

    of course you'll have to remind people to deactivate and reactivate

    actually I am not sure if bbpress supports that add_action, I borrowed the idea from wordpress... anyone know?

    Posted: 1 year ago #
  7. I found the bug! I seriously cannot believe I figured this out.

    Sub-forums require an indexed/keyed list of forms returned from the filter because the core then does some weird array slices and stuff. You were returning a flat array.

    in

    function private_forums_filter_forums($forums) {

    change

    $new_forums[] = $forum;

    to

    $new_forums[$forum->forum_id] = $forum;

    Wow. I wonder if topics and such need that too?

    Posted: 1 year ago #
  8. try the latest code from the trunk.. i think that should solve the problem

    http://plugins-dev.bbpress.org/changeset/487/private-forums/trunk?old_path=%2F&format=zip

    Posted: 1 year ago #
  9. Awh I thought I was so clever to find it and then you recode the entire filter method... oh well...

    That's a freaky number of filters you have to attach to!
    Still trying to figure out the approach.

    I'm curious as I don't see how the new method is filtering search, can you tell me in a nutshell?

    Posted: 1 year ago #
  10. ouch! i think i missed that one.. :)

    Posted: 1 year ago #
  11. bug report:
    private forum topics show up in the moderator's profile & favorites for any viewer

    Posted: 1 year ago #
  12. Yes, very much a problem. If they are marked pricate are they displayed as such?

    I just hacked out that part of the profile code. Is there a function I can call to check userlevel=subscriber and display only if this is true?

    Posted: 1 year ago #
  13. Well fixing favorites showing private topics is going to be tricky without hacking the core.

    This is because for some unknown reason get_user_favorites has no filter/action that can be applied.

    It has a filter for "get_user_favorites_order_by" but not for the "where" clause which makes this very difficult.

    Only thing I can think of is to hook the favorites template and post-process the list of topics that is passed to it that way. Messy but possible.

    Either that or don't allow non-moderators to view moderator favorites entirely.

    I'll add a request to trac for a filter.

    Posted: 1 year ago #
  14. Oh figured out how to fix the moderator's profile, very easy to do when using my additional function - just attached more "where filters":

    function private_forums_filter_private($where,$prefix=''){
    if (function_exists("private_forums_custom_get_options")) {
    $private_forums = private_forums_custom_get_options('private_forums');
    foreach($private_forums as $forum => $role) {
    	if(!private_forums_check_user_access_to_forum($role)) {
    		$where.=" AND ".$prefix."forum_id != ".$forum."  ";
    	}
    }
    }
      return  $where;
    }
    add_filter( 'get_latest_topics_where', 'private_forums_filter_private');
    add_filter( 'get_latest_posts_where', 'private_forums_filter_private');
    add_filter( 'get_recent_user_replies_where', 'private_forums_filter_private');
    add_filter( 'get_recent_user_threads_where', 'private_forums_filter_private');
    Posted: 1 year ago #
  15. I've discovered a weird but "dangerous" bug, where the forum settings are all being reset back to "participate" - making moderator-only forums visible. I have to then go back into the admin menu and change it.

    I can't tell if this is a bug in this plugin or in bbpress core itself. Not good though. What else could be writing back to the database ??!

    Posted: 1 year ago #
  16. Oh this is driving me crazy.

    Every so often, the private forum settings reset back to open to all and expose the moderator forum to everyone. Not good.

    Until this bug is found I need to to hardwire a forum by number via code to always be moderator's only.

    update: I hardwired private_forums_custom_get_options, adding

    if (!bb_current_user_can("moderate")) {$private_forums_for_user[8] = "MODERATOR";}

    This should make sure no matter what, #8 stays private

    Hopefully you can find the bug soon... it might even be a bbpress core bug which is scary... then again, your settings are the only ones that seem to reset?

    Posted: 1 year ago #
  17. Yes, I've noticed that this plugin will reset itself when you access the Admin area and when active, restricts logged out users views of the forums. Hopefully this is fixed soon =).

    Posted: 1 year ago #
  18. http://bbpress.org/plugins/topic/12/page/2?replies=37#post-457

    this is already in the latest trunk code.. its not stable yet. but its there..

    Posted: 1 year ago #
  19. ok .. the filtering for profile and favorites should be fixed in here..
    http://plugins-dev.bbpress.org/changeset/530/private-forums/trunk?old_path=%2F&format=zip

    let me know whenever you guys are done testing and i will release it.

    Posted: 1 year ago #
  20. coustom error message did in t work!

    Posted: 1 year ago #

RSS feed for this topic

Add a Comment »

You must log in to post.

Code is Poetry.