<!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" />
<title>[BuddyPress][5339] trunk: See #3660.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://buddypress.trac.wordpress.org/changeset/5339">5339</a></dd>
<dt>Author</dt> <dd>djpaul</dd>
<dt>Date</dt> <dd>2011-11-20 23:39:56 +0000 (Sun, 20 Nov 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>See <a href="http://buddypress.trac.wordpress.org/ticket/3660">#3660</a>. Activity admin iteration.

* &quot;Reply&quot; button now works.
* Fixed incorrect HTML markup.
* Improve error handling when an update on an activity fails.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityadminphp">trunk/bp-activity/bp-activity-admin.php</a></li>
<li><a href="#trunkreadmetxt">trunk/readme.txt</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/bp-activity/admin/</li>
<li>trunk/bp-activity/admin/css/</li>
<li><a href="#trunkbpactivityadmincssadmincss">trunk/bp-activity/admin/css/admin.css</a></li>
<li><a href="#trunkbpactivityadmincssadmindevcss">trunk/bp-activity/admin/css/admin.dev.css</a></li>
<li>trunk/bp-activity/admin/js/</li>
<li><a href="#trunkbpactivityadminjsadmindevjs">trunk/bp-activity/admin/js/admin.dev.js</a></li>
<li><a href="#trunkbpactivityadminjsadminjs">trunk/bp-activity/admin/js/admin.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivityadmincssadmincss"></a>
<div class="addfile"><h4>Added: trunk/bp-activity/admin/css/admin.css (0 => 5339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/admin/css/admin.css                                (rev 0)
+++ trunk/bp-activity/admin/css/admin.css        2011-11-20 23:39:56 UTC (rev 5339)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+#wp-bp-activities-wrap{padding:5px 0;}#bp-activities{height:120px;}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0;}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center;}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center;}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top;}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpactivityadmincssadmindevcss"></a>
<div class="addfile"><h4>Added: trunk/bp-activity/admin/css/admin.dev.css (0 => 5339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/admin/css/admin.dev.css                                (rev 0)
+++ trunk/bp-activity/admin/css/admin.dev.css        2011-11-20 23:39:56 UTC (rev 5339)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+#wp-bp-activities-wrap {
+        padding: 5px 0;
+}
+
+#bp-activities {
+        height: 120px;
+}
+
+#bp-replyhead {
+        font-size: 1em;
+        line-height: 1.4em;
+        margin: 0;
+}
+
+#bp-replysubmit {
+        margin: 0;
+        padding: 0 0 3px;
+        text-align: center;
+}
+
+#bp-replysubmit .error {
+        color: red;
+        line-height: 21px;
+        text-align: center;
+        vertical-align: center;
+}
+
+#bp-replysubmit img.waiting {
+        float: right;
+        padding: 4px 10px 0;
+        vertical-align: top;
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpactivityadminjsadmindevjs"></a>
<div class="addfile"><h4>Added: trunk/bp-activity/admin/js/admin.dev.js (0 => 5339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/admin/js/admin.dev.js                                (rev 0)
+++ trunk/bp-activity/admin/js/admin.dev.js        2011-11-20 23:39:56 UTC (rev 5339)
</span><span class="lines">@@ -0,0 +1,161 @@
</span><ins>+(function( $ ) {
+
+/**
+ * Activity reply object for the admin screen
+ *
+ * @since 1.6
+ */
+activityReply = {
+
+        /**
+         * Attach event handler functions to the relevant elements.
+         *
+         * @since 1.6
+         */
+        init : function() {
+                $(document).on( 'click', '.row-actions a.reply',              activityReply.open );
+                $(document).on( 'click', '#bp-activities-container a.cancel', activityReply.close );
+                $(document).on( 'click', '#bp-activities-container a.save',   activityReply.send );
+
+                // Close textarea on escape
+                $(document).on( 'keyup', '#bp-activities:visible', function( e ) {
+                        if ( 27 == e.which ) {
+                                activityReply.close();
+                        }
+                });
+        },
+
+        /**
+         * Reveals the entire row when &quot;reply&quot; is pressed.
+         *
+         * @since 1.6
+         */
+        open : function( e ) {
+                // Hide the container row, and move it to the new location
+                var box = $( '#bp-activities-container' ).hide();
+                $( this ).parents( 'tr' ).after( box );
+
+                // Fade the whole row in, and set focus on the text area.
+                box.fadeIn( '300' );
+                $( '#bp-activities' ).focus();
+
+                return false;
+        },
+
+        /**
+         * Hide and reset the entire row when &quot;cancel&quot;, or escape, are pressed.
+         *
+         * @since 1.6
+         */
+        close : function( e ) {
+                // Hide the container row
+                $('#bp-activities-container').fadeOut( '200', function () { 
+
+                        // Empty and unfocus the text area
+                        $( '#bp-activities' ).val( '' ).blur();
+
+                        // Remove any error message and disable the spinner
+                        $( '#bp-replysubmit .error' ).html( '' ).hide();
+                        $( '#bp-replysubmit .waiting' ).hide();
+                });
+
+                return false;
+        },
+
+        /**
+         * Submits &quot;form&quot; via AJAX back to WordPress.
+         *
+         * @since 1.6
+         */
+        send : function( e ) {
+                // Hide any existing error message, and show the loading spinner
+                $( '#bp-replysubmit .error' ).hide();
+                $( '#bp-replysubmit .waiting' ).show();
+
+                // Grab the nonce
+                var reply = {};
+                reply['_ajax_nonce-bp-activity-admin-reply'] = $( '#bp-activities-container input[name=&quot;_ajax_nonce-bp-activity-admin-reply&quot;]' ).val();
+
+                // Get the rest of the data
+                reply.action    = 'bp-activity-admin-reply';
+                reply.content   = $( '#bp-activities' ).val();
+                reply.parent_id = $( '#bp-activities-container' ).prev().data( 'parent_id' );
+                reply.root_id   = $( '#bp-activities-container' ).prev().data( 'root_id' );
+
+                // Make the AJAX call
+                $.ajax({
+                        data    : reply,
+                        type    : 'POST',
+                        url     : ajaxurl,
+
+                        // Callbacks
+                        error   : function( r ) { activityReply.error( r ); },
+                        success : function( r ) { activityReply.show( r ); }
+                });
+
+                return false;
+        },
+
+        /**
+         * send() error message handler
+         *
+         * @since 1.6
+         */
+        error : function( r ) {
+                var er = r.statusText;
+                $('#bp-replysubmit .waiting').hide();
+
+                if ( r.responseText ) {
+                        er = r.responseText.replace( /&lt;.[^&lt;&gt;]*?&gt;/g, '' );
+                }
+
+                if ( er ) {
+                        $('#bp-replysubmit .error').html( er ).show();
+                }
+        },
+
+        /**
+         * send() success handler
+         *
+         * @since 1.6
+         */
+        show : function ( xml ) {
+                var bg, id, response;
+
+                // Handle any errors in the response
+                if ( typeof( xml ) == 'string' ) {
+                        activityReply.error( { 'responseText': xml } );
+                        return false;
+                }
+
+                response = wpAjax.parseAjaxResponse( xml );
+                if ( response.errors ) {
+                        activityReply.error( { 'responseText': wpAjax.broken } );
+                        return false;
+                }
+                response = response.responses[0];
+
+                // Close and reset the reply row, and add the new Activity item into the list.
+                $('#bp-activities-container').fadeOut( '200', function () { 
+
+                        // Empty and unfocus the text area
+                        $( '#bp-activities' ).val( '' ).blur();
+
+                        // Remove any error message and disable the spinner
+                        $( '#bp-replysubmit .error' ).html( '' ).hide();
+                        $( '#bp-replysubmit .waiting' ).hide();
+
+                        // Insert new activity item
+                        $( '#bp-activities-container' ).before( response.data );
+
+                        // Get background colour and animate the flash
+                        id = $( '#activity-' + response.id );
+                        bg = id.closest( '.widefat' ).css( 'backgroundColor' );
+                        id.animate( { 'backgroundColor': '#CEB' }, 300 ).animate( { 'backgroundColor': bg }, 300 );
+                });
+        }
+};
+
+// Create the Activity reply object after domready event
+$(document).ready( activityReply.init );
+})(jQuery);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpactivityadminjsadminjs"></a>
<div class="addfile"><h4>Added: trunk/bp-activity/admin/js/admin.js (0 => 5339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/admin/js/admin.js                                (rev 0)
+++ trunk/bp-activity/admin/js/admin.js        2011-11-20 23:39:56 UTC (rev 5339)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+(function(a){activityReply={init:function(){a(document).on(&quot;click&quot;,&quot;.row-actions a.reply&quot;,activityReply.open);a(document).on(&quot;click&quot;,&quot;#bp-activities-container a.cancel&quot;,activityReply.close);a(document).on(&quot;click&quot;,&quot;#bp-activities-container a.save&quot;,activityReply.send);a(document).on(&quot;keyup&quot;,&quot;#bp-activities:visible&quot;,function(b){if(27==b.which){activityReply.close()}})},open:function(c){var b=a(&quot;#bp-activities-container&quot;).hide();a(this).parents(&quot;tr&quot;).after(b);b.fadeIn(&quot;300&quot;);a(&quot;#bp-activities&quot;).focus();return false},close:function(b){a(&quot;#bp-activities-container&quot;).fadeOut(&quot;200&quot;,function(){a(&quot;#bp-activities&quot;).val(&quot;&quot;).blur();a(&quot;#bp-replysubmit .error&quot;).html(&quot;&quot;).hide();a(&quot;#bp-replysubmit .waiting&quot;).hide()});return false},send:function(c){a(&quot;#bp-replysubmit .error&quot;).hide();a(
 &quot;#bp-replysubmit .waiting&quot;).show();var b={};b[&quot;_ajax_nonce-bp-activity-admin-reply&quot;]=a('#bp-activities-container input[name=&quot;_ajax_nonce-bp-activity-admin-reply&quot;]').val();b.action=&quot;bp-activity-admin-reply&quot;;b.content=a(&quot;#bp-activities&quot;).val();b.parent_id=a(&quot;#bp-activities-container&quot;).prev().data(&quot;parent_id&quot;);b.root_id=a(&quot;#bp-activities-container&quot;).prev().data(&quot;root_id&quot;);a.ajax({data:b,type:&quot;POST&quot;,url:ajaxurl,error:function(d){activityReply.error(d)},success:function(d){activityReply.show(d)}});return false},error:function(b){var c=b.statusText;a(&quot;#bp-replysubmit .waiting&quot;).hide();if(b.responseText){c=b.responseText.replace(/&lt;.[^&lt;&gt;]*?&gt;/g,&quot;&quot;)}if(c){a(&quot;#bp-replysubmit .error&quot;).html(c).show()}},show:function(c){var d,e,b;if(typeof(c)==&quot;string&quot;){activityReply.error({responseText:c});return false}b=wpAjax.parseAjaxResponse(c);if(b.e
 rrors){activityReply.error({responseText:wpAjax.broken});return false}b=b.responses[0];a(&quot;#bp-activities-container&quot;).fadeOut(&quot;200&quot;,function(){a(&quot;#bp-activities&quot;).val(&quot;&quot;).blur();a(&quot;#bp-replysubmit .error&quot;).html(&quot;&quot;).hide();a(&quot;#bp-replysubmit .waiting&quot;).hide();a(&quot;#bp-activities-container&quot;).before(b.data);e=a(&quot;#activity-&quot;+b.id);d=e.closest(&quot;.widefat&quot;).css(&quot;backgroundColor&quot;);e.animate({backgroundColor:&quot;#CEB&quot;},300).animate({backgroundColor:d},300)})}};a(document).ready(activityReply.init)})(jQuery);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpactivitybpactivityadminphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-admin.php (5338 => 5339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-admin.php        2011-11-20 00:30:52 UTC (rev 5338)
+++ trunk/bp-activity/bp-activity-admin.php        2011-11-20 23:39:56 UTC (rev 5339)
</span><span class="lines">@@ -41,6 +41,77 @@
</span><span class="cx"> add_action( bp_core_admin_hook(), 'bp_activity_add_admin_menu' );
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * AJAX receiver for Activity replies via the admin screen. Adds a new activity
+ * comment, and returns HTML for a new table row.
+ *
+ * @since 1.6
+ */
+function bp_activity_admin_reply() {
+        // Check nonce
+        check_ajax_referer( 'bp-activity-admin-reply', '_ajax_nonce-bp-activity-admin-reply' );
+
+        $parent_id = ! empty( $_REQUEST['parent_id'] ) ? (int) $_REQUEST['parent_id'] : 0;
+        $root_id   = ! empty( $_REQUEST['root_id'] )   ? (int) $_REQUEST['root_id']   : 0;
+
+        // $parent_id is required
+        if ( empty( $parent_id ) )
+                die( '-1' );
+
+        // If $root_id not set (e.g. for root items), use $parent_id
+        if ( empty( $root_id ) )
+                $root_id = $parent_id;
+
+        // Check that a reply has been entered
+        if ( empty( $_REQUEST['content'] ) )
+                die( __( 'ERROR: Please type a reply.', 'buddypress' ) );
+
+        // Check parent activity exists
+        $parent_activity = new BP_Activity_Activity( $parent_id );
+        if ( empty( $parent_activity-&gt;component ) )
+                die( __( 'ERROR: The item you are trying to reply to cannot be found, or it has been deleted.', 'buddypress' ) );
+
+        // @todo: Check if user is allowed to create new activity items
+        // if ( ! current_user_can( 'bp_new_activity' ) )
+        if ( ! is_super_admin() )
+                die( '-1' );
+
+        // Add new activity comment
+        $new_activity_id = bp_activity_new_comment( array(
+                'activity_id' =&gt; $root_id,              // ID of the root activity item
+                'content'     =&gt; $_REQUEST['content'],
+                'parent_id'   =&gt; $parent_id,            // ID of a parent comment
+        ) );
+
+        // Fetch the new activity item, as we need it to create table markup to return
+        $new_activity = new BP_Activity_Activity( $new_activity_id );
+
+        // This needs to be set for the BP_Activity_List_Table constructor to work
+        set_current_screen( 'toplevel_page_bp-activity' );
+
+        // Set up an output buffer
+        ob_start();
+        $list_table = new BP_Activity_List_Table();
+        $list_table-&gt;single_row( (array) $new_activity );
+
+        // Get table markup
+        $response =  array(
+                'data'     =&gt; ob_get_contents(),
+                'id'       =&gt; $new_activity_id,
+                'position' =&gt; -1,
+                'what'     =&gt; 'bp_activity',
+        );
+        ob_end_clean();
+
+        // Send response
+        $r = new WP_Ajax_Response();
+        $r-&gt;add( $response );
+        $r-&gt;send();
+
+        exit();
+}
+add_action( 'wp_ajax_bp-activity-admin-reply', 'bp_activity_admin_reply' );
+
+/**
</ins><span class="cx">  * Handle save/update of screen options for the Activity component admin screen
</span><span class="cx">  *
</span><span class="cx">  * @param string $value Will always be false unless another plugin filters it first.
</span><span class="lines">@@ -87,6 +158,16 @@
</span><span class="cx">                 '&lt;p&gt;' . __( '&lt;a href=&quot;http://buddypress.org/support/&quot;&gt;Support Forums&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;'
</span><span class="cx">         );
</span><span class="cx"> 
</span><ins>+        // Enqueue CSS and JavaScript
+        if ( defined( 'SCRIPT_DEBUG' ) &amp;&amp; SCRIPT_DEBUG ) {
+                wp_enqueue_script( 'bp_activity_admin_js', BP_PLUGIN_URL . 'bp-activity/admin/js/admin.dev.js', array( 'jquery', 'wp-ajax-response' ), '20111120' );
+                wp_enqueue_style( 'bp_activity_admin_css', BP_PLUGIN_URL . 'bp-activity/admin/css/admin.dev.css', array(), '20111120' );
+
+        } else {
+                wp_enqueue_script( 'bp_activity_admin_js', BP_PLUGIN_URL . 'bp-activity/admin/js/admin.js', array( 'jquery', 'wp-ajax-response' ), '20111120' );
+                wp_enqueue_style( 'bp_activity_admin_css', BP_PLUGIN_URL . 'bp-activity/admin/css/admin.css', array(), '20111120' );
+        }
+
</ins><span class="cx">         // Create the Activity screen list table
</span><span class="cx">         $bp_activity_list_table = new BP_Activity_List_Table();
</span><span class="cx"> 
</span><span class="lines">@@ -95,7 +176,7 @@
</span><span class="cx">         if ( $doaction &amp;&amp; 'edit' != $doaction ) {
</span><span class="cx"> 
</span><span class="cx">                 // Build redirection URL
</span><del>-                $redirect_to = remove_query_arg( array( 'aid', 'deleted', 'spammed', 'unspammed', ), wp_get_referer() );
</del><ins>+                $redirect_to = remove_query_arg( array( 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), wp_get_referer() );
</ins><span class="cx">                 $redirect_to = add_query_arg( 'paged', $bp_activity_list_table-&gt;get_pagenum(), $redirect_to );
</span><span class="cx"> 
</span><span class="cx">                 // Get activity IDs
</span><span class="lines">@@ -119,6 +200,9 @@
</span><span class="cx">                 // Initialise counters for how many of each type of item we perform an action on
</span><span class="cx">                 $deleted = $spammed = $unspammed = 0;
</span><span class="cx"> 
</span><ins>+                // Store any error that occurs when updating the database item
+                $error = 0;
+
</ins><span class="cx">                 // &quot;We'd like to shoot the monster, could you move, please?&quot;
</span><span class="cx">                 foreach ( $activity_ids as $activity_id ) {
</span><span class="cx">                         // @todo: Check the permissions on each
</span><span class="lines">@@ -142,14 +226,27 @@
</span><span class="cx"> 
</span><span class="cx">                                 case 'ham' :
</span><span class="cx">                                         bp_activity_mark_as_ham( $activity );
</span><del>-                                        $activity-&gt;save();
</del><ins>+                                        $result = $activity-&gt;save();
</ins><span class="cx"> 
</span><ins>+                                        // Check for any error during activity save
+                                        if ( ! $result ) {
+                                                $error = $activity-&gt;id;
+                                                break;
+                                        }
+
+                                        $unspammed++;
</ins><span class="cx">                                         break;
</span><span class="cx"> 
</span><span class="cx">                                 case 'spam' :
</span><span class="cx">                                         bp_activity_mark_as_spam( $activity );
</span><del>-                                        $activity-&gt;save();
</del><ins>+                                        $result = $activity-&gt;save();
</ins><span class="cx"> 
</span><ins>+                                        // Check for any error during activity save
+                                        if ( ! $result ) {
+                                                $error = $activity-&gt;id;
+                                                break;
+                                        }
+
</ins><span class="cx">                                         $spammed++;
</span><span class="cx">                                         break;
</span><span class="cx"> 
</span><span class="lines">@@ -157,6 +254,10 @@
</span><span class="cx">                                         break;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><ins>+                        // If an error occured, don't bother looking at the other activities. Bail out of the foreach.
+                        if ( $error )
+                                break;
+
</ins><span class="cx">                         // Release memory
</span><span class="cx">                         unset( $activity );
</span><span class="cx">                 }
</span><span class="lines">@@ -171,6 +272,10 @@
</span><span class="cx">                 if ( $deleted )
</span><span class="cx">                         $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
</span><span class="cx"> 
</span><ins>+                // If an error occured, pass back the activity ID that failed
+                if ( $error )
+                        $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to );
+
</ins><span class="cx">                 // Redirect
</span><span class="cx">                 wp_redirect( $redirect_to );
</span><span class="cx">                 exit;
</span><span class="lines">@@ -194,14 +299,18 @@
</span><span class="cx">         $messages = array();
</span><span class="cx"> 
</span><span class="cx">         // If the user has just made a change to an activity item, build status messages
</span><del>-        if ( !empty( $_REQUEST['deleted'] ) || !empty( $_REQUEST['spammed'] ) || !empty( $_REQUEST['unspammed'] ) ) {
</del><ins>+        if ( !empty( $_REQUEST['deleted'] ) || !empty( $_REQUEST['spammed'] ) || !empty( $_REQUEST['unspammed'] ) || !empty( $_REQUEST['error'] ) ) {
</ins><span class="cx">                 $deleted   = !empty( $_REQUEST['deleted']   ) ? (int) $_REQUEST['deleted']   : 0;
</span><ins>+                $error     = !empty( $_REQUEST['error']     ) ? (int) $_REQUEST['error']     : 0;
</ins><span class="cx">                 $spammed   = !empty( $_REQUEST['spammed']   ) ? (int) $_REQUEST['spammed']   : 0;
</span><span class="cx">                 $unspammed = !empty( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0;
</span><span class="cx"> 
</span><span class="cx">                 if ( $deleted &gt; 0 )
</span><span class="cx">                         $messages[] = sprintf( _n( '%s activity was permanently deleted.', '%s activities were permanently deleted.', $deleted, 'buddypress' ), $deleted );
</span><span class="cx"> 
</span><ins>+                if ( $error &gt; 0 )
+                        $messages[] = sprintf( __( 'An error occured when updating Activity ID #%d.', 'buddypress' ), $error );
+
</ins><span class="cx">                 if ( $spammed &gt; 0 )
</span><span class="cx">                         $messages[] = sprintf( _n( '%s activity marked as spam.', '%s activities marked as spam.', $spammed, 'buddypress' ), $spammed );
</span><span class="cx"> 
</span><span class="lines">@@ -234,7 +343,7 @@
</span><span class="cx"> 
</span><span class="cx">                 &lt;?php // If the user has just made a change to an activity item, display the status messages ?&gt;
</span><span class="cx">                 &lt;?php if ( !empty( $messages ) ) : ?&gt;
</span><del>-                        &lt;div id=&quot;moderated&quot; class=&quot;updated&quot;&gt;&lt;p&gt;&lt;?php echo implode( &quot;&lt;br/&gt;\n&quot;, $messages ); ?&gt;&lt;/p&gt;&lt;/div&gt;
</del><ins>+                        &lt;div id=&quot;moderated&quot; class=&quot;&lt;?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?&gt;&quot;&gt;&lt;p&gt;&lt;?php echo implode( &quot;&lt;br/&gt;\n&quot;, $messages ); ?&gt;&lt;/p&gt;&lt;/div&gt;
</ins><span class="cx">                 &lt;?php endif; ?&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;?php $bp_activity_list_table-&gt;views(); ?&gt;
</span><span class="lines">@@ -245,6 +354,30 @@
</span><span class="cx">                         &lt;input type=&quot;hidden&quot; name=&quot;page&quot; value=&quot;&lt;?php echo esc_attr( $_REQUEST['page'] ); ?&gt;&quot; /&gt;
</span><span class="cx">                         &lt;?php $bp_activity_list_table-&gt;display(); ?&gt;
</span><span class="cx">                 &lt;/form&gt;
</span><ins>+
+                &lt;table style=&quot;display: none;&quot;&gt;
+                        &lt;tr id=&quot;bp-activities-container&quot; style=&quot;display: none;&quot;&gt;
+                                &lt;td colspan=&quot;4&quot;&gt;
+                                        &lt;form method=&quot;get&quot; action=&quot;&quot;&gt;
+
+                                                &lt;h5 id=&quot;bp-replyhead&quot;&gt;&lt;?php _e( 'Reply to Activity', 'buddypress' ); ?&gt;&lt;/h5&gt;
+                                                &lt;?php wp_editor( '', 'bp-activities', array( 'dfw' =&gt; false, 'media_buttons' =&gt; false, 'quicktags' =&gt; array( 'buttons' =&gt; 'strong,em,link,block,del,ins,img,code,spell,close' ), 'tinymce' =&gt; false, ) ); ?&gt;
+
+                                                &lt;p id=&quot;bp-replysubmit&quot; class=&quot;submit&quot;&gt;
+                                                        &lt;a href=&quot;#&quot; class=&quot;cancel button-secondary alignleft&quot;&gt;&lt;?php _e( 'Cancel', 'tmggc' ); ?&gt;&lt;/a&gt;
+                                                        &lt;a href=&quot;#&quot; class=&quot;save button-primary alignright&quot;&gt;&lt;?php _e( 'Reply', 'tmggc' ); ?&gt;&lt;/a&gt;
+
+                                                        &lt;img class=&quot;waiting&quot; style=&quot;display:none;&quot; src=&quot;&lt;?php echo esc_url( network_admin_url( 'images/wpspin_light.gif' ) ); ?&gt;&quot; alt=&quot;&quot; /&gt;
+                                                        &lt;span class=&quot;error&quot; style=&quot;display:none;&quot;&gt;&lt;/span&gt;
+                                                        &lt;br class=&quot;clear&quot; /&gt;
+                                                &lt;/p&gt;
+
+                                                &lt;?php wp_nonce_field( 'bp-activity-admin-reply', '_ajax_nonce-bp-activity-admin-reply', false ); ?&gt;
+
+                                        &lt;/form&gt;
+                                &lt;/td&gt;
+                        &lt;/tr&gt;
+                &lt;/table&gt;
</ins><span class="cx">         &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;?php
</span><span class="lines">@@ -436,6 +569,21 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><ins>+         * Generates content for a single row of the table
+         *
+         * @param object $item The current item
+         * @since 1.6
+         */
+        function single_row( $item ) {
+                static $row_class = '';
+                $row_class = ( $row_class == '' ? ' class=&quot;alternate&quot;' : '' );
+
+                echo '&lt;tr' . $row_class . ' id=&quot;activity-' . esc_attr( $item['id'] ) . '&quot; data-parent_id=&quot;' . esc_attr( $item['id'] ) . '&quot; data-root_id=&quot;' . esc_attr( $item['item_id'] ) . '&quot;&gt;';
+                echo $this-&gt;single_row_columns( $item );
+                echo '&lt;/tr&gt;';
+        }
+
+        /**
</ins><span class="cx">          * Get the list of views available on this table (e.g. &quot;all&quot;, &quot;spam&quot;).
</span><span class="cx">          *
</span><span class="cx">          * @since 1.6
</span><span class="lines">@@ -450,7 +598,7 @@
</span><span class="cx">         &lt;?php
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        /**
</del><ins>+                /**
</ins><span class="cx">          * Get bulk actions
</span><span class="cx">          *
</span><span class="cx">          * @return array Key/value pairs for the bulk actions dropdown
</span><span class="lines">@@ -598,19 +746,20 @@
</span><span class="cx">                 $base_url   = network_admin_url( 'admin.php?page=bp-activity&amp;amp;aid=' . $item['id'] );
</span><span class="cx">                 $spam_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'spam-activity_' . $item['id'] ) );
</span><span class="cx"> 
</span><del>-                $delete_url = $base_url . &quot;&amp;amp;action=delete&amp;$spam_nonce&quot;;
</del><ins>+                $delete_url = $base_url . &quot;&amp;amp;action=delete&amp;amp;$spam_nonce&quot;;
</ins><span class="cx">                 $edit_url   = $base_url . '&amp;amp;action=edit';
</span><del>-                $ham_url    = $base_url . &quot;&amp;amp;action=ham&amp;$spam_nonce&quot;;
-                $spam_url   = $base_url . &quot;&amp;amp;action=spam&amp;$spam_nonce&quot;;
</del><ins>+                $ham_url    = $base_url . &quot;&amp;amp;action=ham&amp;amp;$spam_nonce&quot;;
+                $spam_url   = $base_url . &quot;&amp;amp;action=spam&amp;amp;$spam_nonce&quot;;
</ins><span class="cx"> 
</span><span class="cx">                 // Rollover actions
</span><span class="cx"> 
</span><span class="cx">                 // Reply - javascript only; implemented by AJAX.
</span><del>-                if ( 'spam' != $item_status )
-                        $actions['reply'] = sprintf( '&lt;a href=&quot;%s&quot; class=&quot;reply hide-if-no-js&quot;&gt;%s&lt;/a&gt;', $base_url, __( 'Reply', 'buddypress' ) );
</del><ins>+                if ( 'spam' != $item_status ) {
+                        $actions['reply'] = sprintf( '&lt;a href=&quot;#&quot; class=&quot;reply hide-if-no-js&quot;&gt;%s&lt;/a&gt;', __( 'Reply', 'buddypress' ) );
</ins><span class="cx"> 
</span><del>-                // Edit
-                $actions['edit'] = sprintf( '&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;', $edit_url, __( 'Edit', 'buddypress' ) );
</del><ins>+                        // Edit
+                        $actions['edit'] = sprintf( '&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;', $edit_url, __( 'Edit', 'buddypress' ) );
+                }
</ins><span class="cx"> 
</span><span class="cx">                 // Spam/unspam
</span><span class="cx">                 if ( 'spam' == $item_status )
</span></span></pre></div>
<a id="trunkreadmetxt"></a>
<div class="modfile"><h4>Modified: trunk/readme.txt (5338 => 5339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/readme.txt        2011-11-20 00:30:52 UTC (rev 5338)
+++ trunk/readme.txt        2011-11-20 23:39:56 UTC (rev 5339)
</span><span class="lines">@@ -1,8 +1,8 @@
</span><span class="cx"> === Plugin Name ===
</span><span class="cx"> Contributors: apeatling, johnjamesjacoby, MrMaz, DJPaul, boonebgorges
</span><span class="cx"> Tags: buddypress, social networking, activity, profiles, messaging, friends, groups, forums, microblogging, twitter, facebook, social, community, networks, networking, cms
</span><del>-Requires at least: 3.2
-Tested up to: 3.2.1
</del><ins>+Requires at least: 3.3
+Tested up to: 3.3
</ins><span class="cx"> Stable tag: 1.5
</span><span class="cx"> 
</span><span class="cx"> Social networking in a box. Build a social network for your company, school, sports team or niche community.
</span></span></pre>
</div>
</div>

</body>
</html>