<!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][5484] trunk/bp-activity: Activity admin iteration.</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/5484">5484</a></dd>
<dt>Author</dt> <dd>djpaul</dd>
<dt>Date</dt> <dd>2011-12-10 18:19:44 +0000 (Sat, 10 Dec 2011)</dd>
</dl>

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

* Add remaining activity properties to the edit screen.
* Add new contextual help to the edit screen.
* Add support for 2 columns to the edit screen.
* Fix a typo (props fanquake, see <a href="http://buddypress.trac.wordpress.org/ticket/3822">#3822</a>).
* Update BP_Activity_Activity::save() method to fix a bug where an update operation with no changes was reported as an error.
* Update activity admin CSS, bump version number.</pre>

<h3>Modified Paths</h3>
<ul>
<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><a href="#trunkbpactivitybpactivityadminphp">trunk/bp-activity/bp-activity-admin.php</a></li>
<li><a href="#trunkbpactivitybpactivityclassesphp">trunk/bp-activity/bp-activity-classes.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivityadmincssadmincss"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/admin/css/admin.css (5483 => 5484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/admin/css/admin.css        2011-12-10 18:16:23 UTC (rev 5483)
+++ trunk/bp-activity/admin/css/admin.css        2011-12-10 18:19:44 UTC (rev 5484)
</span><span class="lines">@@ -1 +1 @@
</span><del>-#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;}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px;}#wp-bp-activities-content-wrap{margin-top:20px;}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px;}
</del><span class="cx">\ No newline at end of file
</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;}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px;}#wp-bp-activities-content-wrap{margin-top:20px;}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px;}#bp_activity_link input{width:99%;}#bp-activities-primaryid{margin-bottom:1em;}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpactivityadmincssadmindevcss"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/admin/css/admin.dev.css (5483 => 5484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/admin/css/admin.dev.css        2011-12-10 18:16:23 UTC (rev 5483)
+++ trunk/bp-activity/admin/css/admin.dev.css        2011-12-10 18:19:44 UTC (rev 5484)
</span><span class="lines">@@ -38,4 +38,10 @@
</span><span class="cx"> #post-body #bp-activities-content_resize {
</span><span class="cx">         position: inherit;
</span><span class="cx">         margin-top: -2px;
</span><ins>+}
+#bp_activity_link input {
+        width: 99%;
+}
+#bp-activities-primaryid {
+        margin-bottom: 1em;
</ins><span class="cx"> }
</span><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 (5483 => 5484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-admin.php        2011-12-10 18:16:23 UTC (rev 5483)
+++ trunk/bp-activity/bp-activity-admin.php        2011-12-10 18:19:44 UTC (rev 5484)
</span><span class="lines">@@ -134,13 +134,33 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Hide the advanced edit meta boxes by default, so we don't clutter the scren.
+ *
+ * @param WP_Screen $screen Screen identifier
+ * @return array Hidden Meta Boxes
+ * @since 1.0
+ */
+function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
+        if ( empty( $screen-&gt;id ) || 'toplevel_page_bp-activity' != $screen-&gt;id )
+                return $hidden;
+
+        // Hide the primary link meta box by default
+        $hidden  = array_merge( (array) $hidden, array( 'bp_activity_itemids', 'bp_activity_link', 'bp_activity_type', 'bp_activity_userid', ) );
+
+        return apply_filters( 'bp_hide_meta_boxes', array_unique( $hidden ), $screen );
+}
+add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxes', 10, 2 );
+
+
+/**
</ins><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><ins>+ * @global object $bp BuddyPress global settings
</ins><span class="cx">  * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
</span><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;
</del><ins>+        global $bp, $bp_activity_list_table;
</ins><span class="cx"> 
</span><span class="cx">         // Decide whether to load the dev version of the CSS and JavaScript
</span><span class="cx">         $dev = ( defined( 'SCRIPT_DEBUG' ) &amp;&amp; SCRIPT_DEBUG ) ? 'dev.' : '';
</span><span class="lines">@@ -150,16 +170,41 @@
</span><span class="cx"> 
</span><span class="cx">         // Edit screen
</span><span class="cx">         if ( 'edit' == $doaction &amp;&amp; ! empty( $_GET['aid'] ) ) {
</span><ins>+                // columns screen option
+                add_screen_option( 'layout_columns', array( 'default' =&gt; 2, 'max' =&gt; 2, ) );
+
</ins><span class="cx">                 get_current_screen()-&gt;add_help_tab( array(
</span><span class="cx">                         'id'      =&gt; 'bp-activity-edit-overview',
</span><span class="cx">                         'title'   =&gt; __( 'Overview', 'buddypress' ),
</span><span class="cx">                         'content' =&gt;
</span><del>-                                '&lt;p&gt;' . __( 'You can edit activities made on your site similar to the way you edit a comment. This is useful if you need to change which page the activity links to, or when you notice that the author has made a typographical error.', 'buddypress' ) . '&lt;/p&gt;' .
</del><ins>+                                '&lt;p&gt;' . __( 'You edit activities made on your site similar to the way you edit a comment. This is useful if you need to change which page the activity links to, or when you notice that the author has made a typographical error.', 'buddypress' ) . '&lt;/p&gt;' .
+                                '&lt;p&gt;' . __( 'The two big editing areas for the activity title and content are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Primary Item/Secondary Item, Link, Type, Author ID) or to choose a 1- or 2-column layout for this screen.', 'buddypress' ) . '&lt;/p&gt;' .
</ins><span class="cx">                                 '&lt;p&gt;' . __( 'You can also moderate the activity from this screen using the Status box, where you can also change the timestamp of the activity.', 'buddypress' ) . '&lt;/p&gt;'
</span><span class="cx">                 ) );
</span><span class="cx"> 
</span><ins>+                get_current_screen()-&gt;add_help_tab( array(
+                        'id'      =&gt; 'bp-activity-edit-advanced',
+                        'title'   =&gt; __( 'Item, Link, Type', 'buddypress' ),
+                        'content' =&gt;
+                                '&lt;p&gt;' . __( '&lt;strong&gt;Primary Item/Secondary Item&lt;/strong&gt; - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields.', 'buddypress' ) . '&lt;/p&gt;' .
+                                '&lt;p&gt;' . __( '&lt;strong&gt;Link&lt;/strong&gt; - Activity generated by blog posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item. Some types of activity may not use this field, even if it has been set.', 'buddypress' ) . '&lt;/p&gt;' .
+                                '&lt;p&gt;' . __( '&lt;strong&gt;Type&lt;/strong&gt; - Each distinct kind of activity has its own type. For example, &lt;code&gt;created_group&lt;/code&gt; is used when a group is created and &lt;code&gt;joined_group&lt;/code&gt; is used when a user joins a group.', 'buddypress' ) . '&lt;/p&gt;' .
+                                '&lt;p&gt;' . __( 'For information about when and how BuddyPress uses all of these settings, see the Managing Activity link in the panel to the side.', 'buddypress' ) . '&lt;/p&gt;'
+                ) );
+
+                // Help panel - sidebar links
+                get_current_screen()-&gt;set_help_sidebar(
+                        '&lt;p&gt;&lt;strong&gt;' . __( 'For more information:', 'buddypress' ) . '&lt;/strong&gt;&lt;/p&gt;' .
+                        '&lt;p&gt;' . __( '&lt;a href=&quot;http://codex.buddypress.org/buddypress-site-administration/managing-activity/&quot;&gt;Managing Activity&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;' .
+                        '&lt;p&gt;' . __( '&lt;a href=&quot;http://buddypress.org/support/&quot;&gt;Support Forums&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;'
+                );
+
</ins><span class="cx">                 // Register metaboxes for the edit screen.
</span><del>-                add_meta_box( 'submitdiv', _x( 'Status', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_status', 'toplevel_page_bp-activity', 'side', 'core' );
</del><ins>+                add_meta_box( 'submitdiv',           _x( 'Status', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_status', 'toplevel_page_bp-activity', 'side', 'core' );
+                add_meta_box( 'bp_activity_itemids', _x( 'Primary Item/Secondary Item', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_itemids', 'toplevel_page_bp-activity', 'advanced', 'core' );
+                add_meta_box( 'bp_activity_link',    _x( 'Link', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_link', 'toplevel_page_bp-activity', 'advanced', 'core' );
+                add_meta_box( 'bp_activity_type',    _x( 'Type', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_type', 'toplevel_page_bp-activity', 'advanced', 'core' );
+                add_meta_box( 'bp_activity_userid',  _x( 'Author ID', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_userid', 'toplevel_page_bp-activity', 'advanced', 'core' );
</ins><span class="cx"> 
</span><span class="cx">                 // Enqueue javascripts
</span><span class="cx">                 wp_enqueue_script( 'postbox' );
</span><span class="lines">@@ -167,7 +212,7 @@
</span><span class="cx">                 wp_enqueue_script( 'comment' );
</span><span class="cx"> 
</span><span class="cx">                 // Enqueue CSS
</span><del>-                wp_enqueue_style( 'bp_activity_admin_css', BP_PLUGIN_URL . &quot;bp-activity/admin/css/admin.{$dev}css&quot;, array(), '20111203' );
</del><ins>+                wp_enqueue_style( 'bp_activity_admin_css', BP_PLUGIN_URL . &quot;bp-activity/admin/css/admin.{$dev}css&quot;, array(), '20111210' );
</ins><span class="cx"> 
</span><span class="cx">         // Index screen
</span><span class="cx">         } else {
</span><span class="lines">@@ -191,23 +236,21 @@
</span><span class="cx">                         'id'                =&gt; 'bp-activity-moderating',
</span><span class="cx">                         'title'                =&gt; __( 'Moderating Activity', 'buddypress' ),
</span><span class="cx">                         'content'        =&gt;
</span><del>-                                '&lt;ul&gt;' .
-                                        '&lt;li&gt;' . __( 'In the &lt;strong&gt;Activity&lt;/strong&gt; 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;/li&gt;' .
-                                        '&lt;li&gt;' . __( &quot;In the &lt;strong&gt;In Response To&lt;/strong&gt; column, if the activity was in reply to another activity, it shows that activity's author's picture and name, and a link to that activity on your live site. If there is a small bubble, 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.&quot;, 'buddypress' ) . '&lt;/li&gt;' .
-                                '&lt;/ul&gt;'
</del><ins>+                                '&lt;p&gt;' . __( 'In the &lt;strong&gt;Activity&lt;/strong&gt; 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;' .
+                                '&lt;p&gt;' . __( &quot;In the &lt;strong&gt;In Response To&lt;/strong&gt; column, if the activity was in reply to another activity, it shows that activity's author's picture and name, and a link to that activity on your live site. If there is a small bubble, 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.&quot;, 'buddypress' ) . '&lt;/p&gt;'
</ins><span class="cx">                 ) );
</span><span class="cx"> 
</span><ins>+                // Help panel - sidebar links
+                get_current_screen()-&gt;set_help_sidebar(
+                        '&lt;p&gt;&lt;strong&gt;' . __( 'For more information:', 'buddypress' ) . '&lt;/strong&gt;&lt;/p&gt;' .
+                        '&lt;p&gt;' . __( '&lt;a href=&quot;http://buddypress.org/support/&quot;&gt;Support Forums&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;'
+                );
+
</ins><span class="cx">                 // Enqueue CSS and JavaScript
</span><span class="cx">                 wp_enqueue_script( 'bp_activity_admin_js', BP_PLUGIN_URL . &quot;bp-activity/admin/js/admin.{$dev}js&quot;, array( 'jquery', 'wp-ajax-response' ), '20111120' );
</span><span class="cx">                 wp_enqueue_style( 'bp_activity_admin_css', BP_PLUGIN_URL . &quot;bp-activity/admin/css/admin.{$dev}css&quot;, array(), '20111203' );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        // Help panel - sidebar links
-        get_current_screen()-&gt;set_help_sidebar(
-                '&lt;p&gt;&lt;strong&gt;' . __( 'For more information:', 'buddypress' ) . '&lt;/strong&gt;&lt;/p&gt;' .
-                '&lt;p&gt;' . __( '&lt;a href=&quot;http://buddypress.org/support/&quot;&gt;Support Forums&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;'
-        );
-
</del><span class="cx">         // Handle spam/un-spam/delete of activities
</span><span class="cx">         if ( $doaction &amp;&amp; ! in_array( $doaction, array( '-1', 'edit', 'save', ) ) ) {
</span><span class="cx"> 
</span><span class="lines">@@ -342,25 +385,55 @@
</span><span class="cx">                 // Store any error that occurs when updating the database item
</span><span class="cx">                 $error = 0;
</span><span class="cx"> 
</span><del>-                // Set tainted if a new form value is different from the object's old value
-                $tainted = false;
-                
</del><span class="cx">                 // Activity spam status
</span><ins>+                $prev_spam_status = $new_spam_status = false;
</ins><span class="cx">                 if ( ! empty( $_REQUEST['activity_status'] ) ) {
</span><span class="cx">                         $prev_spam_status = $activity-&gt;is_spam;
</span><del>-                        $new_spam_status  = ( 'spam' == $_REQUEST['activity_status'] ) ? 1 : 0;
</del><ins>+                        $new_spam_status  = ( 'spam' == $_REQUEST['activity_status'] ) ? true : false;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 // Activity action
</span><del>-                if ( ! empty( $_REQUEST['bp-activities-action'] ) &amp;&amp; stripslashes( $activity-&gt;action ) != stripslashes( $_REQUEST['bp-activities-action'] ) ) {
</del><ins>+                if ( ! empty( $_REQUEST['bp-activities-action'] ) )
</ins><span class="cx">                         $activity-&gt;action = $_REQUEST['bp-activities-action'];
</span><del>-                        $tainted = true;
-                }
</del><span class="cx"> 
</span><span class="cx">                 // Activity content
</span><del>-                if ( ! empty( $_REQUEST['bp-activities-content'] ) &amp;&amp; stripslashes( $activity-&gt;content ) != stripslashes( $_REQUEST['bp-activities-content'] ) ) {
</del><ins>+                if ( ! empty( $_REQUEST['bp-activities-content'] ) )
</ins><span class="cx">                         $activity-&gt;content = $_REQUEST['bp-activities-content'];
</span><del>-                        $tainted = true;
</del><ins>+
+                // Activity primary link
+                if ( ! empty( $_REQUEST['bp-activities-link'] ) )
+                        $activity-&gt;primary_link = $_REQUEST['bp-activities-link'];
+
+                // Activity user ID
+                if ( ! empty( $_REQUEST['bp-activities-userid'] ) )
+                        $activity-&gt;user_id = (int) $_REQUEST['bp-activities-userid'];
+
+                // Activity item primary ID
+                if ( ! empty( $_REQUEST['bp-activities-primaryid'] ) )
+                        $activity-&gt;item_id = (int) $_REQUEST['bp-activities-primaryid'];
+
+                // Activity item secondary ID
+                if ( ! empty( $_REQUEST['bp-activities-secondaryid'] ) )
+                        $activity-&gt;secondary_item_id = (int) $_REQUEST['bp-activities-secondaryid'];
+
+                // Activity type
+                if ( ! empty( $_REQUEST['bp-activities-type'] ) ) {
+                        $actions  = array();
+
+                        // Walk through the registered actions, and build an array of actions/values.
+                        foreach ( $bp-&gt;activity-&gt;actions as $action ) {
+                                $action = array_values( (array) $action );
+
+                                for ( $i = 0, $i_count = count( $action ); $i &lt; $i_count; $i++ )
+                                        $actions[] = $action[$i]['key'];
+                        }
+
+                        // This was a mis-named activity type from before BP 1.6
+                        unset( $actions['friends_register_activity_action'] );
+
+                        // Check that the new type is a registered activity type
+                        if ( in_array( $_REQUEST['bp-activities-type'], $actions ) )
+                                $activity-&gt;type = $_REQUEST['bp-activities-type'];
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 // Activity timestamp
</span><span class="lines">@@ -382,20 +455,15 @@
</span><span class="cx">                         // Reconstruct the date into a timestamp. Convert it to GMT.
</span><span class="cx">                         $gmt_date = get_gmt_from_date( sprintf( &quot;%04d-%02d-%02d %02d:%02d:%02d&quot;, $aa, $mm, $jj, $hh, $mn, $ss ) );
</span><span class="cx"> 
</span><del>-                        if ( $activity-&gt;date_recorded != $gmt_date ) {
-                                $activity-&gt;date_recorded = $gmt_date;
-                                $tainted = true;
-                        }
</del><ins>+                        $activity-&gt;date_recorded = $gmt_date;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 // Has the spam status has changed?
</span><del>-                if ( $prev_spam_status != $new_spam_status ) {
-                        if ( 1 == $new_spam_status)
</del><ins>+                if ( $new_spam_status != $prev_spam_status ) {
+                        if ( $new_spam_status )
</ins><span class="cx">                                 bp_activity_mark_as_spam( $activity );
</span><span class="cx">                         else
</span><span class="cx">                                 bp_activity_mark_as_ham( $activity );
</span><del>-
-                        $tainted = true;
</del><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 // Save
</span><span class="lines">@@ -405,7 +473,7 @@
</span><span class="cx">                 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
</span><span class="cx"> 
</span><span class="cx">                 // Check for any error during activity save
</span><del>-                if ( ! $result &amp;&amp; $tainted )
</del><ins>+                if ( false === $result )
</ins><span class="cx">                         $error = $activity-&gt;id;
</span><span class="cx"> 
</span><span class="cx">                 // If an error occured, pass back the activity ID that failed
</span><span class="lines">@@ -447,9 +515,12 @@
</span><span class="cx"> /**
</span><span class="cx">  * Display the single activity edit screen
</span><span class="cx">  *
</span><ins>+ * @global int $screen_layout_columns Number of columns shown on this admin page
</ins><span class="cx">  * @since 1.6
</span><span class="cx">  */
</span><span class="cx"> function bp_activity_admin_edit() {
</span><ins>+        global $screen_layout_columns;
+
</ins><span class="cx">         // @todo: Check if user is allowed to edit activity items
</span><span class="cx">         // if ( ! current_user_can( 'bp_edit_activity' ) )
</span><span class="cx">         if ( ! is_super_admin() )
</span><span class="lines">@@ -485,7 +556,7 @@
</span><span class="cx">                 &lt;?php if ( ! empty( $activity ) ) : ?&gt;
</span><span class="cx"> 
</span><span class="cx">                         &lt;form action=&quot;&lt;?php echo esc_attr( $form_url ); ?&gt;&quot; id=&quot;bp-activities-edit-form&quot; method=&quot;post&quot;&gt;
</span><del>-                                &lt;div id=&quot;poststuff&quot; class=&quot;metabox-holder has-right-sidebar&quot;&gt;
</del><ins>+                                &lt;div id=&quot;poststuff&quot; class=&quot;metabox-holder&lt;?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?&gt;&quot;&gt;
</ins><span class="cx">                                         &lt;div id=&quot;side-info-column&quot; class=&quot;inner-sidebar&quot;&gt;
</span><span class="cx">                                                 &lt;?php do_meta_boxes( 'toplevel_page_bp-activity', 'side', $activity ); ?&gt;
</span><span class="cx">                                         &lt;/div&gt;
</span><span class="lines">@@ -573,6 +644,95 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Primary link metabox for the Activity admin edit screen
+ *
+ * @param object $item Activity item
+ * @since 1.6
+ */
+function bp_activity_admin_edit_metabox_link( $item ) {
+?&gt;
+
+        &lt;label class=&quot;screen-reader-text&quot; for=&quot;bp-activities-link&quot;&gt;&lt;?php _e( 'Link', 'buddypress' ); ?&gt;&lt;/label&gt;
+        &lt;input type=&quot;url&quot; name=&quot;bp-activities-link&quot; value=&quot;&lt;?php echo esc_url( $item-&gt;primary_link ); ?&gt;&quot; /&gt;
+        &lt;p&gt;&lt;?php _e( 'Activity generated by blog posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item.', 'buddypress' ); ?&gt;&lt;/p&gt;
+
+&lt;?php
+}
+
+/**
+ * User ID metabox for the Activity admin edit screen
+ *
+ * @param object $item Activity item
+ * @since 1.6
+ */
+function bp_activity_admin_edit_metabox_userid( $item ) {
+?&gt;
+
+        &lt;label class=&quot;screen-reader-text&quot; for=&quot;bp-activities-userid&quot;&gt;&lt;?php _e( 'Author ID', 'buddypress' ); ?&gt;&lt;/label&gt;
+        &lt;input type=&quot;number&quot; name=&quot;bp-activities-userid&quot; value=&quot;&lt;?php echo esc_attr( $item-&gt;user_id ); ?&gt;&quot; min=&quot;1&quot; /&gt;
+
+&lt;?php
+}
+
+/**
+ * Activity type metabox for the Activity admin edit screen
+ *
+ * @global object $bp BuddyPress global settings
+ * @param object $item Activity item
+ * @since 1.6
+ */
+function bp_activity_admin_edit_metabox_type( $item ) {
+        global $bp;
+
+        $actions  = array();
+        $selected = $item-&gt;type;
+
+        // Walk through the registered actions, and build an array of actions/values.
+        foreach ( $bp-&gt;activity-&gt;actions as $action ) {
+                $action = array_values( (array) $action );
+
+                for ( $i = 0, $i_count = count( $action ); $i &lt; $i_count; $i++ )
+                        $actions[ $action[$i]['key'] ] = $action[$i]['value'];
+        }
+
+        // This was a mis-named activity type from before BP 1.6
+        unset( $actions['friends_register_activity_action'] );
+
+        // Sort array by the human-readable value
+        natsort( $actions );
+?&gt;
+
+        &lt;select name=&quot;bp-activities-type&quot;&gt;
+                &lt;?php foreach ( $actions as $k =&gt; $v ) : ?&gt;
+                        &lt;option value=&quot;&lt;?php echo esc_attr( $k ); ?&gt;&quot; &lt;?php selected( $k,  $selected ); ?&gt;&gt;&lt;?php echo esc_html( $v ); ?&gt;&lt;/option&gt;
+                &lt;?php endforeach; ?&gt;
+        &lt;/select&gt;
+
+&lt;?php
+}
+
+/**
+ * Primary item ID/Secondary item ID metabox for the Activity admin edit screen
+ *
+ * @param object $item Activity item
+ * @since 1.6
+ */
+function bp_activity_admin_edit_metabox_itemids( $item ) {
+?&gt;
+
+        &lt;label for=&quot;bp-activities-primaryid&quot;&gt;&lt;?php _e( 'Primary Item ID', 'buddypress' ); ?&gt;&lt;/label&gt;
+        &lt;input type=&quot;number&quot; name=&quot;bp-activities-primaryid&quot; id=&quot;bp-activities-primaryid&quot; value=&quot;&lt;?php echo esc_attr( $item-&gt;item_id ); ?&gt;&quot; /&gt;
+        &lt;br /&gt;
+
+        &lt;label for=&quot;bp-activities-secondaryid&quot;&gt;&lt;?php _e( 'Secondary Item ID', 'buddypress' ); ?&gt;&lt;/label&gt;
+        &lt;input type=&quot;number&quot; name=&quot;bp-activities-secondaryid&quot; id=&quot;bp-activities-secondaryid&quot; value=&quot;&lt;?php echo esc_attr( $item-&gt;secondary_item_id ); ?&gt;&quot; /&gt;
+
+        &lt;p&gt;&lt;?php _e( 'These identify the object that created this activity. For example, the fields could reference a pair of site and comment IDs.', 'buddypress' ); ?&gt;&lt;/p&gt;
+
+&lt;?php
+}
+
+/**
</ins><span class="cx">  * Display the Activity admin index screen, which contains a list of all the activities.
</span><span class="cx">  *
</span><span class="cx">  * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
</span><span class="lines">@@ -590,13 +750,13 @@
</span><span class="cx">                 $error     = !empty( $_REQUEST['error']     ) ? (int) $_REQUEST['error']     : 0;
</span><span class="cx">                 $spammed   = !empty( $_REQUEST['spammed']   ) ? (int) $_REQUEST['spammed']   : 0;
</span><span class="cx">                 $unspammed = !empty( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0;
</span><del>-                $updated   = !empty( $_REQUEST['updated'] )   ? (int) $_REQUEST['updated']   : 0;
</del><ins>+                $updated   = !empty( $_REQUEST['updated']   ) ? (int) $_REQUEST['updated']   : 0;
</ins><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' ), number_format_i18n( $deleted ) );
</span><span class="cx"> 
</span><span class="cx">                 if ( $error &gt; 0 )
</span><del>-                        $messages[] = sprintf( __( 'An error occured when updating Activity ID #%s.', 'buddypress' ), number_format_i18n( $error ) );
</del><ins>+                        $messages[] = sprintf( __( 'An error occurred when updating Activity ID #%s.', 'buddypress' ), number_format_i18n( $error ) );
</ins><span class="cx"> 
</span><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' ), number_format_i18n( $spammed ) );
</span></span></pre></div>
<a id="trunkbpactivitybpactivityclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-classes.php (5483 => 5484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-classes.php        2011-12-10 18:16:23 UTC (rev 5483)
+++ trunk/bp-activity/bp-activity-classes.php        2011-12-10 18:19:44 UTC (rev 5484)
</span><span class="lines">@@ -86,7 +86,7 @@
</span><span class="cx">                 else
</span><span class="cx">                         $q = $wpdb-&gt;prepare( &quot;INSERT INTO {$bp-&gt;activity-&gt;table_name} ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d )&quot;, $this-&gt;user_id, $this-&gt;component, $this-&gt;type, $this-&gt;action, $this-&gt;content, $this-&gt;primary_link, $this-&gt;date_recorded, $this-&gt;item_id, $this-&gt;secondary_item_id, $this-&gt;hide_sitewide, $this-&gt;is_spam );
</span><span class="cx"> 
</span><del>-                if ( !$wpdb-&gt;query( $q ) )
</del><ins>+                if ( false === $wpdb-&gt;query( $q ) )
</ins><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="cx">                 if ( empty( $this-&gt;id ) )
</span></span></pre>
</div>
</div>

</body>
</html>