Skip to:
Content

BuddyPress.org

Changeset 2077 for trunk/bp-blogs.php


Ignore:
Timestamp:
11/02/2009 07:54:21 PM (15 years ago)
Author:
apeatling
Message:

Merging 1.1 branch changes and syncing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs.php

    r2055 r2077  
    1313/* Include deprecated functions if settings allow */
    1414if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
    15     require ( BP_PLUGIN_DIR . '/bp-blogs/deprecated/bp-blogs-deprecated.php' ); 
    16    
     15    require ( BP_PLUGIN_DIR . '/bp-blogs/deprecated/bp-blogs-deprecated.php' );
     16
    1717function bp_blogs_install() {
    1818    global $wpdb, $bp;
    19    
     19
    2020    if ( !empty($wpdb->charset) )
    2121        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    22    
     22
    2323    $sql[] = "CREATE TABLE {$bp->blogs->table_name} (
    2424                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    5252                KEY comment_post_id (comment_post_id)
    5353             ) {$charset_collate};";
    54    
     54
    5555    $sql[] = "CREATE TABLE {$bp->blogs->table_name_blogmeta} (
    5656            id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    6161            KEY meta_key (meta_key)
    6262           ) {$charset_collate};";
    63        
    64    
     63
     64
    6565    require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    6666
     
    6969    // On first installation - record all existing blogs in the system.
    7070    if ( !(int)get_site_option( 'bp-blogs-first-install') ) {
    71        
     71
    7272        bp_blogs_record_existing_blogs();
    7373        add_site_option( 'bp-blogs-first-install', 1 );
    74        
     74
    7575    } else {
    76        
    77         // Import blog titles and descriptions into the blogmeta table 
     76
     77        // Import blog titles and descriptions into the blogmeta table
    7878        if ( get_site_option( 'bp-blogs-version' ) <= '0.1.5' ) {
    7979            $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM " . $bp->blogs->table_name ) );
     
    8282                $name = get_blog_option( $blog_ids[$i], 'blogname' );
    8383                $desc = get_blog_option( $blog_ids[$i], 'blogdescription' );
    84                
     84
    8585                bp_blogs_update_blogmeta( $blog_ids[$i], 'name', $name );
    8686                bp_blogs_update_blogmeta( $blog_ids[$i], 'description', $desc );
     
    8888            }
    8989        }
    90        
    91     }
    92    
     90
     91    }
     92
    9393    update_site_option( 'bp-blogs-db-version', BP_BLOGS_DB_VERSION );
    9494}
    9595
    96 function bp_blogs_check_installed() {   
     96function bp_blogs_check_installed() {
    9797    global $wpdb, $bp, $userdata;
    98    
     98
    9999    if ( is_site_admin() ) {
    100100        /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
     
    107107function bp_blogs_setup_globals() {
    108108    global $bp, $wpdb;
    109    
     109
    110110    /* For internal identification */
    111111    $bp->blogs->id = 'blogs';
    112    
     112
    113113    $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs';
    114114    $bp->blogs->table_name_blog_posts = $wpdb->base_prefix . 'bp_user_blogs_posts';
     
    117117    $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
    118118    $bp->blogs->slug = BP_BLOGS_SLUG;
    119    
     119
    120120    /* Register this in the active components array */
    121121    $bp->active_components[$bp->blogs->slug] = $bp->blogs->id;
     
    123123    do_action( 'bp_blogs_setup_globals' );
    124124}
    125 add_action( 'plugins_loaded', 'bp_blogs_setup_globals', 5 );   
     125add_action( 'plugins_loaded', 'bp_blogs_setup_globals', 5 );
    126126add_action( 'admin_menu', 'bp_blogs_setup_globals', 2 );
    127127
     
    136136 *
    137137 * Adds "Blog" to the navigation arrays for the current and logged in user.
    138  * 
     138 *
    139139 * @package BuddyPress Blogs
    140140 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    143143function bp_blogs_setup_nav() {
    144144    global $bp;
    145    
     145
    146146    /* Add 'Blogs' to the main navigation */
    147147    bp_core_new_nav_item( array( 'name' => __( 'Blogs', 'buddypress' ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
    148    
     148
    149149    $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
    150    
     150
    151151    /* Add the subnav items to the blogs nav item */
    152152    bp_core_new_subnav_item( array( 'name' => __( 'My Blogs', 'buddypress' ), 'slug' => 'my-blogs', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_my_blogs', 'position' => 10, 'item_css_id' => 'my-blogs-list' ) );
     
    159159        if ( bp_is_home() ) {
    160160            if ( function_exists('xprofile_setup_nav') ) {
    161                 $bp->bp_options_title = __('My Blogs', 'buddypress'); 
     161                $bp->bp_options_title = __('My Blogs', 'buddypress');
    162162            }
    163163        } else {
    164164            /* If we are not viewing the logged in user, set up the current users avatar and name */
    165165            $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
    166             $bp->bp_options_title = $bp->displayed_user->fullname; 
     166            $bp->bp_options_title = $bp->displayed_user->fullname;
    167167        }
    168168    }
    169    
     169
    170170    do_action( 'bp_blogs_setup_nav' );
    171171}
     
    178178    if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {
    179179        $bp->is_directory = true;
    180        
     180
    181181        do_action( 'bp_blogs_directory_blogs_setup' );
    182182        bp_core_load_template( apply_filters( 'bp_blogs_template_directory_blogs_setup', 'directories/blogs/index' ) );
     
    196196function bp_blogs_screen_my_blogs() {
    197197    do_action( 'bp_blogs_screen_my_blogs' );
    198     bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'blogs/my-blogs' ) );   
     198    bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'blogs/my-blogs' ) );
    199199}
    200200
     
    224224function bp_blogs_register_activity_actions() {
    225225    global $bp;
    226    
     226
    227227    if ( !function_exists( 'bp_activity_set_action' ) )
    228228        return false;
     
    238238function bp_blogs_record_activity( $args = '' ) {
    239239    global $bp;
    240    
     240
    241241    if ( !function_exists( 'bp_activity_add' ) )
    242242        return false;
    243        
     243
    244244    /* Because blog, comment, and blog post code execution happens before anything else
    245245       we may need to manually instantiate the activity component globals */
    246246    if ( !$bp->activity && function_exists('bp_activity_setup_globals') )
    247247        bp_activity_setup_globals();
    248        
     248
    249249    $defaults = array(
    250250        'user_id' => $bp->loggedin_user->id,
     
    260260
    261261    $r = wp_parse_args( $args, $defaults );
    262     extract( $r, EXTR_SKIP );   
    263    
     262    extract( $r, EXTR_SKIP );
     263
    264264    return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
    265265}
     
    268268    if ( function_exists('bp_activity_delete_by_item_id') ) {
    269269        extract($args);
    270        
    271         bp_activity_delete_by_item_id( array( 
    272             'item_id' => $item_id, 
     270
     271        bp_activity_delete_by_item_id( array(
     272            'item_id' => $item_id,
    273273            'component_name' => $component_name,
    274             'component_action' => $component_action, 
     274            'component_action' => $component_action,
    275275            'user_id' => $user_id,
    276276            'secondary_item_id' => $secondary_item_id
     
    292292
    293293    $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE public = 1 AND mature = 0 AND spam = 0 AND deleted = 0" ) );
    294    
     294
    295295    if ( $blog_ids ) {
    296296        foreach( $blog_ids as $blog_id ) {
     
    311311function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = true ) {
    312312    global $bp;
    313    
     313
    314314    if ( !$user_id )
    315315        $user_id = $bp->loggedin_user->id;
    316    
     316
    317317    $name = get_blog_option( $blog_id, 'blogname' );
    318318    $description = get_blog_option( $blog_id, 'blogdescription' );
    319    
     319
    320320    $recorded_blog = new BP_Blogs_Blog;
    321321    $recorded_blog->user_id = $user_id;
     
    323323
    324324    $recorded_blog_id = $recorded_blog->save();
    325    
     325
    326326    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name );
    327327    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description );
    328328    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', time() );
    329    
     329
    330330    /* Only record this activity if the blog is public */
    331331    if ( (int)$_POST['blog_public'] || !$no_activity ) {
     
    333333        bp_blogs_record_activity( array(
    334334            'user_id' => $recorded_blog->user_id,
    335             'content' => apply_filters( 'bp_blogs_activity_created_blog', sprintf( __( '%s created the blog %s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_blog_option( $recorded_blog->blog_id, 'siteurl' ) . '">' . attribute_escape( $name ) . '</a>' ), &$recorded_blog, $name, $description ), 
     335            'content' => apply_filters( 'bp_blogs_activity_created_blog', sprintf( __( '%s created the blog %s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_blog_option( $recorded_blog->blog_id, 'siteurl' ) . '">' . attribute_escape( $name ) . '</a>' ), &$recorded_blog, $name, $description ),
    336336            'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_blog_option( $recorded_blog->blog_id, 'siteurl' ), $recorded_blog->blog_id ),
    337337            'component_action' => 'new_blog',
     
    339339        ) );
    340340    }
    341    
     341
    342342    do_action( 'bp_blogs_new_blog', &$recorded_blog, $is_private, $is_recorded );
    343343}
     
    346346function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
    347347    global $bp, $wpdb;
    348    
     348
    349349    $post_id = (int)$post_id;
    350350    $blog_id = (int)$wpdb->blogid;
    351    
     351
    352352    if ( !$user_id )
    353353        $user_id = (int)$post->post_author;
    354    
    355354    /* This is to stop infinate loops with Donncha's sitewide tags plugin */
    356355    if ( (int)get_site_option( 'tags_blog_id' ) == (int)$blog_id )
    357356        return false;
    358    
     357
    359358    /* Don't record this if it's not a post */
    360359    if ( $post->post_type != 'post' )
    361360        return false;
    362    
     361
    363362    if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) {
    364363        if ( 'publish' == $post->post_status && '' == $post->post_password ) {
    365            
     364
    366365            $recorded_post = new BP_Blogs_Post;
    367366            $recorded_post->user_id = $user_id;
     
    369368            $recorded_post->post_id = $post_id;
    370369            $recorded_post->date_created = strtotime( $post->post_date );
    371            
     370
    372371            $recorded_post_id = $recorded_post->save();
    373            
     372
    374373            bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() );
    375374
     
    380379                $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
    381380                $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
    382            
     381
    383382                bp_blogs_record_activity( array(
    384383                    'user_id' => (int)$post->post_author,
    385                     'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ), 
     384                    'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
    386385                    'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
    387386                    'component_action' => 'new_blog_post',
     
    399398        /* Delete the recorded post if the status is not published or it is password protected */
    400399        if ( 'publish' != $post->post_status || '' != $post->post_password ) {
    401             return bp_blogs_remove_post( $post_id, $blog_id, $existing_post );         
    402        
     400            return bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
     401
    403402        /* If the post author has changed, delete the post and re-add it. */
    404403        } else if ( (int)$existing_post->user_id != (int)$post->post_author ) {
    405404            // Delete the existing recorded post
    406405            bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
    407            
     406
    408407            // Re-record the post with the new author.
    409             bp_blogs_record_post( $post_id );               
     408            bp_blogs_record_post( $post_id );
    410409        }
    411410
    412411        if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) {
    413             /* Now re-record the post in the activity streams */       
     412            /* Now re-record the post in the activity streams */
    414413            $post_permalink = bp_post_get_permalink( $post, $blog_id );
    415414
    416415            $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
    417416            $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
    418        
     417
    419418            /* Record this in activity streams */
    420419            bp_blogs_record_activity( array(
    421420                'user_id' => (int)$post->post_author,
    422                 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ), 
     421                'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
    423422                'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
    424423                'component_action' => 'new_blog_post',
     
    435434function bp_blogs_record_comment( $comment_id, $is_approved ) {
    436435    global $wpdb, $bp;
    437    
     436
    438437    if ( !$is_approved )
    439438        return false;
    440        
     439
    441440    $comment = get_comment($comment_id);
    442441    $comment->post = get_post( $comment->comment_post_ID );
    443    
     442
    444443    /* Get the user_id from the author email. */
    445444    $user = get_user_by_email( $comment->comment_author_email );
    446445    $user_id = (int)$user->ID;
    447    
     446
    448447    if ( !$user_id )
    449448        return false;
     
    457456
    458457    $recorded_commment_id = $recorded_comment->save();
    459    
     458
    460459    bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() );
    461460
     
    463462        /* Record in activity streams */
    464463        $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
    465         $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );         
     464        $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );
    466465        $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
    467466
     
    469468        bp_blogs_record_activity( array(
    470469            'user_id' => $recorded_comment->user_id,
    471             'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ), 
     470            'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
    472471            'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
    473472            'component_action' => 'new_blog_comment',
     
    484483function bp_blogs_approve_comment( $comment_id, $comment_status ) {
    485484    global $bp, $wpdb;
    486    
     485
    487486    if ( 'approve' != $comment_status )
    488487        return false;
     
    491490    $comment = get_comment($comment_id);
    492491    $comment->post = get_post( $comment->comment_post_ID );
    493    
     492
    494493    bp_blogs_delete_activity( array( 'item_id' => $comment_id, 'secondary_item_id' => $recorded_comment->blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_comment' ) );
    495494
     
    497496        /* Record in activity streams */
    498497        $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
    499         $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );           
     498        $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );
    500499        $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
    501500
     
    503502        bp_blogs_record_activity( array(
    504503            'user_id' => $recorded_comment->user_id,
    505             'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ), 
     504            'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
    506505            'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
    507506            'component_action' => 'new_blog_comment',
    508507            'item_id' => $comment_id,
    509508            'secondary_item_id' => $recorded_comment->blog_id,
    510             'recorded_time' =>  $recorded_comment->date_created 
     509            'recorded_time' =>  $recorded_comment->date_created
    511510        ) );
    512511    }
     
    516515function bp_blogs_unapprove_comment( $comment_id, $comment_status ) {
    517516    if ( 'spam' == $comment_status || 'hold' == $comment_status || 'delete' == $comment_status )
    518         bp_blogs_remove_comment( $comment_id );     
     517        bp_blogs_remove_comment( $comment_id );
    519518}
    520519add_action( 'wp_set_comment_status', 'bp_blogs_unapprove_comment', 10, 2 );
     
    538537
    539538    BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    540    
     539
    541540    // Delete activity stream item
    542541    bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog' ) );
    543    
     542
    544543    do_action( 'bp_blogs_remove_blog', $blog_id );
    545544}
     
    548547function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
    549548    global $current_user;
    550    
     549
    551550    $blog_id = (int)$blog_id;
    552551    $user_id = (int)$user_id;
     
    565564
    566565    $post_id = (int)$post_id;
    567    
     566
    568567    if ( !$blog_id )
    569568        $blog_id = (int)$current_blog->blog_id;
    570    
     569
    571570    if ( !$existing_post )
    572571        $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
     
    574573    // Delete post from the bp_blogs table
    575574    BP_Blogs_Post::delete( $post_id, $blog_id );
    576        
     575
    577576    // Delete activity stream item
    578577    bp_blogs_delete_activity( array( 'item_id' => $existing_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post' ) );
     
    586585
    587586    $recorded_comment = new BP_Blogs_Comment( false, $wpdb->blogid, $comment_id );
    588     BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid ); 
     587    BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid );
    589588
    590589    // Delete activity stream item
     
    597596function bp_blogs_remove_data_for_blog( $blog_id ) {
    598597    global $bp;
    599    
     598
    600599    /* If this is regular blog, delete all data for that blog. */
    601600    BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    602     BP_Blogs_Post::delete_posts_for_blog( $blog_id );       
     601    BP_Blogs_Post::delete_posts_for_blog( $blog_id );
    603602    BP_Blogs_Comment::delete_comments_for_blog( $blog_id );
    604603
     
    624623function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) {
    625624    global $bp;
    626    
     625
    627626    if ( !is_numeric( $limit ) )
    628627        $limit = 5;
    629    
     628
    630629    return BP_Blogs_Post::get_latest_posts( $blog_id, $limit );
    631630}
     
    645644function bp_blogs_total_post_count( $blog_id ) {
    646645    return BP_Blogs_Post::total_post_count( $blog_id );
    647 } 
     646}
    648647
    649648function bp_blogs_total_comment_count( $blog_id, $post_id = false ) {
    650649    return BP_Blogs_Post::total_comment_count( $blog_id, $post_id );
    651 } 
     650}
    652651
    653652function bp_blogs_is_blog_hidden( $blog_id ) {
     
    657656function bp_blogs_redirect_to_random_blog() {
    658657    global $bp, $wpdb;
    659    
     658
    660659    if ( $bp->current_component == $bp->blogs->slug && isset( $_GET['random-blog'] ) ) {
    661660        $blog = bp_blogs_get_random_blog();
     
    676675function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) {
    677676    global $wpdb, $bp;
    678    
     677
    679678    if ( !is_numeric( $blog_id ) )
    680679        return false;
    681        
     680
    682681    $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
    683682
    684683    if ( is_array($meta_value) || is_object($meta_value) )
    685684        $meta_value = serialize($meta_value);
    686        
     685
    687686    $meta_value = trim( $meta_value );
    688687
    689688    if ( !$meta_key ) {
    690         $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) );     
     689        $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) );
    691690    } else if ( $meta_value ) {
    692691        $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s AND meta_value = %s", $blog_id, $meta_key, $meta_value ) );
     
    694693        $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
    695694    }
    696    
     695
    697696    // TODO need to look into using this.
    698697    // wp_cache_delete($group_id, 'groups');
     
    703702function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') {
    704703    global $wpdb, $bp;
    705    
     704
    706705    $blog_id = (int) $blog_id;
    707706
     
    711710    if ( !empty($meta_key) ) {
    712711        $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
    713        
     712
    714713        // TODO need to look into using this.
    715714        //$user = wp_cache_get($user_id, 'users');
    716        
     715
    717716        // Check the cached user object
    718717        //if ( false !== $user && isset($user->$meta_key) )
     
    741740function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
    742741    global $wpdb, $bp;
    743    
     742
    744743    if ( !is_numeric( $blog_id ) )
    745744        return false;
    746    
     745
    747746    $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
    748747
    749748    if ( is_string($meta_value) )
    750749        $meta_value = stripslashes($wpdb->escape($meta_value));
    751        
     750
    752751    $meta_value = maybe_serialize($meta_value);
    753752
     
    757756
    758757    $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
    759    
     758
    760759    if ( !$cur ) {
    761760        $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blogmeta} ( blog_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $blog_id, $meta_key, $meta_value ) );
     
    775774    /* If this is regular blog, delete all data for that blog. */
    776775    BP_Blogs_Blog::delete_blogs_for_user( $user_id );
    777     BP_Blogs_Post::delete_posts_for_user( $user_id );       
     776    BP_Blogs_Post::delete_posts_for_user( $user_id );
    778777    BP_Blogs_Comment::delete_comments_for_user( $user_id );
    779778
Note: See TracChangeset for help on using the changeset viewer.