Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/19/2011 05:01:39 PM (15 years ago)
Author:
boonebgorges
Message:

Modifies schema queries to use the filtered bp_core_get_table_prefix(). Fixes #3228. Props wpmuguru

File:
1 edited

Legend:

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

    r3771 r4391  
    11<?php
     2require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );
     3 
    24function bp_core_set_charset() {
    35        global $wpdb;
    … …  
    1618
    1719        $charset_collate = bp_core_set_charset();
    18 
    19         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_notifications (
     20        $bp_prefix = bp_core_get_table_prefix();
     21
     22        $sql[] = "CREATE TABLE {$bp_prefix}bp_notifications (
    2023                            id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    2124                            user_id bigint(20) NOT NULL,
    … …  
    4245
    4346        $charset_collate = bp_core_set_charset();
    44 
    45         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_activity (
     47        $bp_prefix = bp_core_get_table_prefix();
     48
     49        $sql[] = "CREATE TABLE {$bp_prefix}bp_activity (
    4650                                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    4751                                user_id bigint(20) NOT NULL,
    … …  
    6872                           ) {$charset_collate};";
    6973
    70         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_activity_meta (
     74        $sql[] = "CREATE TABLE {$bp_prefix}bp_activity_meta (
    7175                                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    7276                                activity_id bigint(20) NOT NULL,
    … …  
    8488
    8589        $charset_collate = bp_core_set_charset();
    86 
    87         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_friends (
     90        $bp_prefix = bp_core_get_table_prefix();
     91
     92        $sql[] = "CREATE TABLE {$bp_prefix}bp_friends (
    8893                            id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    8994                            initiator_user_id bigint(20) NOT NULL,
    … …  
    103108
    104109        $charset_collate = bp_core_set_charset();
    105 
    106         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_groups (
     110        $bp_prefix = bp_core_get_table_prefix();
     111
     112        $sql[] = "CREATE TABLE {$bp_prefix}bp_groups (
    107113                                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    108114                                creator_id bigint(20) NOT NULL,
    … …  
    117123                           ) {$charset_collate};";
    118124
    119         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_groups_members (
     125        $sql[] = "CREATE TABLE {$bp_prefix}bp_groups_members (
    120126                                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    121127                                group_id bigint(20) NOT NULL,
    … …  
    138144                           ) {$charset_collate};";
    139145
    140         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_groups_groupmeta (
     146        $sql[] = "CREATE TABLE {$bp_prefix}bp_groups_groupmeta (
    141147                                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    142148                                group_id bigint(20) NOT NULL,
    … …  
    154160
    155161        $charset_collate = bp_core_set_charset();
    156 
    157         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_messages_messages (
     162        $bp_prefix = bp_core_get_table_prefix();
     163
     164        $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_messages (
    158165                                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    159166                                thread_id bigint(20) NOT NULL,
    … …  
    166173                           ) {$charset_collate};";
    167174
    168         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_messages_recipients (
     175        $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_recipients (
    169176                                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    170177                                user_id bigint(20) NOT NULL,
    … …  
    180187                           ) {$charset_collate};";
    181188
    182         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_messages_notices (
     189        $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_notices (
    183190                                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    184191                                subject varchar(200) NOT NULL,
    … …  
    196203
    197204        $charset_collate = bp_core_set_charset();
     205        $bp_prefix = bp_core_get_table_prefix();
    198206
    199207        update_site_option( 'bp-xprofile-base-group-name', _x( 'Base', 'First XProfile group name', 'buddypress' ) );
    200208        update_site_option( 'bp-xprofile-fullname-field-name', _x( 'Name', 'XProfile fullname field name', 'buddypress' ) );
    201209
    202         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_xprofile_groups (
     210        $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_groups (
    203211                            id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    204212                            name varchar(150) NOT NULL,
    … …  
    209217                           ) {$charset_collate};";
    210218
    211         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_xprofile_fields (
     219        $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_fields (
    212220                            id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    213221                            group_id bigint(20) unsigned NOT NULL,
    … …  
    229237                           ) {$charset_collate};";
    230238
    231         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_xprofile_data (
     239        $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_data (
    232240                            id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    233241                            field_id bigint(20) unsigned NOT NULL,
    … …  
    239247                           ) {$charset_collate};";
    240248
    241         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_xprofile_meta (
     249        $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_meta (
    242250                                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    243251                                object_id bigint(20) NOT NULL,
    … …  
    254262        $insert_sql = array();
    255263
    256         if ( !$wpdb->get_var( "SELECT id FROM {$wpdb->base_prefix}bp_xprofile_groups WHERE id = 1" ) )
    257                 $insert_sql[] = "INSERT INTO {$wpdb->base_prefix}bp_xprofile_groups ( name, description, can_delete ) VALUES ( " . $wpdb->prepare( '%s', stripslashes( get_site_option( 'bp-xprofile-base-group-name' ) ) ) . ", '', 0 );";
    258 
    259         if ( !$wpdb->get_var( "SELECT id FROM {$wpdb->base_prefix}bp_xprofile_fields WHERE id = 1" ) )
    260                 $insert_sql[] = "INSERT INTO {$wpdb->base_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( get_site_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
     264        if ( !$wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_groups WHERE id = 1" ) )
     265                $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_groups ( name, description, can_delete ) VALUES ( " . $wpdb->prepare( '%s', stripslashes( get_site_option( 'bp-xprofile-base-group-name' ) ) ) . ", '', 0 );";
     266
     267        if ( !$wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1" ) )
     268                $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( get_site_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
    261269
    262270        dbDelta( $insert_sql );
    … …  
    267275
    268276        $charset_collate = bp_core_set_charset();
    269 
    270         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_user_blogs (
     277        $bp_prefix = bp_core_get_table_prefix();
     278
     279        $sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs (
    271280                            id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    272281                            user_id bigint(20) NOT NULL,
    … …  
    276285                       ) {$charset_collate};";
    277286
    278         $sql[] = "CREATE TABLE {$wpdb->base_prefix}bp_user_blogs_blogmeta (
     287        $sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs_blogmeta (
    279288                                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    280289                                blog_id bigint(20) NOT NULL,
Note: See TracChangeset for help on using the changeset viewer.