Skip to:
Content

BuddyPress.org

Changeset 2077 for trunk/bp-activity.php


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

Merging 1.1 branch changes and syncing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r2002 r2077  
    1414/* Include deprecated functions if settings allow */
    1515if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
    16     require ( BP_PLUGIN_DIR . '/bp-activity/deprecated/bp-activity-deprecated.php' );   
    17    
     16    require ( BP_PLUGIN_DIR . '/bp-activity/deprecated/bp-activity-deprecated.php' );
     17
    1818function bp_activity_install() {
    1919    global $wpdb, $bp;
    20    
     20
    2121    if ( !empty($wpdb->charset) )
    2222        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    23    
     23
    2424    $sql[] = "CREATE TABLE {$bp->activity->table_name} (
    2525                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    4141    require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    4242    dbDelta($sql);
    43    
     43
    4444    /* Drop the old sitewide and user activity tables */
    4545    $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_user_activity" );
    4646    $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_sitewide" );
    47    
     47
    4848    /* TODO: Rename the old user activity cached table */
    4949    //$wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );
     
    5757    /* Internal identifier */
    5858    $bp->activity->id = 'activity';
    59    
     59
    6060    $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity_user_activity_cached';
    6161    $bp->activity->slug = BP_ACTIVITY_SLUG;
    62        
     62
    6363    /* Register this in the active components array */
    6464    $bp->active_components[$bp->activity->slug] = $bp->activity->id;
    65    
     65
    6666    do_action( 'bp_activity_setup_globals' );
    6767}
     
    6969add_action( 'admin_menu', 'bp_activity_setup_globals', 2 );
    7070
    71 function bp_activity_check_installed() {   
     71function bp_activity_check_installed() {
    7272    global $wpdb, $bp;
    73    
     73
    7474    if ( get_site_option('bp-activity-db-version') < BP_ACTIVITY_DB_VERSION )
    7575        bp_activity_install();
     
    100100        } else {
    101101            $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
    102             $bp->bp_options_title = $bp->displayed_user->fullname; 
     102            $bp->bp_options_title = $bp->displayed_user->fullname;
    103103        }
    104104    }
     
    120120function bp_activity_screen_my_activity() {
    121121    do_action( 'bp_activity_screen_my_activity' );
    122     bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'activity/just-me' ) );   
     122    bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'activity/just-me' ) );
    123123}
    124124
    125125function bp_activity_screen_friends_activity() {
    126126    do_action( 'bp_activity_screen_friends_activity' );
    127     bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'activity/my-friends' ) );   
     127    bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'activity/my-friends' ) );
    128128}
    129129
     
    148148    /* Check the nonce */
    149149    check_admin_referer( 'bp_activity_delete_link' );
    150    
     150
    151151    $activity_id = $bp->action_variables[0];
    152    
     152
    153153    /* Check access */
    154154    if ( !is_site_admin() ) {
    155155        $activity = new BP_Activity_Activity( $activity_id );
    156        
     156
    157157        if ( $activity->user_id != $bp->loggedin_user->id )
    158158            return false;
    159159    }
    160    
     160
    161161    /* Now delete the activity item */
    162162    if ( bp_activity_delete_by_activity_id( $activity_id ) )
     
    164164    else
    165165        bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
    166        
     166
    167167    do_action( 'bp_activity_action_delete_activity', $activity_id );
    168    
     168
    169169    bp_core_redirect( $_SERVER['HTTP_REFERER'] );
    170170}
     
    187187
    188188function bp_activity_action_personal_feed() {
    189     global $bp, $wp_query; 
     189    global $bp, $wp_query;
    190190
    191191    if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'feed' )
    192192        return false;
    193    
     193
    194194    $wp_query->is_404 = false;
    195195    status_header( 200 );
     
    206206        return false;
    207207
    208     $wp_query->is_404 = false; 
     208    $wp_query->is_404 = false;
    209209    status_header( 200 );
    210210
    211211    include_once( 'bp-activity/feeds/bp-activity-friends-feed.php' );
    212     die;   
     212    die;
    213213}
    214214add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
     
    226226function bp_activity_add( $args = '' ) {
    227227    global $bp, $wpdb;
    228    
     228
    229229    $defaults = array(
    230230        'content' => false, // The content of the activity item
     
    232232        'component_name' => false, // The name/ID of the component e.g. groups, profile, mycomponent
    233233        'component_action' => false, // The component action e.g. new_wire_post, profile_updated
    234        
     234
    235235        'user_id' => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
    236236        'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id, or wire_post_id
     
    242242    $r = wp_parse_args( $args, $defaults );
    243243    extract( $r, EXTR_SKIP );
    244    
     244
    245245    /* Insert the "time-since" placeholder */
    246246    if ( $content )
     
    257257    $activity->date_recorded = $recorded_time;
    258258    $activity->hide_sitewide = $hide_sitewide;
    259    
     259
    260260    if ( !$activity->save() )
    261261        return false;
    262262
    263263    do_action( 'bp_activity_add', $args );
    264    
     264
    265265    return true;
    266266}
     
    296296    do_action( 'bp_activity_delete_by_activity_id', $activity_id );
    297297
    298     return true;   
     298    return true;
    299299}
    300300
     
    316316
    317317    do_action( 'bp_activity_delete_for_user_by_component', $user_id, $component_name );
    318    
     318
    319319    return true;
    320320}
     
    322322function bp_activity_add_timesince_placeholder( $content ) {
    323323    /* Check a time-since span doesn't already exist */
    324     if ( false === strpos( $content, '<span class="time-since">' ) ) {     
     324    if ( false === strpos( $content, '<span class="time-since">' ) ) {
    325325        if ( !$pos = strpos( $content, '<blockquote' ) ) {
    326326            if ( !$pos = strpos( $content, '<div' ) ) {
     
    331331        }
    332332    }
    333    
     333
    334334    if ( (int) $pos ) {
    335335        $before = substr( $content, 0, (int) $pos );
    336336        $after = substr( $content, (int) $pos, strlen( $content ) );
    337        
     337
    338338        $content = $before . ' <span class="time-since">%s</span>' . $after;
    339339    }
     
    342342}
    343343
    344 function bp_activity_set_action( $component_id, $key, $value ) { 
    345     global $bp; 
    346 
    347     if ( empty( $component_id ) || empty( $key ) || empty( $value ) ) 
    348         return false; 
    349 
    350     $bp->activity->actions->{$component_id}->{$key} = apply_filters( 'bp_activity_set_action', array( 
    351         'key' => $key, 
    352         'value' => $value 
    353     ), $component_id, $key, $value ); 
    354 } 
    355 
    356 function bp_activity_get_action( $component_id, $key ) { 
    357     global $bp; 
    358 
    359     if ( empty( $component_id ) || empty( $key ) ) 
    360         return false; 
    361 
    362     return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key ); 
    363 } 
     344function bp_activity_set_action( $component_id, $key, $value ) {
     345    global $bp;
     346
     347    if ( empty( $component_id ) || empty( $key ) || empty( $value ) )
     348        return false;
     349
     350    $bp->activity->actions->{$component_id}->{$key} = apply_filters( 'bp_activity_set_action', array(
     351        'key' => $key,
     352        'value' => $value
     353    ), $component_id, $key, $value );
     354}
     355
     356function bp_activity_get_action( $component_id, $key ) {
     357    global $bp;
     358
     359    if ( empty( $component_id ) || empty( $key ) )
     360        return false;
     361
     362    return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key );
     363}
    364364
    365365function bp_activity_check_exists_by_content( $content ) {
     
    389389    // Clear the user's activity from the sitewide stream and clear their activity tables
    390390    BP_Activity_Activity::delete_for_user( $user_id );
    391    
     391
    392392    do_action( 'bp_activity_remove_data', $user_id );
    393393}
     
    398398/* Ordering function - don't call this directly */
    399399function bp_activity_order_by_date( $a, $b ) {
    400     return apply_filters( 'bp_activity_order_by_date', strcasecmp( $b['date_recorded'], $a['date_recorded'] ) );   
     400    return apply_filters( 'bp_activity_order_by_date', strcasecmp( $b['date_recorded'], $a['date_recorded'] ) );
    401401}
    402402
Note: See TracChangeset for help on using the changeset viewer.