Skip to:
Content

bbPress.org


Ignore:
Timestamp:
02/26/2017 07:12:34 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Engagements: First pass at:

  • User profile section
  • Template parts changes
  • Rewrite rules support
  • Repair & upgrade tools
  • BuddyPress support
  • engagement slug setting

See #3068.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/tools/repair.php

    r6282 r6320  
    233233    $result    = __( 'Failed!', 'bbpress' );
    234234
    235     $sql_delete = "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_voice_count'";
     235    $sql_delete = "DELETE FROM {$bbp_db->postmeta} WHERE meta_key IN ('_bbp_voice_count', '_bbp_engagement')";
    236236    if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) {
    237237        return array( 1, sprintf( $statement, $result ) );
     
    244244    $cps = bbp_get_closed_status_id();
    245245
    246     $sql = "INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`) (
    247             SELECT `postmeta`.`meta_value`, '_bbp_voice_count', COUNT(DISTINCT `post_author`) as `meta_value`
    248                 FROM `{$bbp_db->posts}` AS `posts`
    249                 LEFT JOIN `{$bbp_db->postmeta}` AS `postmeta`
    250                     ON `posts`.`ID` = `postmeta`.`post_id`
    251                     AND `postmeta`.`meta_key` = '_bbp_topic_id'
    252                 WHERE `posts`.`post_type` IN ( '{$tpt}', '{$rpt}' )
    253                     AND `posts`.`post_status` IN ( '{$pps}', '{$cps}' )
    254                     AND `posts`.`post_author` != '0'
    255                 GROUP BY `postmeta`.`meta_value`)";
    256 
    257     if ( is_wp_error( $bbp_db->query( $sql ) ) ) {
     246    $voice_id_sql = $bbp_db->prepare( "INSERT INTO {$bbp_db->postmeta} (post_id, meta_key, meta_value) (
     247        SELECT postmeta.meta_value, '_bbp_engagement', posts.post_author
     248            FROM {$bbp_db->posts} AS posts
     249            LEFT JOIN {$bbp_db->postmeta} AS postmeta
     250                ON posts.ID = postmeta.post_id
     251                AND postmeta.meta_key = '_bbp_topic_id'
     252            WHERE posts.post_type IN (%s, %s)
     253                AND posts.post_status IN (%s, %s))", $tpt, $rpt, $pps, $cps );
     254
     255    if ( is_wp_error( $bbp_db->query( $voice_id_sql ) ) ) {
    258256        return array( 2, sprintf( $statement, $result ) );
     257    }
     258
     259    $voice_count_sql = "INSERT INTO {$bbp_db->postmeta} (post_id, meta_key, meta_value) (
     260        SELECT post_id, '_bbp_voice_count', COUNT(DISTINCT meta_value)
     261            FROM {$bbp_db->postmeta}
     262            WHERE meta_key = '_bbp_engagement'
     263            GROUP BY post_id ORDER BY post_id)";
     264
     265    if ( is_wp_error( $bbp_db->query( $voice_count_sql ) ) ) {
     266        return array( 3, sprintf( $statement, $result ) );
    259267    }
    260268
     
    695703
    696704    // Query for users with favorites
     705    $key       = $bbp_db->prefix . '_bbp_favorites';
    697706    $users     = $bbp_db->get_results( "SELECT `user_id`, `meta_value` AS `favorites` FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}'" );
    698707
Note: See TracChangeset for help on using the changeset viewer.