Skip to:
Content

bbPress.org

Changeset 4553


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

BuddyPress Groups:

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

Legend:

Unmodified
Added
Removed
  • trunk/includes/extend/buddypress/group.php

    r4551 r4553  
    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';
     69    }
     70
     71    /**
     72     * Setup the group forums class actions
     73     *
     74     * @since bbPress (r4552)
     75     */
     76    private function setup_actions() {
    5777
    5878        // Possibly redirect
    59         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() {
    6091
    6192        // Group forum pagination
     
    84115        add_filter( 'bbp_map_reply_meta_caps',   array( $this, 'map_topic_meta_caps'          ), 10, 4 );
    85116
    86         // Remove topic cap map when view is done
    87         add_action( 'bbp_after_group_forum_display', array( $this, 'remove_topic_meta_cap_map' ) );
    88 
    89117        // Map group forum activity items to groups
    90118        add_filter( 'bbp_before_record_activity_parse_args', array( $this, 'map_activity_to_group' ) );
     
    113141
    114142        $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;
    115163    }
    116164
Note: See TracChangeset for help on using the changeset viewer.