Changeset 3300 for trunk/bp-forums.php
- Timestamp:
- 10/24/2010 09:22:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-forums.php
r3232 r3300 1 1 <?php 2 2 3 /* Define the parent forum ID */ 3 4 if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) 4 5 define( 'BP_FORUMS_PARENT_FORUM_ID', 1 ); 5 6 7 if ( !defined( 'BP_FORUMS_SLUG' ) ) 8 define( 'BP_FORUMS_SLUG', 'forums' ); 9 6 10 if ( !defined( 'BB_PATH' ) ) 7 11 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress.php' ); … … 13 17 global $bp; 14 18 15 if ( !defined( 'BP_FORUMS_SLUG' ) )16 define ( 'BP_FORUMS_SLUG', $bp->pages->forums->slug );17 18 19 /* For internal identification */ 19 20 $bp->forums->id = 'forums'; 20 $bp->forums->name = $bp->pages->forums->name;21 $bp->forums->slug = BP_FORUMS_SLUG;22 21 23 22 $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images'; 24 23 $bp->forums->bbconfig = $bp->site_options['bb-config-location']; 24 $bp->forums->slug = BP_FORUMS_SLUG; 25 25 26 26 /* Register this in the active components array */ … … 40 40 } 41 41 42 function bp_forums_setup_root_component() { 43 /* Register 'forums' as a root component */ 44 bp_core_add_root_component( BP_FORUMS_SLUG ); 45 } 46 add_action( 'bp_setup_root_components', 'bp_forums_setup_root_component' ); 47 42 48 function bp_forums_directory_forums_setup() { 43 49 global $bp; 44 50 45 51 if ( $bp->current_component == $bp->forums->slug ) { 46 if ( (int) $bp->site_options['bp-disable-forum-directory'] || ! bp_is_active( 'groups' ) )52 if ( (int) $bp->site_options['bp-disable-forum-directory'] || !function_exists( 'groups_install' ) ) 47 53 return false; 48 54 … … 63 69 if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) { 64 70 /* Auto join this user if they are not yet a member of this group */ 65 if ( !is_s ite_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )71 if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 66 72 groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id ); 67 73 … … 73 79 74 80 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' ); 81 } else { 82 bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' ); 75 83 } 76 84 } … … 87 95 global $bp; 88 96 89 if ( !is_s ite_admin() )97 if ( !is_super_admin() ) 90 98 return false; 91 99 … … 119 127 120 128 return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) ); 129 } 130 131 function bp_forums_update_forum( $args = '' ) { 132 do_action( 'bbpress_init' ); 133 134 $defaults = array( 135 'forum_id' => '', 136 'forum_name' => '', 137 'forum_desc' => '', 138 'forum_slug' => '', 139 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID, 140 'forum_order' => false, 141 'forum_is_category' => 0 142 ); 143 144 $r = wp_parse_args( $args, $defaults ); 145 extract( $r, EXTR_SKIP ); 146 147 return bb_update_forum( array( 'forum_id' => (int)$forum_id, 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_slug' => stripslashes( $forum_slug ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) ); 121 148 } 122 149 … … 356 383 357 384 /* Fetch fullname for the topic's last poster */ 358 if ( bp_is_active( 'xprofile' ) ) {385 if ( function_exists( 'xprofile_install' ) ) { 359 386 $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} )" ) ); 360 387 for ( $i = 0; $i < count( $topics ); $i++ ) { … … 441 468 $post_position = $post->post_position; 442 469 443 $post = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) );444 445 if ( $post )470 $post_id = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) ); 471 472 if ( $post_id ) 446 473 do_action( 'bp_forums_new_post', $post_id ); 447 474 448 return $post ;475 return $post_id; 449 476 } 450 477 … … 474 501 475 502 /* Fetch fullname for each poster. */ 476 if ( bp_is_active( 'xprofile' ) ) {503 if ( function_exists( 'xprofile_install' ) ) { 477 504 $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} )" ) ); 478 505 for ( $i = 0; $i < count( $posts ); $i++ ) { … … 501 528 global $bp, $wp_roles, $bb_table_prefix; 502 529 503 $bb_cap = get_user meta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities');530 $bb_cap = get_user_meta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities', true ); 504 531 505 532 if ( empty( $bb_cap ) )
Note: See TracChangeset
for help on using the changeset viewer.