Skip to:
Content

bbPress.org


Ignore:
Timestamp:
05/22/2012 08:00:55 AM (10 years ago)
Author:
johnjamesjacoby
Message:

User Options:

  • Introduce bbp-user-options.php to handle all user option related code.
  • Add $user_options array to main bbPress class to allow for easy, static, per-user option overrides.
  • Tweak action order for option and user_option overrides in bbp-core-hooks.php.
  • Replace all appropriate user_meta calls with user_option calls to automatically prefix keys with blog ID.
  • Update favorites, subscriptions, and topic/reply count option keys to be per-blog in multisite configurations.
  • Fixes #1826.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-admin/bbp-tools.php

    r3890 r3911  
    385385        return array( 1, sprintf( $statement, $result ) );
    386386
     387    $key           = $wpdb->prefix . '_bbp_topic_count';
    387388    $insert_values = array();
    388389    foreach ( $insert_rows as $insert_row )
    389         $insert_values[] = "('{$insert_row->post_author}', '_bbp_topic_count', '{$insert_row->_count}')";
     390        $insert_values[] = "('{$insert_row->post_author}', '{$key}', '{$insert_row->_count}')";
    390391
    391392    if ( !count( $insert_values ) )
    392393        return array( 2, sprintf( $statement, $result ) );
    393394
    394     $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` = '_bbp_topic_count';";
     395    $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` = '{$key}';";
    395396    if ( is_wp_error( $wpdb->query( $sql_delete ) ) )
    396397        return array( 3, sprintf( $statement, $result ) );
     
    431432        return array( 1, sprintf( $statement, $result ) );
    432433
     434    $key           = $wpdb->prefix . '_bbp_reply_count';
    433435    $insert_values = array();
    434436    foreach ( $insert_rows as $insert_row )
    435         $insert_values[] = "('{$insert_row->post_author}', '_bbp_reply_count', '{$insert_row->_count}')";
     437        $insert_values[] = "('{$insert_row->post_author}', '{$key}', '{$insert_row->_count}')";
    436438
    437439    if ( !count( $insert_values ) )
    438440        return array( 2, sprintf( $statement, $result ) );
    439441
    440     $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` = '_bbp_reply_count';";
     442    $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` = '{$key}';";
    441443    if ( is_wp_error( $wpdb->query( $sql_delete ) ) )
    442444        return array( 3, sprintf( $statement, $result ) );
     
    471473    $statement = __( 'Removing trashed topics from user favorites… %s', 'bbpress' );
    472474    $result    = __( 'Failed!', 'bbpress' );
    473     $key       = bbp_get_favorites_key();
     475    $key       = $wpdb->prefix . '_bbp_favorites';
    474476    $users     = $wpdb->get_results( "SELECT `user_id`, `meta_value` AS `favorites` FROM `{$wpdb->usermeta}` WHERE `meta_key` = '{$key}';" );
    475477
     
    531533    $statement = __( 'Removing trashed topics from user subscriptions… %s', 'bbpress' );
    532534    $result    = __( 'Failed!', 'bbpress' );
    533     $key       = bbp_get_subscriptions_key();
     535    $key       = $wpdb->prefix . '_bbp_subscriptions';
    534536    $users     = $wpdb->get_results( "SELECT `user_id`, `meta_value` AS `subscriptions` FROM `{$wpdb->usermeta}` WHERE `meta_key` = '{$key}';" );
    535537
Note: See TracChangeset for help on using the changeset viewer.