<!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][5280] trunk: Add Akismet history information to the Activity admin page's items.</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/5280">5280</a></dd>
<dt>Author</dt> <dd>djpaul</dd>
<dt>Date</dt> <dd>2011-11-05 21:38:08 +0000 (Sat, 05 Nov 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add Akismet history information to the Activity admin page's items.
Use new wrapper functions to get user's UA and IP for Akismet calls.
Rename Activity admin page slug.</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="#trunkbpcorebpcorecssjsphp">trunk/bp-core/bp-core-cssjs.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 (5279 => 5280)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-admin.php        2011-11-05 21:31:07 UTC (rev 5279)
+++ trunk/bp-activity/bp-activity-admin.php        2011-11-05 21:38:08 UTC (rev 5280)
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx">                 return;
</span><span class="cx">
</span><span class="cx">         // Add our screen
</span><del>-        $hook = add_menu_page( __( 'Activity', 'buddypress' ), __( 'Activity', 'buddypress' ), 'manage_options', 'bp-activity-settings', 'bp_activity_admin' );
</del><ins>+        $hook = add_menu_page( __( 'Activity', 'buddypress' ), __( 'Activity', 'buddypress' ), 'manage_options', 'bp-activity', 'bp_activity_admin' );
</ins><span class="cx">
</span><span class="cx">         // Hook into early actions to load custom CSS and our init handler.
</span><span class="cx">         add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
</span><span class="lines">@@ -520,6 +520,6 @@
</span><span class="cx">                         return;
</span><span class="cx">
</span><span class="cx">                 /* translators: 1: activity admin screen permalink, 2: activity ID */
</span><del>-                printf( __( '<a href="%1$s">Activity ID #%2$d</a>', 'buddypress' ), network_admin_url( 'admin.php?page=bp-activity-settings&a=' . $item['secondary_item_id'] ), $item['secondary_item_id'] );
</del><ins>+                printf( __( '<a href="%1$s">Activity ID #%2$d</a>', 'buddypress' ), network_admin_url( 'admin.php?page=bp-activity&a=' . $item['secondary_item_id'] ), $item['secondary_item_id'] );
</ins><span class="cx">         }
</span><span class="cx"> }?>
</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 (5279 => 5280)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-akismet.php        2011-11-05 21:31:07 UTC (rev 5279)
+++ trunk/bp-activity/bp-activity-akismet.php        2011-11-05 21:38:08 UTC (rev 5280)
</span><span class="lines">@@ -54,10 +54,62 @@
</span><span class="cx">                 add_action( 'bp_activity_mark_as_ham', array( $this, 'mark_as_ham' ), 10, 2 );
</span><span class="cx">
</span><span class="cx">                 // Hook into the Activity wp-admin screen
</span><del>-                //add_action( 'bp_activity_admin_comment_row_actions', array( $this, 'add_activity_status_row' ), 10, 2 );
</del><ins>+                add_action( 'bp_activity_admin_comment_row_actions', array( $this, 'comment_row_action' ), 10, 2 );
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><ins>+         * Add a history item to the hover links in an activity's row.
+         *
+         * This function lifted with love from the Akismet WordPress plugin's
+         * akismet_comment_row_action() function. Thanks!
+         *
+         * @param array $actions The hover links
+         * @param array $activity The activity for the current row being processed
+         * @return array The hover links
+         * @since 1.6
+         */
+        function comment_row_action( $actions, $activity ) {
+                $akismet_result = bp_activity_get_meta( $activity['id'], '_bp_akismet_result' );
+                $user_result = bp_activity_get_meta( $activity['id'], '_bp_akismet_user_result' );
+                $desc = '';
+
+                if ( !$user_result || $user_result == $akismet_result ) {
+                        // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
+                        if ( $akismet_result == 'true' && $activity['is_spam'] )
+                                $desc = __( 'Flagged as spam by Akismet', 'buddypress' );
+
+                        elseif ( $akismet_result == 'false' && !$activity['is_spam'] )
+                                $desc = __( 'Cleared by Akismet', 'buddypress' );
+
+                } else {
+                        $who = bp_activity_get_meta( $activity['id'], '_bp_akismet_user' );
+
+                        if ( $user_result == 'true' )
+                                $desc = sprintf( __( 'Flagged as spam by %s', 'buddypress' ), $who );
+                        else
+                                $desc = sprintf( __( 'Un-spammed by %s', 'buddypress' ), $who );
+                }
+
+                // add a History item to the hover links, just after Edit
+                if ( $akismet_result ) {
+                        $b = array();
+                        foreach ( $actions as $k => $item ) {
+                                $b[ $k ] = $item;
+                                if ( $k == 'edit' )
+                                        $b['history'] = '<a href="#"> '. __( 'History', 'buddypress' ) . '</a>';
+                        }
+
+                        $actions = $b;
+                }
+
+                if ( $desc )
+                        echo '<span class="akismet-status"><a href="#">' . htmlspecialchars( $desc ) . '</a></span>';
+
+                return apply_filters( 'bp_akismet_comment_row_action', $actions );
+        }
+
+
+        /**
</ins><span class="cx">          * Adds a nonce to the member profile status form, and to the reply form of each activity stream item.
</span><span class="cx">          * This is used by Akismet to help detect spam activity.
</span><span class="cx">          *
</span><span class="lines">@@ -371,8 +423,8 @@
</span><span class="cx">                 $activity_data['blog_charset'] = bp_get_option( 'blog_charset' );
</span><span class="cx">                 $activity_data['blog_lang'] = get_locale();
</span><span class="cx">                 $activity_data['referrer'] = $_SERVER['HTTP_REFERER'];
</span><del>-                $activity_data['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
-                $activity_data['user_ip'] = $_SERVER['REMOTE_ADDR'];
</del><ins>+                $activity_data['user_agent'] = bp_core_current_user_ua();
+                $activity_data['user_ip'] = bp_core_current_user_ip();
</ins><span class="cx">
</span><span class="cx">                 if ( akismet_test_mode() )
</span><span class="cx">                         $activity_data['is_test'] = 'true';
</span></span></pre></div>
<a id="trunkbpcorebpcorecssjsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-cssjs.php (5279 => 5280)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-cssjs.php        2011-11-05 21:31:07 UTC (rev 5279)
+++ trunk/bp-core/bp-core-cssjs.php        2011-11-05 21:38:08 UTC (rev 5280)
</span><span class="lines">@@ -30,10 +30,10 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 /* Activity Icon */
</span><del>-                ul#adminmenu li.toplevel_page_bp-activity-settings .wp-menu-image a img { display: none; }
-                ul#adminmenu li.toplevel_page_bp-activity-settings .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }
-                ul#adminmenu li.toplevel_page_bp-activity-settings:hover .wp-menu-image a,
-                ul#adminmenu li.toplevel_page_bp-activity-settings.wp-has-current-submenu .wp-menu-image a {
</del><ins>+                ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image a img { display: none; }
+                ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }
+                ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image a,
+                ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image a {
</ins><span class="cx">                         background-position: -1px 0;
</span><span class="cx">                 }
</span><span class="cx">         </style>
</span></span></pre>
</div>
</div>
</body>
</html>