/**
  * Setup BuddyBar navigation
  */
 public function setup_nav($main_nav = array(), $sub_nav = array())
 {
     // Stop if forums haven't been set up yet
     if (!bp_forums_is_installed_correctly()) {
         return;
     }
     // Stop if there is no user displayed or logged in
     if (!is_user_logged_in() && !bp_displayed_user_id()) {
         return;
     }
     // Add 'Forums' to the main navigation
     $main_nav = array('name' => __('Forums', 'buddypress'), 'slug' => $this->slug, 'position' => 80, 'screen_function' => 'bp_member_forums_screen_topics', 'default_subnav_slug' => 'topics', 'item_css_id' => $this->id);
     // Determine user to use
     if (bp_displayed_user_domain()) {
         $user_domain = bp_displayed_user_domain();
     } elseif (bp_loggedin_user_domain()) {
         $user_domain = bp_loggedin_user_domain();
     } else {
         return;
     }
     // User link
     $forums_link = trailingslashit($user_domain . $this->slug);
     // Additional menu if friends is active
     $sub_nav[] = array('name' => __('Topics Started', 'buddypress'), 'slug' => 'topics', 'parent_url' => $forums_link, 'parent_slug' => $this->slug, 'screen_function' => 'bp_member_forums_screen_topics', 'position' => 20, 'item_css_id' => 'topics');
     // Additional menu if friends is active
     $sub_nav[] = array('name' => __('Replied To', 'buddypress'), 'slug' => 'replies', 'parent_url' => $forums_link, 'parent_slug' => $this->slug, 'screen_function' => 'bp_member_forums_screen_replies', 'position' => 40, 'item_css_id' => 'replies');
     parent::setup_nav($main_nav, $sub_nav);
 }
/**
 * Prevent specific pages (eg 'Activate') from showing on page listings.
 *
 * @uses bp_is_active() checks if a BuddyPress component is active.
 *
 * @param array $pages List of excluded page IDs, as passed to the
 *                     'wp_list_pages_excludes' filter.
 * @return array The exclude list, with BP's pages added.
 */
function bp_core_exclude_pages($pages = array())
{
    // Bail if not the root blog.
    if (!bp_is_root_blog()) {
        return $pages;
    }
    $bp = buddypress();
    if (!empty($bp->pages->activate)) {
        $pages[] = $bp->pages->activate->id;
    }
    if (!empty($bp->pages->register)) {
        $pages[] = $bp->pages->register->id;
    }
    if (!empty($bp->pages->forums) && (!bp_is_active('forums') || bp_is_active('forums') && bp_forums_has_directory() && !bp_forums_is_installed_correctly())) {
        $pages[] = $bp->pages->forums->id;
    }
    /**
     * Filters specific pages that shouldn't show up on page listings.
     *
     * @since 1.5.0
     *
     * @param array $pages Array of pages to exclude.
     */
    return apply_filters('bp_core_exclude_pages', $pages);
}
Example #3
0
function bp_forums_bbpress_admin() {
	global $bp;
?>
	<div class="wrap">

		<h2><?php _e( 'Forums Setup', 'buddypress' ) ?></h2>

		<?php if ( isset( $_POST['submit'] ) ) : ?>
			<div id="message" class="updated fade">
				<p><?php _e( 'Settings Saved.', 'buddypress' ) ?></p>
			</div>
		<?php endif;

		if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) {
			update_site_option( 'bb-config-location', false );
			bp_forums_bbpress_install_wizard();
		} else {
			$reinstall = network_admin_url( 'admin.php?page=bb-forums-setup&reinstall=1' ); ?>

			<p><?php printf( __( 'bbPress forum integration in BuddyPress has been set up correctly. If you are having problems you can <a href="%s" title="Reinstall bbPress">re-install</a>', 'buddypress' ), $reinstall ); ?>
			<p><?php _e( 'NOTE: The forums directory will only work if your bbPress tables are in the same database as your WordPress tables. If you are not using an existing bbPress install you can ignore this message.', 'buddypress' ) ?></p>

		<?php
		}
		?>
	</div>
<?php
}
function bp_forums_directory_forums_setup()
{
    global $bp;
    if (bp_is_forums_component() && (!bp_current_action() || 'tag' == bp_current_action() && bp_action_variables()) && !bp_current_item()) {
        if (!bp_forums_has_directory()) {
            return false;
        }
        if (!bp_forums_is_installed_correctly()) {
            bp_core_add_message(__('The forums component has not been set up yet.', 'buddypress'), 'error');
            bp_core_redirect(bp_get_root_domain());
        }
        bp_update_is_directory(true, 'forums');
        do_action('bbpress_init');
        // Check to see if the user has posted a new topic from the forums page.
        if (isset($_POST['submit_topic']) && bp_is_active('forums')) {
            check_admin_referer('bp_forums_new_topic');
            $bp->groups->current_group = groups_get_group(array('group_id' => $_POST['topic_group_id']));
            if (!empty($bp->groups->current_group->id)) {
                // Auto join this user if they are not yet a member of this group
                if (!is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member($bp->loggedin_user->id, $bp->groups->current_group->id)) {
                    groups_join_group($bp->groups->current_group->id);
                }
                $error_message = '';
                $forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
                if (!empty($forum_id)) {
                    if (empty($_POST['topic_title'])) {
                        $error_message = __('Please provide a title for your forum topic.', 'buddypress');
                    } else {
                        if (empty($_POST['topic_text'])) {
                            $error_message = __('Forum posts cannot be empty. Please enter some text.', 'buddypress');
                        }
                    }
                    if ($error_message) {
                        bp_core_add_message($error_message, 'error');
                        $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                    } else {
                        if (!($topic = groups_new_group_forum_topic($_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id))) {
                            bp_core_add_message(__('There was an error when creating the topic', 'buddypress'), 'error');
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                        } else {
                            bp_core_add_message(__('The topic was created successfully', 'buddypress'));
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug . '/';
                        }
                    }
                    bp_core_redirect($redirect);
                } else {
                    bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                    bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
                }
            } else {
                bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
            }
        }
        do_action('bp_forums_directory_forums_setup');
        bp_core_load_template(apply_filters('bp_forums_template_directory_forums_setup', 'forums/index'));
    }
}
Example #5
0
/**
 * bp_core_exclude_pages()
 *
 * Excludes specific pages from showing on page listings, for example the "Activation" page.
 *
 * @package BuddyPress Core
 * @uses bp_is_active() checks if a BuddyPress component is active.
 * @return array The list of page ID's to exclude
 */
function bp_core_exclude_pages($pages)
{
    global $bp;
    if (!empty($bp->pages->activate)) {
        $pages[] = $bp->pages->activate->id;
    }
    if (!empty($bp->pages->register)) {
        $pages[] = $bp->pages->register->id;
    }
    if (!empty($bp->pages->forums) && (!bp_is_active('forums') || bp_is_active('forums') && bp_forums_has_directory() && !bp_forums_is_installed_correctly())) {
        $pages[] = $bp->pages->forums->id;
    }
    return apply_filters('bp_core_exclude_pages', $pages);
}
/**
 * Update group forum metadata (title, description, slug) when the group's details are edited.
 *
 * @since BuddyPress (1.1.0)
 *
 * @param int $group_id Group id, passed from groups_details_updated.
 */
function groups_update_group_forum($group_id)
{
    $group = groups_get_group(array('group_id' => $group_id));
    /**
     * Bail in the following three situations:
     *  1. Forums are not enabled for this group
     *  2. The BP Forum component is not enabled
     *  3. The built-in bbPress forums are not correctly installed (usually means they've been
     *     uninstalled)
     */
    if (empty($group->enable_forum) || !bp_is_active('forums') || function_exists('bp_forums_is_installed_correctly') && !bp_forums_is_installed_correctly()) {
        return false;
    }
    bp_forums_update_forum(apply_filters('groups_update_group_forum', array('forum_id' => groups_get_groupmeta($group_id, 'forum_id'), 'forum_name' => $group->name, 'forum_desc' => $group->description, 'forum_slug' => $group->slug)));
}
Example #7
0
/**
 * Prevent specific pages (eg 'Activate') from showing on page listings.
 *
 * @uses bp_is_active() checks if a BuddyPress component is active.
 *
 * @param array $pages List of excluded page IDs, as passed to the
 *        'wp_list_pages_excludes' filter.
 * @return array The exclude list, with BP's pages added.
 */
function bp_core_exclude_pages($pages = array())
{
    // Bail if not the root blog
    if (!bp_is_root_blog()) {
        return $pages;
    }
    $bp = buddypress();
    if (!empty($bp->pages->activate)) {
        $pages[] = $bp->pages->activate->id;
    }
    if (!empty($bp->pages->register)) {
        $pages[] = $bp->pages->register->id;
    }
    if (!empty($bp->pages->forums) && (!bp_is_active('forums') || bp_is_active('forums') && bp_forums_has_directory() && !bp_forums_is_installed_correctly())) {
        $pages[] = $bp->pages->forums->id;
    }
    return apply_filters('bp_core_exclude_pages', $pages);
}
Example #8
0
function bp_forums_directory_forums_setup() {
	global $bp;

	if ( $bp->current_component == $bp->forums->slug ) {
		if ( (int) $bp->site_options['bp-disable-forum-directory'] || !function_exists( 'groups_install' ) )
			return false;

		if ( !bp_forums_is_installed_correctly() ) {
			bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );
			bp_core_redirect( $bp->root_domain );
		}

		$bp->is_directory = true;

		do_action( 'bbpress_init' );

		/* Check to see if the user has posted a new topic from the forums page. */
		if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) {
			/* Check the nonce */
			check_admin_referer( 'bp_forums_new_topic' );

			if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
				/* Auto join this user if they are not yet a member of this group */
				if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
					groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );

				if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) {
					if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) )
						bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );
					else
						bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );

					bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' );
				} else {
					bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );
				}
			}
		}

		do_action( 'bp_forums_directory_forums_setup' );

		bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'forums/index' ) );
	}
}
 /**
  * Setup BuddyBar navigation
  *
  * @global obj $bp
  */
 function setup_nav()
 {
     global $bp;
     // Stop if forums haven't been set up yet
     if (!bp_forums_is_installed_correctly()) {
         return;
     }
     // Stop if there is no user displayed or logged in
     if (!is_user_logged_in() && !bp_displayed_user_id()) {
         return;
     }
     // Add 'Forums' to the main navigation
     $main_nav = array('name' => __('Forums', 'buddypress'), 'slug' => $this->slug, 'position' => 80, 'screen_function' => 'bp_member_forums_screen_topics', 'default_subnav_slug' => 'topics', 'item_css_id' => $this->id);
     // Determine user to use
     if (isset($bp->displayed_user->domain)) {
         $user_domain = $bp->displayed_user->domain;
         $user_login = $bp->displayed_user->userdata->user_login;
     } elseif (isset($bp->loggedin_user->domain)) {
         $user_domain = $bp->loggedin_user->domain;
         $user_login = $bp->loggedin_user->userdata->user_login;
     } else {
         return;
     }
     // User link
     $forums_link = trailingslashit($user_domain . $this->slug);
     // Additional menu if friends is active
     $sub_nav[] = array('name' => __('Topics Started', 'buddypress'), 'slug' => 'topics', 'parent_url' => $forums_link, 'parent_slug' => $this->slug, 'screen_function' => 'bp_member_forums_screen_topics', 'position' => 20, 'item_css_id' => 'topics');
     // Additional menu if friends is active
     $sub_nav[] = array('name' => __('Replied To', 'buddypress'), 'slug' => 'replies', 'parent_url' => $forums_link, 'parent_slug' => $this->slug, 'screen_function' => 'bp_member_forums_screen_replies', 'position' => 40, 'item_css_id' => 'replies');
     // Favorite forums items. Disabled until future release.
     /*
     $sub_nav[] = array(
     	'name'            => __( 'Favorites', 'buddypress' ),
     	'slug'            => 'favorites',
     	'parent_url'      => $forums_link,
     	'parent_slug'     => $this->slug,
     	'screen_function' => 'bp_member_forums_screen_favorites',
     	'position'        => 60,
     	'item_css_id'     => 'favorites'
     );
     */
     parent::setup_nav($main_nav, $sub_nav);
 }
Example #10
0
function bp_forums_bbpress_admin()
{
    global $bp;
    $action = bp_get_admin_url('admin.php?page=bb-forums-setup&reinstall=1');
    ?>

	<div class="wrap">
		<?php 
    screen_icon('buddypress');
    ?>

		<h2 class="nav-tab-wrapper"><?php 
    bp_core_admin_tabs(__('Forums', 'buddypress'));
    ?>
</h2>

		<?php 
    if (isset($_POST['submit'])) {
        ?>

			<div id="message" class="updated fade">
				<p><?php 
        _e('Settings Saved.', 'buddypress');
        ?>
</p>
			</div>

		<?php 
    }
    ?>

		<?php 
    if (isset($_REQUEST['reinstall']) || !bp_forums_is_installed_correctly()) {
        // Delete the bb-config.php location option
        bp_delete_option('bb-config-location');
        bp_forums_bbpress_install_wizard();
    } else {
        ?>

			<div style="width: 45%; float: left; margin-top: 20px;">
				<h3><?php 
        _e('(Installed)', 'buddypress');
        ?>
 <?php 
        _e('Forums for Groups', 'buddypress');
        ?>
</h3>

				<p><?php 
        _e('Give each individual group its own discussion forum. Choose this if you\'d like to keep your members\' conversations separated into distinct areas.', 'buddypress');
        ?>
</p>
				<p class="description"><?php 
        _e('You may use an existing bbPress installation if you have one.', 'buddypress');
        ?>
</p>

				<h4 style="margin-bottom: 10px;"><?php 
        _e('Features', 'buddypress');
        ?>
</h4>
				<ul class="description" style="list-style: square; margin-left: 30px;">
					<li><?php 
        _e('Group Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Member Profile Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Activity Stream Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('@ Mention Integration', 'buddypress');
        ?>
</p></li>
				</ul>

				<div>
					<a class="button button-primary" href="<?php 
        echo $action;
        ?>
"><?php 
        _e('Uninstall Group Forums', 'buddypress');
        ?>
</a> &nbsp;
				</div>
			</div>

			<div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;">
				<h3><?php 
        _e('New! Site Wide Forums', 'buddypress');
        ?>
</h3>
				<p><?php 
        _e('Your site will have central forums that are not isolated to any specific group. Choose this if you\'d like to have a central forum area for your members.', 'buddypress');
        ?>
</p>
				<p class="description"><?php 
        _e('You may activate both Group and Site Wide forums, but this may create a poor experience for your members.', 'buddypress');
        ?>
</p>

				<h4 style="margin-bottom: 10px;"><?php 
        _e('Features', 'buddypress');
        ?>
</h4>
				<ul class="description" style="list-style: square; margin-left: 30px;">
					<li><?php 
        _e('Central Discussion Area', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Forum Plugins Available', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Activity Stream Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('@ Mention Integration', 'buddypress');
        ?>
</p></li>
				</ul>
				<div>
					<a class="button thickbox button-primary" href="<?php 
        bp_admin_url(add_query_arg(array('tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500'), 'plugin-install.php'));
        ?>
"><?php 
        _e('Install Site Wide Forums', 'buddypress');
        ?>
</a> &nbsp;
				</div>
			</div>

		<?php 
    }
    ?>

	</div>
<?php 
}
/**
 * This screen function handles actions related to group forums.
 */
function groups_screen_group_forum()
{
    if (!bp_is_active('forums') || !bp_forums_is_installed_correctly()) {
        return false;
    }
    if (bp_action_variable(0) && !bp_is_action_variable('topic', 0)) {
        bp_do_404();
        return;
    }
    $bp = buddypress();
    if (!$bp->groups->current_group->user_has_access) {
        bp_core_no_access();
        return;
    }
    if (!bp_is_single_item()) {
        return false;
    }
    // Fetch the details we need.
    $topic_slug = (string) bp_action_variable(1);
    $topic_id = bp_forums_get_topic_id_from_slug($topic_slug);
    $forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
    $user_is_banned = false;
    if (!bp_current_user_can('bp_moderate') && groups_is_user_banned(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
        $user_is_banned = true;
    }
    if (!empty($topic_slug) && !empty($topic_id)) {
        // Posting a reply.
        if (!$user_is_banned && !bp_action_variable(2) && isset($_POST['submit_reply'])) {
            // Check the nonce.
            check_admin_referer('bp_forums_new_reply');
            // Auto join this user if they are not yet a member of this group.
            if (bp_groups_auto_join() && !bp_current_user_can('bp_moderate') && 'public' == $bp->groups->current_group->status && !groups_is_user_member(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
                groups_join_group($bp->groups->current_group->id, bp_loggedin_user_id());
            }
            $topic_page = isset($_GET['topic_page']) ? $_GET['topic_page'] : false;
            // Don't allow reply flooding.
            if (bp_forums_reply_exists($_POST['reply_text'], $topic_id, bp_loggedin_user_id())) {
                bp_core_add_message(__('It looks like you\'ve already said that!', 'buddypress'), 'error');
            } else {
                if (!($post_id = groups_new_group_forum_post($_POST['reply_text'], $topic_id, $topic_page))) {
                    bp_core_add_message(__('There was an error when replying to that topic', 'buddypress'), 'error');
                } else {
                    bp_core_add_message(__('Your reply was posted successfully', 'buddypress'));
                }
            }
            $query_vars = isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '';
            $redirect = bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic_slug . '/' . $query_vars;
            if (!empty($post_id)) {
                $redirect .= '#post-' . $post_id;
            }
            bp_core_redirect($redirect);
        } elseif (bp_is_action_variable('stick', 2) && (bp_is_item_admin() || bp_is_item_mod())) {
            // Check the nonce.
            check_admin_referer('bp_forums_stick_topic');
            if (!bp_forums_sticky_topic(array('topic_id' => $topic_id))) {
                bp_core_add_message(__('There was an error when making that topic a sticky', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('The topic was made sticky successfully', 'buddypress'));
            }
            /**
             * Fires after a group forum topic has been stickied.
             *
             * @since 1.1.0
             *
             * @param int $topic_id ID of the topic being stickied.
             */
            do_action('groups_stick_forum_topic', $topic_id);
            bp_core_redirect(wp_get_referer());
        } elseif (bp_is_action_variable('unstick', 2) && (bp_is_item_admin() || bp_is_item_mod())) {
            // Check the nonce.
            check_admin_referer('bp_forums_unstick_topic');
            if (!bp_forums_sticky_topic(array('topic_id' => $topic_id, 'mode' => 'unstick'))) {
                bp_core_add_message(__('There was an error when unsticking that topic', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('The topic was unstuck successfully', 'buddypress'));
            }
            /**
             * Fires after a group forum topic has been un-stickied.
             *
             * @since 1.1.0
             *
             * @param int $topic_id ID of the topic being un-stickied.
             */
            do_action('groups_unstick_forum_topic', $topic_id);
            bp_core_redirect(wp_get_referer());
        } elseif (bp_is_action_variable('close', 2) && (bp_is_item_admin() || bp_is_item_mod())) {
            // Check the nonce.
            check_admin_referer('bp_forums_close_topic');
            if (!bp_forums_openclose_topic(array('topic_id' => $topic_id))) {
                bp_core_add_message(__('There was an error when closing that topic', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('The topic was closed successfully', 'buddypress'));
            }
            /**
             * Fires after a group forum topic has been closed.
             *
             * @since 1.1.0
             *
             * @param int $topic_id ID of the topic being closed.
             */
            do_action('groups_close_forum_topic', $topic_id);
            bp_core_redirect(wp_get_referer());
        } elseif (bp_is_action_variable('open', 2) && (bp_is_item_admin() || bp_is_item_mod())) {
            // Check the nonce.
            check_admin_referer('bp_forums_open_topic');
            if (!bp_forums_openclose_topic(array('topic_id' => $topic_id, 'mode' => 'open'))) {
                bp_core_add_message(__('There was an error when opening that topic', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('The topic was opened successfully', 'buddypress'));
            }
            /**
             * Fires after a group forum topic has been opened.
             *
             * @since 1.1.0
             *
             * @param int $topic_id ID of the topic being opened.
             */
            do_action('groups_open_forum_topic', $topic_id);
            bp_core_redirect(wp_get_referer());
        } elseif (empty($user_is_banned) && bp_is_action_variable('delete', 2) && !bp_action_variable(3)) {
            // Fetch the topic.
            $topic = bp_forums_get_topic_details($topic_id);
            /* Check the logged in user can delete this topic */
            if (!bp_is_item_admin() && !bp_is_item_mod() && (int) bp_loggedin_user_id() != (int) $topic->topic_poster) {
                bp_core_redirect(wp_get_referer());
            }
            // Check the nonce.
            check_admin_referer('bp_forums_delete_topic');
            /**
             * Fires before a group forum topic is deleted.
             *
             * @since 1.5.0
             *
             * @param int $topic_id ID of the topic being deleted.
             */
            do_action('groups_before_delete_forum_topic', $topic_id);
            if (!groups_delete_group_forum_topic($topic_id)) {
                bp_core_add_message(__('There was an error deleting the topic', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('The topic was deleted successfully', 'buddypress'));
            }
            /**
             * Fires after a group forum topic has been deleted.
             *
             * @since 1.5.0
             *
             * @param int $topic_id ID of the topic being deleted.
             */
            do_action('groups_delete_forum_topic', $topic_id);
            bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'forum/');
        } elseif (empty($user_is_banned) && bp_is_action_variable('edit', 2) && !bp_action_variable(3)) {
            // Fetch the topic.
            $topic = bp_forums_get_topic_details($topic_id);
            // Check the logged in user can edit this topic.
            if (!bp_is_item_admin() && !bp_is_item_mod() && (int) bp_loggedin_user_id() != (int) $topic->topic_poster) {
                bp_core_redirect(wp_get_referer());
            }
            if (isset($_POST['save_changes'])) {
                // Check the nonce.
                check_admin_referer('bp_forums_edit_topic');
                $topic_tags = !empty($_POST['topic_tags']) ? $_POST['topic_tags'] : false;
                if (!groups_update_group_forum_topic($topic_id, $_POST['topic_title'], $_POST['topic_text'], $topic_tags)) {
                    bp_core_add_message(__('There was an error when editing that topic', 'buddypress'), 'error');
                } else {
                    bp_core_add_message(__('The topic was edited successfully', 'buddypress'));
                }
                /**
                 * Fires after a group forum topic has been edited.
                 *
                 * @since 1.1.0
                 *
                 * @param int $topic_id ID of the topic being edited.
                 */
                do_action('groups_edit_forum_topic', $topic_id);
                bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic_slug . '/');
            }
            /**
             * Filters the template to load for a topic edit page.
             *
             * @since 1.1.0
             *
             * @param string $value Path to a topic edit template.
             */
            bp_core_load_template(apply_filters('groups_template_group_forum_topic_edit', 'groups/single/home'));
            // Delete a post.
        } elseif (empty($user_is_banned) && bp_is_action_variable('delete', 2) && ($post_id = bp_action_variable(4))) {
            // Fetch the post.
            $post = bp_forums_get_post($post_id);
            // Check the logged in user can edit this topic.
            if (!bp_is_item_admin() && !bp_is_item_mod() && (int) bp_loggedin_user_id() != (int) $post->poster_id) {
                bp_core_redirect(wp_get_referer());
            }
            // Check the nonce.
            check_admin_referer('bp_forums_delete_post');
            /**
             * Fires before the deletion of a group forum post.
             *
             * @since 1.5.0
             *
             * @param int $post_id ID of the forum post being deleted.
             */
            do_action('groups_before_delete_forum_post', $post_id);
            if (!groups_delete_group_forum_post($post_id)) {
                bp_core_add_message(__('There was an error deleting that post', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('The post was deleted successfully', 'buddypress'));
            }
            /**
             * Fires after the deletion of a group forum post.
             *
             * @since 1.1.0
             *
             * @param int $post_id ID of the forum post being deleted.
             */
            do_action('groups_delete_forum_post', $post_id);
            bp_core_redirect(wp_get_referer());
            // Editing a post.
        } elseif (empty($user_is_banned) && bp_is_action_variable('edit', 2) && ($post_id = bp_action_variable(4))) {
            // Fetch the post.
            $post = bp_forums_get_post($post_id);
            // Check the logged in user can edit this topic.
            if (!bp_is_item_admin() && !bp_is_item_mod() && (int) bp_loggedin_user_id() != (int) $post->poster_id) {
                bp_core_redirect(wp_get_referer());
            }
            if (isset($_POST['save_changes'])) {
                // Check the nonce.
                check_admin_referer('bp_forums_edit_post');
                $topic_page = isset($_GET['topic_page']) ? $_GET['topic_page'] : false;
                if (!($post_id = groups_update_group_forum_post($post_id, $_POST['post_text'], $topic_id, $topic_page))) {
                    bp_core_add_message(__('There was an error when editing that post', 'buddypress'), 'error');
                } else {
                    bp_core_add_message(__('The post was edited successfully', 'buddypress'));
                }
                if ($_SERVER['QUERY_STRING']) {
                    $query_vars = '?' . $_SERVER['QUERY_STRING'];
                }
                /**
                 * Fires after the editing of a group forum post.
                 *
                 * @since 1.1.0
                 *
                 * @param int $post_id ID of the forum post being edited.
                 */
                do_action('groups_edit_forum_post', $post_id);
                bp_core_redirect(bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id);
            }
            /** This filter is documented in bp-groups/bp-groups-screens.php */
            bp_core_load_template(apply_filters('groups_template_group_forum_topic_edit', 'groups/single/home'));
            // Standard topic display.
        } else {
            if (!empty($user_is_banned)) {
                bp_core_add_message(__("You have been banned from this group.", 'buddypress'));
            }
            /**
             * Filters the template to load for a topic page.
             *
             * @since 1.1.0
             *
             * @param string $value Path to a topic template.
             */
            bp_core_load_template(apply_filters('groups_template_group_forum_topic', 'groups/single/home'));
        }
        // Forum topic does not exist.
    } elseif (!empty($topic_slug) && empty($topic_id)) {
        bp_do_404();
        return;
    } else {
        // Posting a topic.
        if (isset($_POST['submit_topic']) && bp_is_active('forums')) {
            // Check the nonce.
            check_admin_referer('bp_forums_new_topic');
            if ($user_is_banned) {
                $error_message = __("You have been banned from this group.", 'buddypress');
            } elseif (bp_groups_auto_join() && !bp_current_user_can('bp_moderate') && 'public' == $bp->groups->current_group->status && !groups_is_user_member(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
                // Auto join this user if they are not yet a member of this group.
                groups_join_group($bp->groups->current_group->id, bp_loggedin_user_id());
            }
            if (empty($_POST['topic_title'])) {
                $error_message = __('Please provide a title for your forum topic.', 'buddypress');
            } elseif (empty($_POST['topic_text'])) {
                $error_message = __('Forum posts cannot be empty. Please enter some text.', 'buddypress');
            }
            if (empty($forum_id)) {
                $error_message = __('This group does not have a forum setup yet.', 'buddypress');
            }
            if (isset($error_message)) {
                bp_core_add_message($error_message, 'error');
                $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
            } else {
                if (!($topic = groups_new_group_forum_topic($_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id))) {
                    bp_core_add_message(__('There was an error when creating the topic', 'buddypress'), 'error');
                    $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                } else {
                    bp_core_add_message(__('The topic was created successfully', 'buddypress'));
                    $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug . '/';
                }
            }
            bp_core_redirect($redirect);
        }
        /**
         * Fires at the end of the group forum screen loading process.
         *
         * @since 1.0.0
         *
         * @param int $topic_id ID of the topic being displayed.
         * @param int $forum_id ID of the forum being displayed.
         */
        do_action('groups_screen_group_forum', $topic_id, $forum_id);
        /**
         * Filters the template to load for a group forum page.
         *
         * @since 1.0.0
         *
         * @param string $value Path to a group forum template.
         */
        bp_core_load_template(apply_filters('groups_template_group_forum', 'groups/single/home'));
    }
}
/**
 * Generates the basic search form as used in BP-Default's header.
 *
 * @global object $bp BuddyPress global settings
 * @return string HTML <select> element
 * @since 1.0
 */
function bp_search_form_type_select()
{
    global $bp;
    $options = array();
    if (bp_is_active('xprofile')) {
        $options['members'] = __('Members', 'buddypress');
    }
    if (bp_is_active('groups')) {
        $options['groups'] = __('Groups', 'buddypress');
    }
    if (bp_is_active('blogs') && is_multisite()) {
        $options['blogs'] = __('Blogs', 'buddypress');
    }
    if (bp_is_active('forums') && bp_forums_is_installed_correctly() && bp_forums_has_directory()) {
        $options['forums'] = __('Forums', 'buddypress');
    }
    $options['posts'] = __('Posts', 'buddypress');
    // Eventually this won't be needed and a page will be built to integrate all search results.
    $selection_box = '<label for="search-which" class="accessibly-hidden">' . __('Search these:', 'buddypress') . '</label>';
    $selection_box .= '<select name="search-which" id="search-which" style="width: auto">';
    $options = apply_filters('bp_search_form_type_select_options', $options);
    foreach ((array) $options as $option_value => $option_title) {
        $selection_box .= sprintf('<option value="%s">%s</option>', $option_value, $option_title);
    }
    $selection_box .= '</select>';
    return apply_filters('bp_search_form_type_select', $selection_box);
}
/**
 * Is the current page a group's forum page?
 *
 * Only applies to legacy bbPress forums.
 *
 * @since 1.1.0
 *
 * @return bool True if the current page is a group forum page.
 */
function bp_is_group_forum()
{
    $retval = false;
    // At a forum URL.
    if (bp_is_single_item() && bp_is_groups_component() && bp_is_current_action('forum')) {
        $retval = true;
        // If at a forum URL, set back to false if forums are inactive, or not
        // installed correctly.
        if (!bp_is_active('forums') || !bp_forums_is_installed_correctly()) {
            $retval = false;
        }
    }
    return $retval;
}
Example #14
0
						</label>

						<label>
							<input type="radio" name="group-invite-status" value="admins"<?php 
    bp_group_show_invite_status_setting('admins');
    ?>
 />
							<strong><?php 
    _e('Group admins only', 'buddypress');
    ?>
</strong>
						</label>
					</div>

					<?php 
    if (bp_is_active('forums') && bp_forums_is_installed_correctly()) {
        ?>

						<h4><?php 
        _e('Group Forums', 'buddypress');
        ?>
</h4>

						<p><?php 
        _e('Should this group have a forum?', 'buddypress');
        ?>
</p>

						<div class="checkbox">
							<label><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php 
        checked(bp_get_new_group_enable_forum(), true, true);
/**
 * Bootstrap bbPress 1.x, and manipulate globals to integrate with BuddyPress.
 *
 * @return bool|null Returns false on failure.
 */
function bp_forums_load_bbpress()
{
    global $wpdb, $wp_roles, $current_user, $wp_users_object;
    global $bb, $bbdb, $bb_table_prefix, $bb_current_user;
    global $bb_roles, $wp_taxonomy_object, $bb_queries;
    // Return if we've already run this function.
    if (is_object($bbdb)) {
        return;
    }
    if (!bp_forums_is_installed_correctly()) {
        return false;
    }
    $bp = buddypress();
    define('BB_PATH', $bp->plugin_dir . '/bp-forums/bbpress/');
    define('BACKPRESS_PATH', $bp->plugin_dir . '/bp-forums/bbpress/bb-includes/backpress/');
    define('BB_URL', $bp->plugin_url . 'bp-forums/bbpress/');
    define('BB_INC', 'bb-includes/');
    require BB_PATH . BB_INC . 'class.bb-query.php';
    require BB_PATH . BB_INC . 'class.bb-walker.php';
    require BB_PATH . BB_INC . 'functions.bb-core.php';
    require BB_PATH . BB_INC . 'functions.bb-forums.php';
    require BB_PATH . BB_INC . 'functions.bb-topics.php';
    require BB_PATH . BB_INC . 'functions.bb-posts.php';
    require BB_PATH . BB_INC . 'functions.bb-topic-tags.php';
    require BB_PATH . BB_INC . 'functions.bb-capabilities.php';
    require BB_PATH . BB_INC . 'functions.bb-meta.php';
    require BB_PATH . BB_INC . 'functions.bb-pluggable.php';
    require BB_PATH . BB_INC . 'functions.bb-formatting.php';
    require BB_PATH . BB_INC . 'functions.bb-template.php';
    require BACKPRESS_PATH . 'class.wp-taxonomy.php';
    require BB_PATH . BB_INC . 'class.bb-taxonomy.php';
    require BB_PATH . 'bb-admin/includes/functions.bb-admin.php';
    $bb = new stdClass();
    require bp_get_option('bb-config-location');
    // Setup the global database connection
    $bbdb = new BPDB(BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST);
    // Set the table names
    $bbdb->forums = $bb_table_prefix . 'forums';
    $bbdb->meta = $bb_table_prefix . 'meta';
    $bbdb->posts = $bb_table_prefix . 'posts';
    $bbdb->terms = $bb_table_prefix . 'terms';
    $bbdb->term_relationships = $bb_table_prefix . 'term_relationships';
    $bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy';
    $bbdb->topics = $bb_table_prefix . 'topics';
    if (isset($bb->custom_user_table)) {
        $bbdb->users = $bb->custom_user_table;
    } else {
        $bbdb->users = $wpdb->users;
    }
    if (isset($bb->custom_user_meta_table)) {
        $bbdb->usermeta = $bb->custom_user_meta_table;
    } else {
        $bbdb->usermeta = $wpdb->usermeta;
    }
    $bbdb->prefix = $bb_table_prefix;
    define('BB_INSTALLING', false);
    if (is_object($wp_roles)) {
        $bb_roles = $wp_roles;
        bb_init_roles($bb_roles);
    }
    /**
     * Fires during the bootstrap setup for bbPress 1.x.
     *
     * @since 1.1.0
     */
    do_action('bb_got_roles');
    /**
     * Fires during the bootstrap setup for bbPress 1.x.
     *
     * @since 1.1.0
     */
    do_action('bb_init');
    /**
     * Fires during the bootstrap setup for bbPress 1.x.
     *
     * @since 1.1.0
     */
    do_action('init_roles');
    $bb_current_user = $current_user;
    $wp_users_object = new BP_Forums_BB_Auth();
    if (!isset($wp_taxonomy_object)) {
        $wp_taxonomy_object = new BB_Taxonomy($bbdb);
    }
    $wp_taxonomy_object->register_taxonomy('bb_topic_tag', 'bb_topic');
    // Set a site id if there isn't one already
    if (!isset($bb->site_id)) {
        $bb->site_id = bp_get_root_blog_id();
    }
    // Check if the tables are installed, if not, install them
    if (!($tables_installed = (bool) $bbdb->get_results('DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A))) {
        require BB_PATH . 'bb-admin/includes/defaults.bb-schema.php';
        // Backticks and "IF NOT EXISTS" break the dbDelta function.
        bp_bb_dbDelta(str_replace(' IF NOT EXISTS', '', str_replace('`', '', $bb_queries)));
        require BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php';
        bb_update_db_version();
        // Set the site admins as the keymasters
        $site_admins = get_site_option('site_admins', array('admin'));
        foreach ((array) $site_admins as $site_admin) {
            bp_update_user_meta(bp_core_get_userid($site_admin), $bb_table_prefix . 'capabilities', array('keymaster' => true));
        }
        // Create the first forum.
        bb_new_forum(array('forum_name' => 'Default Forum'));
        // Set the site URI
        bb_update_option('uri', BB_URL);
    }
    /**
     * Fires inside an anonymous function that is run on bbPress shutdown.
     *
     * @since 1.1.0
     */
    register_shutdown_function(create_function('', 'do_action("bb_shutdown");'));
}
/**
 * This screen function handles actions related to group forums
 *
 * @package BuddyPress
 */
function groups_screen_group_forum()
{
    global $bp;
    if (!bp_is_active('forums') || !bp_forums_is_installed_correctly()) {
        return false;
    }
    if (bp_action_variable(0) && !bp_is_action_variable('topic', 0)) {
        bp_do_404();
        return;
    }
    if (!$bp->groups->current_group->user_has_access) {
        bp_core_no_access();
        return;
    }
    if (bp_is_single_item()) {
        // Fetch the details we need
        $topic_slug = (string) bp_action_variable(1);
        $topic_id = bp_forums_get_topic_id_from_slug($topic_slug);
        $forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
        $user_is_banned = false;
        if (!bp_current_user_can('bp_moderate') && groups_is_user_banned(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
            $user_is_banned = true;
        }
        if (!empty($topic_slug) && !empty($topic_id)) {
            // Posting a reply
            if (!$user_is_banned && !bp_action_variable(2) && isset($_POST['submit_reply'])) {
                // Check the nonce
                check_admin_referer('bp_forums_new_reply');
                // Auto join this user if they are not yet a member of this group
                if (bp_groups_auto_join() && !bp_current_user_can('bp_moderate') && 'public' == $bp->groups->current_group->status && !groups_is_user_member(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
                    groups_join_group($bp->groups->current_group->id, bp_loggedin_user_id());
                }
                $topic_page = isset($_GET['topic_page']) ? $_GET['topic_page'] : false;
                if (!($post_id = groups_new_group_forum_post($_POST['reply_text'], $topic_id, $topic_page))) {
                    bp_core_add_message(__('There was an error when replying to that topic', 'buddypress'), 'error');
                } else {
                    bp_core_add_message(__('Your reply was posted successfully', 'buddypress'));
                }
                if (isset($_SERVER['QUERY_STRING'])) {
                    $query_vars = '?' . $_SERVER['QUERY_STRING'];
                }
                bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id);
            } else {
                if (bp_is_action_variable('stick', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
                    // Check the nonce
                    check_admin_referer('bp_forums_stick_topic');
                    if (!bp_forums_sticky_topic(array('topic_id' => $topic_id))) {
                        bp_core_add_message(__('There was an error when making that topic a sticky', 'buddypress'), 'error');
                    } else {
                        bp_core_add_message(__('The topic was made sticky successfully', 'buddypress'));
                    }
                    do_action('groups_stick_forum_topic', $topic_id);
                    bp_core_redirect(wp_get_referer());
                } else {
                    if (bp_is_action_variable('unstick', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
                        // Check the nonce
                        check_admin_referer('bp_forums_unstick_topic');
                        if (!bp_forums_sticky_topic(array('topic_id' => $topic_id, 'mode' => 'unstick'))) {
                            bp_core_add_message(__('There was an error when unsticking that topic', 'buddypress'), 'error');
                        } else {
                            bp_core_add_message(__('The topic was unstuck successfully', 'buddypress'));
                        }
                        do_action('groups_unstick_forum_topic', $topic_id);
                        bp_core_redirect(wp_get_referer());
                    } else {
                        if (bp_is_action_variable('close', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
                            // Check the nonce
                            check_admin_referer('bp_forums_close_topic');
                            if (!bp_forums_openclose_topic(array('topic_id' => $topic_id))) {
                                bp_core_add_message(__('There was an error when closing that topic', 'buddypress'), 'error');
                            } else {
                                bp_core_add_message(__('The topic was closed successfully', 'buddypress'));
                            }
                            do_action('groups_close_forum_topic', $topic_id);
                            bp_core_redirect(wp_get_referer());
                        } else {
                            if (bp_is_action_variable('open', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
                                // Check the nonce
                                check_admin_referer('bp_forums_open_topic');
                                if (!bp_forums_openclose_topic(array('topic_id' => $topic_id, 'mode' => 'open'))) {
                                    bp_core_add_message(__('There was an error when opening that topic', 'buddypress'), 'error');
                                } else {
                                    bp_core_add_message(__('The topic was opened successfully', 'buddypress'));
                                }
                                do_action('groups_open_forum_topic', $topic_id);
                                bp_core_redirect(wp_get_referer());
                            } else {
                                if (empty($user_is_banned) && bp_is_action_variable('delete', 2) && !bp_action_variable(3)) {
                                    // Fetch the topic
                                    $topic = bp_forums_get_topic_details($topic_id);
                                    /* Check the logged in user can delete this topic */
                                    if (!$bp->is_item_admin && !$bp->is_item_mod && (int) bp_loggedin_user_id() != (int) $topic->topic_poster) {
                                        bp_core_redirect(wp_get_referer());
                                    }
                                    // Check the nonce
                                    check_admin_referer('bp_forums_delete_topic');
                                    do_action('groups_before_delete_forum_topic', $topic_id);
                                    if (!groups_delete_group_forum_topic($topic_id)) {
                                        bp_core_add_message(__('There was an error deleting the topic', 'buddypress'), 'error');
                                    } else {
                                        bp_core_add_message(__('The topic was deleted successfully', 'buddypress'));
                                    }
                                    do_action('groups_delete_forum_topic', $topic_id);
                                    bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'forum/');
                                } else {
                                    if (empty($user_is_banned) && bp_is_action_variable('edit', 2) && !bp_action_variable(3)) {
                                        // Fetch the topic
                                        $topic = bp_forums_get_topic_details($topic_id);
                                        // Check the logged in user can edit this topic
                                        if (!$bp->is_item_admin && !$bp->is_item_mod && (int) bp_loggedin_user_id() != (int) $topic->topic_poster) {
                                            bp_core_redirect(wp_get_referer());
                                        }
                                        if (isset($_POST['save_changes'])) {
                                            // Check the nonce
                                            check_admin_referer('bp_forums_edit_topic');
                                            $topic_tags = !empty($_POST['topic_tags']) ? $_POST['topic_tags'] : false;
                                            if (!groups_update_group_forum_topic($topic_id, $_POST['topic_title'], $_POST['topic_text'], $topic_tags)) {
                                                bp_core_add_message(__('There was an error when editing that topic', 'buddypress'), 'error');
                                            } else {
                                                bp_core_add_message(__('The topic was edited successfully', 'buddypress'));
                                            }
                                            do_action('groups_edit_forum_topic', $topic_id);
                                            bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic_slug . '/');
                                        }
                                        bp_core_load_template(apply_filters('groups_template_group_forum_topic_edit', 'groups/single/home'));
                                    } else {
                                        if (empty($user_is_banned) && bp_is_action_variable('delete', 2) && ($post_id = bp_action_variable(4))) {
                                            // Fetch the post
                                            $post = bp_forums_get_post($post_id);
                                            // Check the logged in user can edit this topic
                                            if (!$bp->is_item_admin && !$bp->is_item_mod && (int) bp_loggedin_user_id() != (int) $post->poster_id) {
                                                bp_core_redirect(wp_get_referer());
                                            }
                                            // Check the nonce
                                            check_admin_referer('bp_forums_delete_post');
                                            do_action('groups_before_delete_forum_post', $post_id);
                                            if (!groups_delete_group_forum_post($post_id)) {
                                                bp_core_add_message(__('There was an error deleting that post', 'buddypress'), 'error');
                                            } else {
                                                bp_core_add_message(__('The post was deleted successfully', 'buddypress'));
                                            }
                                            do_action('groups_delete_forum_post', $post_id);
                                            bp_core_redirect(wp_get_referer());
                                        } else {
                                            if (empty($user_is_banned) && bp_is_action_variable('edit', 2) && ($post_id = bp_action_variable(4))) {
                                                // Fetch the post
                                                $post = bp_forums_get_post($post_id);
                                                // Check the logged in user can edit this topic
                                                if (!$bp->is_item_admin && !$bp->is_item_mod && (int) bp_loggedin_user_id() != (int) $post->poster_id) {
                                                    bp_core_redirect(wp_get_referer());
                                                }
                                                if (isset($_POST['save_changes'])) {
                                                    // Check the nonce
                                                    check_admin_referer('bp_forums_edit_post');
                                                    $topic_page = isset($_GET['topic_page']) ? $_GET['topic_page'] : false;
                                                    if (!($post_id = groups_update_group_forum_post($post_id, $_POST['post_text'], $topic_id, $topic_page))) {
                                                        bp_core_add_message(__('There was an error when editing that post', 'buddypress'), 'error');
                                                    } else {
                                                        bp_core_add_message(__('The post was edited successfully', 'buddypress'));
                                                    }
                                                    if ($_SERVER['QUERY_STRING']) {
                                                        $query_vars = '?' . $_SERVER['QUERY_STRING'];
                                                    }
                                                    do_action('groups_edit_forum_post', $post_id);
                                                    bp_core_redirect(bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id);
                                                }
                                                bp_core_load_template(apply_filters('groups_template_group_forum_topic_edit', 'groups/single/home'));
                                            } else {
                                                if (!empty($user_is_banned)) {
                                                    bp_core_add_message(__("You have been banned from this group.", 'buddypress'));
                                                }
                                                bp_core_load_template(apply_filters('groups_template_group_forum_topic', 'groups/single/home'));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            // Forum topic does not exist
        } elseif (!empty($topic_slug) && empty($topic_id)) {
            bp_do_404();
            return;
        } else {
            // Posting a topic
            if (isset($_POST['submit_topic']) && bp_is_active('forums')) {
                // Check the nonce
                check_admin_referer('bp_forums_new_topic');
                if ($user_is_banned) {
                    $error_message = __("You have been banned from this group.", 'buddypress');
                } elseif (bp_groups_auto_join() && !bp_current_user_can('bp_moderate') && 'public' == $bp->groups->current_group->status && !groups_is_user_member(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
                    // Auto join this user if they are not yet a member of this group
                    groups_join_group($bp->groups->current_group->id, bp_loggedin_user_id());
                }
                if (empty($_POST['topic_title'])) {
                    $error_message = __('Please provide a title for your forum topic.', 'buddypress');
                } else {
                    if (empty($_POST['topic_text'])) {
                        $error_message = __('Forum posts cannot be empty. Please enter some text.', 'buddypress');
                    }
                }
                if (empty($forum_id)) {
                    $error_message = __('This group does not have a forum setup yet.', 'buddypress');
                }
                if (isset($error_message)) {
                    bp_core_add_message($error_message, 'error');
                    $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                } else {
                    if (!($topic = groups_new_group_forum_topic($_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id))) {
                        bp_core_add_message(__('There was an error when creating the topic', 'buddypress'), 'error');
                        $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                    } else {
                        bp_core_add_message(__('The topic was created successfully', 'buddypress'));
                        $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug . '/';
                    }
                }
                bp_core_redirect($redirect);
            }
            do_action('groups_screen_group_forum', $topic_id, $forum_id);
            bp_core_load_template(apply_filters('groups_template_group_forum', 'groups/single/home'));
        }
    }
}
Example #17
0
 /**
  * Register the settings
  *
  * @since BuddyPress (1.6)
  *
  * @uses add_settings_section() To add our own settings section
  * @uses add_settings_field() To add various settings fields
  * @uses register_setting() To register various settings
  * @uses do_action() Calls 'bp_register_admin_settings'
  */
 public function register_admin_settings()
 {
     /** Main Section ******************************************************/
     // Add the main section
     add_settings_section('bp_main', __('Main Settings', 'buddypress'), 'bp_admin_setting_callback_main_section', 'buddypress');
     // Hide toolbar for logged out users setting
     add_settings_field('hide-loggedout-adminbar', __('Toolbar', 'buddypress'), 'bp_admin_setting_callback_admin_bar', 'buddypress', 'bp_main');
     register_setting('buddypress', 'hide-loggedout-adminbar', 'intval');
     // Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade
     if ((bool) bp_get_option('_bp_force_buddybar', false)) {
         add_settings_field('_bp_force_buddybar', __('Toolbar', 'buddypress'), 'bp_admin_setting_callback_force_buddybar', 'buddypress', 'bp_main');
         register_setting('buddypress', '_bp_force_buddybar', 'bp_admin_sanitize_callback_force_buddybar');
     }
     // Allow account deletion
     add_settings_field('bp-disable-account-deletion', __('Account Deletion', 'buddypress'), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main');
     register_setting('buddypress', 'bp-disable-account-deletion', 'intval');
     /** XProfile Section **************************************************/
     if (bp_is_active('xprofile')) {
         // Add the main section
         add_settings_section('bp_xprofile', __('Profile Settings', 'buddypress'), 'bp_admin_setting_callback_xprofile_section', 'buddypress');
         // Allow avatar uploads
         add_settings_field('bp-disable-avatar-uploads', __('Avatar Uploads', 'buddypress'), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_xprofile');
         register_setting('buddypress', 'bp-disable-avatar-uploads', 'intval');
         // Profile sync setting
         add_settings_field('bp-disable-profile-sync', __('Profile Syncing', 'buddypress'), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile');
         register_setting('buddypress', 'bp-disable-profile-sync', 'intval');
     }
     /** Groups Section ****************************************************/
     if (bp_is_active('groups')) {
         // Add the main section
         add_settings_section('bp_groups', __('Groups Settings', 'buddypress'), 'bp_admin_setting_callback_groups_section', 'buddypress');
         // Allow subscriptions setting
         add_settings_field('bp_restrict_group_creation', __('Group Creation', 'buddypress'), 'bp_admin_setting_callback_group_creation', 'buddypress', 'bp_groups');
         register_setting('buddypress', 'bp_restrict_group_creation', 'intval');
     }
     /** Forums ************************************************************/
     if (bp_is_active('forums') && bp_forums_is_installed_correctly()) {
         // Add the main section
         add_settings_section('bp_forums', __('Forums Settings', 'buddypress'), 'bp_admin_setting_callback_bbpress_section', 'buddypress');
         // Allow subscriptions setting
         add_settings_field('bb-config-location', __('bbPress Configuration', 'buddypress'), 'bp_admin_setting_callback_bbpress_configuration', 'buddypress', 'bp_forums');
         register_setting('buddypress', 'bb-config-location', '');
     }
     /** Activity Section **************************************************/
     if (bp_is_active('activity')) {
         // Add the main section
         add_settings_section('bp_activity', __('Activity Settings', 'buddypress'), 'bp_admin_setting_callback_activity_section', 'buddypress');
         // Activity commenting on blog and forum posts
         add_settings_field('bp-disable-blogforum-comments', __('Blog &amp; Forum Comments', 'buddypress'), 'bp_admin_setting_callback_blogforum_comments', 'buddypress', 'bp_activity');
         register_setting('buddypress', 'bp-disable-blogforum-comments', 'bp_admin_sanitize_callback_blogforum_comments');
         // Allow activity akismet
         if (is_plugin_active('akismet/akismet.php') && defined('AKISMET_VERSION')) {
             add_settings_field('_bp_enable_akismet', __('Akismet', 'buddypress'), 'bp_admin_setting_callback_activity_akismet', 'buddypress', 'bp_activity');
             register_setting('buddypress', '_bp_enable_akismet', 'intval');
         }
     }
     do_action('bp_register_admin_settings');
 }
Example #18
0
/**
 *  widget for the community navigation
 *
 * @package Custom Community
 * @since 1.8.3
 */
function widget_community_nav($sidebar_id = false)
{
    ?>
		<?php 
    global $cap;
    if ($sidebar_id == 'leftsidebar' && $cap->bg_leftsidebar_default_nav && $cap->bg_leftsidebar_default_nav == 'no') {
        return;
    }
    ?>
  		<div id="community-nav" class="widget widget-title" >
        	<h3 class="widgettitle"><?php 
    _e('Community', 'cc');
    ?>
</h3>
  				<ul class="item-list">
					
			  		<?php 
    if ('activity' != bp_dtheme_page_on_front() && bp_is_active('activity')) {
        ?>
                                        <li<?php 
        if (bp_is_activity_component()) {
            ?>
 class="selected"<?php 
        }
        ?>
>
							<a href="<?php 
        echo site_url();
        ?>
/<?php 
        echo BP_ACTIVITY_SLUG;
        ?>
/" title="<?php 
        _e('Activity', 'cc');
        ?>
"><?php 
        _e('Activity', 'cc');
        ?>
</a>
						</li>
					<?php 
    }
    ?>

                                        <li<?php 
    if (bp_is_members_component() || bp_is_user()) {
        ?>
 class="selected"<?php 
    }
    ?>
>
                                                <a href="<?php 
    echo site_url();
    ?>
/<?php 
    echo BP_MEMBERS_SLUG;
    ?>
/" title="<?php 
    _e('Members', 'cc');
    ?>
"><?php 
    _e('Members', 'cc');
    ?>
</a>
                                        </li>
			
                                    <?php 
    if (bp_is_active('groups')) {
        ?>
                                            <li<?php 
        if (bp_is_groups_component() || bp_is_group()) {
            ?>
 class="selected"<?php 
        }
        ?>
>
                                                    <a href="<?php 
        echo site_url();
        ?>
/<?php 
        echo BP_GROUPS_SLUG;
        ?>
/" title="<?php 
        _e('Groups', 'cc');
        ?>
"><?php 
        _e('Groups', 'cc');
        ?>
</a>
                                            </li>
			
                                        <?php 
        if (bp_is_active('forums') && (function_exists('bp_forums_is_installed_correctly') && !(int) bp_get_option('bp-disable-forum-directory')) && bp_forums_is_installed_correctly()) {
            ?>
                                                <li<?php 
            if (bp_is_forums_component()) {
                ?>
 class="selected"<?php 
            }
            ?>
>
                                                        <a href="<?php 
            echo site_url();
            ?>
/<?php 
            echo BP_FORUMS_SLUG;
            ?>
/" title="<?php 
            _e('Forums', 'cc');
            ?>
"><?php 
            _e('Forums', 'cc');
            ?>
</a>
                                                </li>
                                        <?php 
        }
        ?>
					<?php 
    }
    ?>
					<?php 
    if (bp_is_active('blogs') && is_multisite()) {
        ?>
                                                        <li<?php 
        if (bp_is_blogs_component()) {
            ?>
 class="selected"<?php 
        }
        ?>
>
							<a href="<?php 
        echo site_url();
        ?>
/<?php 
        echo BP_BLOGS_SLUG;
        ?>
/" title="<?php 
        _e('Blogs', 'cc');
        ?>
"><?php 
        _e('Blogs', 'cc');
        ?>
</a>
						</li>
					<?php 
    }
    ?>
  				</ul>
				
   <?php 
    if (bp_is_single_item() || bp_is_user()) {
        ?>
	   	<?php 
        if (bp_is_group()) {
            ?>
		<div id="community-single-nav" class="widget-title" >
		  <ul class="item-list">
		  <h3 class="widgettitle"><?php 
            _e('@ Group', 'cc');
            ?>
</h3>
				<?php 
            bp_get_options_nav();
            ?>
				<?php 
            do_action('bp_group_options_nav');
            ?>
			</ul>
		
		</div>	
		<?php 
        }
        ?>

		<?php 
        if (bp_is_user()) {
            ?>
		<div id="community-single-nav" class="widget-title" >
		  <ul class="item-list">
		  <h3 class="widgettitle"><?php 
            _e('@ Member', 'cc');
            ?>
</h3>
		  <?php 
            bp_get_displayed_user_nav();
            ?>
				<?php 
            do_action('bp_group_options_nav');
            ?>
			</ul>
		
		</div>	
		<?php 
        }
        ?>
  	<?php 
    }
    ?>
  	</div>
<?php 
}
Example #19
0
/**
 * Verify that some BP prerequisites are set up properly, and notify the admin if not
 *
 * On every Dashboard page, this function checks the following:
 *   - that pretty permalinks are enabled
 *   - that a BP-compatible theme is activated
 *   - that every BP component that needs a WP page for a directory has one
 *   - that no WP page has multiple BP components associated with it
 * The administrator will be shown a notice for each check that fails.
 *
 * @package BuddyPress Core
 */
function bp_core_activation_notice()
{
    global $wp_rewrite, $wpdb, $bp;
    // Only the super admin gets warnings
    if (!bp_current_user_can('bp_moderate')) {
        return;
    }
    // On multisite installs, don't load on a non-root blog, unless do_network_admin is
    // overridden
    if (is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog()) {
        return;
    }
    // Don't show these messages during setup or upgrade
    if (!empty($bp->maintenance_mode)) {
        return;
    }
    /**
     * Check to make sure that the blog setup routine has run. This can't happen during the
     * wizard because of the order which the components are loaded. We check for multisite here
     * on the off chance that someone has activated the blogs component and then disabled MS
     */
    if (bp_is_active('blogs')) {
        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$bp->blogs->table_name}"));
        if (empty($count)) {
            bp_blogs_record_existing_blogs();
        }
    }
    /**
     * Are pretty permalinks enabled?
     */
    if (isset($_POST['permalink_structure'])) {
        return false;
    }
    if (empty($wp_rewrite->permalink_structure)) {
        bp_core_add_admin_notice(sprintf(__('<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress'), admin_url('options-permalink.php')));
    }
    /**
     * Are you using a BP-compatible theme?
     */
    // Get current theme info
    $ct = wp_get_theme();
    // Make sure tags is an array to suppress notices
    if (!isset($ct->tags)) {
        $ct->tags = array();
    } else {
        $ct->tags = (array) $ct->tags;
    }
    // The best way to remove this notice is to add a "buddypress" tag to
    // your active theme's CSS header.
    if (!defined('BP_SILENCE_THEME_NOTICE') && !in_array('buddypress', $ct->tags)) {
        bp_core_add_admin_notice(sprintf(__("You'll need to <a href='%s'>activate a <strong>BuddyPress-compatible theme</strong></a> to take advantage of all of BuddyPress's features. We've bundled a default theme, but you can always <a href='%s'>install some other compatible themes</a> or <a href='%s'>update your existing WordPress theme</a>.", 'buddypress'), admin_url('themes.php'), network_admin_url('theme-install.php?type=tag&s=buddypress&tab=search'), network_admin_url('plugin-install.php?type=term&tab=search&s=%22bp-template-pack%22')));
    }
    /**
     * Check for orphaned BP components (BP component is enabled, no WP page exists)
     */
    $orphaned_components = array();
    $wp_page_components = array();
    // Only components with 'has_directory' require a WP page to function
    foreach ($bp->loaded_components as $component_id => $is_active) {
        if (!empty($bp->{$component_id}->has_directory)) {
            $wp_page_components[] = array('id' => $component_id, 'name' => isset($bp->{$component_id}->name) ? $bp->{$component_id}->name : ucwords($bp->{$component_id}->id));
        }
    }
    // Activate and Register are special cases. They are not components but they need WP pages.
    // If user registration is disabled, we can skip this step.
    if (bp_get_signup_allowed()) {
        $wp_page_components[] = array('id' => 'activate', 'name' => __('Activate', 'buddypress'));
        $wp_page_components[] = array('id' => 'register', 'name' => __('Register', 'buddypress'));
    }
    foreach ($wp_page_components as $component) {
        if (!isset($bp->pages->{$component['id']})) {
            $orphaned_components[] = $component['name'];
        }
    }
    // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is
    // not correctly set up, don't show a nag. (In these cases, it's probably the case that the
    // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292
    if (isset($bp->forums->name) && in_array($bp->forums->name, $orphaned_components) && !bp_forums_is_installed_correctly()) {
        $forum_key = array_search($bp->forums->name, $orphaned_components);
        unset($orphaned_components[$forum_key]);
        $orphaned_components = array_values($orphaned_components);
    }
    if (!empty($orphaned_components)) {
        $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php'));
        $notice = sprintf(__('The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress'), $admin_url, '<strong>' . implode('</strong>, <strong>', $orphaned_components) . '</strong>');
        bp_core_add_admin_notice($notice);
    }
    /**
     * BP components cannot share a single WP page. Check for duplicate assignments, and post
     * a message if found.
     */
    $dupe_names = array();
    $page_ids = (array) bp_core_get_directory_page_ids();
    $dupes = array_diff_assoc($page_ids, array_unique($page_ids));
    if (!empty($dupes)) {
        foreach ($dupes as $dupe_component => $dupe_id) {
            $dupe_names[] = $bp->pages->{$dupe_component}->title;
        }
        // Make sure that there are no duplicate duplicates :)
        $dupe_names = array_unique($dupe_names);
    }
    // If there are duplicates, post a message about them
    if (!empty($dupe_names)) {
        $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php'));
        $notice = sprintf(__('Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress'), $admin_url, '<strong>' . implode('</strong>, <strong>', $dupe_names) . '</strong>');
        bp_core_add_admin_notice($notice);
    }
}
/**
 * Verify that some BP prerequisites are set up properly, and notify the admin if not.
 *
 * On every Dashboard page, this function checks the following:
 *   - that pretty permalinks are enabled.
 *   - that every BP component that needs a WP page for a directory has one.
 *   - that no WP page has multiple BP components associated with it.
 * The administrator will be shown a notice for each check that fails.
 *
 * @global WPDB $wpdb WordPress DB object
 * @global WP_Rewrite $wp_rewrite
 *
 * @since 1.2.0
 */
function bp_core_activation_notice()
{
    global $wp_rewrite, $wpdb;
    // Only the super admin gets warnings.
    if (!bp_current_user_can('bp_moderate')) {
        return;
    }
    // Bail in user admin.
    if (is_user_admin()) {
        return;
    }
    // On multisite installs, don't load on a non-root blog, unless do_network_admin is overridden.
    if (is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog()) {
        return;
    }
    // Bail if in network admin, and BuddyPress is not network activated.
    if (is_network_admin() && !bp_is_network_activated()) {
        return;
    }
    /**
     * Check to make sure that the blog setup routine has run. This can't
     * happen during the wizard because of the order which the components
     * are loaded.
     */
    if (bp_is_active('blogs')) {
        $bp = buddypress();
        $count = $wpdb->get_var("SELECT COUNT(*) FROM {$bp->blogs->table_name}");
        if (empty($count)) {
            bp_blogs_record_existing_blogs();
        }
    }
    // Add notice if no rewrite rules are enabled.
    if (empty($wp_rewrite->permalink_structure)) {
        bp_core_add_admin_notice(sprintf(__('<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress'), admin_url('options-permalink.php')), 'error');
    }
    // Get BuddyPress instance.
    $bp = buddypress();
    /**
     * Check for orphaned BP components (BP component is enabled, no WP page exists).
     */
    $orphaned_components = array();
    $wp_page_components = array();
    // Only components with 'has_directory' require a WP page to function.
    foreach (array_keys($bp->loaded_components) as $component_id) {
        if (!empty($bp->{$component_id}->has_directory)) {
            $wp_page_components[] = array('id' => $component_id, 'name' => isset($bp->{$component_id}->name) ? $bp->{$component_id}->name : ucwords($bp->{$component_id}->id));
        }
    }
    // Activate and Register are special cases. They are not components but they need WP pages.
    // If user registration is disabled, we can skip this step.
    if (bp_get_signup_allowed()) {
        $wp_page_components[] = array('id' => 'activate', 'name' => __('Activate', 'buddypress'));
        $wp_page_components[] = array('id' => 'register', 'name' => __('Register', 'buddypress'));
    }
    // On the first admin screen after a new installation, this isn't set, so grab it to suppress
    // a misleading error message.
    if (empty($bp->pages->members)) {
        $bp->pages = bp_core_get_directory_pages();
    }
    foreach ($wp_page_components as $component) {
        if (!isset($bp->pages->{$component['id']})) {
            $orphaned_components[] = $component['name'];
        }
    }
    // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is
    // not correctly set up, don't show a nag. (In these cases, it's probably the case that the
    // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292.
    if (isset($bp->forums->name) && in_array($bp->forums->name, $orphaned_components) && !bp_forums_is_installed_correctly()) {
        $forum_key = array_search($bp->forums->name, $orphaned_components);
        unset($orphaned_components[$forum_key]);
        $orphaned_components = array_values($orphaned_components);
    }
    if (!empty($orphaned_components)) {
        $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php'));
        $notice = sprintf(__('The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href="%1$s">Repair</a>', 'buddypress'), esc_url($admin_url), '<strong>' . implode('</strong>, <strong>', $orphaned_components) . '</strong>');
        bp_core_add_admin_notice($notice);
    }
    // BP components cannot share a single WP page. Check for duplicate assignments, and post a message if found.
    $dupe_names = array();
    $page_ids = (array) bp_core_get_directory_page_ids();
    $dupes = array_diff_assoc($page_ids, array_unique($page_ids));
    if (!empty($dupes)) {
        foreach (array_keys($dupes) as $dupe_component) {
            $dupe_names[] = $bp->pages->{$dupe_component}->title;
        }
        // Make sure that there are no duplicate duplicates :).
        $dupe_names = array_unique($dupe_names);
    }
    // If there are duplicates, post a message about them.
    if (!empty($dupe_names)) {
        $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php'));
        $notice = sprintf(__('Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %2$s. <a href="%1$s">Repair</a>', 'buddypress'), esc_url($admin_url), '<strong>' . implode('</strong>, <strong>', $dupe_names) . '</strong>');
        bp_core_add_admin_notice($notice);
    }
}
Example #21
0
/**
 * Outputs the markup for the bb-forums-admin panel
 */
function bp_forums_bbpress_admin()
{
    global $bp;
    // The text and URL of the Site Wide Forums button differs depending on whether bbPress
    // is running
    if (is_plugin_active('bbpress/bbpress.php')) {
        // The bbPress admin page will always be on the root blog. switch_to_blog() will
        // pass through if we're already there.
        switch_to_blog(bp_get_root_blog_id());
        $button_url = admin_url(add_query_arg(array('page' => 'bbpress'), 'options-general.php'));
        restore_current_blog();
        $button_text = __('Configure Site Wide Forums', 'buddypress');
    } else {
        $button_url = bp_get_admin_url(add_query_arg(array('tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500'), 'plugin-install.php'));
        $button_text = __('Install Site Wide Forums', 'buddypress');
    }
    $action = bp_get_admin_url('admin.php?page=bb-forums-setup&reinstall=1');
    ?>

	<div class="wrap">
		<?php 
    screen_icon('buddypress');
    ?>

		<h2 class="nav-tab-wrapper"><?php 
    bp_core_admin_tabs(__('Forums', 'buddypress'));
    ?>
</h2>

		<?php 
    if (isset($_POST['submit'])) {
        ?>

			<div id="message" class="updated fade">
				<p><?php 
        _e('Settings Saved.', 'buddypress');
        ?>
</p>
			</div>

		<?php 
    }
    ?>

		<?php 
    if (isset($_REQUEST['reinstall']) || !bp_forums_is_installed_correctly()) {
        // Delete the bb-config.php location option
        bp_delete_option('bb-config-location');
        bp_forums_bbpress_install_wizard();
    } else {
        ?>

			<div style="width: 45%; float: left; margin-top: 20px;">
				<h3><?php 
        _e('(Installed)', 'buddypress');
        ?>
 <?php 
        _e('Forums for Groups', 'buddypress');
        ?>
</h3>

				<p><?php 
        _e('Give each individual group its own discussion forum. Choose this if you\'d like to keep your members\' conversations separated into distinct areas.', 'buddypress');
        ?>
</p>
				<p class="description"><?php 
        _e('You may use an existing bbPress installation if you have one.', 'buddypress');
        ?>
</p>

				<h4 style="margin-bottom: 10px;"><?php 
        _e('Features', 'buddypress');
        ?>
</h4>
				<ul class="description" style="list-style: square; margin-left: 30px;">
					<li><?php 
        _e('Group Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Member Profile Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Activity Stream Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('@ Mention Integration', 'buddypress');
        ?>
</p></li>
				</ul>

				<div>
					<a class="button button-primary" href="<?php 
        echo $action;
        ?>
"><?php 
        _e('Uninstall Group Forums', 'buddypress');
        ?>
</a> &nbsp;
				</div>
			</div>

			<div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;">
				<h3><?php 
        _e('New! Site Wide Forums', 'buddypress');
        ?>
</h3>
				<p><?php 
        _e('Your site will have central forums that are not isolated to any specific group. Choose this if you\'d like to have a central forum area for your members.', 'buddypress');
        ?>
</p>
				<p class="description"><?php 
        _e('You may activate both Group and Site Wide forums, but this may create a poor experience for your members.', 'buddypress');
        ?>
</p>

				<h4 style="margin-bottom: 10px;"><?php 
        _e('Features', 'buddypress');
        ?>
</h4>
				<ul class="description" style="list-style: square; margin-left: 30px;">
					<li><?php 
        _e('Central Discussion Area', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Forum Plugins Available', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Activity Stream Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('@ Mention Integration', 'buddypress');
        ?>
</p></li>
				</ul>

				<div>
					<a class="button thickbox button-primary" href="<?php 
        echo esc_attr($button_url);
        ?>
"><?php 
        echo esc_html($button_text);
        ?>
</a> &nbsp;
				</div>
			</div>

		<?php 
    }
    ?>

		<p class="clear description"><?php 
    printf(__('Need help deciding between Group Forums and Site Wide Forums? Visit <a href="%s">the BuddyPress codex</a> for more information.', 'buddypress'), 'http://codex.buddypress.org/getting-started/installing-group-and-sitewide-forums/');
    ?>
</p>
	</div>
<?php 
}
Example #22
0
function bpdd_clear_db()
{
    global $wpdb;
    $prefix = bp_core_get_table_prefix();
    if (bp_is_active('activity')) {
        $sqls[] = "TRUNCATE TABLE {$prefix}bp_activity;";
        $sqls[] = "TRUNCATE TABLE {$prefix}bp_activity_meta;";
    }
    if (bp_is_active('groups')) {
        $sqls[] = "TRUNCATE TABLE {$prefix}bp_groups;";
        $sqls[] = "TRUNCATE TABLE {$prefix}bp_groups_members;";
        $sqls[] = "TRUNCATE TABLE {$prefix}bp_groups_groupmeta;";
    }
    if (bp_is_active('messages')) {
        $sqls[] = "TRUNCATE TABLE {$prefix}bp_messages_recipients;";
        $sqls[] = "TRUNCATE TABLE {$prefix}bp_messages_messages;";
    }
    if (bp_is_active('friends')) {
        $sqls[] = "TRUNCATE TABLE {$prefix}bp_friends;";
    }
    if (bp_is_active('xprofile')) {
        $sqls[] = "DELETE FROM {$prefix}bp_xprofile_data WHERE user_id > 1;";
    }
    if (bp_is_active('forums') && bp_forums_is_installed_correctly()) {
        $sqls[] = "TRUNCATE TABLE {$prefix}bb_posts;";
        $sqls[] = "DELETE FROM {$prefix}bb_forums WHERE forum_id > 1;";
    }
    $sqls[] = "TRUNCATE TABLE {$prefix}bp_notifications;";
    $sqls[] = "DELETE FROM {$wpdb->prefix}users WHERE ID > 1;";
    $sqls[] = "DELETE FROM {$wpdb->prefix}usermeta WHERE user_id > 1;";
    $sqls[] = "DELETE FROM {$wpdb->prefix}usermeta WHERE meta_key = 'total_friend_count';";
    foreach ($sqls as $sql) {
        $wpdb->query($sql);
    }
}
function bp_group_is_forum_enabled($group = false)
{
    global $groups_template;
    if (!$group) {
        $group =& $groups_template->group;
    }
    if (bp_is_active('forums')) {
        if (bp_forums_is_installed_correctly()) {
            if ($group->enable_forum) {
                return true;
            }
            return false;
        } else {
            return false;
        }
    }
    return false;
}
 /**
  * Are we looking at something that needs old forum theme compatibility?
  *
  * @since 1.7.0
  */
 public function is_legacy_forum()
 {
     // Bail if not looking at a group.
     if (!bp_is_forums_component()) {
         return;
     }
     // Forum Directory.
     if ((!bp_current_action() || 'tag' == bp_current_action() && bp_action_variables()) && !bp_current_item()) {
         if (!bp_forums_has_directory()) {
             return false;
         }
         if (!bp_forums_is_installed_correctly()) {
             bp_core_add_message(__('The forums component has not been set up yet.', 'buddypress'), 'error');
             bp_core_redirect(bp_get_root_domain());
         }
         bp_update_is_directory(true, 'forums');
         do_action('bp_forums_directory_forums_setup');
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
     }
 }
        ?>

					<?php 
        if (bp_is_page(BP_GROUPS_SLUG)) {
            ?>
							<?php 
            dynamic_sidebar('groups');
            ?>
					<?php 
        }
        ?>
					
					<!-- Forums Sidebar -->
					
					<?php 
        if (bp_is_active('forums') && (function_exists('bp_forums_is_installed_correctly') && !(int) bp_get_option('bp-disable-forum-directory')) && bp_forums_is_installed_correctly()) {
            ?>
						<?php 
            if (bp_is_page(BP_FORUMS_SLUG)) {
                ?>
								<?php 
                dynamic_sidebar('forums');
                ?>
						<?php 
            }
            ?>
					<?php 
        }
        ?>
				
				<?php 
Example #26
0
/**
 * bp_groupblog_options_nav()
 *
 * Manually create the navigation for the group since we can't fetch any other way.
 * You should manually add items if you have third party plugins that add a menu item.
 *
 * The BuddyPress function we duplicate is called bp_get_options_nav()
 */
function bp_groupblog_options_nav()
{
    global $bp;
    $checks = get_site_option('bp_groupblog_blog_defaults_options');
    ?>

	  <li id="home-personal-li"<?php 
    if ($checks['deep_group_integration']) {
        ?>
 class="current selected"<?php 
    }
    ?>
>
			<a id="home" href="<?php 
    bp_group_permalink();
    ?>
"><?php 
    _e('Home', 'groupblog');
    ?>
</a>
		</li>

    <?php 
    if (groups_is_user_admin($bp->loggedin_user->id, bp_get_group_id()) || groups_is_user_mod($bp->loggedin_user->id, bp_get_group_id())) {
        ?>
			<li id="admin-personal-li" >
				<a id="admin" href="<?php 
        bp_group_permalink();
        ?>
admin/"><?php 
        _e('Admin', 'groupblog');
        ?>
</a>
			</li>
		<?php 
    }
    ?>

		<?php 
    if (bp_group_is_visible()) {
        ?>

			<?php 
        if (bp_groupblog_is_blog_enabled(bp_get_group_id())) {
            ?>
				<?php 
            if (!$checks['deep_group_integration']) {
                ?>
					<li id="<?php 
                echo BP_GROUPBLOG_SLUG;
                ?>
-personal-li"<?php 
                //if ( is_page() ) :
                ?>
 class="current selected"<?php 
                //endif;
                ?>
>
						<a id="<?php 
                echo BP_GROUPBLOG_SLUG;
                ?>
" href="<?php 
                bp_group_permalink();
                ?>
blog/"><?php 
                _e('Blog', 'groupblog');
                ?>
</a>
					</li>
				<?php 
            }
            ?>
		  <?php 
        }
        ?>

			<?php 
        if (bp_is_active('forums') && (function_exists('bp_forums_is_installed_correctly') && bp_group_is_forum_enabled() && !(int) bp_get_option('bp-disable-forum-directory')) && bp_forums_is_installed_correctly()) {
            ?>
				<li id="<?php 
            echo BP_FORUMS_SLUG;
            ?>
-personal-li" >
					<a id="<?php 
            echo BP_FORUMS_SLUG;
            ?>
" href="<?php 
            bp_group_permalink();
            ?>
forum/"><?php 
            _e('Forum', 'groupblog');
            ?>
</a>
				</li>
			<?php 
        }
        ?>

			<li id="<?php 
        echo BP_MEMBERS_SLUG;
        ?>
-personal-li" >
				<a id="<?php 
        echo BP_MEMBERS_SLUG;
        ?>
" href="<?php 
        bp_group_permalink();
        ?>
members/"><?php 
        _e('Members', 'groupblog');
        ?>
 (<?php 
        bp_group_total_members();
        ?>
)</a>
			</li>

			<li id="invite-personal-li" >
				<a id="invite" href="<?php 
        bp_group_permalink();
        ?>
send-invites/"><?php 
        _e('Send Invites', 'groupblog');
        ?>
</a>
			</li>

		<?php 
    } elseif (!bp_group_is_visible() && bp_get_group_status() != 'hidden') {
        ?>

			<li id="request-membership-personal-li" >
				<a id="request-membership" href="<?php 
        bp_group_permalink();
        ?>
request-membership/"><?php 
        _e('Request Membership', 'groupblog');
        ?>
</a>
			</li>

		<?php 
    }
    ?>

	<?php 
}
Example #27
0
/**
 * Outputs the markup for the bb-forums-admin panel
 */
function bp_forums_bbpress_admin()
{
    // The text and URL of the Site Wide Forums button differs depending on whether bbPress
    // is running
    if (is_plugin_active('bbpress/bbpress.php')) {
        // The bbPress admin page will always be on the root blog. switch_to_blog() will
        // pass through if we're already there.
        switch_to_blog(bp_get_root_blog_id());
        $button_url = admin_url(add_query_arg(array('page' => 'bbpress'), 'options-general.php'));
        restore_current_blog();
        $button_text = __('Configure bbPress', 'buddypress');
    } else {
        $button_url = bp_get_admin_url(add_query_arg(array('tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500'), 'plugin-install.php'));
        $button_text = __('Install bbPress', 'buddypress');
    }
    $action = bp_get_admin_url('admin.php?page=bb-forums-setup&reinstall=1');
    ?>

	<div class="wrap">
		<?php 
    screen_icon('buddypress');
    ?>

		<h2 class="nav-tab-wrapper"><?php 
    bp_core_admin_tabs(__('Forums', 'buddypress'));
    ?>
</h2>

		<?php 
    if (isset($_POST['submit'])) {
        ?>

			<div id="message" class="updated fade">
				<p><?php 
        _e('Settings Saved.', 'buddypress');
        ?>
</p>
			</div>

		<?php 
    }
    ?>

		<?php 
    if (isset($_REQUEST['reinstall']) || !bp_forums_is_installed_correctly()) {
        // Delete the bb-config.php location option
        bp_delete_option('bb-config-location');
        // Now delete the bb-config.php file
        @unlink(ABSPATH . 'bb-config.php');
        // show the updated wizard
        bp_forums_bbpress_install_wizard();
    } else {
        ?>

			<div style="width: 45%; float: left; margin-top: 20px;">
				<h3><?php 
        _e('(Installed)', 'buddypress');
        ?>
 <?php 
        _e('Forums for Groups', 'buddypress');
        ?>
</h3>

				<p><?php 
        _e('Give each individual group its own discussion forum. Choose this if you\'d like to keep your members\' conversations separated into distinct areas.', 'buddypress');
        ?>
</p>

				<p><?php 
        _e('Note: This component is retired and will not be receiving any updates in the future.  Only use this component if your current site relies on it.', 'buddypress');
        ?>
</p>

				<h4 style="margin-bottom: 10px;"><?php 
        _e('Features', 'buddypress');
        ?>
</h4>
				<ul class="description" style="list-style: square; margin-left: 30px;">
					<li><?php 
        _e('Group Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Member Profile Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Activity Stream Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('@ Mention Integration', 'buddypress');
        ?>
</p></li>
				</ul>

				<div>
					<a class="button button-primary confirm" href="<?php 
        echo $action;
        ?>
"><?php 
        _e('Uninstall Group Forums', 'buddypress');
        ?>
</a> &nbsp;
				</div>
			</div>

			<div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;">
				<h3><?php 
        _e('New! bbPress', 'buddypress');
        ?>
</h3>
				<p><?php 
        _e('bbPress is a brand-new forum plugin from one of the lead developers of BuddyPress.', 'buddypress');
        ?>
</p>

				<p><?php 
        _e('It boasts a bunch of cool features that the BP Legacy Discussion Forums does not have including:', 'buddypress');
        ?>
</p>

				<ul class="description" style="list-style: square; margin-left: 30px;">
					<li><?php 
        _e('Non-group specific forum creation', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Moderation via the WP admin dashboard', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Topic splitting', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Revisions', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Spam management', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Subscriptions', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('And more!', 'buddypress');
        ?>
</p></li>
				</ul>

				<p><?php 
        printf(__('If you decide to use bbPress, you will need to deactivate the legacy group forum component.  For more info, <a href="%s">read this codex article</a>.', 'buddypress'), 'http://codex.buddypress.org/user/setting-up-a-new-installation/installing-group-and-sitewide-forums/using-bbpress-2-2-with-buddypress/');
        ?>
</p>

				<div>
					<a class="button thickbox button-primary" href="<?php 
        echo esc_attr($button_url);
        ?>
"><?php 
        echo esc_html($button_text);
        ?>
</a> &nbsp;
				</div>
			</div>

		<?php 
    }
    ?>

	</div>
<?php 
}
Example #28
0
function bp_group_is_forum_enabled( $group = false ) {
	global $groups_template;

	if ( !$group )
		$group =& $groups_template->group;

	if ( function_exists( 'bp_forums_is_installed_correctly' ) ) {
		if ( bp_forums_is_installed_correctly() ) {
			if ( $group->enable_forum )
				return true;

			return false;
		} else {
			return false;
		}
	}

	return false;
}
Example #29
0
    ?>
</strong>
										</label>
									</div>

									<?php 
    if (bp_is_active('forums')) {
        ?>

										<h4><?php 
        _e('Group Forums', 'vibe');
        ?>
</h4>

										<?php 
        if (bp_forums_is_installed_correctly()) {
            ?>

											<p><?php 
            _e('Should this group have a forum?', 'vibe');
            ?>
</p>

											<div class="checkbox">
												<label><input type="checkbox" name="group-show-forum"
												              id="group-show-forum"
												              value="1"<?php 
            checked(bp_get_new_group_enable_forum(), true, true);
            ?>
 /> <?php 
            _e('Enable discussion forum', 'vibe');
Example #30
0
					</ul>
				</div>
			</div><!-- #item-nav -->

			<div id="item-body">

				<?php 
        do_action('bp_before_group_body');
        if (bp_is_group_admin_page() && bp_group_is_visible()) {
            locate_template(array('groups/single/admin.php'), true);
        } elseif (bp_is_group_members() && bp_group_is_visible()) {
            locate_template(array('groups/single/members.php'), true);
        } elseif (bp_is_group_invites() && bp_group_is_visible()) {
            locate_template(array('groups/single/send-invites.php'), true);
        } elseif (bp_is_group_forum() && bp_group_is_visible() && bp_is_active('forums') && bp_forums_is_installed_correctly()) {
            locate_template(array('groups/single/forum.php'), true);
        } elseif (bp_is_group_membership_request()) {
            locate_template(array('groups/single/request-membership.php'), true);
        } elseif (bp_group_is_visible() && bp_is_active('activity')) {
            locate_template(array('groups/single/activity.php'), true);
        } elseif (bp_group_is_visible()) {
            locate_template(array('groups/single/members.php'), true);
        } elseif (!bp_group_is_visible()) {
            // The group is not visible, show the status message
            do_action('bp_before_group_status_message');
            ?>

					<div id="message" class="info">
						<p><?php 
            bp_group_status_message();