Skip to:
Content

bbPress.org

Ticket #2599: 2599.2.diff

File 2599.2.diff, 1.8 KB (added by boonebgorges, 10 years ago)
  • src/includes/extend/buddypress/groups.php

    diff --git src/includes/extend/buddypress/groups.php src/includes/extend/buddypress/groups.php
    index 7940160..9aeee32 100644
    class BBP_Forums_Group_Extension extends BP_Group_Extension { 
    8787                // Remove group forum cap map when view is done
    8888                add_action( 'bbp_after_group_forum_display', array( $this, 'remove_group_forum_meta_cap_map' ) );
    8989
     90                // When a group is updated, check to see whether group forum status should be changed as well.
     91                add_action( 'groups_group_after_save', array( $this, 'mirror_group_forum_status' ) );
     92
    9093                // bbPress needs to listen to BuddyPress group deletion.
    9194                add_action( 'groups_before_delete_group',    array( $this, 'disconnect_forum_from_group'     ) );
    9295
    class BBP_Forums_Group_Extension extends BP_Group_Extension { 
    683686        }
    684687
    685688        /**
     689         * Set forums' status to match the privacy status of the associated group.
     690         *
     691         * Fired whenever a group is saved.
     692         *
     693         * @param BP_Groups_Group $group Group object.
     694         */
     695        public static function mirror_group_forum_status( BP_Groups_Group $group ) {
     696                $forum_ids = bbp_get_group_forum_ids( $group->id );
     697
     698                if ( empty( $forum_ids ) ) {
     699                        return;
     700                }
     701
     702                foreach ( $forum_ids as $forum_id ) {
     703                        $forum = bbp_get_forum( $forum_id );
     704                        if ( $group->status !== $forum->post_status ) {
     705                                switch ( $group->status ) {
     706                                        case 'hidden' :
     707                                                bbp_hide_forum( $forum_id, $forum->post_status );
     708                                                break;
     709                                        case 'private' :
     710                                                bbp_privatize_forum( $forum_id, $forum->post_status );
     711                                                break;
     712                                        case 'public' :
     713                                        default :
     714                                                bbp_publicize_forum( $forum_id, $forum->post_status );
     715                                                break;
     716                                }
     717                        }
     718                }
     719        }
     720
     721        /**
    686722         * Toggle the enable_forum group setting on or off
    687723         *
    688724         * @since bbPress (r4612)