Changeset 2692
- Timestamp:
- 02/12/2010 01:17:56 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 8 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 -
trunk/bp-activity/bp-activity-classes.php
r2686 r2692 248 248 'item_id' => false, 249 249 'secondary_item_id' => false, 250 ' recorded_time' => false,250 'date_recorded' => false, 251 251 'hide_sitewide' => false 252 252 ); … … 281 281 $where_args[] = $wpdb->prepare( "secondary_item_id = %s", $secondary_item_id ); 282 282 283 if ( !empty( $ recorded_time) )284 $where_args[] = $wpdb->prepare( " recorded_time = %s", $recorded_time);283 if ( !empty( $date_recorded ) ) 284 $where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded ); 285 285 286 286 if ( !empty( $hide_sitewide ) ) 287 $where_args[] = $wpdb->prepare( " recorded_time = %d", $hide_sitewide );287 $where_args[] = $wpdb->prepare( "hide_sitewide = %d", $hide_sitewide ); 288 288 289 289 if ( !empty( $where_args ) ) -
trunk/bp-activity/bp-activity-templatetags.php
r2681 r2692 569 569 $content .= '<div class="acomment-meta"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . apply_filters( 'bp_get_member_name', $comment->user_fullname ) . '</a> · ' . sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( strtotime( $comment->date_recorded ) ) ); 570 570 571 /* Reply link */571 /* Reply link - the span is so that threaded reply links can be hidden when JS is off. */ 572 572 if ( is_user_logged_in() ) 573 $content .= ' · <a href="#acomment-' . $comment->id . '" class="acomment-reply" id="acomment-reply-' . $activities_template->activity->id . '">' . __( 'Reply', 'buddypress' ) . '</a>';573 $content .= '<span class="acomment-replylink"> · <a href="#acomment-' . $comment->id . '" class="acomment-reply" id="acomment-reply-' . $activities_template->activity->id . '">' . __( 'Reply', 'buddypress' ) . '</a></span>'; 574 574 575 575 /* Delete link */ … … 615 615 } 616 616 617 function bp_activity_comment_link() { 618 echo bp_get_activity_comment_link(); 619 } 620 function bp_get_activity_comment_link() { 621 global $activities_template; 622 return apply_filters( 'bp_get_activity_comment_link', '?ac=' . $activities_template->activity->id . '/#ac-form-' . $activities_template->activity->id ); 623 } 624 625 function bp_activity_comment_form_nojs_display() { 626 echo bp_get_activity_comment_form_nojs_display(); 627 } 628 function bp_get_activity_comment_form_nojs_display() { 629 global $activities_template; 630 if ( $_GET['ac'] == $activities_template->activity->id . '/' ) 631 return 'style="display: block"'; 632 633 return false; 634 } 635 636 function bp_activity_comment_form_action() { 637 echo bp_get_activity_comment_form_action(); 638 } 639 function bp_get_activity_comment_form_action() { 640 return apply_filters( 'bp_get_activity_comment_form_action', site_url( BP_ACTIVITY_SLUG . '/reply/' ) ); 641 } 642 617 643 function bp_activity_permalink_id() { 618 644 echo bp_get_activity_permalink_id(); … … 633 659 634 660 return apply_filters( 'bp_get_activity_thread_permalink', $link ); 661 } 662 663 function bp_activity_favorite_link() { 664 echo bp_get_activity_favorite_link(); 665 } 666 function bp_get_activity_favorite_link() { 667 global $activities_template; 668 return apply_filters( 'bp_get_activity_favorite_link', wp_nonce_url( site_url( BP_ACTIVITY_SLUG . '/favorite/' . $activities_template->activity->id . '/' ), 'mark_favorite' ) ); 669 } 670 671 function bp_activity_unfavorite_link() { 672 echo bp_get_activity_unfavorite_link(); 673 } 674 function bp_get_activity_unfavorite_link() { 675 global $activities_template; 676 return apply_filters( 'bp_get_activity_unfavorite_link', wp_nonce_url( site_url( BP_ACTIVITY_SLUG . '/unfavorite/' . $activities_template->activity->id . '/' ), 'unmark_favorite' ) ); 635 677 } 636 678 … … 792 834 } 793 835 836 function bp_activity_post_form_action() { 837 echo bp_get_activity_post_form_action(); 838 } 839 function bp_get_activity_post_form_action() { 840 return apply_filters( 'bp_get_activity_post_form_action', site_url( BP_ACTIVITY_SLUG . '/post/' ) ); 841 } 794 842 795 843 /* RSS Feed Template Tags ***************************/ -
trunk/bp-themes/bp-default/_inc/ajax.php
r2666 r2692 11 11 12 12 /*** 13 * Each object loop (activity/members/groups/blogs/forums) contains parameters to 13 * This function looks scarier than it actually is. :) 14 * Each object loop (activity/members/groups/blogs/forums) contains default parameters to 14 15 * show specific information based on the page we are currently looking at. 15 16 * The following function will take into account any cookies set in the JS and allow us 16 17 * to override the parameters sent. That way we can change the results returned without reloading the page. 18 * By using cookies we can also make sure that user settings are retained across page loads. 17 19 */ 18 20 function bp_dtheme_ajax_querystring( $object = false ) { … … 61 63 } 62 64 65 /* This function will simply load the template loop for the current object. On an AJAX request */ 63 66 function bp_dtheme_object_template_loader() { 64 67 $object = esc_attr( $_POST['object'] ); … … 70 73 add_action( 'wp_ajax_forums_filter', 'bp_dtheme_object_template_loader' ); 71 74 75 /* This function will load the activity loop template when activity is requested via AJAX */ 72 76 function bp_dtheme_activity_template_loader() { 73 77 global $bp; … … 104 108 add_action( 'wp_ajax_activity_get_older_updates', 'bp_dtheme_activity_template_loader' ); 105 109 110 /* AJAX update posting */ 106 111 function bp_dtheme_post_update() { 107 112 global $bp; … … 120 125 } 121 126 122 if ( empty( $_POST['object'] ) ) { 123 $activity_id = bp_activity_post_update( array( 124 'content' => $_POST['content'] 125 )); 127 if ( empty( $_POST['object'] ) && function_exists( 'bp_activity_post_update' ) ) { 128 $activity_id = bp_activity_post_update( array( 'content' => $_POST['content'] ) ); 126 129 } elseif ( $_POST['object'] == 'groups' ) { 127 if ( !empty( $_POST['item_id'] ) ) { 128 $activity_id = groups_post_update( array( 129 'content' => $_POST['content'], 130 'group_id' => $_POST['item_id'] 131 )); 132 } 133 } else { 130 if ( !empty( $_POST['item_id'] ) && function_exists( 'groups_post_update' ) ) 131 $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $_POST['item_id'] ) ); 132 } else 134 133 $activity_id = apply_filters( 'bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content'] ); 135 }136 134 137 135 if ( !$activity_id ) { … … 148 146 add_action( 'wp_ajax_post_update', 'bp_dtheme_post_update' ); 149 147 148 /* AJAX activity comment posting */ 150 149 function bp_dtheme_new_activity_comment() { 151 150 global $bp; … … 202 201 add_action( 'wp_ajax_new_activity_comment', 'bp_dtheme_new_activity_comment' ); 203 202 203 /* AJAX delete an activity */ 204 204 function bp_dtheme_delete_activity() { 205 205 global $bp; … … 228 228 add_action( 'wp_ajax_delete_activity', 'bp_dtheme_delete_activity' ); 229 229 230 /* AJAX delete an activity comment */ 230 231 function bp_dtheme_delete_activity_comment() { 231 232 global $bp; … … 254 255 add_action( 'wp_ajax_delete_activity_comment', 'bp_dtheme_delete_activity_comment' ); 255 256 257 /* AJAX mark an activity as a favorite */ 256 258 function bp_dtheme_mark_activity_favorite() { 257 259 global $bp; … … 262 264 add_action( 'wp_ajax_activity_mark_fav', 'bp_dtheme_mark_activity_favorite' ); 263 265 266 /* AJAX mark an activity as not a favorite */ 264 267 function bp_dtheme_unmark_activity_favorite() { 265 268 global $bp; … … 270 273 add_action( 'wp_ajax_activity_mark_unfav', 'bp_dtheme_unmark_activity_favorite' ); 271 274 275 /* AJAX invite a friend to a group functionality */ 272 276 function bp_dtheme_ajax_invite_user() { 273 277 global $bp; … … 313 317 add_action( 'wp_ajax_groups_invite_user', 'bp_dtheme_ajax_invite_user' ); 314 318 319 /* AJAX add/remove a user as a friend when clicking the button */ 315 320 function bp_dtheme_ajax_addremove_friend() { 316 321 global $bp; … … 343 348 add_action( 'wp_ajax_addremove_friend', 'bp_dtheme_ajax_addremove_friend' ); 344 349 350 /* AJAX accept a user as a friend when clicking the "accept" button */ 345 351 function bp_dtheme_ajax_accept_friendship() { 346 352 check_admin_referer( 'friends_accept_friendship' ); … … 353 359 add_action( 'wp_ajax_accept_friendship', 'bp_dtheme_ajax_accept_friendship' ); 354 360 361 /* AJAX reject a user as a friend when clicking the "reject" button */ 355 362 function bp_dtheme_ajax_reject_friendship() { 356 363 check_admin_referer( 'friends_reject_friendship' ); … … 363 370 add_action( 'wp_ajax_reject_friendship', 'bp_dtheme_ajax_reject_friendship' ); 364 371 372 /* AJAX join or leave a group when clicking the "join/leave" button */ 365 373 function bp_dtheme_ajax_joinleave_group() { 366 374 global $bp; … … 415 423 add_action( 'wp_ajax_joinleave_group', 'bp_dtheme_ajax_joinleave_group' ); 416 424 425 /* AJAX close and keep closed site wide notices from an admin in the sidebar */ 417 426 function bp_dtheme_ajax_close_notice() { 418 427 global $userdata; … … 430 439 add_action( 'wp_ajax_messages_close_notice', 'bp_dtheme_ajax_close_notice' ); 431 440 441 /* AJAX send a private message reply to a thread */ 432 442 function bp_dtheme_ajax_messages_send_reply() { 433 443 global $bp; … … 465 475 add_action( 'wp_ajax_messages_send_reply', 'bp_dtheme_ajax_messages_send_reply' ); 466 476 477 /* AJAX mark a private message as unread in your inbox */ 467 478 function bp_dtheme_ajax_message_markunread() { 468 479 global $bp; … … 480 491 add_action( 'wp_ajax_messages_markunread', 'bp_dtheme_ajax_message_markunread' ); 481 492 493 /* AJAX mark a private message as read in your inbox */ 482 494 function bp_dtheme_ajax_message_markread() { 483 495 global $bp; … … 495 507 add_action( 'wp_ajax_messages_markread', 'bp_dtheme_ajax_message_markread' ); 496 508 509 /* AJAX delete a private message or array of messages in your inbox */ 497 510 function bp_dtheme_ajax_messages_delete() { 498 511 global $bp; … … 511 524 add_action( 'wp_ajax_messages_delete', 'bp_dtheme_ajax_messages_delete' ); 512 525 526 /* AJAX autocomplete your friends names on the compose screen */ 513 527 function bp_dtheme_ajax_messages_autocomplete_results() { 514 528 global $bp; -
trunk/bp-themes/bp-default/_inc/css/default.css
r2684 r2692 1296 1296 } 1297 1297 1298 div.activity-comments span.acomment-replylink { display: none; } 1299 1298 1300 div.activity-comments ul li p:last-child { 1299 1301 margin-bottom: 0; -
trunk/bp-themes/bp-default/_inc/global.js
r2688 r2692 7 7 j(document).ready( function() { 8 8 /**** Page Load Actions *******************************************************/ 9 10 /* Hide Forums Post Form */ 11 if ( j('div.forums').length ) 12 j('div#new-topic-post').hide(); 13 14 /* Show threaded reply links */ 15 if ( j('span.acomment-replylink').length ) 16 j('span.acomment-replylink').show(); 9 17 10 18 /* Activity filter and scope set */ … … 14 22 var objects = [ 'members', 'groups', 'blogs', 'forums' ]; 15 23 bp_init_objects( objects ); 16 17 /* Hide Forums Post Form */18 if ( j('div.forums').length )19 j('div#new-topic-post').hide();20 24 21 25 /* @mention Compose Scrolling */ … … 308 312 309 313 /* Activity comment posting */ 310 if ( target.attr('name') == 'ac -form-submit' ) {314 if ( target.attr('name') == 'ac_form_submit' ) { 311 315 var form = target.parent().parent(); 312 316 var form_parent = form.parent(); -
trunk/bp-themes/bp-default/activity/entry.php
r2683 r2692 26 26 <div class="activity-meta"> 27 27 <?php if ( is_user_logged_in() && bp_activity_can_comment() ) : ?> 28 <a href=" #acomment-<?php bp_activity_id() ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'Reply', 'buddypress' ) ?> (<span><?php bp_activity_comment_count() ?></span>)</a>28 <a href="<?php bp_activity_comment_link() ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'Reply', 'buddypress' ) ?> (<span><?php bp_activity_comment_count() ?></span>)</a> 29 29 <?php endif; ?> 30 30 31 31 <?php if ( is_user_logged_in() ) : ?> 32 32 <?php if ( !bp_get_activity_is_favorite() ) : ?> 33 <a href=" " class="fav" title="<?php _e( 'Mark as Favorite', 'buddypress' ) ?>"><?php _e( 'Favorite', 'buddypress' ) ?></a>33 <a href="<?php bp_activity_favorite_link() ?>" class="fav" title="<?php _e( 'Mark as Favorite', 'buddypress' ) ?>"><?php _e( 'Favorite', 'buddypress' ) ?></a> 34 34 <?php else : ?> 35 <a href=" " class="unfav" title="<?php _e( 'Remove Favorite', 'buddypress' ) ?>"><?php _e( 'Remove Favorite', 'buddypress' ) ?></a>35 <a href="<?php bp_activity_unfavorite_link() ?>" class="unfav" title="<?php _e( 'Remove Favorite', 'buddypress' ) ?>"><?php _e( 'Remove Favorite', 'buddypress' ) ?></a> 36 36 <?php endif; ?> 37 37 <?php endif;?> … … 55 55 56 56 <?php if ( is_user_logged_in() ) : ?> 57 <form action=" " method="post" name="activity-comment-form" id="ac-form-<?php bp_activity_id() ?>" class="ac-form">57 <form action="<?php bp_activity_comment_form_action() ?>" method="post" id="ac-form-<?php bp_activity_id() ?>" class="ac-form"<?php bp_activity_comment_form_nojs_display() ?>> 58 58 <div class="ac-reply-avatar"><?php bp_loggedin_user_avatar( 'width=25&height=25' ) ?></div> 59 59 <div class="ac-reply-content"> 60 60 <div class="ac-textarea"> 61 <textarea id="ac-input-<?php bp_activity_id() ?>" class="ac-input" name="ac -input-<?php bp_activity_id() ?>"></textarea>61 <textarea id="ac-input-<?php bp_activity_id() ?>" class="ac-input" name="ac_input_<?php bp_activity_id() ?>"></textarea> 62 62 </div> 63 <input type="submit" name="ac-form-submit" value="<?php _e( 'Post', 'buddypress' ) ?> →" /> <?php _e( 'or press esc to cancel.', 'buddypress' ) ?> 63 <input type="submit" name="ac_form_submit" value="<?php _e( 'Post', 'buddypress' ) ?> →" /> <?php _e( 'or press esc to cancel.', 'buddypress' ) ?> 64 <input type="hidden" name="comment_form_id" value="<?php bp_activity_id() ?>" /> 64 65 </div> 65 66 <?php wp_nonce_field( 'new_activity_comment', '_wpnonce_new_activity_comment' ) ?> -
trunk/bp-themes/bp-default/activity/post-form.php
r2622 r2692 1 <form action=" " method="post" id="whats-new-form" name="whats-new-form">1 <form action="<?php bp_activity_post_form_action() ?>" method="post" id="whats-new-form" name="whats-new-form"> 2 2 3 3 <?php do_action( 'bp_before_activity_post_form' ) ?>
Note: See TracChangeset
for help on using the changeset viewer.