Skip to:
Content

BuddyPress.org

Changeset 846


Ignore:
Timestamp:
01/15/2009 08:08:59 PM (18 years ago)
Author:
apeatling
Message:

Fixes #312

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r805 r846  
    213213function bp_activity_record( $item_id, $component_name, $component_action, $is_private, $secondary_item_id = false, $user_id = false, $secondary_user_id = false ) {
    214214        global $bp, $wpdb;
    215 
     215       
    216216        if ( !$user_id )
    217217                $user_id = $bp['loggedin_userid'];
  • trunk/bp-activity/bp-activity-classes.php

    r835 r846  
    6868                        // Add the cached version of the activity to the sitewide activity table.
    6969                        if ( !$this->no_sitewide_recording )
    70                                 $sitewide_cached = $wpdb->query( $wpdb->prepare( "INSERT INTO " . $bp['activity']['table_name_sitewide'] . " ( user_id, item_id, secondary_item_id, content, primary_link, component_name, component_action, date_cached, date_recorded ) VALUES ( %d, %d, %d, %s, %s, %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d) )", $bp['loggedin_userid'], $this->item_id, $this->secondary_item_id, $activity_content['content'], $activity_content['primary_link'], $this->component_name, $this->component_action, time(), $this->date_recorded ) );
     70                                $sitewide_cached = $wpdb->query( $wpdb->prepare( "INSERT INTO " . $bp['activity']['table_name_sitewide'] . " ( user_id, item_id, secondary_item_id, content, primary_link, component_name, component_action, date_cached, date_recorded ) VALUES ( %d, %d, %d, %s, %s, %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d) )", $this->user_id, $this->item_id, $this->secondary_item_id, $activity_content['content'], $activity_content['primary_link'], $this->component_name, $this->component_action, time(), $this->date_recorded ) );
    7171                       
    7272                        if ( $activity && $activity_cached )
     
    9393                        $secondary_sql = $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id );
    9494               
    95                 //var_dump($wpdb->prepare( "DELETE FROM {$wpdb->base_prefix}user_{$user_id}_activity WHERE item_id = %d{$secondary_sql} AND user_id = %d AND component_name = %s AND component_action = %s", $item_id, $user_id, $component_name, $component_action ) );
    96                 //var_dump($wpdb->prepare( "DELETE FROM {$wpdb->base_prefix}user_{$user_id}_activity_cached WHERE item_id = %d{$secondary_sql} AND component_name = %s AND component_action = %s", $item_id, $component_name, $component_action ) );
    97                 //var_dump($wpdb->prepare( "DELETE FROM " . $bp['activity']['table_name_sitewide'] . " WHERE item_id = %d{$secondary_sql} AND user_id = %d AND component_name = %s AND component_action = %s", $item_id, $user_id, $component_name, $component_action ) );
    98                 //die;
     95                //error_log($wpdb->prepare( "DELETE FROM {$wpdb->base_prefix}user_{$user_id}_activity WHERE item_id = %d{$secondary_sql} AND user_id = %d AND component_name = %s AND component_action = %s", $item_id, $user_id, $component_name, $component_action ) );
     96                //error_log($wpdb->prepare( "DELETE FROM {$wpdb->base_prefix}user_{$user_id}_activity_cached WHERE item_id = %d{$secondary_sql} AND component_name = %s AND component_action = %s", $item_id, $component_name, $component_action ) );
     97                //error_log($wpdb->prepare( "DELETE FROM " . $bp['activity']['table_name_sitewide'] . " WHERE item_id = %d{$secondary_sql} AND user_id = %d AND component_name = %s AND component_action = %s", $item_id, $user_id, $component_name, $component_action ) );
    9998               
    10099                $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->base_prefix}user_{$user_id}_activity WHERE item_id = %d{$secondary_sql} AND user_id = %d AND component_name = %s AND component_action = %s", $item_id, $user_id, $component_name, $component_action ) );
  • trunk/bp-blogs.php

    r843 r846  
    374374       
    375375        $post_id = (int)$post_id;
     376        $post = get_post($post_id);
    376377       
    377378        if ( !$user_id )
    378                 $user_id = (int)$bp['loggedin_userid'];
     379                $user_id = (int)$post->post_author;
    379380               
    380381        if ( !$blog_id )
     
    384385        if ( (int)get_site_option('tags_blog_id') == $blog_id )
    385386                return false;
    386        
    387         $post = get_post($post_id);
    388        
    389         /* If another user is editing this post, don't record this at all, otherwise
    390            we will get multiple post recordings for each revisor. */
    391         if ( $user_id != (int)$post->post_author )
    392                 return false;
    393        
     387               
    394388        /* Don't record this if it's not a post */
    395389        if ( $post->post_type != 'post' )
     
    403397                         * at the max, then delete the oldest recorded post first.
    404398                         */
    405                         if ( BP_Blogs_Post::get_total_recorded_for_user() >= TOTAL_RECORDED_POSTS )
    406                                 BP_Blogs_Post::delete_oldest();
     399                        if ( BP_Blogs_Post::get_total_recorded_for_user( $user_id ) >= TOTAL_RECORDED_POSTS )
     400                                BP_Blogs_Post::delete_oldest( $user_id );
    407401                       
    408402                        $recorded_post = new BP_Blogs_Post;
     
    422416                }
    423417        } else {
    424                 /**
    425                  * Check to see if the post have previously been recorded.
    426                  * If the post status has changed from public to private then we need
    427                  * to remove the record of the post.
     418                $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
     419               
     420                /**
     421                 *  Delete the recorded post if:
     422                 *  - The status is no longer "published"
     423                 *  - The post is password protected
    428424                 */
    429                 if ( $post->post_status != 'publish' || $post->post_password != '')
    430                         BP_Blogs_Post::delete( $post_id, $blog_id );
     425                if ( $post->post_status != 'publish' || $post->post_password != '' )
     426                        bp_blogs_remove_post( $post_id, $blog_id );
     427               
     428                // Check to see if the post author has changed.
     429                if ( (int)$existing_post->user_id != (int)$post->post_author ) {
     430                        // Delete the existing recorded post
     431                        bp_blogs_remove_post( $post_id, $blog_id );
     432                       
     433                        // Re-record the post with the new author.
     434                        bp_blogs_record_post( $post_id );
     435                }
    431436        }
    432437
     
    580585        // Delete post from the bp_blogs table
    581586        BP_Blogs_Post::delete( $post_id, $blog_id );
    582 
     587       
    583588        // Delete activity stream item
    584589        bp_blogs_delete_activity( array( 'item_id' => $post->id, 'component_name' => 'blogs', 'component_action' => 'new_blog_post', 'user_id' => $post->user_id ) );
  • trunk/bp-core/bp-core-templatetags.php

    r842 r846  
    1313 * or not to highlight a particular nav item.
    1414 *
    15  * It will also compare the current user to the logged in user, if a user profile is being viewed.
    16  * This allows the "Friends" item to be highlighted if the users are friends. This is only if the friends
    17  * component is installed.
    18  *
    1915 * @package BuddyPress Core
    2016 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    21  * @uses friends_check_friendship() Checks to see if the logged in user is a friend of the currently viewed user.
    2217 */
    2318function bp_get_nav() {
Note: See TracChangeset for help on using the changeset viewer.