Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/19/2009 10:41:25 PM (18 years ago)
Author:
apeatling
Message:

Added clean up routine to activity component that will flush the site wide activity stream of any activity from that user. The users' activity tables will also be dropped when the user is deleted. Activity for that user in friends' activity streams will be removed when recached.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-classes.php

    r864 r883  
    328328        }
    329329       
     330        function delete_activity_for_user( $user_id ) {
     331                global $wpdb, $bp;
     332
     333                /* Empty user's activities from the sitewide stream */
     334                $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['activity']['table_name_sitewide'] . " WHERE user_id = %d", $user_id ) );
     335
     336                /* Empty the user's activity items and cached activity items */
     337                $wpdb->query( $wpdb->prepare( "TRUNCATE TABLE wp_user_{$user_id}_activity" ) );
     338                $wpdb->query( $wpdb->prepare( "TRUNCATE TABLE wp_user_{$user_id}_activity_cached" ) ); 
     339               
     340                return true;
     341        }
     342       
    330343        function get_last_updated() {
    331344                global $bp, $wpdb;
     
    334347        }
    335348       
     349        function kill_tables_for_user( $user_id ) {
     350                global $bp, $wpdb;
     351               
     352                $wpdb->query( $wpdb->prepare( "DROP TABLE wp_user_{$user_id}_activity" ) );
     353                $wpdb->query( $wpdb->prepare( "DROP TABLE wp_user_{$user_id}_activity_cached" ) );     
     354                $wpdb->query( $wpdb->prepare( "DROP TABLE wp_user_{$user_id}_friends_activity_cached" ) );     
     355               
     356                return true;
     357        }
     358       
    336359
    337360}
Note: See TracChangeset for help on using the changeset viewer.