Changeset 1858 for trunk/bp-groups.php
- Timestamp:
- 09/11/2009 11:59:16 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/bp-groups.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups.php
r1852 r1858 581 581 582 582 if ( $topic_slug && $topic_id ) { 583 583 584 584 /* Posting a reply */ 585 585 if ( !$bp->action_variables[2] && isset( $_POST['submit_reply'] ) ) { 586 586 /* Check the nonce */ 587 587 check_admin_referer( 'bp_forums_new_reply' ); 588 588 589 /* Auto join this user if they are not yet a member of this group */ 590 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 591 groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id ); 592 589 593 if ( !groups_new_group_forum_post( $_POST['reply_text'], $topic_id ) ) 590 594 bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' ); … … 593 597 594 598 if ( $_SERVER['QUERY_STRING'] ) 595 $query_vars = '?' . $_SERVER['QUERY_STRING']; 596 599 $query_vars = '?' . $_SERVER['QUERY_STRING']; 600 597 601 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' . $query_vars ); 598 602 } … … 609 613 610 614 do_action( 'groups_stick_topic', $topic_id ); 611 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/');615 bp_core_redirect( wp_get_referer() ); 612 616 } 613 617 … … 623 627 624 628 do_action( 'groups_unstick_topic', $topic_id ); 625 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/');629 bp_core_redirect( wp_get_referer() ); 626 630 } 627 631 … … 637 641 638 642 do_action( 'groups_close_topic', $topic_id ); 639 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/');643 bp_core_redirect( wp_get_referer() ); 640 644 } 641 645 … … 651 655 652 656 do_action( 'groups_open_topic', $topic_id ); 653 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/');657 bp_core_redirect( wp_get_referer() ); 654 658 } 655 659 656 660 /* Delete a topic */ 657 else if ( 'delete' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {661 else if ( 'delete' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 658 662 /* Check the nonce */ 659 663 check_admin_referer( 'bp_forums_delete_topic' ); 660 664 661 if ( !groups_delete_ forum_topic( $topic_id ) )665 if ( !groups_delete_group_forum_topic( $topic_id ) ) 662 666 bp_core_add_message( __( 'There was an error deleting the topic', 'buddypress'), 'error' ); 663 667 else 664 668 bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress') ); 665 666 do_action( 'groups_delete_topic', $topic_id ); 667 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/' ); 669 670 bp_core_redirect( wp_get_referer() ); 668 671 } 669 672 670 673 /* Editing a topic */ 671 else if ( 'edit' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {674 else if ( 'edit' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 672 675 if ( isset( $_POST['save_changes'] ) ) { 673 676 /* Check the nonce */ … … 691 694 692 695 /* Delete a post */ 693 else if ( 'delete' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 696 697 else if ( 'delete' == $bp->action_variables[2] && $bp->action_variables[4] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 694 698 /* Check the nonce */ 695 check_admin_referer( 'bp_forums_delete_ topic' );696 697 if ( !groups_delete_ forum_topic($topic_id ) )698 bp_core_add_message( __( 'There was an error deleting th e topic', 'buddypress'), 'error' );699 check_admin_referer( 'bp_forums_delete_post' ); 700 701 if ( !groups_delete_group_forum_post( $bp->action_variables[3], $topic_id ) ) 702 bp_core_add_message( __( 'There was an error deleting that post', 'buddypress'), 'error' ); 699 703 else 700 bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress') ); 701 702 do_action( 'groups_delete_topic', $topic_id ); 703 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/' ); 704 } 705 706 704 bp_core_add_message( __( 'The post was deleted successfully', 'buddypress') ); 705 706 bp_core_redirect( wp_get_referer() ); 707 } 708 707 709 /* Editing a post */ 708 else if ( 'edit' == $bp->action_variables[ 4] && $post_id = $bp->action_variables[3] ) {710 else if ( 'edit' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) { 709 711 if ( isset( $_POST['save_changes'] ) ) { 710 712 /* Check the nonce */ 711 713 check_admin_referer( 'bp_forums_edit_post' ); 712 714 713 715 if ( !groups_update_group_forum_post( $post_id, $_POST['post_text'], $topic_id ) ) 714 716 bp_core_add_message( __( 'There was an error when editing that post', 'buddypress'), 'error' ); … … 741 743 check_admin_referer( 'bp_forums_new_topic' ); 742 744 743 if ( !groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) 745 /* Auto join this user if they are not yet a member of this group */ 746 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 747 groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id ); 748 749 if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) 744 750 bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' ); 745 751 else 746 752 bp_core_add_message( __( 'The topic was created successfully', 'buddypress') ); 747 753 748 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/ ' );754 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' ); 749 755 } 750 756 … … 2028 2034 $group_desc = $bp->groups->current_group->description; 2029 2035 2030 $forum_id = bp_forums_new_forum( array( 'forum_name' => $group_name, 'forum_desc ription' => $group_desc ) );2031 2036 $forum_id = bp_forums_new_forum( array( 'forum_name' => $group_name, 'forum_desc' => $group_desc ) ); 2037 2032 2038 groups_update_groupmeta( $group_id, 'forum_id', $forum_id ); 2033 2039 … … 2037 2043 function groups_new_group_forum_post( $post_text, $topic_id ) { 2038 2044 global $bp; 2045 2046 if ( empty( $post_text ) ) 2047 return false; 2039 2048 2040 2049 if ( $forum_post = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) { … … 2063 2072 function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $forum_id ) { 2064 2073 global $bp; 2074 2075 if ( empty( $topic_title ) || empty( $topic_text ) ) 2076 return false; 2065 2077 2066 2078 if ( $topic_id = bp_forums_new_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_tags' => $topic_tags, 'forum_id' => $forum_id ) ) ) { … … 2116 2128 } 2117 2129 2118 function groups_delete_forum_topic( $topic_id ) {2119 global $bp;2120 2121 if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) {2122 /* Delete the activity stream item */2123 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {2124 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_topic' ) );2125 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_post' ) );2126 }2127 2128 do_action( 'groups_delete_forum_topic', $topic_id );2129 2130 return true;2131 }2132 2133 return false;2134 }2135 2136 2130 function groups_update_group_forum_post( $post_id, $post_text, $topic_id ) { 2137 2131 global $bp; … … 2166 2160 } 2167 2161 2168 // function groups_delete_forum_post( $post_id, $topic_id ) { 2169 // global $bp; 2170 // 2171 // if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) { 2172 // /* Delete the activity stream item */ 2173 // if ( function_exists( 'bp_activity_delete_by_item_id' ) ) { 2174 // bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'secondary_item_id' => $post_id 'component_name' => 'groups', 'component_action' => 'new_forum_post' ) ); 2175 // } 2176 // 2177 // do_action( 'groups_delete_forum_topic', $topic_id ); 2178 // 2179 // return true; 2180 // } 2181 // 2182 // return false; 2183 // } 2162 function groups_delete_group_forum_topic( $topic_id ) { 2163 global $bp; 2164 2165 if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) { 2166 /* Delete the activity stream item */ 2167 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) { 2168 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_topic' ) ); 2169 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_post' ) ); 2170 } 2171 2172 do_action( 'groups_delete_group_forum_topic', $topic_id ); 2173 2174 return true; 2175 } 2176 2177 return false; 2178 } 2179 2180 function groups_delete_group_forum_post( $post_id, $topic_id ) { 2181 global $bp; 2182 2183 if ( bp_forums_delete_post( array( 'post_id' => $post_id ) ) ) { 2184 /* Delete the activity stream item */ 2185 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) { 2186 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' ) ); 2187 } 2188 2189 do_action( 'groups_delete_group_forum_post', $post_id, $topic_id ); 2190 2191 return true; 2192 } 2193 2194 return false; 2195 } 2196 2197 2198 function groups_total_public_forum_topic_count( $type = 'newest' ) { 2199 return apply_filters( 'groups_total_public_forum_topic_count', BP_Groups_Group::get_global_forum_topic_count( $type ) ); 2200 } 2184 2201 2185 2202 /*** Group Invitations *********************************************************/
Note: See TracChangeset
for help on using the changeset viewer.