Changeset 2692 for trunk/bp-activity.php
- Timestamp:
- 02/12/2010 01:17:56 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r2691 r2692 361 361 add_action( 'wp', 'bp_activity_action_delete_activity', 3 ); 362 362 363 function bp_activity_action_post_update() { 364 global $bp; 365 366 if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'post' ) 367 return false; 368 369 /* Check the nonce */ 370 check_admin_referer( 'post_update', '_wpnonce_post_update' ); 371 372 $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] ); 373 $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] ); 374 $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] ); 375 376 if ( empty( $content ) ) { 377 bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' ); 378 bp_core_redirect( wp_get_referer() ); 379 } 380 381 if ( !(int)$item_id ) { 382 $activity_id = bp_activity_post_update( array( 'content' => $content ) ); 383 384 } else if ( 'groups' == $object && function_exists( 'groups_post_update' ) ) { 385 if ( (int)$item_id ) { 386 $activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) ); 387 } 388 } else 389 $activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content ); 390 391 if ( !empty( $activity_id ) ) 392 bp_core_add_message( __( 'Update Posted!', 'buddypress' ) ); 393 else 394 bp_core_add_message( __( 'There was an error when posting your update, please try again.', 'buddypress' ), 'error' ); 395 396 bp_core_redirect( wp_get_referer() ); 397 } 398 add_action( 'wp', 'bp_activity_action_post_update', 3 ); 399 400 function bp_activity_action_post_comment() { 401 global $bp; 402 403 if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'reply' ) 404 return false; 405 406 /* Check the nonce */ 407 check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' ); 408 409 $activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] ); 410 $content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] ); 411 412 if ( empty( $content ) ) { 413 bp_core_add_message( __( 'Please do not leave the comment area blank.', 'buddypress' ), 'error' ); 414 bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id ); 415 } 416 417 $comment_id = bp_activity_new_comment( array( 418 'content' => $content, 419 'activity_id' => $activity_id, 420 'parent_id' => $parent_id 421 )); 422 423 if ( !empty( $comment_id ) ) 424 bp_core_add_message( __( 'Reply Posted!', 'buddypress' ) ); 425 else 426 bp_core_add_message( __( 'There was an error posting that reply, please try again.', 'buddypress' ), 'error' ); 427 428 bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id ); 429 } 430 add_action( 'wp', 'bp_activity_action_post_comment', 3 ); 431 432 function bp_activity_action_mark_favorite() { 433 global $bp; 434 435 if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'favorite' ) 436 return false; 437 438 /* Check the nonce */ 439 check_admin_referer( 'mark_favorite' ); 440 441 if ( bp_activity_add_user_favorite( $bp->action_variables[0] ) ) 442 bp_core_add_message( __( 'Activity marked as favorite.', 'buddypress' ) ); 443 else 444 bp_core_add_message( __( 'There was an error marking that activity as a favorite, please try again.', 'buddypress' ), 'error' ); 445 446 bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] ); 447 } 448 add_action( 'wp', 'bp_activity_action_mark_favorite', 3 ); 449 450 function bp_activity_action_remove_favorite() { 451 global $bp; 452 453 if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'unfavorite' ) 454 return false; 455 456 /* Check the nonce */ 457 check_admin_referer( 'unmark_favorite' ); 458 459 if ( bp_activity_remove_user_favorite( $bp->action_variables[0] ) ) 460 bp_core_add_message( __( 'Activity removed as favorite.', 'buddypress' ) ); 461 else 462 bp_core_add_message( __( 'There was an error removing that activity as a favorite, please try again.', 'buddypress' ), 'error' ); 463 464 bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] ); 465 } 466 add_action( 'wp', 'bp_activity_action_remove_favorite', 3 ); 467 363 468 function bp_activity_action_sitewide_feed() { 364 469 global $bp, $wp_query; … … 895 1000 /* Update the user's personal favorites */ 896 1001 $my_favs = maybe_unserialize( get_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities' ) ); 897 $my_favs[] = $ _POST['id'];1002 $my_favs[] = $activity_id; 898 1003 899 1004 /* Update the total number of users who have favorited this activity */ 900 $fav_count = bp_activity_get_meta( $ _POST['id'], 'favorite_count' );1005 $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' ); 901 1006 902 1007 if ( !empty( $fav_count ) ) … … 906 1011 907 1012 update_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities', $my_favs ); 908 bp_activity_update_meta( $ _POST['id'], 'favorite_count', $fav_count );1013 bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count ); 909 1014 910 1015 return true; … … 920 1025 $my_favs = maybe_unserialize( get_usermeta( $user_id, 'bp_favorite_activities' ) ); 921 1026 $my_favs = array_flip( (array) $my_favs ); 922 unset( $my_favs[$ _POST['id']] );1027 unset( $my_favs[$activity_id] ); 923 1028 $my_favs = array_unique( array_flip( $my_favs ) ); 924 1029 925 1030 /* Update the total number of users who have favorited this activity */ 926 $fav_count = bp_activity_get_meta( $ _POST['id'], 'favorite_count' );1031 $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' ); 927 1032 928 1033 if ( !empty( $fav_count ) ) { 929 1034 $fav_count = (int)$fav_count - 1; 930 bp_activity_update_meta( $ _POST['id'], 'favorite_count', $fav_count );1035 bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count ); 931 1036 } 932 1037
Note: See TracChangeset
for help on using the changeset viewer.