<!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][5325] trunk/bp-activity: 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/5325">5325</a></dd>
<dt>Author</dt> <dd>djpaul</dd>
<dt>Date</dt> <dd>2011-11-12 21:09:29 +0000 (Sat, 12 Nov 2011)</dd>
</dl>

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

* Update automatic Akismet submission hook priority (r5276).
* Update &quot;In Response To&quot; column.
* Update Contextual Help.
* Spam, un-spam and delete action buttons work.
* Small styling tweaks.
* Switched some $bp global and BP_VERSION to use the new wrapper functions.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityadminphp">trunk/bp-activity/bp-activity-admin.php</a></li>
<li><a href="#trunkbpactivitybpactivityakismetphp">trunk/bp-activity/bp-activity-akismet.php</a></li>
<li><a href="#trunkbpactivitybpactivityfunctionsphp">trunk/bp-activity/bp-activity-functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivitybpactivityadminphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-admin.php (5324 => 5325)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-admin.php        2011-11-11 21:38:21 UTC (rev 5324)
+++ trunk/bp-activity/bp-activity-admin.php        2011-11-12 21:09:29 UTC (rev 5325)
</span><span class="lines">@@ -2,7 +2,8 @@
</span><span class="cx"> /**
</span><span class="cx">  * BuddyPress Activity component admin screen
</span><span class="cx">  *
</span><del>- * Props to WordPress core for the Comments admin screen and its contextual help text, on which this is heavily based.
</del><ins>+ * Props to WordPress core for the Comments admin screen, and its contextual help text,
+ * on which this implementation is heavily based.
</ins><span class="cx">  *
</span><span class="cx">  * @package BuddyPress
</span><span class="cx">  * @since 1.6
</span><span class="lines">@@ -64,19 +65,24 @@
</span><span class="cx">  * Set up the admin page before any output is sent. Register contextual help and screen options for this admin page.
</span><span class="cx">  *
</span><span class="cx">  * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
</span><del>- * @global WP_Screen $current_screen Current screen object
</del><span class="cx">  * @since 1.6
</span><span class="cx">  */
</span><span class="cx"> function bp_activity_admin_load() {
</span><del>-        global $bp_activity_list_table, $current_screen;
</del><ins>+        global $bp_activity_list_table;
</ins><span class="cx"> 
</span><span class="cx">         // per_page screen option
</span><span class="cx">         add_screen_option( 'per_page', array( 'label' =&gt; _x( 'Activities', 'Activity items per page (screen options)', 'buddypress' )) );
</span><span class="cx"> 
</span><del>-        // Help text
-        add_contextual_help( $current_screen, '&lt;p&gt;' . __( 'You can manage activities made on your site similar to the way you manage comments and other content. This screen is customizable in the same ways as other management screens, and you can act on activities using the on-hover action links or the Bulk Actions.', 'buddypress' ) . '&lt;/p&gt;' .
</del><ins>+        // Help panel - text
+        add_contextual_help( get_current_screen(), '&lt;p&gt;' . __( 'You can manage activities made on your site similar to the way you manage comments and other content. This screen is customizable in the same ways as other management screens, and you can act on activities using the on-hover action links or the Bulk Actions.', 'buddypress' ) . '&lt;/p&gt;' .
+                '&lt;p&gt;' . __( 'There are many different types of activities. Some are generated by BuddyPress automatically, and others are entered directly by a user in the form of status update. To help manage the different activity types, use the filter dropdown box to switch between them.', 'buddypress' ) . '&lt;/p&gt;' .
+
</ins><span class="cx">                 '&lt;p&gt;' . __( 'In the Activity column, above each activity it says &amp;#8220;Submitted on,&amp;#8221; followed by the date and time the activity item was generated on your site. Clicking on the date/time link will take you to that activity on your live site. Hovering over any activity gives you options to reply, edit, spam mark, or delete that activity.', 'buddypress' ) . '&lt;/p&gt;' .
</span><del>-                '&lt;p&gt;' . __( 'There are many different types of activities. Some are generated by BuddyPress automatically, and others are entered directly by a user in the form of status update. To help manage the different activity types, use the filter dropdown box to switch between them.', 'buddypress' ) . '&lt;/p&gt;' .
</del><ins>+                '&lt;p&gt;' . __( 'In the In Response To column, the text is the name of the user who generated the activity, and a link to the activity on your live site. The small bubble with the number in it shows how many other activities are related to this one; these are usually comments. Clicking the bubble will filter the activity screen to show only related activity items.', 'buddypress' ) . '&lt;/p&gt;'
+        );
+
+        // Help panel - sidebar links
+        get_current_screen()-&gt;set_help_sidebar(
</ins><span class="cx">                 '&lt;p&gt;&lt;strong&gt;' . __( 'For more information:', 'buddypress' ) . '&lt;/strong&gt;&lt;/p&gt;' .
</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="lines">@@ -84,14 +90,95 @@
</span><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><del>-        // Handle edit/reply/spam/unspam/delete of activities
</del><ins>+        // Handle spam/un-spam/delete of activities
</ins><span class="cx">         $doaction = $bp_activity_list_table-&gt;current_action();
</span><del>-        if ( $doaction ) {
-                check_admin_referer( 'bulk-activities' );
</del><ins>+        if ( $doaction &amp;&amp; 'edit' != $doaction ) {
</ins><span class="cx"> 
</span><ins>+                // Build redirection URL
+                $redirect_to = remove_query_arg( array( 'aid', 'deleted', 'spammed', 'unspammed', ), wp_get_referer() );
+                $redirect_to = add_query_arg( 'paged', $bp_activity_list_table-&gt;get_pagenum(), $redirect_to );
+
+                // Get activity IDs
+                $activity_ids = array_map( 'absint', (array) $_REQUEST['aid'] );
+
+                // Is this a bulk request?
+                if ( 'bulk_' == substr( $doaction, 0, 5 ) &amp;&amp; !empty( $_REQUEST['aid'] ) ) {
+                        // Check this is a valid form submission
+                        check_admin_referer( 'bulk-activities' );
+
+                        // Trim 'bulk_' off the action name to avoid duplicating a ton of code
+                        $doaction = substr( $doaction, 5 );
+
+                // This is a request to delete, spam, or un-spam, a single item.
+                } elseif ( !empty( $_REQUEST['aid'] ) ) {
+
+                        // Check this is a valid form submission
+                        check_admin_referer( 'spam-activity_' . $activity_ids[0] );
+                }
+
+                // Initialise counters for how many of each type of item we perform an action on
+                $deleted = $spammed = $unspammed = 0;
+
+                // &quot;We'd like to shoot the monster, could you move, please?&quot;
+                foreach ( $activity_ids as $activity_id ) {
+                        // @todo: Check the permissions on each
+                        //if ( ! current_user_can( 'bp_edit_activity', $activity_id ) )
+                        //        continue;
+
+                        // Get the activity from the database
+                        $activity = new BP_Activity_Activity( $activity_id );
+                        if ( empty( $activity-&gt;component ) )
+                                continue;
+
+                        switch ( $doaction ) {
+                                case 'delete' :
+                                        if ( 'activity_comment' == $activity-&gt;type )
+                                                bp_activity_delete_comment( $activity-&gt;item_id, $activity-&gt;id );
+                                        else
+                                                bp_activity_delete( array( 'id' =&gt; $activity-&gt;id ) );
+
+                                        $deleted++;
+                                        break;
+
+                                case 'ham' :
+                                        bp_activity_mark_as_ham( $activity );
+                                        $activity-&gt;save();
+
+                                        break;
+
+                                case 'spam' :
+                                        bp_activity_mark_as_spam( $activity );
+                                        $activity-&gt;save();
+
+                                        $spammed++;
+                                        break;
+
+                                default:
+                                        break;
+                        }
+
+                        // Release memory
+                        unset( $activity );
+                }
+
+                // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done.
+                if ( $spammed )
+                        $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to );
+
+                if ( $unspammed )
+                        $redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to );
+
+                if ( $deleted )
+                        $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
+
+                // Redirect
+                wp_redirect( $redirect_to );
+                exit;
+
+        // If a referrer and a nonce is supplied, but no action, redirect back.
</ins><span class="cx">         } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
</span><del>-                 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
-                 exit;
</del><ins>+                wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
+                exit;
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -104,14 +191,38 @@
</span><span class="cx"> function bp_activity_admin() {
</span><span class="cx">         global $bp_activity_list_table;
</span><span class="cx"> 
</span><ins>+        $messages = array();
+
+        // If the user has just made a change to an activity item, build status messages
+        if ( !empty( $_REQUEST['deleted'] ) || !empty( $_REQUEST['spammed'] ) || !empty( $_REQUEST['unspammed'] ) ) {
+                $deleted   = !empty( $_REQUEST['deleted']   ) ? (int) $_REQUEST['deleted']   : 0;
+                $spammed   = !empty( $_REQUEST['spammed']   ) ? (int) $_REQUEST['spammed']   : 0;
+                $unspammed = !empty( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0;
+
+                if ( $deleted &gt; 0 )
+                        $messages[] = sprintf( _n( '%s activity was permanently deleted.', '%s activities were permanently deleted.', $deleted, 'buddypress' ), $deleted );
+
+                if ( $spammed &gt; 0 )
+                        $messages[] = sprintf( _n( '%s activity marked as spam.', '%s activities marked as spam.', $spammed, 'buddypress' ), $spammed );
+
+                if ( $unspammed &gt; 0 )
+                        $messages[] = sprintf( _n( '%s activity restored from the spam.', '%s activities restored from the spam.', $unspammed, 'buddypress' ), $unspammed );
+
+        // Handle the edit screen
+        } elseif ( 'edit' == $bp_activity_list_table-&gt;current_action() &amp;&amp; !empty( $_GET['aid'] ) ) {
+                echo '@TODO: Activity Edit screen.';
+                return;
+        }
+
+        // Prepare the activity items for display
</ins><span class="cx">         $bp_activity_list_table-&gt;prepare_items();
</span><span class="cx"> ?&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;div class=&quot;wrap&quot;&gt;
</span><span class="cx">                 &lt;?php screen_icon( 'buddypress' ); ?&gt;
</span><span class="cx">                 &lt;h2&gt;
</span><del>-                        &lt;?php if ( !empty( $_REQUEST['a'] ) ) : ?&gt;
-                                &lt;?php printf( __( 'Activity (ID #%d)', 'buddypress' ), (int) $_REQUEST['a'] ); ?&gt;
</del><ins>+                        &lt;?php if ( !empty( $_REQUEST['aid'] ) ) : ?&gt;
+                                &lt;?php printf( __( 'Activity (ID #%d)', 'buddypress' ), (int) $_REQUEST['aid'] ); ?&gt;
</ins><span class="cx">                         &lt;?php else : ?&gt;
</span><span class="cx">                                 &lt;?php _e( 'Activity', 'buddypress' ); ?&gt;
</span><span class="cx">                         &lt;?php endif; ?&gt;
</span><span class="lines">@@ -121,6 +232,11 @@
</span><span class="cx">                         &lt;?php endif; ?&gt;
</span><span class="cx">                 &lt;/h2&gt;
</span><span class="cx"> 
</span><ins>+                &lt;?php // If the user has just made a change to an activity item, display the status messages ?&gt;
+                &lt;?php if ( !empty( $messages ) ) : ?&gt;
+                        &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;
+                &lt;?php endif; ?&gt;
+
</ins><span class="cx">                 &lt;?php $bp_activity_list_table-&gt;views(); ?&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;form id=&quot;bp-activities-form&quot; action=&quot;&quot; method=&quot;get&quot;&gt;
</span><span class="lines">@@ -180,11 +296,11 @@
</span><span class="cx">                 $screen = get_current_screen();
</span><span class="cx"> 
</span><span class="cx">                 // Option defaults
</span><del>-                $filter       = array();
-                $activity     = false;
-                $search_terms = false;
-                $sort         = 'DESC';
-                $spam         = 'ham_only';
</del><ins>+                $filter           = array();
+                $include_id       = false;
+                $search_terms     = false;
+                $sort             = 'DESC';
+                $spam             = 'ham_only';
</ins><span class="cx"> 
</span><span class="cx">                 // Set current page
</span><span class="cx">                 $page = $this-&gt;get_pagenum();
</span><span class="lines">@@ -215,8 +331,8 @@
</span><span class="cx">                         $search_terms = $_REQUEST['s'];
</span><span class="cx"> 
</span><span class="cx">                 // Check if user has clicked on a specific activity (if so, fetch only that, and any related, activity).
</span><del>-                if ( !empty( $_REQUEST['a'] ) )
-                        $activity = (int) $_REQUEST['a'];
</del><ins>+                if ( !empty( $_REQUEST['aid'] ) )
+                        $include_id = (int) $_REQUEST['aid'];
</ins><span class="cx"> 
</span><span class="cx">                 // Get the spam total (ignoring any search query or filter)
</span><span class="cx">                 $spams = bp_activity_get( array(
</span><span class="lines">@@ -227,11 +343,11 @@
</span><span class="cx">                 $this-&gt;spam_count = $spams['total'];
</span><span class="cx">                 unset( $spams );
</span><span class="cx"> 
</span><del>-                // Get the activites from the database
</del><ins>+                // Get the activities from the database
</ins><span class="cx">                 $activities = bp_activity_get( array(
</span><span class="cx">                         'display_comments' =&gt; 'stream',
</span><span class="cx">                         'filter'           =&gt; $filter,
</span><del>-                        'in'               =&gt; $activity,
</del><ins>+                        'in'               =&gt; $include_id,
</ins><span class="cx">                         'page'             =&gt; $page,
</span><span class="cx">                         'per_page'         =&gt; $per_page,
</span><span class="cx">                         'search_terms'     =&gt; $search_terms,
</span><span class="lines">@@ -245,6 +361,10 @@
</span><span class="cx">                 foreach ( $activities['activities'] as $activity_item )
</span><span class="cx">                         $new_activities[] = (array) $activity_item;
</span><span class="cx"> 
</span><ins>+                // @todo If we're viewing a specific activity, check/merge $activity-&gt;children into the main list (recursive).
+                /*if ( $include_id ) {
+                }*/
+
</ins><span class="cx">                 // Set raw data to display
</span><span class="cx">                 $this-&gt;items       = $new_activities;
</span><span class="cx">                 $this-&gt;extra_items = array();
</span><span class="lines">@@ -306,13 +426,9 @@
</span><span class="cx">                                 &lt;/tr&gt;
</span><span class="cx">                         &lt;/tfoot&gt;
</span><span class="cx"> 
</span><del>-                        &lt;tbody id=&quot;the-comment-list&quot; class=&quot;list:comment&quot;&gt;
</del><ins>+                        &lt;tbody id=&quot;the-comment-list&quot;&gt;
</ins><span class="cx">                                 &lt;?php $this-&gt;display_rows_or_placeholder(); ?&gt;
</span><span class="cx">                         &lt;/tbody&gt;
</span><del>-
-                        &lt;tbody id=&quot;the-extra-comment-list&quot; class=&quot;list:comment&quot; style=&quot;display: none;&quot;&gt;
-                                &lt;?php $this-&gt;items = $this-&gt;extra_items; $this-&gt;display_rows(); ?&gt;
-                        &lt;/tbody&gt;
</del><span class="cx">                 &lt;/table&gt;
</span><span class="cx">                 &lt;?php
</span><span class="cx"> 
</span><span class="lines">@@ -325,10 +441,11 @@
</span><span class="cx">          * @since 1.6
</span><span class="cx">          */
</span><span class="cx">         function get_views() {
</span><ins>+                $redirect_to = remove_query_arg( array( 'activity_status', 'aid', 'deleted', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] );
</ins><span class="cx">         ?&gt;
</span><span class="cx">                 &lt;ul class=&quot;subsubsub&quot;&gt;
</span><del>-                        &lt;li class=&quot;all&quot;&gt;&lt;a href=&quot;&lt;?php echo remove_query_arg( 'activity_status' ); ?&gt;&quot; class=&quot;&lt;?php if ( 'spam' != $this-&gt;view ) echo 'current'; ?&gt;&quot;&gt;&lt;?php _e( 'All', 'buddypress' ); ?&gt;&lt;/a&gt; |&lt;/li&gt;
-                        &lt;li class=&quot;spam&quot;&gt;&lt;a href=&quot;&lt;?php echo add_query_arg( 'activity_status', 'spam' ); ?&gt;&quot; class=&quot;&lt;?php if ( 'spam' == $this-&gt;view ) echo 'current'; ?&gt;&quot;&gt;&lt;?php printf( __( 'Spam (%d)', 'buddypress' ), $this-&gt;spam_count ); ?&gt;&lt;/a&gt;&lt;/li&gt;
</del><ins>+                        &lt;li class=&quot;all&quot;&gt;&lt;a href=&quot;&lt;?php echo esc_attr( esc_url( $redirect_to ) ); ?&gt;&quot; class=&quot;&lt;?php if ( 'spam' != $this-&gt;view ) echo 'current'; ?&gt;&quot;&gt;&lt;?php _e( 'All', 'buddypress' ); ?&gt;&lt;/a&gt; |&lt;/li&gt;
+                        &lt;li class=&quot;spam&quot;&gt;&lt;a href=&quot;&lt;?php echo esc_attr( esc_url( add_query_arg( 'activity_status', 'spam', $redirect_to ) ) ); ?&gt;&quot; class=&quot;&lt;?php if ( 'spam' == $this-&gt;view ) echo 'current'; ?&gt;&quot;&gt;&lt;?php printf( __( 'Spam &lt;span class=&quot;count&quot;&gt;(%d)&lt;/span&gt;', 'buddypress' ), $this-&gt;spam_count ); ?&gt;&lt;/a&gt;&lt;/li&gt;
</ins><span class="cx">                 &lt;/ul&gt;
</span><span class="cx">         &lt;?php
</span><span class="cx">         }
</span><span class="lines">@@ -341,9 +458,9 @@
</span><span class="cx">          */
</span><span class="cx">         function get_bulk_actions() {
</span><span class="cx">                 $actions = array();
</span><del>-                $actions['spam']   = __( 'Mark as Spam', 'buddypress' );
-                $actions['unspam'] = __( 'Not Spam', 'buddypress' );
-                $actions['delete'] = __( 'Delete Permanently', 'buddypress' );
</del><ins>+                $actions['bulk_spam']   = __( 'Mark as Spam', 'buddypress' );
+                $actions['bulk_ham']    = __( 'Not Spam', 'buddypress' );
+                $actions['bulk_delete'] = __( 'Delete Permanently', 'buddypress' );
</ins><span class="cx"> 
</span><span class="cx">                 return $actions;
</span><span class="cx">         }
</span><span class="lines">@@ -439,7 +556,7 @@
</span><span class="cx">          * @since 1.6
</span><span class="cx">          */
</span><span class="cx">         function column_cb( $item ) {
</span><del>-                printf( '&lt;input type=&quot;checkbox&quot; name=&quot;activity_id[]&quot; value=&quot;%d&quot; /&gt;', (int) $item['id'] );
</del><ins>+                printf( '&lt;input type=&quot;checkbox&quot; name=&quot;aid[]&quot; value=&quot;%d&quot; /&gt;', (int) $item['id'] );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -477,22 +594,32 @@
</span><span class="cx">                         'delete' =&gt; '',
</span><span class="cx">                 );
</span><span class="cx"> 
</span><del>-                // Get rollover actions.
-                // Reply
</del><ins>+                // Build actions URLs
+                $base_url   = network_admin_url( 'admin.php?page=bp-activity&amp;amp;aid=' . $item['id'] );
+                $spam_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'spam-activity_' . $item['id'] ) );
+
+                $delete_url = $base_url . &quot;&amp;amp;action=delete&amp;$spam_nonce&quot;;
+                $edit_url   = $base_url . '&amp;amp;action=edit';
+                $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;;
+
+                // Rollover actions
+
+                // Reply - javascript only; implemented by AJAX.
</ins><span class="cx">                 if ( 'spam' != $item_status )
</span><del>-                        $actions['reply'] = sprintf( '&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;', esc_attr( '#' ), __( 'Reply', 'buddypress' ) );
</del><ins>+                        $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' ) );
</ins><span class="cx"> 
</span><span class="cx">                 // Edit
</span><del>-                $actions['edit'] = sprintf( '&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;', esc_attr( '#' ), __( 'Edit', 'buddypress' ) );
</del><ins>+                $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><del>-                        $actions['unspam'] = sprintf( '&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;', esc_attr( '#' ), __( 'Not Spam', 'buddypress' ) );
</del><ins>+                        $actions['unspam'] = sprintf( '&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;', $ham_url, __( 'Not Spam', 'buddypress' ) );
</ins><span class="cx">                 else
</span><del>-                        $actions['spam'] = sprintf( '&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;', esc_attr( '#' ), __( 'Spam', 'buddypress' ) );
</del><ins>+                        $actions['spam'] = sprintf( '&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;', $spam_url, __( 'Spam', 'buddypress' ) );
</ins><span class="cx"> 
</span><span class="cx">                 // Delete
</span><del>-                $actions['delete'] = sprintf( '&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;', esc_attr( '#' ), __( 'Delete Permanently', 'buddypress' ) );
</del><ins>+                $actions['delete'] = sprintf( '&lt;a href=&quot;%s&quot; onclick=&quot;%s&quot;&gt;%s&lt;/a&gt;', $delete_url, &quot;javascript:return confirm('&quot; . esc_js( __( 'Are you sure?', 'buddypress' ) ) . &quot;'); &quot;, __( 'Delete Permanently', 'buddypress' ) );
</ins><span class="cx"> 
</span><span class="cx">                 // Start timestamp
</span><span class="cx">                 echo '&lt;div class=&quot;submitted-on&quot;&gt;';
</span><span class="lines">@@ -506,8 +633,11 @@
</span><span class="cx">                 // End timestamp
</span><span class="cx">                 echo '&lt;/div&gt;';
</span><span class="cx"> 
</span><del>-                // Get activity item content
-                $content = apply_filters_ref_array( 'bp_get_activity_content_body', array( $item['content'] ) );
</del><ins>+                // Get activity content - if not set, use the action
+                if ( !empty( $item['content'] ) )
+                        $content = apply_filters_ref_array( 'bp_get_activity_content_body', array( $item['content'] ) );
+                else
+                        $content = apply_filters_ref_array( 'bp_get_activity_action', array( $item['action'] ) );
</ins><span class="cx"> 
</span><span class="cx">                 echo $content . ' ' . $this-&gt;row_actions( $actions );
</span><span class="cx">         }
</span><span class="lines">@@ -520,11 +650,38 @@
</span><span class="cx">          * @since 1.6
</span><span class="cx">          */
</span><span class="cx">         function column_response( $item ) {
</span><del>-                // Does this activity have a parent?
-                if ( empty( $item['secondary_item_id'] ) )
</del><ins>+                // Display link to user's profile
+                echo bp_core_get_userlink( $item['user_id'] );
+
+                // Get activity permalink
+                $activity_link = bp_activity_get_permalink( $item['id'], (object) $item );
+
+                // Get the root activity ID by parsing the permalink; this may be not be the same as $item['id'] for nested items (e.g. activity_comments)
+                $root_activity_id = array();
+                preg_match( '/\/p\/(\d+)\/*$/i', $activity_link, $root_activity_id );
+                if ( empty( $root_activity_id[1] ) )
</ins><span class="cx">                         return;
</span><span class="cx"> 
</span><del>-                /* translators: 1: activity admin screen permalink, 2: activity ID */
-                printf( __( '&lt;a href=&quot;%1$s&quot;&gt;Activity ID #%2$d&lt;/a&gt;', 'buddypress' ), network_admin_url( 'admin.php?page=bp-activity&amp;a=' . $item['secondary_item_id'] ), $item['secondary_item_id'] );
</del><ins>+                $root_activity_id = (int) $root_activity_id[1];
+
+                // Is $item the root activity?
+                if ( (int) $item['id'] == $root_activity_id ) {
+                        $root_activity = (object) $item;
+
+                        // Get root activity comment count
+                        $comment_count = !empty( $root_activity-&gt;children ) ? bp_activity_recurse_comment_count( $root_activity ) : 0;
+
+                        // Display a link to the root activity's permalink, with its comment count in a speech bubble
+                        printf( '&lt;br /&gt;&lt;a href=&quot;%1$s&quot; title=&quot;%2$s&quot; class=&quot;post-com-count&quot;&gt;&lt;span class=&quot;comment-count&quot;&gt;%3$d&lt;/span&gt;&lt;/a&gt;',  network_admin_url( 'admin.php?page=bp-activity&amp;amp;aid=' . $root_activity_id ), esc_attr( sprintf( __( '%d related activities', 'buddypress' ), $comment_count ) ), $comment_count );
+
+                // $item is not the root activity (it is probably an activity_comment).
+                } else {
+                        echo '&lt;br /&gt;';
+
+                        // @todo Get comment count from a specific node ($root_activity_id) in the tree, not $root_activity_id's root.
+                }
+
+                // Link to the activity permalink
+                printf( __( '&lt;a href=&quot;%1$s&quot;&gt;View Activity&lt;/a&gt;', 'buddypress' ), bp_activity_get_permalink( $item['id'], (object) $item ) );
</ins><span class="cx">         }
</span><span class="cx"> }?&gt;
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpactivitybpactivityakismetphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-akismet.php (5324 => 5325)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-akismet.php        2011-11-11 21:38:21 UTC (rev 5324)
+++ trunk/bp-activity/bp-activity-akismet.php        2011-11-12 21:09:29 UTC (rev 5325)
</span><span class="lines">@@ -75,16 +75,16 @@
</span><span class="cx"> 
</span><span class="cx">                 if ( !$user_result || $user_result == $akismet_result ) {
</span><span class="cx">                         // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
</span><del>-                        if ( $akismet_result == 'true' &amp;&amp; $activity['is_spam'] )
</del><ins>+                        if ( 'true' == $akismet_result &amp;&amp; $activity['is_spam'] )
</ins><span class="cx">                                 $desc = __( 'Flagged as spam by Akismet', 'buddypress' );
</span><span class="cx"> 
</span><del>-                        elseif ( $akismet_result == 'false' &amp;&amp; !$activity['is_spam'] )
</del><ins>+                        elseif ( 'false' == $akismet_result &amp;&amp; !$activity['is_spam'] )
</ins><span class="cx">                                 $desc = __( 'Cleared by Akismet', 'buddypress' );
</span><span class="cx"> 
</span><span class="cx">                 } else {
</span><span class="cx">                         $who = bp_activity_get_meta( $activity['id'], '_bp_akismet_user' );
</span><span class="cx"> 
</span><del>-                        if ( $user_result == 'true' )
</del><ins>+                        if ( 'true' == $user_result )
</ins><span class="cx">                                 $desc = sprintf( __( 'Flagged as spam by %s', 'buddypress' ), $who );
</span><span class="cx">                         else
</span><span class="cx">                                 $desc = sprintf( __( 'Un-spammed by %s', 'buddypress' ), $who );
</span><span class="lines">@@ -96,14 +96,14 @@
</span><span class="cx">                         foreach ( $actions as $k =&gt; $item ) {
</span><span class="cx">                                 $b[ $k ] = $item;
</span><span class="cx">                                 if ( $k == 'edit' )
</span><del>-                                        $b['history'] = '&lt;a href=&quot;#&quot;&gt; '. __( 'History', 'buddypress' ) . '&lt;/a&gt;';
</del><ins>+                                        $b['history'] = '&lt;a href=&quot;' . network_admin_url( 'admin.php?page=bp-activity&amp;amp;action=edit&amp;aid=' . $activity['id'] ) . '#history&quot;&gt; '. __( 'History', 'buddypress' ) . '&lt;/a&gt;';
</ins><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         $actions = $b;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if ( $desc )
</span><del>-                        echo '&lt;span class=&quot;akismet-status&quot;&gt;&lt;a href=&quot;#&quot;&gt;' . htmlspecialchars( $desc ) . '&lt;/a&gt;&lt;/span&gt;';
</del><ins>+                        echo '&lt;span class=&quot;akismet-status&quot;&gt;&lt;a href=&quot;' . network_admin_url( 'admin.php?page=bp-activity&amp;amp;action=edit&amp;aid=' . $activity['id'] ) . '#history&quot;&gt;' . htmlspecialchars( $desc ) . '&lt;/a&gt;&lt;/span&gt;';
</ins><span class="cx"> 
</span><span class="cx">                 return apply_filters( 'bp_akismet_comment_row_action', $actions );
</span><span class="cx">         }
</span><span class="lines">@@ -239,11 +239,13 @@
</span><span class="cx">          * Mark activity item as ham
</span><span class="cx">          *
</span><span class="cx">          * @param BP_Activity_Activity $activity
</span><del>-         * @param string $source Either &quot;by_a_person&quot; (e.g. a person has manually marked the activity as spam) or &quot;by_akismet&quot; (automatically spammed).
</del><ins>+         * @param string $source Either &quot;by_a_person&quot; (e.g. a person has manually marked the activity as ham) or &quot;by_akismet&quot; (automatically hammed).
</ins><span class="cx">          * @since 1.6
</span><span class="cx">          */
</span><span class="cx">         public function mark_as_ham( $activity, $source ) {
</span><del>-                //DJPAULTODO: Run bp_activity_at_name_filter() somehow... but not twice, if we can help it. Maybe check if it was auto-spammed by Akismet?
</del><ins>+                // If the activity was, originally, automatically marked as spam by Akismet, run the @mentions filter as it would have been skipped.
+                if ( 'true' == bp_activity_get_meta( $activity-&gt;id, '_bp_akismet_result' ) &amp;&amp; !bp_activity_get_meta( $activity-&gt;id, '_bp_akismet_user_result' ) )
+                        $activity-&gt;content = bp_activity_at_name_filter( $activity-&gt;content, $activity-&gt;id );
</ins><span class="cx"> 
</span><span class="cx">                 do_action( 'bp_activity_akismet_mark_as_ham', $activity, $source );
</span><span class="cx">         } 
</span><span class="lines">@@ -332,39 +334,33 @@
</span><span class="cx">         /**
</span><span class="cx">          * Update activity meta after a manual spam change (user initiated)
</span><span class="cx">          *
</span><del>-         * @global object $bp BuddyPress global settings
</del><span class="cx">          * @param BP_Activity_Activity $activity The activity to check
</span><span class="cx">          * @since 1.6
</span><span class="cx">          */
</span><span class="cx">         public function update_activity_spam_meta( $activity ) {
</span><del>-                global $bp;
-
</del><span class="cx">                 // By default, only handle activity updates and activity comments.
</span><span class="cx">                 if ( !in_array( $activity-&gt;type, BP_Akismet::get_activity_types() ) )
</span><span class="cx">                         return;
</span><span class="cx"> 
</span><del>-                $this-&gt;update_activity_history( $activity-&gt;id, sprintf( __( '%s reported this activity as spam', 'buddypress' ), $bp-&gt;loggedin_user-&gt;fullname ), 'report-spam' );
</del><ins>+                $this-&gt;update_activity_history( $activity-&gt;id, sprintf( __( '%s reported this activity as spam', 'buddypress' ), bp_get_loggedin_user_fullname() ), 'report-spam' );
</ins><span class="cx">                 bp_activity_update_meta( $activity-&gt;id, '_bp_akismet_user_result', 'true' );
</span><del>-                bp_activity_update_meta( $activity-&gt;id, '_bp_akismet_user', $bp-&gt;loggedin_user-&gt;fullname );
</del><ins>+                bp_activity_update_meta( $activity-&gt;id, '_bp_akismet_user', bp_get_loggedin_user_fullname() );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * Update activity meta after a manual ham change (user initiated)
</span><span class="cx">          *
</span><del>-         * @global object $bp BuddyPress global settings
</del><span class="cx">          * @param BP_Activity_Activity $activity The activity to check
</span><span class="cx">          * @since 1.6
</span><span class="cx">          */
</span><span class="cx">         public function update_activity_ham_meta( $activity ) {
</span><del>-                global $bp;
-
</del><span class="cx">                 // By default, only handle activity updates and activity comments.
</span><span class="cx">                 if ( !in_array( $activity-&gt;type, BP_Akismet::get_activity_types() ) )
</span><span class="cx">                         return;
</span><span class="cx"> 
</span><del>-                $this-&gt;update_activity_history( $activity-&gt;id, sprintf( __( '%s reported this activity as not spam', 'buddypress' ), $bp-&gt;loggedin_user-&gt;fullname ), 'report-ham' );
</del><ins>+                $this-&gt;update_activity_history( $activity-&gt;id, sprintf( __( '%s reported this activity as not spam', 'buddypress' ), bp_get_loggedin_user_fullname() ), 'report-ham' );
</ins><span class="cx">                 bp_activity_update_meta( $activity-&gt;id, '_bp_akismet_user_result', 'false' );
</span><del>-                bp_activity_update_meta( $activity-&gt;id, '_bp_akismet_user', $bp-&gt;loggedin_user-&gt;fullname );
</del><ins>+                bp_activity_update_meta( $activity-&gt;id, '_bp_akismet_user', bp_get_loggedin_user_fullname() );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -491,7 +487,7 @@
</span><span class="cx">                 $response       = '';
</span><span class="cx"> 
</span><span class="cx">                 // Unique User Agent
</span><del>-                $akismet_ua     = 'BuddyPress/' . constant( 'BP_VERSION' ) . ' | Akismet/'. constant( 'AKISMET_VERSION' );
</del><ins>+                $akismet_ua     = 'BuddyPress/' . bp_get_version() . ' | Akismet/'. constant( 'AKISMET_VERSION' );
</ins><span class="cx"> 
</span><span class="cx">                 // Use specific IP (if provided)
</span><span class="cx">                 if ( !empty( $ip ) &amp;&amp; long2ip( ip2long( $ip ) ) )
</span></span></pre></div>
<a id="trunkbpactivitybpactivityfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-functions.php (5324 => 5325)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-functions.php        2011-11-11 21:38:21 UTC (rev 5324)
+++ trunk/bp-activity/bp-activity-functions.php        2011-11-12 21:09:29 UTC (rev 5325)
</span><span class="lines">@@ -1359,7 +1359,7 @@
</span><span class="cx"> 
</span><span class="cx">         // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity
</span><span class="cx">         if ( 'by_a_person' == $source &amp;&amp; !empty( $bp-&gt;activity-&gt;akismet ) ) {
</span><del>-                remove_action( 'bp_activity_before_save', array( $bp-&gt;activity-&gt;akismet, 'check_activity' ), 1, 1 );
</del><ins>+                remove_action( 'bp_activity_before_save', array( $bp-&gt;activity-&gt;akismet, 'check_activity' ), 4, 1 );
</ins><span class="cx"> 
</span><span class="cx">                 // Build data package for Akismet
</span><span class="cx">                 $activity_data = BP_Akismet::build_akismet_data_package( $activity );
</span><span class="lines">@@ -1395,7 +1395,7 @@
</span><span class="cx"> 
</span><span class="cx">         // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity
</span><span class="cx">         if ( 'by_a_person' == $source &amp;&amp; !empty( $bp-&gt;activity-&gt;akismet ) ) {
</span><del>-                remove_action( 'bp_activity_before_save', array( $bp-&gt;activity-&gt;akismet, 'check_activity' ), 1, 1 );
</del><ins>+                remove_action( 'bp_activity_before_save', array( $bp-&gt;activity-&gt;akismet, 'check_activity' ), 4, 1 );
</ins><span class="cx"> 
</span><span class="cx">                 // Build data package for Akismet
</span><span class="cx">                 $activity_data = BP_Akismet::build_akismet_data_package( $activity );
</span><span class="lines">@@ -1407,7 +1407,6 @@
</span><span class="cx">                 add_action( 'bp_activity_after_save', array( $bp-&gt;activity-&gt;akismet, 'update_activity_ham_meta' ), 1, 1 );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        //DJPAULTODO: Run bp_activity_at_name_filter() somehow... but not twice, if we can help it. Maybe check if it was auto-spammed by Akismet?
</del><span class="cx">         do_action( 'bp_activity_mark_as_ham', $activity, $source );
</span><span class="cx"> } 
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>