Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/13/2012 04:03:55 AM (14 years ago)
Author:
johnjamesjacoby
Message:

First pass at refactoring update/install wizard to remove code duplication:

  • Rename and move admin images, css, and js into bp-core/admin/ folders
  • Load the wizard from inside BP_Admin instead of selectively alone, so that basic functions are available
  • Properly enqueue admin scripts
  • Remove duplicated _update_ functions in bp-core-updater.php
  • Remove weird redirect hack as it's no longer needed
  • Remove purpose built functions that are no longer needed
  • See #4005.
  • Indirectly fixes #3964.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/admin/bp-core-schema.php

    r5683 r5749  
    11<?php
     2
    23// Exit if accessed directly
    34if ( !defined( 'ABSPATH' ) ) exit;
     
    1314
    1415    return '';
     16}
     17
     18function bp_core_install( $active_components = false ) {
     19
     20    if ( empty( $active_components ) )
     21        $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
     22
     23    // Core DB Tables
     24    bp_core_install_notifications();
     25
     26    // Activity Streams
     27    if ( !empty( $active_components['activity'] ) )
     28        bp_core_install_activity_streams();
     29
     30    // Friend Connections
     31    if ( !empty( $active_components['friends'] ) )
     32        bp_core_install_friends();
     33
     34    // Extensible Groups
     35    if ( !empty( $active_components['groups'] ) )
     36        bp_core_install_groups();
     37
     38    // Private Messaging
     39    if ( !empty( $active_components['messages'] ) )
     40        bp_core_install_private_messaging();
     41
     42    // Extended Profiles
     43    if ( !empty( $active_components['xprofile'] ) )
     44        bp_core_install_extended_profiles();
     45
     46    // Blog tracking
     47    if ( !empty( $active_components['blogs'] ) )
     48        bp_core_install_blog_tracking();
    1549}
    1650
     
    301335}
    302336
     337/**
     338 * I don't appear to be used anymore, but I'm here anyways. I was originally
     339 * used in olden days to update pre-1.1 schemas, but that was before we had
     340 * a legitimate update process. Keep me around just incase.
     341 *
     342 * @global WPDB $wpdb
     343 * @global BuddyPress $bp
     344 */
     345function bp_update_db_stuff() {
     346    global $wpdb, $bp;
     347
     348    $bp_prefix = bp_core_get_table_prefix();
     349
     350    // Rename the old user activity cached table if needed.
     351    if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp_prefix}bp_activity_user_activity_cached%'" ) )
     352        $wpdb->query( "RENAME TABLE {$bp_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );
     353
     354    // Rename fields from pre BP 1.2
     355    if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp->activity->table_name}%'" ) ) {
     356        if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_action'" ) ) {
     357            $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_action type varchar(75) NOT NULL" );
     358        }
     359
     360        if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_name'" ) ) {
     361            $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_name component varchar(75) NOT NULL" );
     362        }
     363    }
     364
     365    // On first installation - record all existing blogs in the system.
     366    if ( !(int) $bp->site_options['bp-blogs-first-install'] ) {
     367        bp_blogs_record_existing_blogs();
     368        bp_update_option( 'bp-blogs-first-install', 1 );
     369    }
     370
     371    if ( is_multisite() ) {
     372        bp_core_add_illegal_names();
     373    }
     374
     375    // Update and remove the message threads table if it exists
     376    if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp_prefix}bp_messages_threads%'" ) ) {
     377        if ( BP_Messages_Thread::update_tables() ) {
     378            $wpdb->query( "DROP TABLE {$bp_prefix}bp_messages_threads" );
     379        }
     380    }
     381
     382}
     383
    303384?>
Note: See TracChangeset for help on using the changeset viewer.