Changeset 3136
- Timestamp:
- 05/11/2011 10:47:51 PM (14 years ago)
- Location:
- branches/plugin/bbp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-topic-functions.php
r3135 r3136 1087 1087 global $wpdb, $bbp; 1088 1088 1089 if ( !$from_reply_id = (int) $_POST['bbp_reply_id'] ) 1089 // Prevent debug notices 1090 $from_reply_id = $destination_topic_id = 0; 1091 $destination_topic_title = ''; 1092 $destination_topic = $from_reply = $source_topic = ''; 1093 $split_option = false; 1094 1095 /** Split Reply *******************************************************/ 1096 1097 if ( empty( $_POST['bbp_reply_id'] ) ) 1090 1098 $bbp->errors->add( 'bbp_split_topic_reply_id', __( '<strong>ERROR</strong>: Reply ID to split the topic from not found!', 'bbpress' ) ); 1091 1092 if ( !$from_reply = bbp_get_reply( $from_reply_id ) ) 1093 $bbp->errors->add( 'bbp_split_topic_r_not_found', __( '<strong>ERROR</strong>: The reply you want to split from was not found!', 'bbpress' ) ); 1094 1095 if ( !$source_topic = bbp_get_topic( $from_reply->post_parent ) ) 1096 $bbp->errors->add( 'bbp_split_topic_source_not_found', __( '<strong>ERROR</strong>: The topic you want to split was not found!', 'bbpress' ) ); 1099 else 1100 $from_reply_id = (int) $_POST['bbp_reply_id']; 1101 1102 $from_reply = bbp_get_reply( $from_reply_id ); 1103 1104 // Reply exists 1105 if ( empty( $from_reply ) ) 1106 $bbp->errors->add( 'bbp_split_topic_r_not_found', __( '<strong>ERROR</strong>: The reply you want to split from was not found.', 'bbpress' ) ); 1107 1108 /** Topic to Split ****************************************************/ 1109 1110 // Get the topic being split 1111 $source_topic = bbp_get_topic( $from_reply->post_parent ); 1112 1113 // No topic 1114 if ( empty( $source_topic ) ) 1115 $bbp->errors->add( 'bbp_split_topic_source_not_found', __( '<strong>ERROR</strong>: The topic you want to split was not found.', 'bbpress' ) ); 1097 1116 1098 1117 // Nonce check 1099 1118 check_admin_referer( 'bbp-split-topic_' . $source_topic->ID ); 1100 1119 1120 // Use cannot edit topic 1101 1121 if ( !current_user_can( 'edit_topic', $source_topic->ID ) ) 1102 $bbp->errors->add( 'bbp_split_topic_source_permission', __( '<strong>ERROR</strong>: You do not have the permissions to edit the source topic!', 'bbpress' ) ); 1103 1104 $split_option = !empty( $_POST['bbp_topic_split_option'] ) ? (string) trim( $_POST['bbp_topic_split_option'] ) : false; 1105 if ( empty( $split_option ) || !in_array( $split_option, array( 'existing', 'reply' ) ) ) 1106 $bbp->errors->add( 'bbp_split_topic_option', __( '<strong>ERROR</strong>: You need to choose a valid split option!', 'bbpress' ) ); 1107 1108 switch ( $split_option ) { 1109 case 'existing' : 1110 if ( !$destination_topic_id = (int) $_POST['bbp_destination_topic'] ) 1111 $bbp->errors->add( 'bbp_split_topic_destination_id', __( '<strong>ERROR</strong>: Destination topic ID not found!', 'bbpress' ) ); 1112 1113 if ( !$destination_topic = bbp_get_topic( $destination_topic_id ) ) 1114 $bbp->errors->add( 'bbp_split_topic_destination_not_found', __( '<strong>ERROR</strong>: The topic you want to split to was not found!', 'bbpress' ) ); 1115 1116 if ( !current_user_can( 'edit_topic', $destination_topic->ID ) ) 1117 $bbp->errors->add( 'bbp_split_topic_destination_permission', __( '<strong>ERROR</strong>: You do not have the permissions to edit the destination topic!', 'bbpress' ) ); 1118 1119 break; 1120 1121 case 'reply' : 1122 default : 1123 if ( current_user_can( 'publish_topics' ) ) { 1124 1125 if ( !$destination_topic_title = esc_attr( strip_tags( $_POST['bbp_topic_split_destination_title'] ) ) ) 1126 $destination_topic_title = $source_topic->post_title; 1127 1122 $bbp->errors->add( 'bbp_split_topic_source_permission', __( '<strong>ERROR</strong>: You do not have the permissions to edit the source topic.', 'bbpress' ) ); 1123 1124 /** How to Split ******************************************************/ 1125 1126 if ( !empty( $_POST['bbp_topic_split_option'] ) ) 1127 $split_option = (string) trim( $_POST['bbp_topic_split_option'] ); 1128 1129 // Invalid split option 1130 if ( empty( $split_option ) || !in_array( $split_option, array( 'existing', 'reply' ) ) ) { 1131 $bbp->errors->add( 'bbp_split_topic_option', __( '<strong>ERROR</strong>: You need to choose a valid split option.', 'bbpress' ) ); 1132 1133 // Valid Split Option 1134 } else { 1135 1136 // What kind of split 1137 switch ( $split_option ) { 1138 1139 // Into an existing topic 1140 case 'existing' : 1141 1142 // Get destination topic id 1143 if ( empty( $_POST['bbp_destination_topic'] ) ) 1144 $bbp->errors->add( 'bbp_split_topic_destination_id', __( '<strong>ERROR</strong>: Destination topic ID not found!', 'bbpress' ) ); 1145 else 1146 $destination_topic_id = (int) $_POST['bbp_destination_topic']; 1147 1148 // Get the destination topic 1149 $destination_topic = bbp_get_topic( $destination_topic_id ); 1150 1151 // No destination topic 1152 if ( empty( $destination_topic ) ) 1153 $bbp->errors->add( 'bbp_split_topic_destination_not_found', __( '<strong>ERROR</strong>: The topic you want to split to was not found!', 'bbpress' ) ); 1154 1155 // User cannot edit the destination topic 1156 if ( !current_user_can( 'edit_topic', $destination_topic->ID ) ) 1157 $bbp->errors->add( 'bbp_split_topic_destination_permission', __( '<strong>ERROR</strong>: You do not have the permissions to edit the destination topic!', 'bbpress' ) ); 1158 1159 break; 1160 1161 // Split at reply into a new topic 1162 case 'reply' : 1163 default : 1164 1165 // User needs to be able to publish topics 1166 if ( current_user_can( 'publish_topics' ) ) { 1167 1168 // Use the new title that was passed 1169 if ( !empty( $_POST['bbp_topic_split_destination_title'] ) ) 1170 $destination_topic_title = esc_attr( strip_tags( $_POST['bbp_topic_split_destination_title'] ) ); 1171 1172 // Use the source topic title 1173 else 1174 $destination_topic_title = $source_topic->post_title; 1175 1176 // Setup the new post parameters 1177 $postarr = array( 1178 'ID' => $from_reply->ID, 1179 'post_title' => $destination_topic_title, 1180 'post_name' => false, 1181 'post_type' => bbp_get_topic_post_type(), 1182 'post_parent' => $source_topic->post_parent, 1183 'guid' => '' 1184 ); 1185 1186 $destination_topic_id = wp_update_post( $postarr ); 1187 1188 // Shouldn't happen 1189 if ( false == $destination_topic_id || is_wp_error( $destination_topic_id ) || !$destination_topic = bbp_get_topic( $destination_topic_id ) ) 1190 $bbp->errors->add( 'bbp_split_topic_destination_reply', __( '<strong>ERROR</strong>: There was a problem converting the reply into the topic. Please try again.', 'bbpress' ) ); 1191 1192 // User cannot publish posts 1193 } else { 1194 $bbp->errors->add( 'bbp_split_topic_destination_permission', __( '<strong>ERROR</strong>: You do not have the permissions to create new topics. The reply could not be converted into a topic.', 'bbpress' ) ); 1195 } 1196 1197 break; 1198 } 1199 } 1200 1201 /** No Errors - Do the Spit *******************************************/ 1202 1203 if ( !is_wp_error( $bbp->errors ) || !$bbp->errors->get_error_codes() ) { 1204 1205 // Update counts, etc... 1206 do_action( 'bbp_pre_split_topic', $from_reply->ID, $source_topic->ID, $destination_topic->ID ); 1207 1208 /** Subscriptions *************************************************/ 1209 1210 // Copy the subscribers 1211 if ( !empty( $_POST['bbp_topic_subscribers'] ) && 1 == $_POST['bbp_topic_subscribers'] && bbp_is_subscriptions_active() ) { 1212 1213 // Get the subscribers 1214 if ( $subscribers = bbp_get_topic_subscribers( $source_topic->ID ) ) { 1215 1216 // Add subscribers to new topic 1217 foreach ( (array) $subscribers as $subscriber ) { 1218 bbp_add_user_subscription( $subscriber, $destination_topic->ID ); 1219 } 1220 } 1221 } 1222 1223 /** Favorites *****************************************************/ 1224 1225 // Copy the favoriters if told to 1226 if ( !empty( $_POST['bbp_topic_favoriters'] ) && 1 == $_POST['bbp_topic_favoriters'] ) { 1227 1228 // Get the favoriters 1229 if ( $favoriters = bbp_get_topic_favoriters( $source_topic->ID ) ) { 1230 1231 // Add the favoriters to new topic 1232 foreach ( (array) $favoriters as $favoriter ) { 1233 bbp_add_user_favorite( $favoriter, $destination_topic->ID ); 1234 } 1235 } 1236 } 1237 1238 /** Tags **********************************************************/ 1239 1240 // Copy the tags if told to 1241 if ( !empty( $_POST['bbp_topic_tags'] ) && 1 == $_POST['bbp_topic_tags'] ) { 1242 1243 // Get the source topic tags 1244 if ( $source_topic_tags = wp_get_post_terms( $source_topic->ID, $bbp->topic_tag_id, array( 'fields' => 'names' ) ) ) { 1245 wp_set_post_terms( $destination_topic->ID, $source_topic_tags, $bbp->topic_tag_id, true ); 1246 } 1247 } 1248 1249 /** Split Replies *************************************************/ 1250 1251 // get_posts() is not used because it doesn't allow us to use '>=' 1252 // comparision without a filter. 1253 $replies = (array) $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_date >= %s AND {$wpdb->posts}.post_parent = %d AND {$wpdb->posts}.post_type = %s ORDER BY {$wpdb->posts}.post_date ASC", $from_reply->post_date, $source_topic->ID, bbp_get_reply_post_type() ) ); 1254 1255 // Make sure there are replies to loop through 1256 if ( !empty( $replies ) && !is_wp_error( $replies ) ) { 1257 1258 // Change the post_parent of each reply to the destination topic id 1259 foreach ( $replies as $reply ) { 1260 1261 // New reply data 1128 1262 $postarr = array( 1129 'ID' => $from_reply->ID, 1130 'post_title' => $destination_topic_title, 1131 'post_name' => false, 1132 'post_type' => bbp_get_topic_post_type(), 1133 'post_parent' => $source_topic->post_parent, 1263 'ID' => $reply->ID, 1264 'post_title' => sprintf( __( 'Reply To: %s', 'bbpress' ), $destination_topic->post_title ), 1265 'post_name' => false, // will be automatically generated 1266 'post_parent' => $destination_topic->ID, 1134 1267 'guid' => '' 1135 1268 ); 1136 1269 1137 $destination_topic_id = wp_update_post( $postarr ); 1138 1139 // Shouldn't happen 1140 if ( false == $destination_topic_id || is_wp_error( $destination_topic_id ) || !$destination_topic = bbp_get_topic( $destination_topic_id ) ) 1141 $bbp->errors->add( 'bbp_split_topic_destination_reply', __( '<strong>ERROR</strong>: There was a problem converting the reply into the topic, please try again!', 'bbpress' ) ); 1142 1143 } else { 1144 $bbp->errors->add( 'bbp_split_topic_destination_permission', __( '<strong>ERROR</strong>: You do not have the permissions to create new topics and hence the reply could not be converted into a topic!', 'bbpress' ) ); 1145 } 1146 1147 break; 1148 } 1149 1150 // We should have the from reply, source topic & destination topic by now. 1151 1152 // Handle the split 1153 if ( !is_wp_error( $bbp->errors ) || !$bbp->errors->get_error_codes() ) { 1154 1155 // Update counts, etc... 1156 do_action( 'bbp_pre_split_topic', $from_reply->ID, $source_topic->ID, $destination_topic->ID ); 1157 1158 // Copy the subscribers if told to 1159 if ( !empty( $_POST['bbp_topic_subscribers'] ) && 1 == $_POST['bbp_topic_subscribers'] && bbp_is_subscriptions_active() ) { 1160 $subscribers = bbp_get_topic_subscribers( $source_topic->ID ); 1161 1162 foreach ( (array) $subscribers as $subscriber ) { 1163 bbp_add_user_subscription( $subscriber, $destination_topic->ID ); 1270 // Update the reply 1271 wp_update_post( $postarr ); 1272 1273 // Adjust reply meta values 1274 bbp_update_reply_topic_id( $reply->ID, $destination_topic->ID ); 1275 bbp_update_reply_forum_id( $reply->ID, bbp_get_topic_forum_id( $destination_topic->ID ) ); 1276 1277 // Do additional actions per split reply 1278 do_action( 'bbp_split_topic_reply', $reply->ID, $destination_topic->ID ); 1164 1279 } 1165 1280 } 1166 1281 1167 // Copy the favoriters if told to 1168 if ( !empty( $_POST['bbp_topic_favoriters'] ) && 1 == $_POST['bbp_topic_favoriters'] ) { 1169 $favoriters = bbp_get_topic_favoriters( $source_topic->ID ); 1170 1171 foreach ( (array) $favoriters as $favoriter ) { 1172 bbp_add_user_favorite( $favoriter, $destination_topic->ID ); 1173 } 1174 } 1175 1176 // Copy the tags if told to 1177 if ( !empty( $_POST['bbp_topic_tags'] ) && 1 == $_POST['bbp_topic_tags'] ) { 1178 // Get the source topic tags 1179 $source_topic_tags = wp_get_post_terms( $source_topic->ID, $bbp->topic_tag_id, array( 'fields' => 'names' ) ); 1180 1181 wp_set_post_terms( $destination_topic->ID, $source_topic_tags, $bbp->topic_tag_id, true ); 1182 } 1183 1184 // Get the replies of the source topic 1185 // get_posts() is not used because it doesn't allow us to use '>=' comparision without a filter 1186 $replies = (array) $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_date >= %s AND {$wpdb->posts}.post_parent = %d AND {$wpdb->posts}.post_type = %s ORDER BY {$wpdb->posts}.post_date ASC", $from_reply->post_date, $source_topic->ID, bbp_get_reply_post_type() ) ); 1187 1188 // Change the post_parent of each reply to the destination topic id 1189 foreach ( $replies as $reply ) { 1190 $postarr = array( 1191 'ID' => $reply->ID, 1192 'post_title' => sprintf( __( 'Reply To: %s', 'bbpress' ), $destination_topic->post_title ), 1193 'post_name' => false, // will be automatically generated 1194 'post_parent' => $destination_topic->ID, 1195 'guid' => '' 1196 ); 1197 1198 wp_update_post( $postarr ); 1199 1200 // Adjust reply meta values 1201 bbp_update_reply_topic_id( $reply->ID, $destination_topic->ID ); 1202 bbp_update_reply_forum_id( $reply->ID, bbp_get_topic_forum_id( $destination_topic->ID ) ); 1203 1204 // Do additional actions per split reply 1205 do_action( 'bbp_split_topic_reply', $reply->ID, $destination_topic->ID ); 1206 } 1207 1208 // It is a new topic and we need to set some default metas to make the topic display in bbp_has_topics() list 1282 // It is a new topic and we need to set some default metas to make 1283 // the topic display in bbp_has_topics() list 1209 1284 if ( 'reply' == $split_option ) { 1210 1285 $last_reply_id = ( empty( $reply ) || empty( $reply->ID ) ) ? 0 : $reply->ID; … … 1214 1289 bbp_update_topic_last_active_time( $destination_topic->ID, $freshness ); 1215 1290 } 1291 1292 /** Successful Split **********************************************/ 1216 1293 1217 1294 // Update counts, etc... … … 1250 1327 1251 1328 // Forum Topic Counts 1252 // bbp_update_forum_topic_count( $source_topic_id );1253 1329 bbp_update_forum_topic_count( $destination_topic_id ); 1254 1330 1255 1331 // Forum Reply Counts 1256 // bbp_update_forum_reply_count( $source_topic_id );1257 1332 bbp_update_forum_reply_count( $destination_topic_id ); 1258 1333 … … 1308 1383 } 1309 1384 1310 // What action are we trying to perform 1385 // What action are we trying to perform? 1311 1386 switch ( $action ) { 1387 1388 // Update tag 1312 1389 case 'bbp-update-topic-tag' : 1313 1390 … … 1317 1394 // Can user edit topic tags? 1318 1395 if ( !current_user_can( 'edit_topic_tags' ) ) { 1319 $bbp->errors->add( 'bbp_manage_topic_tag_update_permissions', __( '<strong>ERROR</strong>: You do not have the permissions to edit the topic tags !', 'bbpress' ) );1396 $bbp->errors->add( 'bbp_manage_topic_tag_update_permissions', __( '<strong>ERROR</strong>: You do not have the permissions to edit the topic tags.', 'bbpress' ) ); 1320 1397 return; 1321 1398 } … … 1323 1400 // No tag name was provided 1324 1401 if ( empty( $_POST['tag-name'] ) || !$name = $_POST['tag-name'] ) { 1325 $bbp->errors->add( 'bbp_manage_topic_tag_update_name', __( '<strong>ERROR</strong>: You need to enter a tag name !', 'bbpress' ) );1402 $bbp->errors->add( 'bbp_manage_topic_tag_update_name', __( '<strong>ERROR</strong>: You need to enter a tag name.', 'bbpress' ) ); 1326 1403 return; 1327 1404 } … … 1345 1422 break; 1346 1423 1424 // Merge two tags 1347 1425 case 'bbp-merge-topic-tag' : 1348 1426 … … 1352 1430 // Can user edit topic tags? 1353 1431 if ( !current_user_can( 'edit_topic_tags' ) ) { 1354 $bbp->errors->add( 'bbp_manage_topic_tag_merge_permissions', __( '<strong>ERROR</strong>: You do not have the permissions to edit the topic tags !', 'bbpress' ) );1432 $bbp->errors->add( 'bbp_manage_topic_tag_merge_permissions', __( '<strong>ERROR</strong>: You do not have the permissions to edit the topic tags.', 'bbpress' ) ); 1355 1433 return; 1356 1434 } … … 1358 1436 // No tag name was provided 1359 1437 if ( empty( $_POST['tag-name'] ) || !$name = $_POST['tag-name'] ) { 1360 $bbp->errors->add( 'bbp_manage_topic_tag_merge_name', __( '<strong>ERROR</strong>: You need to enter a tag name !', 'bbpress' ) );1438 $bbp->errors->add( 'bbp_manage_topic_tag_merge_name', __( '<strong>ERROR</strong>: You need to enter a tag name.', 'bbpress' ) ); 1361 1439 return; 1362 1440 } … … 1398 1476 break; 1399 1477 1478 // Delete tag 1400 1479 case 'bbp-delete-topic-tag' : 1401 1480 … … 1405 1484 // Can user delete topic tags? 1406 1485 if ( !current_user_can( 'delete_topic_tags' ) ) { 1407 $bbp->errors->add( 'bbp_manage_topic_tag_delete_permissions', __( '<strong>ERROR</strong>: You do not have the permissions to delete the topic tags !', 'bbpress' ) );1486 $bbp->errors->add( 'bbp_manage_topic_tag_delete_permissions', __( '<strong>ERROR</strong>: You do not have the permissions to delete the topic tags.', 'bbpress' ) ); 1408 1487 return; 1409 1488 } … … 1426 1505 break; 1427 1506 } 1507 1508 /** Successful Moderation *********************************************/ 1428 1509 1429 1510 // Redirect back … … 1522 1603 // What is the user doing here? 1523 1604 if ( !current_user_can( 'edit_topic', $topic->ID ) || ( 'bbp_toggle_topic_trash' == $action && !current_user_can( 'delete_topic', $topic->ID ) ) ) { 1524 $bbp->errors->add( 'bbp_toggle_topic_permission', __( '<strong>ERROR:</strong> You do not have the permission to do that !', 'bbpress' ) );1605 $bbp->errors->add( 'bbp_toggle_topic_permission', __( '<strong>ERROR:</strong> You do not have the permission to do that.', 'bbpress' ) ); 1525 1606 return; 1526 1607 } 1527 1608 1609 // What action are we trying to perform? 1528 1610 switch ( $action ) { 1611 1612 // Toggle open/close 1529 1613 case 'bbp_toggle_topic_close' : 1530 1614 check_ajax_referer( 'close-topic_' . $topic_id ); … … 1532 1616 $is_open = bbp_is_topic_open( $topic_id ); 1533 1617 $success = $is_open ? bbp_close_topic( $topic_id ) : bbp_open_topic( $topic_id ); 1534 $failure = $is_open ? __( '<strong>ERROR</strong>: There was a problem closing the topic !', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem opening the topic!', 'bbpress' );1618 $failure = $is_open ? __( '<strong>ERROR</strong>: There was a problem closing the topic.', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem opening the topic.', 'bbpress' ); 1535 1619 1536 1620 break; 1537 1621 1622 // Toggle sticky/super-sticky/unstick 1538 1623 case 'bbp_toggle_topic_stick' : 1539 1624 check_ajax_referer( 'stick-topic_' . $topic_id ); … … 1542 1627 $is_super = ( empty( $is_sticky ) && !empty( $_GET['super'] ) && 1 == (int) $_GET['super'] ) ? true : false; 1543 1628 $success = $is_sticky ? bbp_unstick_topic( $topic_id ) : bbp_stick_topic( $topic_id, $is_super ); 1544 $failure = $is_sticky ? __( '<strong>ERROR</strong>: There was a problem unsticking the topic !', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem sticking the topic!', 'bbpress' );1629 $failure = $is_sticky ? __( '<strong>ERROR</strong>: There was a problem unsticking the topic.', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem sticking the topic.', 'bbpress' ); 1545 1630 1546 1631 break; 1547 1632 1633 // Toggle spam 1548 1634 case 'bbp_toggle_topic_spam' : 1549 1635 check_ajax_referer( 'spam-topic_' . $topic_id ); … … 1551 1637 $is_spam = bbp_is_topic_spam( $topic_id ); 1552 1638 $success = $is_spam ? bbp_unspam_topic( $topic_id ) : bbp_spam_topic( $topic_id ); 1553 $failure = $is_spam ? __( '<strong>ERROR</strong>: There was a problem unmarking the topic as spam !', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem marking the topic as spam!', 'bbpress' );1639 $failure = $is_spam ? __( '<strong>ERROR</strong>: There was a problem unmarking the topic as spam.', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem marking the topic as spam.', 'bbpress' ); 1554 1640 1555 1641 break; 1556 1642 1643 // Toggle trash 1557 1644 case 'bbp_toggle_topic_trash' : 1558 1645 … … 1567 1654 1568 1655 $success = wp_trash_post( $topic_id ); 1569 $failure = __( '<strong>ERROR</strong>: There was a problem trashing the topic !', 'bbpress' );1656 $failure = __( '<strong>ERROR</strong>: There was a problem trashing the topic.', 'bbpress' ); 1570 1657 1571 1658 break; … … 1575 1662 1576 1663 $success = wp_untrash_post( $topic_id ); 1577 $failure = __( '<strong>ERROR</strong>: There was a problem untrashing the topic !', 'bbpress' );1664 $failure = __( '<strong>ERROR</strong>: There was a problem untrashing the topic.', 'bbpress' ); 1578 1665 1579 1666 break; … … 1583 1670 1584 1671 $success = wp_delete_post( $topic_id ); 1585 $failure = __( '<strong>ERROR</strong>: There was a problem deleting the topic !', 'bbpress' );1672 $failure = __( '<strong>ERROR</strong>: There was a problem deleting the topic.', 'bbpress' ); 1586 1673 1587 1674 break; … … 1594 1681 do_action( 'bbp_toggle_topic_handler', $success, $post_data, $action ); 1595 1682 1596 // Check for errors1683 // No Errors 1597 1684 if ( false != $success && !is_wp_error( $success ) ) { 1598 1685 … … 1629 1716 */ 1630 1717 function bbp_remove_topic_from_all_favorites( $topic_id = 0 ) { 1718 $topic_id = bbp_get_topic_id( $topic_id ); 1719 1720 // Bail if no topic 1631 1721 if ( empty( $topic_id ) ) 1632 1722 return; 1633 1723 1724 // Get users 1634 1725 $users = (array) bbp_get_topic_favoriters( $topic_id ); 1635 1726 1727 // Users exist 1636 1728 if ( !empty( $users ) ) { 1729 1730 // Loop through users 1637 1731 foreach ( $users as $user ) { 1732 1733 // Remove each user 1638 1734 bbp_remove_user_favorite( $user, $topic_id ); 1639 1735 } … … 1652 1748 */ 1653 1749 function bbp_remove_topic_from_all_subscriptions( $topic_id = 0 ) { 1750 1751 // Subscriptions are not active 1752 if ( !bbp_is_subscriptions_active() ) 1753 return; 1754 1755 $topic_id = bbp_get_topic_id( $topic_id ); 1756 1757 // Bail if no topic 1654 1758 if ( empty( $topic_id ) ) 1655 1759 return; 1656 1760 1657 if ( !bbp_is_subscriptions_active() ) 1658 return; 1659 1761 // Get users 1660 1762 $users = (array) bbp_get_topic_subscribers( $topic_id ); 1661 1763 1764 // Users exist 1662 1765 if ( !empty( $users ) ) { 1766 1767 // Loop through users 1663 1768 foreach ( $users as $user ) { 1769 1770 // Remove each user 1664 1771 bbp_remove_user_subscription( $user, $topic_id ); 1665 1772 } … … 1714 1821 */ 1715 1822 function bbp_update_topic_topic_id( $topic_id = 0 ) { 1716 1717 // If it's a reply, then get the parent (topic id)1718 1823 $topic_id = bbp_get_topic_id( $topic_id ); 1719 1824 -
branches/plugin/bbp-includes/bbp-topic-template.php
r3134 r3136 1255 1255 * @uses bbp_get_topic_id() To get topic id 1256 1256 * @uses get_post_meta() To retrieve get topic's forum id meta 1257 * @uses get_post_field() To get the topic's parent, i.e. forum id1258 * @uses bbp_update_topic_forum_id() To update the topic forum id1259 1257 * @uses apply_filters() Calls 'bbp_get_topic_forum_id' with the forum 1260 1258 * id and topic id
Note: See TracChangeset
for help on using the changeset viewer.