Skip to:
Content

BuddyPress.org

Ticket #2789: 2789.008.patch

File 2789.008.patch, 10.2 KB (added by boonebgorges, 14 years ago)
  • bp-themes/bp-default/functions.php

     
    4040 * Temporary work-around to prevent errors with bp-default being active
    4141 * when BuddyPress is not installed.
    4242 */
    43 if ( !constant( 'BP_VERSION' ) || !get_site_option( 'bp-db-version' ) ) {
     43/*if ( !constant( 'BP_VERSION' ) || !get_site_option( 'bp-db-version' ) ) {
    4444        switch_theme( 'twentyten', 'twentyten' );
    4545        wp_redirect( $_SERVER['HTTP_REFERER'] );
    4646        exit;
    47 }
     47}*/
    4848
    4949if ( !function_exists( 'bp_dtheme_setup' ) ) :
    5050/**
  • bp-core/admin/bp-core-update.php

     
    11<?php
    22
    3 if ( !defined( 'BP_ROOT_BLOG' ) )
    4         define( 'BP_ROOT_BLOG', 1 );
    5 
    6 require_once( dirname( dirname( __FILE__ ) ) . '/bp-core-wpabstraction.php' );
    7 
    8 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
    9 
    10 // Install site options on activation
    11 bp_core_activate_site_options( array( 'bp-disable-account-deletion' => 0, 'bp-disable-avatar-uploads' => 0, 'bp-disable-blogforum-comments' => 0,  'bp-disable-forum-directory' => 0,  'bp-disable-profile-sync' => 0 ) );
    12 
    13 /**
    14  * bp_core_activate_site_options()
    15  *
    16  * When switching from single to multisite we need to copy blog options to
    17  * site options.
    18  *
    19  * @package BuddyPress Core
    20  */
    21 function bp_core_activate_site_options( $keys = array() ) {
    22         global $bp;
    23 
    24         $bp->site_options = bp_core_get_site_options();
    25 
    26         if ( !empty( $keys ) && is_array( $keys ) ) {
    27                 $errors = false;
    28 
    29                 foreach ( $keys as $key => $default ) {
    30                         if ( empty( $bp->site_options[ $key ] ) ) {
    31                                 $bp->site_options[ $key ] = get_blog_option( BP_ROOT_BLOG, $key, $default );
    32 
    33                                 if ( !update_site_option( $key, $bp->site_options[ $key ] ) )
    34                                         $errors = true;
    35                         }
    36                 }
    37 
    38                 if ( empty( $errors ) )
    39                         return true;
    40         }
    41 
    42         return false;
    43 }
    44 
    453class BP_Core_Setup_Wizard {
    464        var $current_step;
    475        var $steps;
     
    819777                        if ( $this->current_version < 1225 )
    820778                                $this->update_1_3();
    821779
     780                        // Update the DB version in the database
     781                        update_site_option( 'bp-db-version', constant( 'BP_DB_VERSION' ) );
     782                        delete_site_option( 'bp-core-db-version' );
     783
    822784                        return true;
    823785                }
    824786
     
    10451007        function step_finish_save() {
    10461008                if ( isset( $_POST['submit'] ) ) {
    10471009                        check_admin_referer( 'bpwizard_finish' );
    1048 
     1010                       
    10491011                        // Delete the setup cookie
    10501012                        @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH );
    10511013
     
    11831145}
    11841146
    11851147/**
    1186  * bp_core_add_admin_menu_page()
     1148 * bp_core_update_add_admin_menu_page()
    11871149 *
    11881150 * A better version of add_admin_menu_page() that allows positioning of menus.
    11891151 *
    11901152 * @package BuddyPress Core
    11911153 */
    1192 function bp_core_add_admin_menu_page( $args = '' ) {
     1154function bp_core_update_add_admin_menu_page( $args = '' ) {
    11931155        global $menu, $admin_page_hooks, $_registered_pages;
    11941156
    11951157        $defaults = array(
     
    12461208add_action( 'admin_footer', 'bp_core_wizard_thickbox' );
    12471209
    12481210/**
    1249  * bp_core_add_admin_menu()
     1211 * bp_core_update_add_admin_menu()
    12501212 *
    12511213 * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
    12521214 *
     
    12551217 * @global $wpdb WordPress DB access object.
    12561218 * @uses add_submenu_page() WP function to add a submenu item
    12571219 */
    1258 function bp_core_add_admin_menu() {
     1220function bp_core_update_add_admin_menu() {
    12591221        global $bp_wizard;
    12601222
     1223        // Only load this version of the menu if this is an upgrade or a new installation
     1224        if ( ( !defined( 'BP_IS_UPGRADE' ) || !BP_IS_UPGRADE ) && ( !defined( 'BP_IS_INSTALL' ) || !BP_IS_INSTALL ) )
     1225                return false;
     1226       
    12611227        if ( !current_user_can( 'activate_plugins' ) )
    12621228                return false;
    12631229
     
    12671233                $status = __( 'Update', 'buddypress' );
    12681234
    12691235        // Add the administration tab under the "Site Admin" tab for site administrators
    1270         bp_core_add_admin_menu_page( array(
     1236        bp_core_update_add_admin_menu_page( array(
    12711237                'menu_title'   => __( 'BuddyPress', 'buddypress' ),
    12721238                'page_title'   => __( 'BuddyPress', 'buddypress' ),
    12731239                'capability'   => 'manage_options',
     
    12791245        $hook = add_submenu_page( 'bp-wizard', $status, $status, 'manage_options', 'bp-wizard', array( $bp_wizard, 'html' ) );
    12801246
    12811247        // Add a hook for css/js
    1282         add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
     1248        add_action( "admin_print_styles-$hook", 'bp_core_update_add_admin_menu_styles' );
    12831249}
    1284 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu',  'bp_core_add_admin_menu', 9 );
     1250add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu',  'bp_core_update_add_admin_menu', 9 );
    12851251
    1286 function bp_core_add_admin_menu_styles() {
     1252function bp_core_update_add_admin_menu_styles() {
    12871253        if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )
    12881254                wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', plugins_url( $path = '/buddypress' ) . '/bp-core/css/admin.dev.css' ) );
    12891255        else
     
    13121278<?php
    13131279}
    13141280add_action( 'admin_head', 'bp_core_add_admin_menu_styles' );
     1281
     1282/**
     1283 * Adds an admin nag about running the BP upgrade/install wizard
     1284 *
     1285 * @package BuddyPress Core
     1286 * @since 1.3
     1287 * @global $pagenow The current admin page
     1288 */
     1289 function bp_core_update_nag() {
     1290        global $pagenow;
     1291       
     1292        if ( !is_super_admin() )
     1293                return;
     1294       
     1295        if ( 'admin.php' == $pagenow && ( empty( $_GET['page'] ) || 'bp-wizard' == $_GET['page'] ) )
     1296                return;
     1297       
     1298        if ( defined( 'BP_IS_UPGRADE' ) && BP_IS_UPGRADE )
     1299                $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">upgrade wizard</a>.', 'buddypress' ), admin_url( 'admin.php?page=bp-wizard' ) );
     1300        else if ( defined( 'BP_IS_INSTALL' ) && BP_IS_INSTALL )
     1301                $msg = sprintf( __( 'BuddyPress has been installed! Please run the <a href="%s">upgrade wizard</a>.', 'buddypress' ), admin_url( 'admin.php?page=bp-wizard' ) );
     1302                 
     1303        echo "<div class='update-nag'>$msg</div>";
     1304}
     1305add_action( 'admin_notices', 'bp_core_update_nag', 5 );
     1306
    13151307?>
     1308 No newline at end of file
  • bp-loader.php

     
    1010*/
    1111
    1212define( 'BP_VERSION', '1.3-bleeding' );
    13 define( 'BP_DB_VERSION', 1225 );
     13define( 'BP_DB_VERSION', 3704 );
    1414
    1515// Define on which blog ID BuddyPress should run
    1616if ( !defined( 'BP_ROOT_BLOG' ) )
    1717        define( 'BP_ROOT_BLOG', 1 );
    1818
    19 /***
    20  * Check if this is the first time BuddyPress has been loaded, or the first time
    21  * since an update. If so, load the install/update routine only.
    22  */
    23 if ( get_site_option( 'bp-db-version' ) < constant( 'BP_DB_VERSION' ) ) {
     19// Register BuddyPress themes contained within the bp-themes folder
     20register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
     21         
     22// Test to see whether this is a new installation or an upgraded version of BuddyPress
     23$bp_db_version = get_site_option( 'bp-db-version' );
     24if ( ! $bp_db_version )
     25        $bp_db_version = get_site_option( 'bp-core-db-version' );  // BP 1.2 option name
     26         
     27if ( ! $bp_db_version ) {
     28        // This is a new installation. Run the wizard before loading BP core files
     29        define( 'BP_IS_INSTALL', true );
    2430        require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' );
    25 
    26 /***
    27  * If the install or update routine is completed and everything is up to date
    28  * continue loading BuddyPress as normal.
    29  */
    3031} else {
    3132        /***
    3233         * This file will load in each BuddyPress component based on which
     
    6465        /* Extended Profiles */
    6566        if ( !isset( $bp_deactivated['bp-xprofile.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') )
    6667                include( BP_PLUGIN_DIR . '/bp-xprofile.php' );
     68               
     69        // If this is an upgrade, load the upgrade file
     70        if ( $bp_db_version < constant( 'BP_DB_VERSION' ) ) {
     71                define( 'BP_IS_UPGRADE', true );
     72                require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' );
     73        }
    6774
    6875        add_action( 'plugins_loaded', 'bp_loaded', 20 );
    6976}
     
    140147        return apply_filters( 'bp_core_get_site_options', $site_options );
    141148}
    142149
    143 /* Activation Function */
     150/**
     151 * Defines BP's activation routine.
     152 *
     153 * Most of BP's crucial setup is handled by the setup wizard. This function takes care of some
     154 * issues with incompatible legacy themes, and provides a hook for other functions to know that
     155 * BP has been activated.
     156 *
     157 * @package BuddyPress Core
     158 */
    144159function bp_loader_activate() {
    145160        /* Force refresh theme roots. */
    146161        delete_site_transient( 'theme_roots' );
    147162
     163        if ( !function_exists( 'get_blog_option' ) )
     164                require ( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-wpabstraction.php' );
     165
    148166        /* Switch the user to the new bp-default if they are using the old bp-default on activation. */
    149167        if ( 'bp-sn-parent' == get_blog_option( BP_ROOT_BLOG, 'template' ) && 'bp-default' == get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) )
    150168                switch_theme( 'bp-default', 'bp-default' );
  • bp-core.php

     
    4242if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )
    4343        require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' );
    4444
    45 /* Register BuddyPress themes contained within the bp-theme folder */
    46 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
    4745
    48 
    4946/* "And now for something completely different" .... */
    5047
    5148
     
    313310function bp_core_add_admin_menu() {
    314311        if ( !is_super_admin() )
    315312                return false;
     313       
     314        // Don't add this version of the admin menu if a BP upgrade is in progress
     315        // See bp_core_update_add_admin_menu()
     316        if ( defined( 'BP_IS_UPGRADE' ) && BP_IS_UPGRADE )
     317                return false;
    316318
    317319        // Add the administration tab under the "Site Admin" tab for site administrators
    318320        $hook = bp_core_add_admin_menu_page( array(
     
    19691971        } else {
    19701972                /* Get current theme info */
    19711973                $ct = current_theme_info();
    1972 
     1974               
    19731975                /* The best way to remove this notice is to add a "buddypress" tag to your active theme's CSS header. */
    19741976                if ( !defined( 'BP_SILENCE_THEME_NOTICE' ) && !in_array( 'buddypress', (array)$ct->tags ) ) { ?>
    19751977                        <div id="message" class="updated fade">