Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/22/2012 10:16:40 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Forum Visibility:

  • Prevent forum metaboxes from saving forum revisions as private/hidden.
  • Add repair function for private/hidden forums to Tools.
  • Add updater for 2.1.1, and run the visibility repair function.
  • Fixes #1891.
  • For 2.2 branch.
File:
1 edited

Legend:

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

    r3966 r4105  
    160160        0  => array( 'bbp-sync-topic-meta',        __( 'Recalculate the parent topic for each post',          'bbpress' ), 'bbp_admin_repair_topic_meta'               ),
    161161        5  => array( 'bbp-sync-forum-meta',        __( 'Recalculate the parent forum for each post',          'bbpress' ), 'bbp_admin_repair_forum_meta'               ),
    162         10 => array( 'bbp-forum-topics',           __( 'Count topics in each forum',                          'bbpress' ), 'bbp_admin_repair_forum_topic_count'        ),
    163         15 => array( 'bbp-forum-replies',          __( 'Count replies in each forum',                         'bbpress' ), 'bbp_admin_repair_forum_reply_count'        ),
    164         20 => array( 'bbp-topic-replies',          __( 'Count replies in each topic',                         'bbpress' ), 'bbp_admin_repair_topic_reply_count'        ),
    165         25 => array( 'bbp-topic-voices',           __( 'Count voices in each topic',                          'bbpress' ), 'bbp_admin_repair_topic_voice_count'        ),
    166         30 => array( 'bbp-topic-hidden-replies',   __( 'Count spammed & trashed replies in each topic',       'bbpress' ), 'bbp_admin_repair_topic_hidden_reply_count' ),
    167         35 => array( 'bbp-user-replies',           __( 'Count topics for each user',                          'bbpress' ), 'bbp_admin_repair_user_topic_count'         ),
    168         35 => array( 'bbp-user-topics',            __( 'Count replies for each user',                         'bbpress' ), 'bbp_admin_repair_user_reply_count'         ),
    169         40 => array( 'bbp-user-favorites',         __( 'Remove trashed topics from user favorites',           'bbpress' ), 'bbp_admin_repair_user_favorites'           ),
    170         45 => array( 'bbp-user-subscriptions',     __( 'Remove trashed topics from user subscriptions',       'bbpress' ), 'bbp_admin_repair_user_subscriptions'       ),
    171         50 => array( 'bbp-sync-all-topics-forums', __( 'Recalculate last activity in each topic and forum',   'bbpress' ), 'bbp_admin_repair_freshness'                )
     162        10 => array( 'bbp-sync-forum-visibility',  __( 'Recalculate private and hidden forums',               'bbpress' ), 'bbp_admin_repair_forum_visibility'         ),
     163        15 => array( 'bbp-forum-topics',           __( 'Count topics in each forum',                          'bbpress' ), 'bbp_admin_repair_forum_topic_count'        ),
     164        20 => array( 'bbp-forum-replies',          __( 'Count replies in each forum',                         'bbpress' ), 'bbp_admin_repair_forum_reply_count'        ),
     165        25 => array( 'bbp-topic-replies',          __( 'Count replies in each topic',                         'bbpress' ), 'bbp_admin_repair_topic_reply_count'        ),
     166        30 => array( 'bbp-topic-voices',           __( 'Count voices in each topic',                          'bbpress' ), 'bbp_admin_repair_topic_voice_count'        ),
     167        35 => array( 'bbp-topic-hidden-replies',   __( 'Count spammed & trashed replies in each topic',       'bbpress' ), 'bbp_admin_repair_topic_hidden_reply_count' ),
     168        40 => array( 'bbp-user-replies',           __( 'Count topics for each user',                          'bbpress' ), 'bbp_admin_repair_user_topic_count'         ),
     169        45 => array( 'bbp-user-topics',            __( 'Count replies for each user',                         'bbpress' ), 'bbp_admin_repair_user_reply_count'         ),
     170        50 => array( 'bbp-user-favorites',         __( 'Remove trashed topics from user favorites',           'bbpress' ), 'bbp_admin_repair_user_favorites'           ),
     171        55 => array( 'bbp-user-subscriptions',     __( 'Remove trashed topics from user subscriptions',       'bbpress' ), 'bbp_admin_repair_user_subscriptions'       ),
     172        60 => array( 'bbp-sync-all-topics-forums', __( 'Recalculate last activity in each topic and forum',   'bbpress' ), 'bbp_admin_repair_freshness'                )
    172173    );
    173174    ksort( $repair_list );
     
    679680    }
    680681   
     682    // Complete results
     683    $result = __( 'Complete!', 'bbpress' );
     684    return array( 0, sprintf( $statement, $result ) );
     685}
     686
     687/**
     688 * Recaches the private and hidden forums
     689 *
     690 * @since bbPress (r4104)
     691 *
     692 * @uses delete_option() to delete private and hidden forum pointers
     693 * @uses WP_Query() To query post IDs
     694 * @uses is_wp_error() To return if error occurred
     695 * @uses update_option() To update the private and hidden post ID pointers
     696 * @return array An array of the status code and the message
     697 */
     698function bbp_admin_repair_forum_visibility() {
     699
     700    $statement = __( 'Recalculating forum visibility … %s', 'bbpress' );
     701    $result    = __( 'Failed!', 'bbpress' );
     702
     703    // First, delete everything.
     704    delete_option( '_bbp_private_forums' );
     705    delete_option( '_bbp_hidden_forums'  );
     706
     707    // Next, get all the private and hidden forums
     708    $private_forums = new WP_Query( array(
     709        'suppress_filters' => true,
     710        'nopaging'         => true,
     711        'post_type'        => bbp_get_forum_post_type(),
     712        'post_status'      => bbp_get_private_status_id(),
     713        'fields'           => 'ids'
     714    ) );
     715    $hidden_forums = new WP_Query( array(
     716        'suppress_filters' => true,
     717        'nopaging'         => true,
     718        'post_type'        => bbp_get_forum_post_type(),
     719        'post_status'      => bbp_get_hidden_status_id(),
     720        'fields'           => 'ids'
     721    ) );
     722
     723    // Bail if queries returned errors
     724    if ( is_wp_error( $private_forums ) || is_wp_error( $hidden_forums ) )
     725        return array( 2, sprintf( $statement, $result ) );
     726
     727    update_option( '_bbp_private_forums', $private_forums->posts ); // Private forums
     728    update_option( '_bbp_hidden_forums',  $hidden_forums->posts  ); // Hidden forums
     729
    681730    // Complete results
    682731    $result = __( 'Complete!', 'bbpress' );
Note: See TracChangeset for help on using the changeset viewer.