Changeset 2077 for trunk/bp-activity.php
- Timestamp:
- 11/02/2009 07:54:21 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r2002 r2077 14 14 /* Include deprecated functions if settings allow */ 15 15 if ( !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 18 18 function bp_activity_install() { 19 19 global $wpdb, $bp; 20 20 21 21 if ( !empty($wpdb->charset) ) 22 22 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 23 23 24 24 $sql[] = "CREATE TABLE {$bp->activity->table_name} ( 25 25 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 41 41 require_once( ABSPATH . 'wp-admin/upgrade-functions.php' ); 42 42 dbDelta($sql); 43 43 44 44 /* Drop the old sitewide and user activity tables */ 45 45 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_user_activity" ); 46 46 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_sitewide" ); 47 47 48 48 /* TODO: Rename the old user activity cached table */ 49 49 //$wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" ); … … 57 57 /* Internal identifier */ 58 58 $bp->activity->id = 'activity'; 59 59 60 60 $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity_user_activity_cached'; 61 61 $bp->activity->slug = BP_ACTIVITY_SLUG; 62 62 63 63 /* Register this in the active components array */ 64 64 $bp->active_components[$bp->activity->slug] = $bp->activity->id; 65 65 66 66 do_action( 'bp_activity_setup_globals' ); 67 67 } … … 69 69 add_action( 'admin_menu', 'bp_activity_setup_globals', 2 ); 70 70 71 function bp_activity_check_installed() { 71 function bp_activity_check_installed() { 72 72 global $wpdb, $bp; 73 73 74 74 if ( get_site_option('bp-activity-db-version') < BP_ACTIVITY_DB_VERSION ) 75 75 bp_activity_install(); … … 100 100 } else { 101 101 $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; 103 103 } 104 104 } … … 120 120 function bp_activity_screen_my_activity() { 121 121 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' ) ); 123 123 } 124 124 125 125 function bp_activity_screen_friends_activity() { 126 126 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' ) ); 128 128 } 129 129 … … 148 148 /* Check the nonce */ 149 149 check_admin_referer( 'bp_activity_delete_link' ); 150 150 151 151 $activity_id = $bp->action_variables[0]; 152 152 153 153 /* Check access */ 154 154 if ( !is_site_admin() ) { 155 155 $activity = new BP_Activity_Activity( $activity_id ); 156 156 157 157 if ( $activity->user_id != $bp->loggedin_user->id ) 158 158 return false; 159 159 } 160 160 161 161 /* Now delete the activity item */ 162 162 if ( bp_activity_delete_by_activity_id( $activity_id ) ) … … 164 164 else 165 165 bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' ); 166 166 167 167 do_action( 'bp_activity_action_delete_activity', $activity_id ); 168 168 169 169 bp_core_redirect( $_SERVER['HTTP_REFERER'] ); 170 170 } … … 187 187 188 188 function bp_activity_action_personal_feed() { 189 global $bp, $wp_query; 189 global $bp, $wp_query; 190 190 191 191 if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'feed' ) 192 192 return false; 193 193 194 194 $wp_query->is_404 = false; 195 195 status_header( 200 ); … … 206 206 return false; 207 207 208 $wp_query->is_404 = false; 208 $wp_query->is_404 = false; 209 209 status_header( 200 ); 210 210 211 211 include_once( 'bp-activity/feeds/bp-activity-friends-feed.php' ); 212 die; 212 die; 213 213 } 214 214 add_action( 'wp', 'bp_activity_action_friends_feed', 3 ); … … 226 226 function bp_activity_add( $args = '' ) { 227 227 global $bp, $wpdb; 228 228 229 229 $defaults = array( 230 230 'content' => false, // The content of the activity item … … 232 232 'component_name' => false, // The name/ID of the component e.g. groups, profile, mycomponent 233 233 'component_action' => false, // The component action e.g. new_wire_post, profile_updated 234 234 235 235 '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. 236 236 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id, or wire_post_id … … 242 242 $r = wp_parse_args( $args, $defaults ); 243 243 extract( $r, EXTR_SKIP ); 244 244 245 245 /* Insert the "time-since" placeholder */ 246 246 if ( $content ) … … 257 257 $activity->date_recorded = $recorded_time; 258 258 $activity->hide_sitewide = $hide_sitewide; 259 259 260 260 if ( !$activity->save() ) 261 261 return false; 262 262 263 263 do_action( 'bp_activity_add', $args ); 264 264 265 265 return true; 266 266 } … … 296 296 do_action( 'bp_activity_delete_by_activity_id', $activity_id ); 297 297 298 return true; 298 return true; 299 299 } 300 300 … … 316 316 317 317 do_action( 'bp_activity_delete_for_user_by_component', $user_id, $component_name ); 318 318 319 319 return true; 320 320 } … … 322 322 function bp_activity_add_timesince_placeholder( $content ) { 323 323 /* 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">' ) ) { 325 325 if ( !$pos = strpos( $content, '<blockquote' ) ) { 326 326 if ( !$pos = strpos( $content, '<div' ) ) { … … 331 331 } 332 332 } 333 333 334 334 if ( (int) $pos ) { 335 335 $before = substr( $content, 0, (int) $pos ); 336 336 $after = substr( $content, (int) $pos, strlen( $content ) ); 337 337 338 338 $content = $before . ' <span class="time-since">%s</span>' . $after; 339 339 } … … 342 342 } 343 343 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 } 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 } 364 364 365 365 function bp_activity_check_exists_by_content( $content ) { … … 389 389 // Clear the user's activity from the sitewide stream and clear their activity tables 390 390 BP_Activity_Activity::delete_for_user( $user_id ); 391 391 392 392 do_action( 'bp_activity_remove_data', $user_id ); 393 393 } … … 398 398 /* Ordering function - don't call this directly */ 399 399 function 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'] ) ); 401 401 } 402 402
Note: See TracChangeset
for help on using the changeset viewer.