Commit 863cafed authored by lechuck's avatar lechuck Committed by lucha

Upgrade buddypress to 2.0.1

parent bad356f4
......@@ -852,3 +852,68 @@ function bp_blogs_activity_comment_permalink( $retval ) {
return $retval;
}
add_filter( 'bp_get_activity_comment_permalink', 'bp_blogs_activity_comment_permalink' );
/**
* Changes single activity comment entries to use the blog comment permalink.
*
* This is only done if the activity comment is associated with a blog comment.
*
* @since BuddyPress (2.0.1)
*
* @param string $retval The activity permalink
* @param BP_Activity_Activity $activity
* @return string
*/
function bp_blogs_activity_comment_single_permalink( $retval, $activity ) {
if ( 'activity_comment' !== $activity->type ) {
return $retval;
}
$blog_comment_id = bp_activity_get_meta( $activity->id, 'bp_blogs_post_comment_id' );
if ( ! empty( $blog_comment_id ) ) {
$retval = $activity->primary_link;
}
return $retval;
}
add_filter( 'bp_activity_get_permalink', 'bp_blogs_activity_comment_single_permalink', 10, 2 );
/**
* Formats single activity comment entries to use the blog comment action.
*
* This is only done if the activity comment is associated with a blog comment.
*
* @since BuddyPress (2.0.1)
*
* @param string $retval The activity action
* @param BP_Activity_Activity $activity
* @return string
*/
function bp_blogs_activity_comment_single_action( $retval, $activity ) {
if ( 'activity_comment' !== $activity->type ) {
return $retval;
}
$blog_comment_id = bp_activity_get_meta( $activity->id, 'bp_blogs_post_comment_id' );
if ( ! empty( $blog_comment_id ) ) {
// fetch the parent blog post activity item
$parent_blog_post_activity = new BP_Activity_Activity( $activity->item_id );
// fake a 'new_blog_comment' activity object
$object = $activity;
// override 'item_id' to use blog ID
$object->item_id = $parent_blog_post_activity->item_id;
// override 'secondary_item_id' to use comment ID
$object->secondary_item_id = $blog_comment_id;
// now format the activity action using the 'new_blog_comment' action callback
$retval = bp_blogs_format_activity_action_new_blog_comment( '', $object );
}
return $retval;
}
add_filter( 'bp_get_activity_action_pre_meta', 'bp_blogs_activity_comment_single_action', 10, 2 );
......@@ -540,6 +540,11 @@ function bp_blogs_update_post( $post ) {
* @return bool|object Returns false on failure, the comment object on success.
*/
function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
// bail if activity component is not active
if ( ! bp_is_active( 'activity' ) ) {
return;
}
// Get the users comment
$recorded_comment = get_comment( $comment_id );
......
......@@ -276,8 +276,6 @@ function bp_core_activation_notice() {
'id' => 'register',
'name' => __( 'Register', 'buddypress' )
);
bp_core_maybe_install_signups();
}
// On the first admin screen after a new installation, this isn't set, so grab it to supress a misleading error message.
......@@ -793,39 +791,6 @@ function bp_admin_wp_nav_menu_restrict_items() {
<?php
}
/**
* Check if the signups table needs to be created.
*
* @since BuddyPress (2.0.0)
*
* @global $wpdb
*/
function bp_core_maybe_install_signups() {
global $wpdb;
// Multisite installations already have the signups table.
if ( ! empty( $wpdb->signups ) ) {
return;
}
$bp_signups = bp_core_get_table_prefix() . 'signups';
// Check for the table
$suppress = $wpdb->suppress_errors();
$table_exists = $wpdb->get_results( "DESCRIBE {$bp_signups};" );
$wpdb->suppress_errors( $suppress );
// Bail if the table exists
if ( ! empty( $table_exists ) ) {
return;
}
// Signups is not there and we need it so let's create it
require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-schema.php' );
bp_core_install_signups();
}
/**
* Add "Mark as Spam/Ham" button to user row actions.
*
......
......@@ -51,9 +51,8 @@ function bp_core_install( $active_components = false ) {
if ( !empty( $active_components['blogs'] ) )
bp_core_install_blog_tracking();
// Install the signups table
bp_core_install_signups();
// Maybe install (or upgrade) the signups table
bp_core_maybe_install_signups();
}
function bp_core_install_notifications() {
......@@ -348,6 +347,8 @@ function bp_core_install_blog_tracking() {
dbDelta( $sql );
}
/** Signups *******************************************************************/
/**
* Install the signups table.
*
......@@ -359,19 +360,15 @@ function bp_core_install_blog_tracking() {
function bp_core_install_signups() {
global $wpdb;
// Multisite installations already have the signups table
if ( ! empty( $wpdb->signups ) ) {
return;
}
// Signups is not there and we need it so let's create it
require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-schema.php' );
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
$wpdb->signups = bp_core_get_table_prefix() . 'signups';
// Setting the charset to be sure WordPress upgrade.php is loaded
$charset_collate = bp_core_set_charset();
// Never use bp_core_get_table_prefix() for any global users tables
$wpdb->signups = $wpdb->base_prefix . 'signups';
// Use WP's core CREATE TABLE query
$create_queries = wp_get_db_schema( 'ms_global' );
if ( ! is_array( $create_queries ) ) {
$create_queries = explode( ';', $create_queries );
$create_queries = array_filter( $create_queries );
......@@ -380,13 +377,40 @@ function bp_core_install_signups() {
// Filter out all the queries except wp_signups
foreach ( $create_queries as $key => $query ) {
if ( preg_match( "|CREATE TABLE ([^ ]*)|", $query, $matches ) ) {
if ( $wpdb->signups != trim( $matches[1], '`' ) ) {
if ( trim( $matches[1], '`' ) !== $wpdb->signups ) {
unset( $create_queries[ $key ] );
}
}
}
// Run WordPress's database upgrader
if ( ! empty( $create_queries ) ) {
dbDelta( $create_queries );
}
}
/**
* Update the signups table, adding `signup_id` column and drop `domain` index.
*
* This is necessary because WordPress's `pre_schema_upgrade()` function wraps
* table ALTER's in multisite checks, and other plugins may have installed their
* own sign-ups table; Eg: Gravity Forms User Registration Add On
*
* @since BuddyPress (2.0.1)
*
* @see pre_schema_upgrade()
* @link https://core.trac.wordpress.org/ticket/27855 WordPress Trac Ticket
* @link https://buddypress.trac.wordpress.org/ticket/5563 BuddyPress Trac Ticket
*
* @global WPDB $wpdb
*/
function bp_core_upgrade_signups() {
global $wpdb;
// Never use bp_core_get_table_prefix() for any global users tables
$wpdb->signups = $wpdb->base_prefix . 'signups';
// Attempt to alter the signups table
$wpdb->query( "ALTER TABLE {$wpdb->signups} ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" );
$wpdb->query( "ALTER TABLE {$wpdb->signups} DROP INDEX domain" );
}
......@@ -652,6 +652,7 @@ class BP_Admin {
<?php printf( __( 'Thanks for updating! With a focus on speed, admin tools, and developer enhancements, BuddyPress %s is our leanest and most powerful version yet.', 'buddypress' ), $display_version ); ?>
<?php endif; ?>
</div>
<div class="bp-badge"></div>
<h2 class="nav-tab-wrapper">
......
......@@ -883,7 +883,7 @@ class BP_Core_User {
$sql = array();
$sql['select_main'] = "SELECT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
$sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
if ( 'active' == $type || 'online' == $type || 'newest' == $type ) {
$sql['select_active'] = ", um.meta_value as last_activity";
......
......@@ -537,10 +537,16 @@ function bp_setup_nav_menu_item( $menu_item ) {
break;
}
// If component is deactivated, make sure menu item doesn't render
if ( empty( $menu_item->url ) ) {
$menu_item->_invalid = true;
// Highlight the current page
$current = bp_get_requested_url();
if ( strpos( $current, $menu_item->url ) !== false ) {
$menu_item->classes[] = 'current_page_item';
} else {
$current = bp_get_requested_url();
if ( strpos( $current, $menu_item->url ) !== false ) {
$menu_item->classes[] = 'current_page_item';
}
}
return $menu_item;
......
......@@ -235,6 +235,11 @@ function bp_version_updater() {
if ( $raw_db_version < 7892 ) {
bp_update_to_2_0();
}
// 2.0.1
if ( $raw_db_version < 8311 ) {
bp_update_to_2_0_1();
}
}
/** All done! *************************************************************/
......@@ -243,6 +248,8 @@ function bp_version_updater() {
bp_version_bump();
}
/** Upgrade Routines **********************************************************/
/**
* Remove unused metadata from database when upgrading from < 1.5.
*
......@@ -338,9 +345,10 @@ function bp_update_to_1_9_2() {
* - Ensure that the activity tables are installed, for last_activity storage.
* - Migrate last_activity data from usermeta to activity table
* - Add values for all BuddyPress options to the options table
*
* @since BuddyPress (2.0.0)
*/
function bp_update_to_2_0() {
global $wpdb;
/** Install activity tables for 'last_activity' ***************************/
......@@ -354,44 +362,11 @@ function bp_update_to_2_0() {
if ( ! is_multisite() ) {
if ( empty( $wpdb->signups ) ) {
bp_core_install_signups();
}
$signups = get_users( array(
'fields' => 'all_with_meta',
'meta_key' => 'activation_key',
'meta_compare' => 'EXISTS',
) );
if ( empty( $signups ) ) {
return;
}
foreach ( $signups as $signup ) {
$meta = array();
if ( bp_is_active( 'xprofile' ) ) {
$meta['field_1'] = $signup->display_name;
}
$meta['password'] = $signup->user_pass;
// Maybe install the signups table
bp_core_maybe_install_signups();
$user_login = preg_replace( '/\s+/', '', sanitize_user( $signup->user_login, true ) );
$user_email = sanitize_email( $signup->user_email );
BP_Signup::add( array(
'user_login' => $user_login,
'user_email' => $user_email,
'registered' => $signup->user_registered,
'activation_key' => $signup->activation_key,
'meta' => $meta
) );
// Deleting these options will remove signups from users count
delete_user_option( $signup->ID, 'capabilities' );
delete_user_option( $signup->ID, 'user_level' );
}
// Run the migration script
bp_members_migrate_signups();
}
/** Add BP options to the options table ***********************************/
......@@ -399,6 +374,20 @@ function bp_update_to_2_0() {
bp_add_options();
}
/**
* 2.0.1 database upgrade routine
*
* @since BuddyPress (2.0.1)
*
* @return void
*/
function bp_update_to_2_0_1() {
// We purposely call this during both the 2.0 upgrade and the 2.0.1 upgrade.
// Don't worry; it won't break anything, and safely handles all cases.
bp_core_maybe_install_signups();
}
/**
* Redirect user to BP's What's New page on first page load after activation.
*
......@@ -424,6 +413,56 @@ function bp_add_activation_redirect() {
set_transient( '_bp_activation_redirect', true, 30 );
}
/** Signups *******************************************************************/
/**
* Check if the signups table needs to be created.
*
* @since BuddyPress (2.0.0)
*
* @global WPDB $wpdb
*
* @return bool If signups table exists
*/
function bp_core_maybe_install_signups() {
// Bail if we are explicitly not upgrading global tables
if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
return false;
}
global $wpdb;
// The table to run queries against
$signups_table = $wpdb->base_prefix . 'signups';
// Suppress errors because users shouldn't see what happens next
$old_suppress = $wpdb->suppress_errors();
// Never use bp_core_get_table_prefix() for any global users tables
$table_exists = (bool) $wpdb->get_results( "DESCRIBE {$signups_table};" );
// Table already exists, so maybe upgrade instead?
if ( true === $table_exists ) {
// Look for the 'signup_id' column
$column_exists = $wpdb->query( "SHOW COLUMNS FROM {$signups_table} LIKE 'signup_id'" );
// 'signup_id' column doesn't exist, so run the upgrade
if ( empty( $column_exists ) ) {
bp_core_upgrade_signups();
}
// Table does not exist, and we are a single site, so install the multisite
// signups table using WordPress core's database schema.
} elseif ( ! is_multisite() ) {
bp_core_install_signups();
}
// Restore previous error suppression setting
$wpdb->suppress_errors( $old_suppress );
}
/** Activation Actions ********************************************************/
/**
......
......@@ -101,6 +101,7 @@ function groups_create_group( $args = '' ) {
$group = groups_get_group( array( 'group_id' => (int) $group_id ) );
$name = ! empty( $name ) ? $name : $group->name;
$slug = ! empty( $slug ) ? $slug : $group->slug;
$description = ! empty( $description ) ? $description : $group->description;
// Groups need at least a name
if ( empty( $name ) ) {
......
......@@ -159,9 +159,29 @@ class BP_Groups_Template {
if ( 'invites' == $type ) {
$this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page, $exclude );
} else if ( 'single-group' == $type ) {
$group = new stdClass;
$group->group_id = bp_get_current_group_id();
$this->groups = array( $group );
$this->single_group = true;
if ( groups_get_current_group() ) {
$group = groups_get_current_group();
} else {
$group = groups_get_group( array(
'group_id' => BP_Groups_Group::get_id_from_slug( $r['slug'] ),
'populate_extras' => $r['populate_extras'],
) );
}
// backwards compatibility - the 'group_id' variable is not part of the
// BP_Groups_Group object, but we add it here for devs doing checks against it
//
// @see https://buddypress.trac.wordpress.org/changeset/3540
//
// this is subject to removal in a future release; devs should check against
// $group->id instead
$group->group_id = $group->id;
$this->groups = array( $group );
} else {
$this->groups = groups_get_groups( array(
'type' => $type,
......@@ -185,9 +205,13 @@ class BP_Groups_Template {
$this->group_count = (int) $this->groups['total'];
$this->groups = $this->groups['groups'];
} else if ( 'single-group' == $type ) {
$this->single_group = true;
$this->total_group_count = 1;
$this->group_count = 1;
if ( empty( $group->id ) ) {
$this->total_group_count = 0;
$this->group_count = 0;
} else {
$this->total_group_count = 1;
$this->group_count = 1;
}
} else {
if ( empty( $max ) || $max >= (int) $this->groups['total'] ) {
$this->total_group_count = (int) $this->groups['total'];
......@@ -260,9 +284,6 @@ class BP_Groups_Template {
$this->in_the_loop = true;
$this->group = $this->next_group();
if ( $this->single_group )
$this->group = groups_get_current_group();
if ( 0 == $this->current_group ) // loop has just started
do_action('group_loop_start');
}
......
......@@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: BuddyPress \n"
"Report-Msgid-Bugs-To: http://wppolyglots.wordpress.com\n"
"POT-Creation-Date: 2014-04-15 14:30:37+00:00\n"
"POT-Creation-Date: 2014-04-18 17:30:35+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
......@@ -316,8 +316,8 @@ msgstr ""
#: bp-activity/bp-activity-admin.php:672 bp-activity/bp-activity-admin.php:1391
#: bp-forums/bp-forums-template.php:2112 bp-groups/bp-groups-admin.php:1396
#: bp-themes/bp-default/functions.php:509 bp-xprofile/bp-xprofile-admin.php:402
#: bp-xprofile/bp-xprofile-loader.php:193
#: bp-xprofile/bp-xprofile-loader.php:271
#: bp-xprofile/bp-xprofile-loader.php:195
#: bp-xprofile/bp-xprofile-loader.php:273
msgid "Edit"
msgstr ""
......@@ -618,7 +618,7 @@ msgid "Search Activity..."
msgstr ""
#: bp-activity/bp-activity-loader.php:165
#: bp-activity/bp-activity-loader.php:286
#: bp-activity/bp-activity-loader.php:276
msgid "Personal"
msgstr ""
......@@ -684,7 +684,7 @@ msgstr ""
#: bp-templates/bp-legacy/buddypress/groups/single/admin.php:212
#: bp-themes/bp-default/groups/single/admin.php:185
#: bp-themes/bp-default/groups/single/admin.php:212
#: bp-xprofile/bp-xprofile-loader.php:317
#: bp-xprofile/bp-xprofile-loader.php:314
msgid "Profile picture of %s"
msgstr ""
......@@ -860,8 +860,8 @@ msgstr ""
#: bp-templates/bp-legacy/buddypress-functions.php:248
#: bp-themes/bp-default/activity/entry.php:37
#: bp-themes/bp-default/functions.php:166
#: bp-xprofile/bp-xprofile-loader.php:183
#: bp-xprofile/bp-xprofile-loader.php:263
#: bp-xprofile/bp-xprofile-loader.php:185
#: bp-xprofile/bp-xprofile-loader.php:265
msgid "View"
msgstr ""
......@@ -1692,23 +1692,23 @@ msgstr ""
msgid "About"
msgstr ""
#: bp-core/bp-core-admin.php:496 bp-core/bp-core-admin.php:645
#: bp-core/bp-core-admin.php:496 bp-core/bp-core-admin.php:647
msgid "Welcome to BuddyPress %s"
msgstr ""
#: bp-core/bp-core-admin.php:499
#: bp-core/bp-core-admin.php:499 bp-core/bp-core-admin.php:650
msgid "It&#8217;s a great time to use BuddyPress! With a focus on speed, admin tools, and developer enhancements, %s is our leanest and most powerful version yet."
msgstr ""
#: bp-core/bp-core-admin.php:501
#: bp-core/bp-core-admin.php:501 bp-core/bp-core-admin.php:652
msgid "Thanks for updating! With a focus on speed, admin tools, and developer enhancements, BuddyPress %s is our leanest and most powerful version yet."
msgstr ""
#: bp-core/bp-core-admin.php:509 bp-core/bp-core-admin.php:651
#: bp-core/bp-core-admin.php:509 bp-core/bp-core-admin.php:660
msgid "What&#8217;s New"
msgstr ""
#: bp-core/bp-core-admin.php:511 bp-core/bp-core-admin.php:653
#: bp-core/bp-core-admin.php:511 bp-core/bp-core-admin.php:662
msgid "Credits"
msgstr ""
......@@ -1828,47 +1828,43 @@ msgstr ""
msgid "<a href=\"%s\">&hellip;and lots more!</a>"
msgstr ""
#: bp-core/bp-core-admin.php:623 bp-core/bp-core-admin.php:757
#: bp-core/bp-core-admin.php:623 bp-core/bp-core-admin.php:766
msgid "Go to the BuddyPress Settings page"
msgstr ""
#: bp-core/bp-core-admin.php:646
msgid "BuddyPress %s is our first version with a new component in over two years. Not only that, there are plenty of new features, enhancements, and bug fixes."
msgstr ""
#: bp-core/bp-core-admin.php:657
#: bp-core/bp-core-admin.php:666
msgid "BuddyPress is created by a worldwide network of friendly folks."
msgstr ""
#: bp-core/bp-core-admin.php:659
#: bp-core/bp-core-admin.php:668
msgid "Project Leaders"
msgstr ""
#: bp-core/bp-core-admin.php:664
#: bp-core/bp-core-admin.php:673
msgid "Project Lead"
msgstr ""
#: bp-core/bp-core-admin.php:669 bp-core/bp-core-admin.php:674
#: bp-core/bp-core-admin.php:678 bp-core/bp-core-admin.php:683
msgid "Lead Developer"
msgstr ""
#: bp-core/bp-core-admin.php:678
#: bp-core/bp-core-admin.php:687
msgid "Core Team"
msgstr ""
#: bp-core/bp-core-admin.php:683 bp-core/bp-core-admin.php:688
#: bp-core/bp-core-admin.php:692 bp-core/bp-core-admin.php:697
msgid "Core Developer"
msgstr ""
#: bp-core/bp-core-admin.php:693
#: bp-core/bp-core-admin.php:702
msgid "Navigator"
msgstr ""
#: bp-core/bp-core-admin.php:697
#: bp-core/bp-core-admin.php:706
msgid "Recent Rockstars"
msgstr ""
#: bp-core/bp-core-admin.php:709
#: bp-core/bp-core-admin.php:718
msgid "Contributors to BuddyPress 2.0"
msgstr ""
......@@ -2153,10 +2149,10 @@ msgid "Not recently active"
msgstr ""
#: bp-core/bp-core-loader.php:233 bp-members/bp-members-admin.php:329
#: bp-members/bp-members-loader.php:184 bp-xprofile/bp-xprofile-loader.php:162
#: bp-xprofile/bp-xprofile-loader.php:223
#: bp-xprofile/bp-xprofile-loader.php:255
#: bp-xprofile/bp-xprofile-loader.php:295