Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/25/2011 08:58:56 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Rename new 'bp-users' component to 'bp-members' for consistency through-out project.
Core, Messages, and Friends Components now use the BP_Component class.
Split Friends and Messages components into smaller files.
Change references to 'profile' to 'xprofile' through-out project for consistency.
Introduce 'bp_actions' and 'bp_screens' standard hooks to replace the usage of 'wp' through-out project.
Move component loader sequence into bp-core-bootstrap.php,
Move old root_component action into 1.3 deprecated file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums/bp-forums-screens.php

    r3806 r3917  
    11<?php
    22
     3function bp_forums_directory_forums_setup() {
     4    global $bp;
     5
     6    if ( bp_is_current_component( 'forums' ) ) {
     7        if ( bp_forum_directory_is_disabled() || !bp_is_active( 'groups' ) )
     8            return false;
     9
     10        if ( !bp_forums_is_installed_correctly() ) {
     11            bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );
     12            bp_core_redirect( $bp->root_domain );
     13        }
     14
     15        $bp->is_directory = true;
     16
     17        do_action( 'bbpress_init' );
     18
     19        // Check to see if the user has posted a new topic from the forums page.
     20        if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) {
     21            check_admin_referer( 'bp_forums_new_topic' );
     22
     23            if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
     24                // Auto join this user if they are not yet a member of this group
     25                if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
     26                    groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );
     27
     28                $error_message = '';
     29                if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) {
     30                    if ( empty( $_POST['topic_title'] ) )
     31                        $error_message = __( 'Please provide a title for your forum topic.', 'buddypress' );
     32                    else if ( empty( $_POST['topic_text'] ) )
     33                        $error_message = __( 'Forum posts cannot be empty. Please enter some text.', 'buddypress' );
     34
     35                    if ( $error_message ) {
     36                        bp_core_add_message( $error_message, 'error' );
     37                        $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';
     38                    } else {
     39                        if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) {
     40                            bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );
     41                            $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';
     42                        } else {
     43                            bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
     44                            $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
     45                        }
     46                    }
     47
     48                    bp_core_redirect( $redirect );
     49
     50                } else {
     51                    bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );
     52                }
     53            }
     54        }
     55
     56        do_action( 'bp_forums_directory_forums_setup' );
     57
     58        bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'forums/index' ) );
     59    }
     60}
     61add_action( 'bp_screens', 'bp_forums_directory_forums_setup' );
     62
    363?>
Note: See TracChangeset for help on using the changeset viewer.