Changeset 3856 for branches/plugin/bbp-admin/bbp-tools.php
- Timestamp:
- 04/28/2012 10:55:53 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-admin/bbp-tools.php
r3811 r3856 723 723 $statement = __( 'Removing trashed topics from user favorites… %s', 'bbpress' ); 724 724 $result = __( 'Failed!', 'bbpress' ); 725 726 $users = $wpdb->get_results( "SELECT `user_id`, `meta_value` AS `favorites` FROM `$wpdb->usermeta` WHERE `meta_key` = '_bbp_favorites';" ); 725 $key = bbp_get_favorites_key(); 726 $users = $wpdb->get_results( "SELECT `user_id`, `meta_value` AS `favorites` FROM `{$wpdb->usermeta}` WHERE `meta_key` = '{$key}';" ); 727 727 728 if ( is_wp_error( $users ) ) 728 729 return array( 1, sprintf( $statement, $result ) ); 729 730 730 $topics = $wpdb->get_col( "SELECT `ID` FROM ` $wpdb->posts` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "';" );731 $topics = $wpdb->get_col( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "';" ); 731 732 732 733 if ( is_wp_error( $topics ) ) … … 743 744 744 745 $favorites = join( ',', $favorites ); 745 $values[] = "(' $user->user_id', '_bbp_favorites', '$favorites')";746 $values[] = "('{$user->user_id}', '{$key}, '{$favorites}')"; 746 747 } 747 748 … … 751 752 } 752 753 753 $sql_delete = "DELETE FROM ` $wpdb->usermeta` WHERE `meta_key` = '_bbp_favorites';";754 $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` = '{$key}';"; 754 755 if ( is_wp_error( $wpdb->query( $sql_delete ) ) ) 755 756 return array( 4, sprintf( $statement, $result ) ); … … 782 783 $statement = __( 'Removing trashed topics from user subscriptions… %s', 'bbpress' ); 783 784 $result = __( 'Failed!', 'bbpress' ); 784 785 $users = $wpdb->get_results( "SELECT `user_id`, `meta_value` AS `subscriptions` FROM `$wpdb->usermeta` WHERE `meta_key` = '_bbp_subscriptions';" ); 785 $key = bbp_get_subscriptions_key(); 786 $users = $wpdb->get_results( "SELECT `user_id`, `meta_value` AS `subscriptions` FROM `{$wpdb->usermeta}` WHERE `meta_key` = '{$key}';" ); 787 786 788 if ( is_wp_error( $users ) ) 787 789 return array( 1, sprintf( $statement, $result ) ); 788 790 789 $topics = $wpdb->get_col( "SELECT `ID` FROM ` $wpdb->posts` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "';" );791 $topics = $wpdb->get_col( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "';" ); 790 792 if ( is_wp_error( $topics ) ) 791 793 return array( 2, sprintf( $statement, $result ) ); … … 801 803 802 804 $subscriptions = join( ',', $subscriptions ); 803 $values[] = "(' $user->user_id', '_bbp_subscriptions', '$subscriptions')";805 $values[] = "('{$user->user_id}', '{$key}', '{$subscriptions}')"; 804 806 } 805 807 … … 809 811 } 810 812 811 $sql_delete = "DELETE FROM ` $wpdb->usermeta` WHERE `meta_key` = '_bbp_subscriptions';";813 $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` = '{$key}';"; 812 814 if ( is_wp_error( $wpdb->query( $sql_delete ) ) ) 813 815 return array( 4, sprintf( $statement, $result ) ); … … 816 818 foreach ( $values as $chunk ) { 817 819 $chunk = "\n" . join( ",\n", $chunk ); 818 $sql_insert = "INSERT INTO ` $wpdb->usermeta` (`user_id`, `meta_key`, `meta_value`) VALUES $chunk;";820 $sql_insert = "INSERT INTO `{$wpdb->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES $chunk;"; 819 821 if ( is_wp_error( $wpdb->query( $sql_insert ) ) ) 820 822 return array( 5, sprintf( $statement, $result ) );
Note: See TracChangeset
for help on using the changeset viewer.