Commons 2.1.0

I’ve just released version 2.1.0 of the CUNY Academic Commons.

Version 2.1.0 is one of our twice-yearly “feature releases”, and includes the following improvements:

  • Redesign of the top-level Events interface
  • Overhaul and consolidation of the Commons’s “About” page and subpages
  • Overhaul of the “Activity” page to replace the old “News” page, with features pulled from “My Commons”
  • Redesign and simplification of the ‘Create’ page

With these changes, we bring the redesign first launched in version 2.0.0 to more areas of the Commons.

In addition, Commons 2.1.0 is a major-release update for plugins and themes.

For complete details, visit the 2.1.0 milestone.

Commons 1.14.2

I’ve just released version 1.14.2 of the CUNY Academic Commons. This is a maintenance release, which addresses the following bugs:

  • Fix escaped quotes on Public Portfolio widgets
  • Increase performance when deleting bbPress topics and replies
  • Increase performance of activity queries with respect to Social Paper filtering
  • Fix bug in BuddyPress that could cause incorrect metadata to be stored for post items in some cases
  • Remove Simple CSS metabox from front-end interface, especially in Events
  • Fix bug preventing the creation of groups in some cases
  • Fix bug that caused Submit button to be inaccessible in some cases when previewing forum post
  • Fix bug in Site Layout tool that prevented site privacy settings from being saved properly
  • Add notice when leaving site creation process (as to visit a demo site) without saving changes

For complete details, visit the 1.14.2 milestone.

Commons 1.3.10

I’ve just released version 1.3.10 of the CUNY Academic Commons. Version 1.3.10 is a bugfix release, addressing a handful of issues:

  • Added a new debug tool to help resolve issues with blog authors occasionally being demoted on their blogs.
  • Changed some configurations to help with overly aggressive browser cache
  • Fixed the Read More javascript on group announcements and activity updates
  • Added a new WP plugin for advanced tag clouds

For full details on the release, visit the 1.3.10 milestone.

Commons 1.3.1

I’ve just released version 1.3.1 of the CUNY Academic Commons. Commons 1.3.1 is a bugfix release, with the following issues addressed:

  • Improves HTML document titles throughout main site
  • Fixes ability to uncouple a groupblog from a group
  • Fixes issue that caused edited blog posts to appear at the top of the activity stream
  • New WP plugins: WP-Print, WP Hide Post, Custom Sidebar
  • New WP theme: Modularity Lite

For complete release details, visit the 1.3.1 milestone.

New BuddyPress plugin: BP External Activity

Here on the CUNY Academic Commons, we have an installation of MediaWiki which runs alongside our WordPress/BuddyPress installation. Without some additional coding, edits on the wiki don’t show up in the Commons News feed, and as a result they tend to get a little lost in the shuffle. This new plugin, BP External Activity, addresses this issue by allowing the administrator of a BuddyPress installation to specify an arbitrary RSS feed whose items will be regularly imported into the activity stream.

The plugin imports RSS feeds every hour. You may find that you need to decrease your Simplepie cache time to make it work:
add_filter( 'wp_feed_cache_transient_lifetime', create_function('$a', 'return 600;') );
reduces the RSS cache to ten minutes, for example. Put that in your bp-custom.php file if you are having problems with the plugin.

At the moment, the plugin uses the Author field from the RSS feed to look for a matching author in your WP database. If it doesn’t find one, it uses the unlinked text ‘A user’, as in ‘A user edited the wiki page…’.

Thanks to Andy Peatling, whose External Group Blogs served as the inspiration for a good part of the code.

Visit the plugin homepage for more details.

Adding an “email to members” checkbox to the BuddyPress group activity stream

During the recent upgrade from BuddyPress 1.1.x to BuddyPress 1.2.x, and the subsequent move away from group wires to interactive group activity streams, one thing that some users on the CUNY Academic Commons missed was the “Notify members by email” checkbox of the old wire.

This morning I wrote a bit of code to add that kind of functionality to group activity streams. There are three functions, each of which goes in your plugins/bp-custom.php file.

First, adding the checkbox to the activity box. Notice that it only shows up when you’re on a group page.


function cac_email_activity_checkbox() {
	if ( !bp_is_groups_component() )
		return;
	?>
	
	
	<?php
}
add_action( 'bp_activity_post_form_options', 'cac_email_activity_checkbox' );

Second, handling the data when it gets to the server and sending the emails. Obviously, you’ll want to change the text of the email to match your own site and your own preferences.


function cac_email_activity_handler( $activity ) {
	global $bp;
	
	if ( $_POST['mailme'] == 'mailme' ) {
		
		$subject = sprintf('[CUNY Academic Commons] New update in the group "%s"',  $bp->groups->current_group->name );
		
		$message = strip_tags($activity->action);
		$message .= '

';
		$message .= strip_tags($activity->content);
		
		$message .= '

-------
';
		
		$message .= sprintf('You recieved this message because you are a member of the group "%s" on the CUNY Academic Commons. Visit the group: %s', $bp->groups->current_group->name, $bp->root_domain . '/' . $bp->groups->current_group->slug . '/' . $bp->groups->current_group->slug . '/' );
		
		//print_r($message);
	
		if ( bp_group_has_members( 'exclude_admins_mods=0&per_page=10000' ) ) {
			global $members_template;
			foreach( $members_template->members as $m ) {
				wp_mail( $m->user_email, $subject, $message );
			}
		}
	}
	
	remove_action( 'bp_activity_after_save' , 'ass_group_notification_activity' , 50 );
}
add_action( 'bp_activity_after_save', 'cac_email_activity_handler', 1 );

Finally, you’ll need some Javascript to make the AJAX activity submission work correctly. This is really just a copy of what’s in the bp-default JS file, with a few added lines to make it work.

function cac_email_activity_js() {
	if ( !bp_is_groups_component() )
		return;
	?>
	

	var jq = jQuery;
	jq(document).ready( function() {
jq("input#aw-whats-new-submit").unbind('click');
			/* New posts */
	jq("input#aw-whats-new-submit").click( function() {
		var button = jq(this);
		var form = button.parent().parent().parent().parent();

		form.children().each( function() {
			if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") )
				jq(this).attr( 'disabled', 'disabled' );
		});

		jq( 'form#' + form.attr('id') + ' span.ajax-loader' ).show();

		/* Remove any errors */
		jq('div.error').remove();
		button.attr('disabled','disabled');

		/* Default POST values */
		var object = '';
		var item_id = jq("#whats-new-post-in").val();
		var content = jq("textarea#whats-new").val();
		var mailme = jq("#cac_activity_mail:checked").val();

		/* Set object for non-profile posts */
		if ( item_id > 0 ) {
			object = jq("#whats-new-post-object").val();
		}

		jq.post( ajaxurl, {
			action: 'post_update',
			'cookie': encodeURIComponent(document.cookie),
			'_wpnonce_post_update': jq("input#_wpnonce_post_update").val(),
			'content': content,
			'object': object,
			'mailme': mailme,
			'item_id': item_id
		},
		function(response)
		{
			jq( 'form#' + form.attr('id') + ' span.ajax-loader' ).hide();

			form.children().each( function() {
				if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") )
					jq(this).attr( 'disabled', '' );
			});

			/* Check for errors and append if found. */
			if ( response[0] + response[1] == '-1' ) {
				form.prepend( response.substr( 2, response.length ) );
				jq( 'form#' + form.attr('id') + ' div.error').hide().fadeIn( 200 );
				button.attr("disabled", '');
			} else {
				if ( 0 == jq("ul.activity-list").length ) {
					jq("div.error").slideUp(100).remove();
					jq("div#message").slideUp(100).remove();
					jq("div.activity").append( '
    ' ); } jq("ul.activity-list").prepend(response); jq("ul.activity-list li:first").addClass('new-update'); jq("li.new-update").hide().slideDown( 300 ); jq("li.new-update").removeClass( 'new-update' ); jq("textarea#whats-new").val(''); jq("#cac_activity_mail").removeAttr('checked'); /* Re-enable the submit button after 8 seconds. */ setTimeout( function() { button.attr("disabled", ''); }, 8000 ); } }); return false; }); }); <?php } add_action( 'bp_activity_post_form_options', 'cac_email_activity_js', 999 );

New BuddyPress plugin: BP Include Non-Member Comments

By default, BuddyPress does not include comments from non-members (or non-logged-in users more generally) in the sitewide activity stream. For some communities, this default behavior is probably just fine. But in a community like the CUNY Academic Commons, which aims to attract readership and conversation from all sorts of folks, whether or not they’re signed in, the sitewide activity stream will be much more meaningful if it includes comments from everyone.

My new plugin, BP Include Non-Member Comments, was built with this purpose in mind. The plugin is activated here on the CUNY Academic Commons, so that all comments on your blog – whether from logged-in users or not – will show up on the news feed.

BP Include Non-Member Comments

The plugin has been tested on version 1.1.3 of BP, as well as the 1.2 release candidate. If you want to use the plugin for 1.1.3 or lower, you will need to uncomment the first few add_action and add_filter lines in the plugin file.

Technical caveat: Non-logged-in commenters have BP user_id 0. When BP creates the activity stream, it decides whether or not to show the Delete button by checking to see whether the user_id for the currently logged in user is the same as the user_id of the person to whom the comment belongs. Presumably, though, you don’t want non-logged-in viewers of the activity stream to be able to delete items from the activity stream at all. BP’s core code is not currently set up to make it easy to remove these buttons, so I employed an ugly fix. If you have changed your theme significantly from the default, you might have to adjust the filter bp_nonmember_comment_content (near the end of the plugin) to remove the button properly.

Download the plugin here.

Version 0.2 of BuddyPressActivity

Since releasing my MediaWiki extension BuddyPressActivity, which puts wiki edits into your BuddyPress activity stream, I’ve noticed a bug or two. In particular, the cool feature that filters out multiple edits of a page by a given author within a 24 hour period wasn’t working right. I’ve made the necessary fixes in v0.2.

Get the updated code today.

New BuddyPress plugin: Remove Previous Comment Edits From BuddyPress Activity

UPDATE: BP Dev Andy writes in a comment to this post that this bug will be fixed in BP core soon. If you’re running a recent version of BP, it’s likely that you won’t need this plugin. Please make sure you can reproduce the issue before installing.

This plugin fixes a small but potentially annoying quirk in BuddyPress. If you, as a blog owner, edit a comment that appears on your blog, BuddyPress adds an entry to the sitewide and individual activity streams – but it doesn’t delete the old entries. As a result, if you end up (for example) editing your own comment a few times in a row, you’ll see multiple items on the activity feed.

This plugin fixes the problem by checking whether a submitted comment is an edit, and if it is, by deleting previous versions of the comment in the activity stream.

Until the plugin is in the WordPress repository, I’ve made it available in a zip file here. Just load bp-activity-skip-comment-edits.php into your /wp-content/plugins folder, activate in Dashboard > Plugins (sitewide, if you’d like), and you should be good to go.

New MediaWiki extension: BuddyPressActivity

One of the most interesting vantage points from which to monitor goings-on around the CUNY Academic Commons is the BuddyPress activity feed. The sitewide feed – located on the Commons’s News page – lists all the activity happening the blogs, groups, and profiles around the site. There are activity streams for individual users and for those users’ friends as well – you can mine, for instance, here.

wiki-activity

Until recently, though, these streams did not include information the activity taking place in the wiki portion of the site. I’ve developed a extension for MediaWiki (the software that powers the Wiki section of the Commons) called BuddyPressActivity that rectifies this shortcoming. For websites – like the CUNY Academic Commons – that have integrated our homegrown MediaWiki/Wordpress MU integration, this extension will update BuddyPress activity streams to include edits to pages within the wiki, thus better reflecting the extent and variety of the action on the site.

You can find out more about the extension – and download the code for use on your own MW/WMPu installation – at http://www.mediawiki.org/wiki/Extension:BuddyPressActivity.