Skip to:
Content

BuddyPress.org

Changeset 2471 for trunk/bp-activity.php


Ignore:
Timestamp:
01/28/2010 06:01:42 PM (17 years ago)
Author:
apeatling
Message:

Merged activity delete functions for better usability. Fixed some issues with the group extension API and plugin compatibility in 1.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r2416 r2471  
    611611                'type' => false,
    612612                'item_id' => false,
    613                 'secondary_item_id' => false
     613                'secondary_item_id' => false,
     614                'action' => false,
     615                'content' => false
    614616        );
    615617
     
    617619        extract( $r, EXTR_SKIP );
    618620
    619         return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $user_id, $component, $type, $item_id, $secondary_item_id ) );
     621        return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content ) );
    620622}
    621623
    622624/***
    623625 * Deleting Activity
    624  *
    625  * There are multiple ways to delete activity items, depending on
    626  * the information you have at the time.
    627626 *
    628627 * If you're looking to hook into one action that provides the ID(s) of
     
    635634*/
    636635
    637 function bp_activity_delete_by_item_id( $args = '' ) {
    638         global $bp;
    639 
     636function bp_activity_delete( $args = '' ) {
     637        global $bp;
     638
     639        /* Pass one or more the of following variables to delete by those variables */
    640640        $defaults = array(
     641                'id' => false,
     642                'action' => false,
     643                'content' => false,
     644                'component' => false,
     645                'type' => false,
     646                'primary_link' => false,
     647                'user_id' => false,
    641648                'item_id' => false,
    642                 'component' => false,
    643                 'type' => false, // optional
    644                 'user_id' => false, // optional
    645                 'secondary_item_id' => false // optional
     649                'secondary_item_id' => false,
     650                'recorded_time' => false,
     651                'hide_sitewide' => false
    646652        );
    647653
    648         $r = wp_parse_args( $args, $defaults );
    649         extract( $r, EXTR_SKIP );
    650 
    651         if ( !$activity_ids_deleted = BP_Activity_Activity::delete_by_item_id( $item_id, $component, $type, $user_id, $secondary_item_id ) )
    652                 return false;
    653 
    654         do_action( 'bp_activity_delete_by_item_id', $item_id, $component, $type, $user_id, $secondary_item_id );
     654        $args = wp_parse_args( $args, $defaults );
     655
     656        if ( !$activity_ids_deleted = BP_Activity_Activity::delete( $args ) )
     657                return false;
     658
     659        do_action( 'bp_activity_delete', $args );
    655660        do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
    656661
    657662        return true;
    658663}
    659 
    660 function bp_activity_delete_by_activity_id( $activity_id ) {
    661         if ( !BP_Activity_Activity::delete_by_activity_id( $activity_id ) )
    662                 return false;
    663 
    664         do_action( 'bp_activity_delete_by_activity_id', $activity_id );
    665         do_action( 'bp_activity_deleted_activities', $activity_id );
    666 
    667         return true;
    668 }
    669 
    670 function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
    671         /* Insert the "time-since" placeholder to match the existing content in the DB */
    672         $content = bp_activity_add_timesince_placeholder( $content );
    673 
    674         if ( !$activity_ids_deleted = BP_Activity_Activity::delete_by_content( $user_id, $content, $component, $type ) )
    675                 return false;
    676 
    677         do_action( 'bp_activity_delete_by_content', $user_id, $content, $component, $type );
    678         do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
    679 
    680         return true;
    681 }
    682 
    683 function bp_activity_delete_for_user_by_component( $user_id, $component ) {
    684         if ( !$activity_ids_deleted = BP_Activity_Activity::delete_for_user_by_component( $user_id, $component ) )
    685                 return false;
    686 
    687         do_action( 'bp_activity_delete_for_user_by_component', $user_id, $component );
    688         do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
    689 
    690         return true;
    691 }
     664        /* The following functions have been deprecated in place of bp_activity_delete() */
     665        function bp_activity_delete_by_item_id( $args = '' ) {
     666                global $bp;
     667
     668                $defaults = array( 'item_id' => false, 'component' => false, 'type' => false, 'user_id' => false, 'secondary_item_id' => false );
     669                $r = wp_parse_args( $args, $defaults );
     670                extract( $r, EXTR_SKIP );
     671
     672                return bp_activity_delete( array( 'item_id' => $item_id, 'component' => $component, 'type' => $type, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) );
     673        }
     674
     675        function bp_activity_delete_by_activity_id( $activity_id ) {
     676                return bp_activity_delete( array( 'id' => $activity_id ) );
     677        }
     678
     679        function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
     680                return bp_activity_delete( array( 'user_id' => $user_id, 'content' => $content, 'component' => $component, 'type' => $type ) );
     681        }
     682
     683        function bp_activity_delete_for_user_by_component( $user_id, $component ) {
     684                return bp_activity_delete( array( 'user_id' => $user_id, 'component' => $component ) );
     685        }
     686        /* End deprecation */
    692687
    693688function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
     
    997992function bp_activity_remove_data( $user_id ) {
    998993        // Clear the user's activity from the sitewide stream and clear their activity tables
    999         BP_Activity_Activity::delete_for_user( $user_id );
     994        bp_activity_delete( array( 'user_id' => $user_id ) );
    1000995
    1001996        // Remove any usermeta
Note: See TracChangeset for help on using the changeset viewer.