<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[BuddyPress] [3186] branches/1.2: Fixes #2561 props wpmuguru</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>3186</dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2010-08-12 06:33:05 +0000 (Thu, 12 Aug 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fixes #2561 props wpmuguru</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches12bpactivityphp">branches/1.2/bp-activity.php</a></li>
<li><a href="#branches12bpblogsphp">branches/1.2/bp-blogs.php</a></li>
<li><a href="#branches12bpcorephp">branches/1.2/bp-core.php</a></li>
<li><a href="#branches12bpforumsbpforumsadminphp">branches/1.2/bp-forums/bp-forums-admin.php</a></li>
<li><a href="#branches12bpfriendsphp">branches/1.2/bp-friends.php</a></li>
<li><a href="#branches12bpgroupsphp">branches/1.2/bp-groups.php</a></li>
<li><a href="#branches12bpmessagesphp">branches/1.2/bp-messages.php</a></li>
<li><a href="#branches12bpxprofilephp">branches/1.2/bp-xprofile.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branches12bpactivityphp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-activity.php (3185 => 3186)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-activity.php        2010-08-12 05:45:09 UTC (rev 3185)
+++ branches/1.2/bp-activity.php        2010-08-12 06:33:05 UTC (rev 3186)
</span><span class="lines">@@ -73,14 +73,16 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_activity_setup_globals() {
</span><del>-        global $bp, $wpdb, $current_blog;
</del><ins>+        global $bp, $current_blog;
</ins><span class="cx">
</span><span class="cx">         /* Internal identifier */
</span><span class="cx">         $bp->activity->id = 'activity';
</span><span class="cx">
</span><del>-        $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity';
-        $bp->activity->table_name_meta = $wpdb->base_prefix . 'bp_activity_meta';
</del><span class="cx">         $bp->activity->slug = BP_ACTIVITY_SLUG;
</span><ins>+
+        $bp->activity->table_name = $bp->table_prefix . 'bp_activity';
+        $bp->activity->table_name_meta = $bp->table_prefix . 'bp_activity_meta';
+
</ins><span class="cx">         $bp->activity->format_notification_function = 'bp_activity_format_notifications';
</span><span class="cx">
</span><span class="cx">         /* Register this in the active components array */
</span><span class="lines">@@ -91,7 +93,7 @@
</span><span class="cx"> add_action( 'bp_setup_globals', 'bp_activity_setup_globals' );
</span><span class="cx">
</span><span class="cx"> function bp_activity_check_installed() {
</span><del>-        global $wpdb, $bp;
</del><ins>+        global $bp;
</ins><span class="cx">
</span><span class="cx">         if ( get_site_option( 'bp-activity-db-version' ) < BP_ACTIVITY_DB_VERSION )
</span><span class="cx">                 bp_activity_install();
</span><span class="lines">@@ -623,7 +625,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_activity_add( $args = '' ) {
</span><del>-        global $bp, $wpdb;
</del><ins>+        global $bp;
</ins><span class="cx">
</span><span class="cx">         $defaults = array(
</span><span class="cx">                 'id' => false, // Pass an existing activity ID to update an existing entry.
</span></span></pre></div>
<a id="branches12bpblogsphp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-blogs.php (3185 => 3186)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-blogs.php        2010-08-12 05:45:09 UTC (rev 3185)
+++ branches/1.2/bp-blogs.php        2010-08-12 06:33:05 UTC (rev 3186)
</span><span class="lines">@@ -68,11 +68,13 @@
</span><span class="cx">         /* For internal identification */
</span><span class="cx">         $bp->blogs->id = 'blogs';
</span><span class="cx">
</span><del>-        $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs';
-        $bp->blogs->table_name_blogmeta = $wpdb->base_prefix . 'bp_user_blogs_blogmeta';
-        $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
</del><span class="cx">         $bp->blogs->slug = BP_BLOGS_SLUG;
</span><span class="cx">
</span><ins>+        $bp->blogs->table_name = $bp->table_prefix . 'bp_user_blogs';
+        $bp->blogs->table_name_blogmeta = $bp->table_prefix . 'bp_user_blogs_blogmeta';
+
+        $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
+
</ins><span class="cx">         /* Register this in the active components array */
</span><span class="cx">         $bp->active_components[$bp->blogs->slug] = $bp->blogs->id;
</span><span class="cx">
</span></span></pre></div>
<a id="branches12bpcorephp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-core.php (3185 => 3186)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-core.php        2010-08-12 05:45:09 UTC (rev 3185)
+++ branches/1.2/bp-core.php        2010-08-12 06:33:05 UTC (rev 3186)
</span><span class="lines">@@ -84,13 +84,16 @@
</span><span class="cx"> * @uses bp_core_get_user_domain() Returns the domain for a user
</span><span class="cx"> */
</span><span class="cx"> function bp_core_setup_globals() {
</span><del>-        global $bp, $wpdb;
</del><ins>+        global $bp;
</ins><span class="cx">         global $current_user, $current_component, $current_action, $current_blog;
</span><span class="cx">         global $displayed_user_id;
</span><span class="cx">         global $action_variables;
</span><span class="cx">
</span><span class="cx">         $current_user = wp_get_current_user();
</span><span class="cx">
</span><ins>+        /* Get the base database prefix */
+        $bp->table_prefix = bp_core_get_table_prefix();
+
</ins><span class="cx">         /* The domain for the root of the site where the main blog resides */
</span><span class="cx">         $bp->root_domain = bp_core_get_root_domain();
</span><span class="cx">
</span><span class="lines">@@ -153,12 +156,12 @@
</span><span class="cx">         $bp->active_components = array();
</span><span class="cx">
</span><span class="cx">         /* Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar */
</span><del>-        $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['user-avatar-default'] );
</del><ins>+        $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['user-avatar-default'] );
</ins><span class="cx">         $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', 'identicon' );
</span><del>-        $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' );
</del><ins>+        $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' );
</ins><span class="cx">
</span><span class="cx">         /* Fetch the full name for the logged in and current user */
</span><del>-        $bp->loggedin_user->fullname = bp_core_get_user_displayname( $bp->loggedin_user->id );
</del><ins>+        $bp->loggedin_user->fullname = bp_core_get_user_displayname( $bp->loggedin_user->id );
</ins><span class="cx">         $bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id );
</span><span class="cx">
</span><span class="cx">         /* Used to determine if user has admin rights on current content. If the logged in user is viewing
</span><span class="lines">@@ -170,7 +173,7 @@
</span><span class="cx">         /* Used to determine if the logged in user is a moderator for the current content. */
</span><span class="cx">         $bp->is_item_mod = false;
</span><span class="cx">
</span><del>-        $bp->core->table_name_notifications = $wpdb->base_prefix . 'bp_notifications';
</del><ins>+        $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
</ins><span class="cx">
</span><span class="cx">         if ( !$bp->current_component && $bp->displayed_user->id )
</span><span class="cx">                 $bp->current_component = $bp->default_component;
</span><span class="lines">@@ -198,7 +201,20 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'bp_setup_root_components', 'bp_core_setup_root_uris' );
</span><span class="cx">
</span><ins>+/**
+ * bp_core_get_table_prefix()
+ *
+ * Allow filtering of database prefix. Intended for use in multinetwork installations.
+ *
+ * @global object $wpdb WordPress database object
+ * @return string Filtered database prefix
+ */
+function bp_core_get_table_prefix() {
+        global $wpdb;
</ins><span class="cx">
</span><ins>+        return apply_filters( 'bp_core_get_table_prefix', $wpdb->base_prefix );
+}
+
</ins><span class="cx"> /**
</span><span class="cx"> * bp_core_install()
</span><span class="cx"> *
</span><span class="lines">@@ -251,14 +267,13 @@
</span><span class="cx"> *
</span><span class="cx"> * @package BuddyPress Core
</span><span class="cx"> * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
</span><del>- * @global $wpdb WordPress DB access object.
</del><span class="cx"> * @global $current_user WordPress global variable containing current logged in user information
</span><span class="cx"> * @uses is_site_admin() returns true if the current user is a site admin, false if not
</span><span class="cx"> * @uses get_site_option() fetches the value for a meta_key in the wp_sitemeta table
</span><span class="cx"> * @uses bp_core_install() runs the installation of DB tables for the core component
</span><span class="cx"> */
</span><span class="cx"> function bp_core_check_installed() {
</span><del>-        global $wpdb, $bp;
</del><ins>+        global $bp;
</ins><span class="cx">
</span><span class="cx">         if ( !is_site_admin() )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -278,7 +293,6 @@
</span><span class="cx"> *
</span><span class="cx"> * @package BuddyPress Core
</span><span class="cx"> * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
</span><del>- * @global $wpdb WordPress DB access object.
</del><span class="cx"> * @uses is_site_admin() returns true if the current user is a site admin, false if not
</span><span class="cx"> * @uses add_submenu_page() WP function to add a submenu item
</span><span class="cx"> */
</span><span class="lines">@@ -933,7 +947,6 @@
</span><span class="cx"> *
</span><span class="cx"> * @package BuddyPress Core
</span><span class="cx"> * @param $username str Username to check.
</span><del>- * @global $wpdb WordPress DB access object.
</del><span class="cx"> * @return false on no match
</span><span class="cx"> * @return int the user ID of the matched user.
</span><span class="cx"> */
</span><span class="lines">@@ -975,12 +988,11 @@
</span><span class="cx"> *
</span><span class="cx"> * @package BuddyPress Core
</span><span class="cx"> * @param $username str Username to check.
</span><del>- * @global $wpdb WordPress DB access object.
</del><span class="cx"> * @return false on no match
</span><span class="cx"> * @return int the user ID of the matched user.
</span><span class="cx"> */
</span><span class="cx"> function bp_core_get_random_member() {
</span><del>-        global $bp, $wpdb;
</del><ins>+        global $bp;
</ins><span class="cx">
</span><span class="cx">         if ( isset( $_GET['random-member'] ) ) {
</span><span class="cx">                 $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) );
</span><span class="lines">@@ -1708,7 +1720,7 @@
</span><span class="cx"> * @uses get_site_option Checks if account deletion is allowed
</span><span class="cx"> */
</span><span class="cx"> function bp_core_delete_account( $user_id = false ) {
</span><del>-        global $bp, $wpdb, $wp_version;
</del><ins>+        global $bp, $wp_version;
</ins><span class="cx">
</span><span class="cx">         if ( !$user_id )
</span><span class="cx">                 $user_id = $bp->loggedin_user->id;
</span><span class="lines">@@ -1842,8 +1854,7 @@
</span><span class="cx"> * @package BuddyPress Core
</span><span class="cx"> */
</span><span class="cx"> function bp_core_print_generation_time() {
</span><del>-        global $wpdb;
-        ?>
</del><ins>+?>
</ins><span class="cx">
</span><span class="cx"> <!-- Generated in <?php timer_stop(1); ?> seconds. -->
</span><span class="cx">
</span></span></pre></div>
<a id="branches12bpforumsbpforumsadminphp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-forums/bp-forums-admin.php (3185 => 3186)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-forums/bp-forums-admin.php        2010-08-12 05:45:09 UTC (rev 3185)
+++ branches/1.2/bp-forums/bp-forums-admin.php        2010-08-12 06:33:05 UTC (rev 3186)
</span><span class="lines">@@ -121,7 +121,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_forums_bbpress_install() {
</span><del>-        global $wpdb, $bbdb;
</del><ins>+        global $wpdb, $bbdb, $bp;
</ins><span class="cx">
</span><span class="cx">         check_admin_referer( 'bp_forums_new_install_init' );
</span><span class="cx">
</span><span class="lines">@@ -140,7 +140,7 @@
</span><span class="cx">                         "define( 'BB_SECURE_A"                 => array( "'put your unique phrase here'", "'" . addslashes( SECURE_AUTH_KEY ) . "'" ),
</span><span class="cx">                         "define( 'BB_LOGGED_I"                 => array( "'put your unique phrase here'", "'" . addslashes( LOGGED_IN_KEY ) . "'" ),
</span><span class="cx">                         "define( 'BB_NONCE_KE"                 => array( "'put your unique phrase here'", "'" . addslashes( NONCE_KEY ) . "'" ),
</span><del>-                        "\$bb_table_prefix = '"                 => array( "'bb_'", "'" . $wpdb->base_prefix . "bb_'" ),
</del><ins>+                        "\$bb_table_prefix = '"                 => array( "'bb_'", "'" . $bp->table_prefix . "bb_'" ),
</ins><span class="cx">                         "define( 'BB_LANG', '"                         => array( "''",         "'" . WPLANG . "'" )
</span><span class="cx">                 )
</span><span class="cx">         );
</span></span></pre></div>
<a id="branches12bpfriendsphp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-friends.php (3185 => 3186)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-friends.php        2010-08-12 05:45:09 UTC (rev 3185)
+++ branches/1.2/bp-friends.php        2010-08-12 06:33:05 UTC (rev 3186)
</span><span class="lines">@@ -33,15 +33,17 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function friends_setup_globals() {
</span><del>-        global $bp, $wpdb;
</del><ins>+        global $bp;
</ins><span class="cx">
</span><span class="cx">         /* For internal identification */
</span><span class="cx">         $bp->friends->id = 'friends';
</span><span class="cx">
</span><del>-        $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends';
-        $bp->friends->format_notification_function = 'friends_format_notifications';
</del><span class="cx">         $bp->friends->slug = BP_FRIENDS_SLUG;
</span><span class="cx">
</span><ins>+        $bp->friends->table_name = $bp->table_prefix . 'bp_friends';
+
+        $bp->friends->format_notification_function = 'friends_format_notifications';
+
</ins><span class="cx">         /* Register this in the active components array */
</span><span class="cx">         $bp->active_components[$bp->friends->slug] = $bp->friends->id;
</span><span class="cx">
</span><span class="lines">@@ -50,7 +52,7 @@
</span><span class="cx"> add_action( 'bp_setup_globals', 'friends_setup_globals' );
</span><span class="cx">
</span><span class="cx"> function friends_check_installed() {
</span><del>-        global $wpdb, $bp;
</del><ins>+        global $bp;
</ins><span class="cx">
</span><span class="cx">         if ( !is_site_admin() )
</span><span class="cx">                 return false;
</span></span></pre></div>
<a id="branches12bpgroupsphp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-groups.php (3185 => 3186)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-groups.php        2010-08-12 05:45:09 UTC (rev 3185)
+++ branches/1.2/bp-groups.php        2010-08-12 06:33:05 UTC (rev 3186)
</span><span class="lines">@@ -74,12 +74,14 @@
</span><span class="cx">         /* For internal identification */
</span><span class="cx">         $bp->groups->id = 'groups';
</span><span class="cx">
</span><del>-        $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups';
-        $bp->groups->table_name_members = $wpdb->base_prefix . 'bp_groups_members';
-        $bp->groups->table_name_groupmeta = $wpdb->base_prefix . 'bp_groups_groupmeta';
-        $bp->groups->format_notification_function = 'groups_format_notifications';
</del><span class="cx">         $bp->groups->slug = BP_GROUPS_SLUG;
</span><span class="cx">
</span><ins>+        $bp->groups->table_name = $bp->table_prefix . 'bp_groups';
+        $bp->groups->table_name_members = $bp->table_prefix . 'bp_groups_members';
+        $bp->groups->table_name_groupmeta = $bp->table_prefix . 'bp_groups_groupmeta';
+
+        $bp->groups->format_notification_function = 'groups_format_notifications';
+
</ins><span class="cx">         /* Register this in the active components array */
</span><span class="cx">         $bp->active_components[$bp->groups->slug] = $bp->groups->id;
</span><span class="cx">
</span></span></pre></div>
<a id="branches12bpmessagesphp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-messages.php (3185 => 3186)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-messages.php        2010-08-12 05:45:09 UTC (rev 3185)
+++ branches/1.2/bp-messages.php        2010-08-12 06:33:05 UTC (rev 3186)
</span><span class="lines">@@ -66,17 +66,19 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function messages_setup_globals() {
</span><del>-        global $bp, $wpdb;
</del><ins>+        global $bp;
</ins><span class="cx">
</span><span class="cx">         /* For internal identification */
</span><span class="cx">         $bp->messages->id = 'messages';
</span><span class="cx">
</span><del>-        $bp->messages->table_name_messages = $wpdb->base_prefix . 'bp_messages_messages';
-        $bp->messages->table_name_recipients = $wpdb->base_prefix . 'bp_messages_recipients';
-        $bp->messages->table_name_notices = $wpdb->base_prefix . 'bp_messages_notices';
-        $bp->messages->format_notification_function = 'messages_format_notifications';
</del><span class="cx">         $bp->messages->slug = BP_MESSAGES_SLUG;
</span><span class="cx">
</span><ins>+        $bp->messages->table_name_notices = $bp->table_prefix . 'bp_messages_notices';
+        $bp->messages->table_name_messages = $bp->table_prefix . 'bp_messages_messages';
+        $bp->messages->table_name_recipients = $bp->table_prefix . 'bp_messages_recipients';
+
+        $bp->messages->format_notification_function = 'messages_format_notifications';
+
</ins><span class="cx">         /* Register this in the active components array */
</span><span class="cx">         $bp->active_components[$bp->messages->slug] = $bp->messages->id;
</span><span class="cx">
</span><span class="lines">@@ -85,7 +87,7 @@
</span><span class="cx"> add_action( 'bp_setup_globals', 'messages_setup_globals' );
</span><span class="cx">
</span><span class="cx"> function messages_check_installed() {
</span><del>-        global $wpdb, $bp;
</del><ins>+        global $bp;
</ins><span class="cx">
</span><span class="cx">         if ( !is_site_admin() )
</span><span class="cx">                 return false;
</span></span></pre></div>
<a id="branches12bpxprofilephp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-xprofile.php (3185 => 3186)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-xprofile.php        2010-08-12 05:45:09 UTC (rev 3185)
+++ branches/1.2/bp-xprofile.php        2010-08-12 06:33:05 UTC (rev 3186)
</span><span class="lines">@@ -104,12 +104,13 @@
</span><span class="cx">         /* For internal identification */
</span><span class="cx">         $bp->profile->id = 'profile';
</span><span class="cx">
</span><del>-        $bp->profile->table_name_groups = $wpdb->base_prefix . 'bp_xprofile_groups';
-        $bp->profile->table_name_fields = $wpdb->base_prefix . 'bp_xprofile_fields';
-        $bp->profile->table_name_data = $wpdb->base_prefix . 'bp_xprofile_data';
</del><ins>+        $bp->profile->slug = BP_XPROFILE_SLUG;
</ins><span class="cx">
</span><ins>+        $bp->profile->table_name_data = $bp->table_prefix . 'bp_xprofile_data';
+        $bp->profile->table_name_groups = $bp->table_prefix . 'bp_xprofile_groups';
+        $bp->profile->table_name_fields = $bp->table_prefix . 'bp_xprofile_fields';
+
</ins><span class="cx">         $bp->profile->format_notification_function = 'xprofile_format_notifications';
</span><del>-        $bp->profile->slug = BP_XPROFILE_SLUG;
</del><span class="cx">
</span><span class="cx">         /* Register this in the active components array */
</span><span class="cx">         $bp->active_components[$bp->profile->slug] = $bp->profile->id;
</span></span></pre>
</div>
</div>
</body>
</html>