Changeset 3917 for trunk/bp-forums/bp-forums-functions.php
- Timestamp:
- 01/25/2011 08:58:56 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-forums/bp-forums-functions.php
r3916 r3917 24 24 return !empty( $bp->site_options['bp-disable-forum-directory'] ); 25 25 } 26 27 function bp_forums_directory_forums_setup() {28 global $bp;29 30 if ( bp_is_current_component( 'forums' ) ) {31 if ( bp_forum_directory_is_disabled() || !bp_is_active( 'groups' ) )32 return false;33 34 if ( !bp_forums_is_installed_correctly() ) {35 bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );36 bp_core_redirect( $bp->root_domain );37 }38 39 $bp->is_directory = true;40 41 do_action( 'bbpress_init' );42 43 // Check to see if the user has posted a new topic from the forums page.44 if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) {45 check_admin_referer( 'bp_forums_new_topic' );46 47 if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {48 // Auto join this user if they are not yet a member of this group49 if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )50 groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );51 52 $error_message = '';53 if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) {54 if ( empty( $_POST['topic_title'] ) )55 $error_message = __( 'Please provide a title for your forum topic.', 'buddypress' );56 else if ( empty( $_POST['topic_text'] ) )57 $error_message = __( 'Forum posts cannot be empty. Please enter some text.', 'buddypress' );58 59 if ( $error_message ) {60 bp_core_add_message( $error_message, 'error' );61 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';62 } else {63 if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) {64 bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );65 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';66 } else {67 bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );68 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';69 }70 }71 72 bp_core_redirect( $redirect );73 74 } else {75 bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );76 }77 }78 }79 80 do_action( 'bp_forums_directory_forums_setup' );81 82 bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'forums/index' ) );83 }84 }85 add_action( 'wp', 'bp_forums_directory_forums_setup', 2 );86 26 87 27 /** Forum Functions ***********************************************************/ … … 380 320 381 321 // Fetch fullname for the topic's last poster 382 if ( bp_is_active( ' profile' ) ) {322 if ( bp_is_active( 'xprofile' ) ) { 383 323 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" ) ); 384 324 for ( $i = 0; $i < count( $topics ); $i++ ) { … … 498 438 499 439 // Fetch fullname for each poster. 500 if ( bp_is_active( ' profile' ) ) {440 if ( bp_is_active( 'xprofile' ) ) { 501 441 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id, pd.value FROM {$bp->profile->table_name_data} pd WHERE pd.user_id IN ( {$user_ids} )" ) ); 502 442 for ( $i = 0; $i < count( $posts ); $i++ ) {
Note: See TracChangeset
for help on using the changeset viewer.