Changeset 2004 for trunk/bp-groups.php
- Timestamp:
- 09/30/2009 04:42:06 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/bp-groups.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups.php
r1995 r2004 601 601 602 602 if ( $bp->is_single_item && $bp->groups->current_group->user_has_access ) { 603 604 /* Fetch the details we need */ 603 605 $topic_slug = $bp->action_variables[1]; 604 606 $topic_id = bp_forums_get_topic_id_from_slug( $topic_slug ); … … 637 639 bp_core_add_message( __( 'The topic was made sticky successfully', 'buddypress' ) ); 638 640 639 do_action( 'groups_stick_ topic', $topic_id );641 do_action( 'groups_stick_forum_topic', $topic_id ); 640 642 bp_core_redirect( wp_get_referer() ); 641 643 } … … 651 653 bp_core_add_message( __( 'The topic was unstuck successfully', 'buddypress') ); 652 654 653 do_action( 'groups_unstick_ topic', $topic_id );655 do_action( 'groups_unstick_forum_topic', $topic_id ); 654 656 bp_core_redirect( wp_get_referer() ); 655 657 } … … 665 667 bp_core_add_message( __( 'The topic was closed successfully', 'buddypress') ); 666 668 667 do_action( 'groups_close_ topic', $topic_id );669 do_action( 'groups_close_forum_topic', $topic_id ); 668 670 bp_core_redirect( wp_get_referer() ); 669 671 } … … 679 681 bp_core_add_message( __( 'The topic was opened successfully', 'buddypress') ); 680 682 681 do_action( 'groups_open_ topic', $topic_id );683 do_action( 'groups_open_forum_topic', $topic_id ); 682 684 bp_core_redirect( wp_get_referer() ); 683 685 } 684 686 685 687 /* Delete a topic */ 686 else if ( 'delete' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 688 else if ( 'delete' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) { 689 /* Fetch the topic */ 690 $topic = bp_forums_get_topic_details( $topic_id ); 691 692 /* Check the logged in user can delete this topic */ 693 if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$topic->topic_poster ) 694 bp_core_redirect( wp_get_referer() ); 695 687 696 /* Check the nonce */ 688 697 check_admin_referer( 'bp_forums_delete_topic' ); … … 692 701 else 693 702 bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress') ); 694 703 704 do_action( 'groups_delete_forum_topic', $topic_id ); 695 705 bp_core_redirect( wp_get_referer() ); 696 706 } 697 707 698 708 /* Editing a topic */ 699 else if ( 'edit' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 709 else if ( 'edit' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) { 710 /* Fetch the topic */ 711 $topic = bp_forums_get_topic_details( $topic_id ); 712 713 /* Check the logged in user can edit this topic */ 714 if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$topic->topic_poster ) 715 bp_core_redirect( wp_get_referer() ); 716 700 717 if ( isset( $_POST['save_changes'] ) ) { 701 718 /* Check the nonce */ … … 707 724 bp_core_add_message( __( 'The topic was edited successfully', 'buddypress') ); 708 725 726 do_action( 'groups_edit_forum_topic', $topic_id ); 709 727 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' ); 710 728 } 711 712 /* Check that the user has access to edit this topic, if not, redirect. */ 713 $topic = bp_forums_get_topic_details( $topic_id ); 714 if ( ( !$bp->is_item_admin && !$bp->is_item_mod ) && $bp->loggedin_user->id != $topic->topic_poster ) 715 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' ); 716 729 717 730 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/forum/edit' ) ); 718 731 } 719 732 720 733 /* Delete a post */ 721 else if ( 'delete' == $bp->action_variables[2] && $bp->action_variables[4] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 734 else if ( 'delete' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) { 735 /* Fetch the post */ 736 $post = bp_forums_get_post( $post_id ); 737 738 /* Check the logged in user can edit this topic */ 739 if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$post->poster_id ) 740 bp_core_redirect( wp_get_referer() ); 741 722 742 /* Check the nonce */ 723 743 check_admin_referer( 'bp_forums_delete_post' ); … … 727 747 else 728 748 bp_core_add_message( __( 'The post was deleted successfully', 'buddypress') ); 729 749 750 do_action( 'groups_delete_forum_post', $post_id ); 730 751 bp_core_redirect( wp_get_referer() ); 731 752 } … … 733 754 /* Editing a post */ 734 755 else if ( 'edit' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) { 756 /* Fetch the post */ 757 $post = bp_forums_get_post( $bp->action_variables[4] ); 758 759 /* Check the logged in user can edit this topic */ 760 if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$post->poster_id ) 761 bp_core_redirect( wp_get_referer() ); 762 735 763 if ( isset( $_POST['save_changes'] ) ) { 736 764 /* Check the nonce */ … … 741 769 else 742 770 bp_core_add_message( __( 'The post was edited successfully', 'buddypress') ); 743 771 772 do_action( 'groups_edit_forum_post', $post_id ); 744 773 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' ); 745 774 } 746 775 747 /* Check that the user has access to edit this post, if not, redirect. */748 $post = bp_forums_get_post( $post_id );749 if ( ( !$bp->is_item_admin && !$bp->is_item_mod ) && $bp->loggedin_user->id != $post->poster_id )750 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' );751 752 776 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/forum/edit' ) ); 753 777 } … … 760 784 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/forum/topic' ) ); 761 785 } 786 762 787 } else { 763 788 … … 2098 2123 'component_action' => 'new_forum_post', 2099 2124 'item_id' => $bp->groups->current_group->id, 2100 'secondary_item_id' => $forum_post ->id2125 'secondary_item_id' => $forum_post 2101 2126 ) ); 2102 2127 … … 2143 2168 if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id ) ) ) { 2144 2169 /* Update the activity stream item */ 2145 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_topic' ) ); 2170 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) 2171 bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_topic' ) ); 2146 2172 2147 2173 $activity_content = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ); … … 2172 2198 $post = bp_forums_get_post( $post_id ); 2173 2199 2174 if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id ) ) ) {2200 if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id ) ) ) { 2175 2201 $topic = bp_forums_get_topic_details( $topic_id ); 2176 2202 2177 2203 /* Update the activity stream item */ 2178 bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component_name' => 'groups', 'component_action' => 'new_forum_post' ) ); 2179 2204 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) 2205 bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_post' ) ); 2206 2180 2207 $activity_content = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ); 2181 2208 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $post_text ) ) . '</blockquote>'; … … 2186 2213 'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ), 2187 2214 'component_action' => 'new_forum_post', 2188 'item_id' => $bp->groups->current_group->id, 2215 'item_id' => (int)$bp->groups->current_group->id, 2216 'user_id' => (int)$post->poster_id, 2189 2217 'secondary_item_id' => $post_id, 2190 2218 'recorded_time' => strtotime( $post->post_time ) … … 2205 2233 /* Delete the activity stream item */ 2206 2234 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) { 2207 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_topic' ) );2208 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_post' ) );2235 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_topic' ) ); 2236 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_post' ) ); 2209 2237 } 2210 2238
Note: See TracChangeset
for help on using the changeset viewer.