Changeset 4816
- Timestamp:
- 03/17/2013 01:27:17 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/topics/functions.php
r4810 r4816 955 955 $new_forum_id = bbp_get_forum_id( $new_forum_id ); 956 956 957 // Update topic forum's ID 958 bbp_update_topic_forum_id( $topic_id, $new_forum_id ); 959 957 960 /** Stickies **************************************************************/ 958 961 … … 966 969 $updated_stickies = array(); 967 970 968 // Loop through stickies of forum 969 foreach ( $old_stickies as $sticky_topic_id ) { 970 971 // Add non-matches to the updated array 971 // Loop through stickies of forum and add misses to the updated array 972 foreach ( (array) $old_stickies as $sticky_topic_id ) { 972 973 if ( $topic_id != $sticky_topic_id ) { 973 974 $updated_stickies[] = $sticky_topic_id; … … 975 976 } 976 977 977 // No more stickies so delete the beta 978 if ( empty( $updated_stickies ) ) { 979 delete_post_meta ( $old_forum_id, '_bbp_sticky_topics' ); 980 981 // Still stickies so update the meta 982 } else { 983 update_post_meta( $old_forum_id, '_bbp_sticky_topics', $updated_stickies ); 984 } 985 986 // Topic was sticky, so restick in new forum 987 bbp_stick_topic( $topic_id ); 978 // If stickies are different, update or delete them 979 if ( $updated_stickies != $old_stickies ) { 980 981 // No more stickies so delete the meta 982 if ( empty( $updated_stickies ) ) { 983 delete_post_meta( $old_forum_id, '_bbp_sticky_topics' ); 984 985 // Still stickies so update the meta 986 } else { 987 update_post_meta( $old_forum_id, '_bbp_sticky_topics', $updated_stickies ); 988 } 989 990 // Topic was sticky, so restick in new forum 991 bbp_stick_topic( $topic_id ); 992 } 988 993 } 989 994 … … 994 999 995 1000 // Update the forum_id of all replies in the topic 996 foreach ( $replies as $reply_id ) 1001 foreach ( $replies as $reply_id ) { 997 1002 bbp_update_reply_forum_id( $reply_id, $new_forum_id ); 998 999 // Forum topic meta 1000 bbp_update_topic_forum_id( $topic_id, $new_forum_id ); 1003 } 1001 1004 1002 1005 /** Old forum_id **********************************************************/ 1003 1006 1004 1007 // Get topic ancestors 1005 $ancestors = array_values( array_unique( array_merge( array( $old_forum_id ), (array) get_post_ancestors( $old_forum_id ) ) ) ); 1006 1007 // Loop through ancestors 1008 if ( !empty( $ancestors ) ) { 1009 foreach ( $ancestors as $ancestor ) { 1010 1011 // If ancestor is a forum, update counts 1008 $old_forum_ancestors = array_values( array_unique( array_merge( array( $old_forum_id ), (array) get_post_ancestors( $old_forum_id ) ) ) ); 1009 1010 // Loop through ancestors and update them 1011 if ( !empty( $old_forum_ancestors ) ) { 1012 foreach ( $old_forum_ancestors as $ancestor ) { 1012 1013 if ( bbp_is_forum( $ancestor ) ) { 1013 1014 // Update the forum1015 1014 bbp_update_forum( array( 1016 1015 'forum_id' => $ancestor, … … 1023 1022 1024 1023 // Make sure we're not walking twice 1025 if ( !in_array( $new_forum_id, $ ancestors ) ) {1024 if ( !in_array( $new_forum_id, $old_forum_ancestors ) ) { 1026 1025 1027 1026 // Get topic ancestors 1028 $ancestors = array_values( array_unique( array_merge( array( $new_forum_id ), (array) get_post_ancestors( $new_forum_id ) ) ) ); 1029 1030 // Loop through ancestors 1031 if ( !empty( $ancestors ) ) { 1032 foreach ( $ancestors as $ancestor ) { 1033 1034 // If ancestor is a forum, update counts 1027 $new_forum_ancestors = array_values( array_unique( array_merge( array( $new_forum_id ), (array) get_post_ancestors( $new_forum_id ) ) ) ); 1028 1029 // Make sure we're not walking twice 1030 $new_forum_ancestors = array_diff( $new_forum_ancestors, $old_forum_ancestors ); 1031 1032 // Loop through ancestors and update them 1033 if ( !empty( $new_forum_ancestors ) ) { 1034 foreach ( $new_forum_ancestors as $ancestor ) { 1035 1035 if ( bbp_is_forum( $ancestor ) ) { 1036 1037 // Update the forum1038 1036 bbp_update_forum( array( 1039 1037 'forum_id' => $ancestor, … … 1098 1096 1099 1097 // Topic id 1100 if ( empty( $_POST['bbp_topic_id'] ) ) 1098 if ( empty( $_POST['bbp_topic_id'] ) ) { 1101 1099 bbp_add_error( 'bbp_merge_topic_source_id', __( '<strong>ERROR</strong>: Topic ID not found.', 'bbpress' ) ); 1102 else1100 } else { 1103 1101 $source_topic_id = (int) $_POST['bbp_topic_id']; 1102 } 1104 1103 1105 1104 // Nonce check
Note: See TracChangeset
for help on using the changeset viewer.