Skip to:
Content

BuddyPress.org

Changeset 3300 for trunk/bp-forums.php


Ignore:
Timestamp:
10/24/2010 09:22:29 PM (15 years ago)
Author:
djpaul
Message:

Fixed #2676

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums.php

    r3232 r3300  
    11<?php
     2
    23/* Define the parent forum ID */
    34if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) )
    45    define( 'BP_FORUMS_PARENT_FORUM_ID', 1 );
    56
     7if ( !defined( 'BP_FORUMS_SLUG' ) )
     8    define( 'BP_FORUMS_SLUG', 'forums' );
     9
    610if ( !defined( 'BB_PATH' ) )
    711    require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress.php' );
     
    1317    global $bp;
    1418
    15     if ( !defined( 'BP_FORUMS_SLUG' ) )
    16         define ( 'BP_FORUMS_SLUG', $bp->pages->forums->slug );
    17 
    1819    /* For internal identification */
    1920    $bp->forums->id = 'forums';
    20     $bp->forums->name = $bp->pages->forums->name;
    21     $bp->forums->slug = BP_FORUMS_SLUG;
    2221
    2322    $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images';
    2423    $bp->forums->bbconfig = $bp->site_options['bb-config-location'];
     24    $bp->forums->slug = BP_FORUMS_SLUG;
    2525
    2626    /* Register this in the active components array */
     
    4040}
    4141
     42function bp_forums_setup_root_component() {
     43    /* Register 'forums' as a root component */
     44    bp_core_add_root_component( BP_FORUMS_SLUG );
     45}
     46add_action( 'bp_setup_root_components', 'bp_forums_setup_root_component' );
     47
    4248function bp_forums_directory_forums_setup() {
    4349    global $bp;
    4450
    4551    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' ) )
    4753            return false;
    4854
     
    6369            if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
    6470                /* Auto join this user if they are not yet a member of this group */
    65                 if ( !is_site_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 ) )
    6672                    groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );
    6773
     
    7379
    7480                    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' );
    7583                }
    7684            }
     
    8795    global $bp;
    8896
    89     if ( !is_site_admin() )
     97    if ( !is_super_admin() )
    9098        return false;
    9199
     
    119127
    120128    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
     131function 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 ) );
    121148}
    122149
     
    356383
    357384    /* Fetch fullname for the topic's last poster */
    358     if ( bp_is_active( 'xprofile' ) ) {
     385    if ( function_exists( 'xprofile_install' ) ) {
    359386        $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} )" ) );
    360387        for ( $i = 0; $i < count( $topics ); $i++ ) {
     
    441468        $post_position = $post->post_position;
    442469
    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 )
    446473        do_action( 'bp_forums_new_post', $post_id );
    447474
    448     return $post;
     475    return $post_id;
    449476}
    450477
     
    474501
    475502    /* Fetch fullname for each poster. */
    476     if ( bp_is_active( 'xprofile' ) ) {
     503    if ( function_exists( 'xprofile_install' ) ) {
    477504        $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} )" ) );
    478505        for ( $i = 0; $i < count( $posts ); $i++ ) {
     
    501528    global $bp, $wp_roles, $bb_table_prefix;
    502529
    503     $bb_cap = get_usermeta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities' );
     530    $bb_cap = get_user_meta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities', true );
    504531
    505532    if ( empty( $bb_cap ) )
Note: See TracChangeset for help on using the changeset viewer.