Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/26/2011 03:28:35 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Introduce Forums tab to user account area, to show topics the user has started, topics the user has replied to, and favorite forum topics. This includes additional template files in bp-default to support new functionality, and edits to the forum_sql filter functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-filters.php

    r3930 r3933  
    6666
    6767    // Only filter the forum SQL on group pages or on the forums directory
    68     if ( bp_is_forums_component() ||
    69             ( !empty( $bp->groups->current_group ) &&
    70                 ( 'public' == $bp->groups->current_group->status ) ||
    71                     ( !empty( $bp->groups->current_group->is_member ) ) ) ) {
    72 
    73         add_filter( 'get_topics_fields',     'groups_add_forum_fields_sql' );
    74         add_filter( 'get_topics_index_hint', 'groups_add_forum_tables_sql' );
    75         add_filter( 'get_topics_where',      'groups_add_forum_where_sql'  );
    76     }
     68    add_filter( 'get_topics_fields',     'groups_add_forum_fields_sql' );
     69    add_filter( 'get_topics_index_hint', 'groups_add_forum_tables_sql' );
     70    add_filter( 'get_topics_where',      'groups_add_forum_where_sql'  );
    7771}
    7872add_filter( 'bbpress_init', 'groups_add_forum_privacy_sql' );
     
    9084    global $bp;
    9185
    92     if ( !is_super_admin() || ( bp_is_single_item() && !bp_group_is_member( $bp->groups->current_group->id ) ) )
    93         $must_be_public = "AND g.status = 'public'";
    94     else
    95         $must_be_public = '';
     86    // Set this for groups
     87    $parts['groups'] = "(gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id)";
    9688
    97     $bp->groups->filter_sql = $must_be_public . ' AND ' . $sql;
     89    // Restrict to public...
     90    $parts['private'] = "g.status = 'public'";
    9891
    99     return "(gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) {$must_be_public} AND {$sql}";
     92    /**
     93     * ...but do some checks to possibly remove public restriction.
     94     *
     95     * Decide if private are visible
     96     */
     97    // Are we in our own profile?
     98    if ( bp_is_my_profile() )
     99        unset( $parts['private'] );
     100
     101    // Are we a super admin?
     102    elseif ( is_super_admin() )
     103        unset( $parts['private'] );
     104
     105    // Are we a member of this group
     106    elseif ( bp_is_single_item() && bp_group_is_member( $bp->groups->current_group->id ) )
     107        unset( $parts['private'] );
     108
     109    // Check the SQL filter that was passed
     110    if ( !empty( $sql ) )
     111        $parts['passed'] = $sql;
     112
     113    // Assemble Voltron
     114    $parts_string = implode( ' AND ', $parts );
     115
     116    // Set it to the global filter
     117    $bp->groups->filter_sql = $parts_string;
     118
     119    // Return the global filter
     120    return $bp->groups->filter_sql;
    100121}
    101122
Note: See TracChangeset for help on using the changeset viewer.