Skip to:
Content

BuddyPress.org

Changeset 518 for trunk/bp-groups.php


Ignore:
Timestamp:
11/08/2008 12:50:13 PM (18 years ago)
Author:
apeatling
Message:

Updating DB tables to support UTF8 charset.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r514 r518  
    33
    44define ( 'BP_GROUPS_IS_INSTALLED', 1 );
    5 define ( 'BP_GROUPS_VERSION', '0.2.1' );
     5define ( 'BP_GROUPS_VERSION', '0.2.3' );
    66
    77include_once( 'bp-groups/bp-groups-classes.php' );
     
    2222        global $wpdb, $bp;
    2323       
     24        if ( !empty($wpdb->charset) )
     25                $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
     26       
    2427        $sql[] = "CREATE TABLE ". $bp['groups']['table_name'] ." (
    25                         id int(11) NOT NULL AUTO_INCREMENT,
     28                        id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    2629                        creator_id int(11) NOT NULL,
    2730                        name varchar(100) NOT NULL,
     
    3841                        avatar_thumb varchar(150) NOT NULL,
    3942                        avatar_full varchar(150) NOT NULL,
    40                 PRIMARY KEY id (id),
    4143                    KEY creator_id (creator_id),
    4244                    KEY status (status),
    4345                    KEY is_invitation_only (is_invitation_only)
    44                    );";
     46                   ) {$charset_collate};";
    4547       
    4648        $sql[] = "CREATE TABLE ". $bp['groups']['table_name_members'] ." (
    47                         id int(11) NOT NULL AUTO_INCREMENT,
     49                        id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    4850                        group_id int(11) NOT NULL,
    4951                        user_id int(11) NOT NULL,
     
    5456                        comments longtext NOT NULL,
    5557                        is_confirmed tinyint(1) NOT NULL DEFAULT '0',
    56                         PRIMARY KEY  (id),
    5758                        KEY group_id (group_id),
    5859                        KEY user_id (user_id),
    5960                        KEY inviter_id (inviter_id),
    6061                        KEY is_confirmed (is_confirmed)
    61                    );";
     62                   ) {$charset_collate};";
    6263
    6364        $sql[] = "CREATE TABLE ". $bp['groups']['table_name_groupmeta'] ." (
    64                         id int(11) NOT NULL AUTO_INCREMENT,
     65                        id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    6566                        group_id int(11) NOT NULL,
    6667                        meta_key varchar(255) DEFAULT NULL,
    6768                        meta_value longtext DEFAULT NULL,
    68                         PRIMARY KEY (id),
    6969                        KEY group_id (group_id),
    7070                        KEY meta_key (meta_key)
    71                    );";
     71                   ) {$charset_collate};";
    7272       
    7373        if ( function_exists('bp_wire_install') ) {
    7474                $sql[] = "CREATE TABLE ". $bp['groups']['table_name_wire'] ." (
    75                                 id int(11) NOT NULL AUTO_INCREMENT,
     75                                id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    7676                                item_id int(11) NOT NULL,
    7777                                user_id int(11) NOT NULL,
    7878                                content longtext NOT NULL,
    7979                                date_posted datetime NOT NULL,
    80                                 PRIMARY KEY id (id),
    8180                                KEY item_id (item_id),
    8281                                KEY user_id (user_id)
    83                            );";         
     82                           ) {$charset_collate};";             
    8483        }
    8584       
    8685        require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    8786        dbDelta($sql);
     87       
     88        // dbDelta won't change character sets, so we need to do this seperately.
     89        // This will only be in here pre v1.0
     90        $wpdb->query( $wpdb->prepare( "ALTER TABLE " . $bp['groups']['table_name'] . " DEFAULT CHARACTER SET %s", $wpdb->charset ) );
     91        $wpdb->query( $wpdb->prepare( "ALTER TABLE " . $bp['groups']['table_name_members'] . " DEFAULT CHARACTER SET %s", $wpdb->charset ) );
     92        $wpdb->query( $wpdb->prepare( "ALTER TABLE " . $bp['groups']['table_name_groupmeta'] . " DEFAULT CHARACTER SET %s", $wpdb->charset ) );
     93       
     94        if ( function_exists('bp_wire_install') )
     95                $wpdb->query( $wpdb->prepare( "ALTER TABLE " . $bp['groups']['table_name_wire'] . " DEFAULT CHARACTER SET %s", $wpdb->charset ) );             
    8896       
    8997        add_site_option( 'bp-groups-version', BP_GROUPS_VERSION );
     
    466474                                bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) );
    467475                        }
     476                        wp_redirect( bp_group_permalink( $group_obj, false ) );
    468477                }
    469478                bp_catch_uri( 'groups/request-membership' );
Note: See TracChangeset for help on using the changeset viewer.