Skip to:
Content

bbPress.org

Changeset 4554


Ignore:
Timestamp:
12/07/2012 09:11:46 AM (12 years ago)
Author:
johnjamesjacoby
Message:

BuddyPress Groups:

  • If group does not have forums active, do not show forum tab.
  • See #2083 (2.2 branch)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/includes/extend/buddypress/group.php

    r4545 r4554  
    3232     */
    3333    public function __construct() {
     34        $this->setup_variables();
     35        $this->setup_actions();
     36        $this->setup_filters();
     37        $this->maybe_unset_forum_menu();
     38    }
     39
     40    /**
     41     * Setup the group forums class variables
     42     *
     43     * @since bbPress ()
     44     */
     45    private function setup_variables() {
    3446
    3547        // Name and slug
     
    5567        $this->template_file        = 'groups/single/plugins';
    5668        $this->display_hook         = 'bp_template_content';
    57 
    58         // Add handlers to bp_actions
    59         add_action( 'bp_actions', 'bbp_new_forum_handler'  );
    60         add_action( 'bp_actions', 'bbp_new_topic_handler'  );
    61         add_action( 'bp_actions', 'bbp_new_reply_handler'  );
    62         add_action( 'bp_actions', 'bbp_edit_forum_handler' );
    63         add_action( 'bp_actions', 'bbp_edit_topic_handler' );
    64         add_action( 'bp_actions', 'bbp_edit_reply_handler' );
     69    }
     70
     71    /**
     72     * Setup the group forums class actions
     73     *
     74     * @since bbPress (r4552)
     75     */
     76    private function setup_actions() {
    6577
    6678        // Possibly redirect
    67         add_action( 'bbp_template_redirect',     array( $this, 'redirect_canonical' ) );
     79        add_action( 'bbp_template_redirect',         array( $this, 'redirect_canonical'        ) );
     80
     81        // Remove topic cap map when view is done
     82        add_action( 'bbp_after_group_forum_display', array( $this, 'remove_topic_meta_cap_map' ) );
     83    }
     84
     85    /**
     86     * Setup the group forums class filters
     87     *
     88     * @since bbPress (r4552)
     89     */
     90    private function setup_filters() {
    6891
    6992        // Group forum pagination
     
    92115        add_filter( 'bbp_map_reply_meta_caps',   array( $this, 'map_topic_meta_caps'          ), 10, 4 );
    93116
    94         // Remove topic cap map when view is done
    95         add_action( 'bbp_after_group_forum_display', array( $this, 'remove_topic_meta_cap_map' ) );
    96 
    97117        // Map group forum activity items to groups
    98118        add_filter( 'bbp_before_record_activity_parse_args', array( $this, 'map_activity_to_group' ) );
     
    121141
    122142        $this->display_forums( 0 );
     143    }
     144
     145    /**
     146     * Maybe unset the group forum nav item if group does not have a forum
     147     *
     148     * @since bbPress (r4552)
     149     *
     150     * @return If not viewing a single group
     151     */
     152    public function maybe_unset_forum_menu() {
     153
     154        // Bail if not viewing a single group
     155        if ( ! bp_is_group() )
     156            return;
     157
     158        // Are forums enabled for this group?
     159        $checked = (bool) ( bp_get_new_group_enable_forum() );
     160
     161        // Tweak the nav item variable based on if group has forum or not
     162        $this->enable_nav_item = $checked;
    123163    }
    124164
     
    578618
    579619                        bbp_set_query_name( 'bbp_forum_form' );
    580 
    581620                        bbp_get_template_part( 'form', 'forum' );
    582621
     
    632671                        if ( !empty( $_GET['action'] ) && 'merge' == $_GET['action'] ) :
    633672                            bbp_set_query_name( 'bbp_topic_merge' );
    634 
    635673                            bbp_get_template_part( 'form', 'topic-merge' );
    636674
     
    638676                        elseif ( !empty( $_GET['action'] ) && 'split' == $_GET['action'] ) :
    639677                            bbp_set_query_name( 'bbp_topic_split' );
    640 
    641678                            bbp_get_template_part( 'form', 'topic-split' );
    642679
     
    650687                    // Single Topic
    651688                    else:
    652 
    653689                        bbp_set_query_name( 'bbp_single_topic' ); ?>
    654690
Note: See TracChangeset for help on using the changeset viewer.