Skip to:
Content

BuddyPress.org

Ticket #3445: 3445-1.patch

File 3445-1.patch, 9.8 KB (added by DJPaul, 13 years ago)
  • bp-core/bp-core-loader.php

     
    5757                /** Components ********************************************************/
    5858
    5959                // Set the included and optional components.
    60                 $bp->optional_components = array( 'activity', 'forums', 'friends', 'groups', 'messages', 'settings', 'xprofile' );
     60                $bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'forums', 'friends', 'groups', 'messages', 'settings', 'xprofile' ) );
    6161
    62                 // Blogs component only available for multisite
    63                 if ( is_multisite() )
    64                         $bp->optional_components[] = 'blogs';
    65 
    66                 $bp->optional_components    = apply_filters( 'bp_optional_components', $bp->optional_components );
    67 
    6862                // Set the required components
    69                 $bp->required_components    = apply_filters( 'bp_required_components', array( 'members' ) );
     63                $bp->required_components = apply_filters( 'bp_required_components', array( 'members' ) );
    7064
    7165                // Get a list of activated components
    7266                if ( $active_components = bp_get_option( 'bp-active-components' ) ) {
  • bp-core/bp-core-functions.php

     
    352352         * wizard because of the order which the components are loaded. We check for multisite here
    353353         * on the off chance that someone has activated the blogs component and then disabled MS
    354354         */
    355         if ( is_multisite() && bp_is_active( 'blogs' ) ) {
     355        if ( bp_is_active( 'blogs' ) ) {
    356356                $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$bp->blogs->table_name}" ) );
    357357
    358358                if ( !$count )
     
    14641464        if ( 'remove_canonical_direct' == $redirect )
    14651465                remove_action( 'template_redirect', 'redirect_canonical' );
    14661466}
    1467 ?>
     1467?>
     1468 No newline at end of file
  • bp-core/admin/bp-core-admin.php

     
    1313add_action( 'in_plugin_update_message-buddypress/bp-loader.php', 'bp_core_update_message' );
    1414
    1515/**
    16  * Renders the main admin panel.
    17  *
    18  * @package BuddyPress Core
    19  * @since {@internal Unknown}}
    20  */
    21 function bp_core_admin_dashboard() {
    22         $base_url = bp_get_admin_url( 'admin.php' );
    23         $action   = add_query_arg( array( 'page' => 'bp-general-settings' ), $base_url );
    24         ?>
    25 
    26         <div class="wrap" id="bp-admin">
    27 
    28                 <div id="bp-admin-header">
    29                         <h3><?php _e( 'BuddyPress', 'buddypress' ); ?></h3>
    30                         <h2><?php _e( 'Dashboard',  'buddypress' ); ?></h2>
    31                 </div>
    32 
    33                 <?php do_action( 'bp_admin_notices' ); ?>
    34 
    35                 <form action="<?php echo $action ?>" method="post" id="bp-admin-form">
    36                         <div id="bp-admin-content">
    37                                 <p>[TODO: All sorts of awesome things will go here. Latest plugins and themes, stats, version check, support topics, news, tips]</p>
    38                         </div>
    39                 </form>
    40 
    41         </div>
    42 
    43 <?php
    44 }
    45 
    46 /**
    4716 * Renders the Settings admin panel.
    4817 *
    4918 * @package BuddyPress Core
     
    366335                'forums' => array(
    367336                        'title'       => __( 'Discussion Forums', 'buddypress' ),
    368337                        'description' => __( 'Full powered discussion forums built directly into groups allow for more conventional in-depth conversations. NOTE: This will require an extra (but easy) setup step.', 'buddypress' )
     338                ),
     339                'blogs' => array(
     340                        'title'       => __( 'Site Tracking', 'buddypress' ),
     341                        'description' => __( 'Track new posts and new comments across your entire site.', 'buddypress' )
    369342                )
    370343        ) );
    371344
    372         if ( is_multisite() ) {
    373                 $optional_components['blogs'] = array(
    374                         'title'       => __( 'Site Tracking', 'buddypress' ),
    375                         'description' => __( 'Track new sites, new posts and new comments across your entire network.', 'buddypress' )
    376                 );
    377         }
     345        if ( is_multisite() )
     346                $optional_components['blogs']['description'] = __( 'Track new sites, new posts and new comments across your entire network.', 'buddypress' );
    378347
    379348        // Required components
    380349        $required_components = apply_filters( 'bp_admin_required_components', array(
     
    620589        wp_enqueue_style( 'thickbox' );
    621590}
    622591
    623 ?>
     592?>
     593 No newline at end of file
  • bp-core/admin/bp-core-update.php

     
    301301                        <tr valign="top">
    302302                                <th scope="row">
    303303                                        <h5><?php _e( 'Sites', 'buddypress' ); ?></h5>
    304                                         <p><?php _e( 'Displays individual groups as well as a directory of groups.', 'buddypress' ); ?></p>
     304                                        <p><?php _e( 'Displays individual sites as well as a directory of sites (multisite only).', 'buddypress' ); ?></p>
    305305                                </th>
    306306                                <td>
    307307                                        <p><input type="radio" name="bp_pages[blogs]" checked="checked" value="<?php echo $blogs_slug; ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ); ?> <?php echo site_url( $blogs_slug ); ?>/</p>
     
    471471                                <tr valign="top">
    472472                                        <th scope="row">
    473473                                                <h5><?php _e( 'Forums', 'buddypress' ); ?></h5>
    474                                                 <p><?php _e( 'Displays individual groups as well as a directory of groups.', 'buddypress' ); ?></p>
     474                                                <p><?php _e( 'Displays individual forums as well as a directory of forums.', 'buddypress' ); ?></p>
    475475                                        </th>
    476476                                        <td>
    477477                                                <p><label><input type="radio" name="bp_pages[forums]" <?php checked( empty( $existing_pages['forums'] ) ); ?>  value="<?php echo $forums_slug; ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ); ?> <?php echo home_url( $forums_slug ); ?>/</label></p>
     
    481481
    482482                        <?php endif; ?>
    483483
    484                         <?php if ( is_multisite() && isset( $active_components['blogs'] ) ) : ?>
     484                        <?php if ( isset( $active_components['blogs'] ) ) : ?>
    485485
    486486                                <tr valign="top">
    487487                                        <th scope="row">
    488488                                                <h5><?php _e( 'Sites', 'buddypress' ); ?></h5>
    489                                                 <p><?php _e( 'Displays individual groups as well as a directory of groups.', 'buddypress' ); ?></p>
     489                                                <p><?php _e( 'Displays individual sites as well as a directory of sites (multisite only).', 'buddypress' ); ?></p>
    490490                                        </th>
    491491                                        <td>
    492492                                                <p><label><input type="radio" name="bp_pages[blogs]" <?php checked( empty( $existing_pages['blogs'] ) ); ?>  value="<?php echo $blogs_slug; ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ); ?> <?php echo home_url( $blogs_slug ); ?>/</label></p>
     
    10221022                        // Load BP and hook the admin menu, so that the redirect is successful
    10231023                        if ( !function_exists( 'bp_core_update_message' ) )
    10241024                                require( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-admin.php' );
     1025
    10251026                        bp_core_add_admin_menu();
    10261027
    10271028                        // Redirect to the BuddyPress dashboard
     
    11091110        if ( !empty( $active_components['xprofile'] ) )
    11101111                bp_core_install_extended_profiles();
    11111112
    1112         // Only install blog tables if this is a multisite installation
    1113         if ( is_multisite() && !empty( $active_components['blogs'] ) )
     1113        // Blog tracking
     1114        if ( !empty( $active_components['blogs'] ) )
    11141115                bp_core_install_blog_tracking();
    11151116}
    11161117
     
    11361137        }
    11371138
    11381139        // On first installation - record all existing blogs in the system.
    1139         if ( !(int)$bp->site_options['bp-blogs-first-install'] && is_multisite() ) {
     1140        if ( !(int)$bp->site_options['bp-blogs-first-install'] ) {
    11401141                bp_blogs_record_existing_blogs();
    11411142                bp_update_option( 'bp-blogs-first-install', 1 );
    11421143        }
     
    13211322add_action( 'admin_notices', 'bp_core_update_nag', 5 );
    13221323add_action( 'network_admin_notices', 'bp_core_update_nag', 5 );
    13231324
    1324 ?>
     1325?>
     1326 No newline at end of file
  • bp-blogs/bp-blogs-functions.php

     
    4949        // Truncate user blogs table and re-record.
    5050        $wpdb->query( "TRUNCATE TABLE {$bp->blogs->table_name}" );
    5151
    52         $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE mature = 0 AND spam = 0 AND deleted = 0" ) );
     52        if ( is_multisite() )
     53                $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE mature = 0 AND spam = 0 AND deleted = 0" ) );
     54        else
     55                $blog_ids = array( 1 );
    5356
    54         if ( $blog_ids ) {
    55                 foreach( (array)$blog_ids as $blog_id ) {
    56                         $users          = get_users( array( 'blog_id' => $blog_id ) );
    57                         $subscribers    = get_users( array( 'blog_id' => $blog_id, 'role' => 'subscriber' ) );
    58                        
    59                         if ( $users ) {
    60                                 foreach ( (array)$users as $user ) {
    61                                         // Don't record blogs for subscribers
    62                                         if ( !in_array( $user, $subscribers ) )
    63                                                 bp_blogs_record_blog( $blog_id, $user->ID, true );
    64                                 }
     57        foreach( (array) $blog_ids as $blog_id ) {
     58                $users       = get_users( array( 'blog_id' => $blog_id ) );
     59                $subscribers = get_users( array( 'blog_id' => $blog_id, 'role' => 'subscriber' ) );
     60               
     61                if ( !empty( $users ) ) {
     62                        foreach ( (array)$users as $user ) {
     63                                // Don't record blogs for subscribers
     64                                if ( !in_array( $user, $subscribers ) )
     65                                        bp_blogs_record_blog( $blog_id, $user->ID, true );
    6566                        }
    6667                }
    6768        }
     
    454455function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) {
    455456        global $wpdb, $bp;
    456457
    457         if ( !is_numeric( $blog_id ) || !is_multisite() )
     458        if ( !is_numeric( $blog_id ) )
    458459                return false;
    459460
    460461        $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
     
    481482
    482483        $blog_id = (int) $blog_id;
    483484
    484         if ( !$blog_id || !is_multisite() )
     485        if ( !$blog_id )
    485486                return false;
    486487
    487488        if ( !empty($meta_key) ) {
     
    513514function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
    514515        global $wpdb, $bp;
    515516
    516         if ( !is_numeric( $blog_id ) || !is_multisite() )
     517        if ( !is_numeric( $blog_id ) )
    517518                return false;
    518519
    519520        $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );