Ticket #3228: 3228.installer.diff
File 3228.installer.diff, 9.1 KB (added by , 13 years ago) |
---|
-
bp-core/admin/bp-core-schema.php
1 1 <?php 2 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' ); 3 2 4 function bp_core_set_charset() { 3 5 global $wpdb; 4 6 … … 15 17 global $wpdb; 16 18 17 19 $charset_collate = bp_core_set_charset(); 20 $bp_prefix = bp_core_get_table_prefix(); 18 21 19 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_notifications (22 $sql[] = "CREATE TABLE {$bp_prefix}bp_notifications ( 20 23 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 21 24 user_id bigint(20) NOT NULL, 22 25 item_id bigint(20) NOT NULL, … … 41 44 global $wpdb; 42 45 43 46 $charset_collate = bp_core_set_charset(); 47 $bp_prefix = bp_core_get_table_prefix(); 44 48 45 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_activity (49 $sql[] = "CREATE TABLE {$bp_prefix}bp_activity ( 46 50 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 47 51 user_id bigint(20) NOT NULL, 48 52 component varchar(75) NOT NULL, … … 67 71 KEY hide_sitewide (hide_sitewide) 68 72 ) {$charset_collate};"; 69 73 70 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_activity_meta (74 $sql[] = "CREATE TABLE {$bp_prefix}bp_activity_meta ( 71 75 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 72 76 activity_id bigint(20) NOT NULL, 73 77 meta_key varchar(255) DEFAULT NULL, … … 83 87 global $wpdb; 84 88 85 89 $charset_collate = bp_core_set_charset(); 90 $bp_prefix = bp_core_get_table_prefix(); 86 91 87 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_friends (92 $sql[] = "CREATE TABLE {$bp_prefix}bp_friends ( 88 93 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 89 94 initiator_user_id bigint(20) NOT NULL, 90 95 friend_user_id bigint(20) NOT NULL, … … 102 107 global $wpdb; 103 108 104 109 $charset_collate = bp_core_set_charset(); 110 $bp_prefix = bp_core_get_table_prefix(); 105 111 106 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_groups (112 $sql[] = "CREATE TABLE {$bp_prefix}bp_groups ( 107 113 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 108 114 creator_id bigint(20) NOT NULL, 109 115 name varchar(100) NOT NULL, … … 116 122 KEY status (status) 117 123 ) {$charset_collate};"; 118 124 119 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_groups_members (125 $sql[] = "CREATE TABLE {$bp_prefix}bp_groups_members ( 120 126 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 121 127 group_id bigint(20) NOT NULL, 122 128 user_id bigint(20) NOT NULL, … … 137 143 KEY is_confirmed (is_confirmed) 138 144 ) {$charset_collate};"; 139 145 140 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_groups_groupmeta (146 $sql[] = "CREATE TABLE {$bp_prefix}bp_groups_groupmeta ( 141 147 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 142 148 group_id bigint(20) NOT NULL, 143 149 meta_key varchar(255) DEFAULT NULL, … … 153 159 global $wpdb; 154 160 155 161 $charset_collate = bp_core_set_charset(); 162 $bp_prefix = bp_core_get_table_prefix(); 156 163 157 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_messages_messages (164 $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_messages ( 158 165 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 159 166 thread_id bigint(20) NOT NULL, 160 167 sender_id bigint(20) NOT NULL, … … 165 172 KEY thread_id (thread_id) 166 173 ) {$charset_collate};"; 167 174 168 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_messages_recipients (175 $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_recipients ( 169 176 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 170 177 user_id bigint(20) NOT NULL, 171 178 thread_id bigint(20) NOT NULL, … … 179 186 KEY unread_count (unread_count) 180 187 ) {$charset_collate};"; 181 188 182 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_messages_notices (189 $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_notices ( 183 190 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 184 191 subject varchar(200) NOT NULL, 185 192 message longtext NOT NULL, … … 195 202 global $wpdb; 196 203 197 204 $charset_collate = bp_core_set_charset(); 205 $bp_prefix = bp_core_get_table_prefix(); 198 206 199 207 update_site_option( 'bp-xprofile-base-group-name', _x( 'Base', 'First XProfile group name', 'buddypress' ) ); 200 208 update_site_option( 'bp-xprofile-fullname-field-name', _x( 'Name', 'XProfile fullname field name', 'buddypress' ) ); 201 209 202 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_xprofile_groups (210 $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_groups ( 203 211 id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, 204 212 name varchar(150) NOT NULL, 205 213 description mediumtext NOT NULL, … … 208 216 KEY can_delete (can_delete) 209 217 ) {$charset_collate};"; 210 218 211 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_xprofile_fields (219 $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_fields ( 212 220 id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, 213 221 group_id bigint(20) unsigned NOT NULL, 214 222 parent_id bigint(20) unsigned NOT NULL, … … 228 236 KEY is_required (is_required) 229 237 ) {$charset_collate};"; 230 238 231 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_xprofile_data (239 $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_data ( 232 240 id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, 233 241 field_id bigint(20) unsigned NOT NULL, 234 242 user_id bigint(20) unsigned NOT NULL, … … 238 246 KEY user_id (user_id) 239 247 ) {$charset_collate};"; 240 248 241 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_xprofile_meta (249 $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_meta ( 242 250 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 243 251 object_id bigint(20) NOT NULL, 244 252 object_type varchar(150) NOT NULL, … … 253 261 // Insert the default group and fields 254 262 $insert_sql = array(); 255 263 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 );";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 );"; 258 266 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 );";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 );"; 261 269 262 270 dbDelta( $insert_sql ); 263 271 } … … 266 274 global $wpdb; 267 275 268 276 $charset_collate = bp_core_set_charset(); 277 $bp_prefix = bp_core_get_table_prefix(); 269 278 270 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_user_blogs (279 $sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs ( 271 280 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 272 281 user_id bigint(20) NOT NULL, 273 282 blog_id bigint(20) NOT NULL, … … 275 284 KEY blog_id (blog_id) 276 285 ) {$charset_collate};"; 277 286 278 $sql[] = "CREATE TABLE {$ wpdb->base_prefix}bp_user_blogs_blogmeta (287 $sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs_blogmeta ( 279 288 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 280 289 blog_id bigint(20) NOT NULL, 281 290 meta_key varchar(255) DEFAULT NULL, -
bp-core/admin/bp-core-update.php
1098 1098 } 1099 1099 1100 1100 function bp_update_db_stuff() { 1101 $bp_prefix = bp_core_get_table_prefix(); 1101 1102 // Rename the old user activity cached table if needed. 1102 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$ wpdb->base_prefix}bp_activity_user_activity_cached%'" ) )1103 $wpdb->query( "RENAME TABLE {$ wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );1103 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp_prefix}bp_activity_user_activity_cached%'" ) ) 1104 $wpdb->query( "RENAME TABLE {$bp_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" ); 1104 1105 1105 1106 // Rename fields from pre BP 1.2 1106 1107 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp->activity->table_name}%'" ) ) { … … 1121 1122 bp_core_add_illegal_names(); 1122 1123 1123 1124 // Update and remove the message threads table if it exists 1124 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$ wpdb->base_prefix}bp_messages_threads%'" ) ) {1125 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp_prefix}bp_messages_threads%'" ) ) { 1125 1126 $update = BP_Messages_Thread::update_tables(); 1126 1127 1127 1128 if ( $update ) 1128 $wpdb->query( "DROP TABLE {$ wpdb->base_prefix}bp_messages_threads" );1129 $wpdb->query( "DROP TABLE {$bp_prefix}bp_messages_threads" ); 1129 1130 } 1130 1131 1131 1132 }