<!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][5426] trunk/bp-activity/bp-activity-admin.php: 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/5426">5426</a></dd>
<dt>Author</dt> <dd>djpaul</dd>
<dt>Date</dt> <dd>2011-12-01 16:34:49 +0000 (Thu, 01 Dec 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Activity admin iteration. See <a href="http://buddypress.trac.wordpress.org/ticket/3660">#3660</a>.
* Pluralise the name of top-level Activity menu to match other menus' titles.
* Update contextual help for Activity index screen, and fix deprecated function use.
* Move index/edit screen generation into separate functions; restructure bp_activity_admin().
* Change the In Response To column to only show speech bubble when item is a root activity, rather than for any node that contains children. This changes the single activity filter screen to match BP-Default's activity permalink screen.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityadminphp">trunk/bp-activity/bp-activity-admin.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 (5425 => 5426)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-admin.php        2011-11-30 21:43:32 UTC (rev 5425)
+++ trunk/bp-activity/bp-activity-admin.php        2011-12-01 16:34:49 UTC (rev 5426)
</span><span class="lines">@@ -28,11 +28,11 @@
</span><span class="cx"> function bp_activity_add_admin_menu() {
</span><span class="cx">         global $bp;
</span><span class="cx">
</span><del>-        if ( !bp_current_user_can( 'bp_moderate' ) )
</del><ins>+        if ( ! bp_current_user_can( 'bp_moderate' ) )
</ins><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', 'bp_activity_admin' );
</del><ins>+        $hook = add_menu_page( __( 'BuddyPress Activities', 'buddypress' ), __( 'Activities', '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">@@ -141,31 +141,50 @@
</span><span class="cx"> function bp_activity_admin_load() {
</span><span class="cx">         global $bp_activity_list_table;
</span><span class="cx">
</span><del>-        // per_page screen option
-        add_screen_option( 'per_page', array( 'label' => _x( 'Activities', 'Activity items per page (screen options)', 'buddypress' )) );
</del><ins>+        // Create the Activity screen list table
+        $bp_activity_list_table = new BP_Activity_List_Table();
</ins><span class="cx">
</span><del>-        // Help panel - text
-        add_contextual_help( get_current_screen(), '<p>' . __( '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' ) . '</p>' .
-                '<p>' . __( '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' ) . '</p>' .
-                '<p>' . __( 'In the Activity column, above each activity it says &#8220;Submitted on,&#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' ) . '</p>' .
-                '<p>' . __( "In the In Response To 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.", 'buddypress' ) . '</p>'
-        );
</del><ins>+        // Edit screen
+        if ( 'edit' == $bp_activity_list_table->current_action() && !empty( $_GET['aid'] ) ) {
+                // @todo Contextual help for the edit screen
</ins><span class="cx">
</span><ins>+        // Index screen
+        } else {
+                // per_page screen option
+                add_screen_option( 'per_page', array( 'label' => _x( 'Activities', 'Activity items per page (screen options)', 'buddypress' )) );
+
+                // Help panel - overview text
+                get_current_screen()->add_help_tab( array(
+                        'id' => 'bp-activity-overview',
+                        'title' => __( 'Overview', 'buddypress' ),
+                        'content' =>
+                                '<p>' . __( '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' ) . '</p>' .
+                                '<p>' . __( 'There are many different types of activities. Some are generated automatically by BuddyPress and other plugins, and some 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' ) . '</p>'
+                ) );
+
+        // Help panel - moderation text
+                get_current_screen()->add_help_tab( array(
+                        'id'                => 'bp-activity-moderating',
+                        'title'                => __( 'Moderating Activities', 'buddypress' ),
+                        'content'        =>
+                                '<ul>' .
+                                        '<li>' . __( 'In the <strong>Activity</strong> column, above each activity it says &#8220;Submitted on,&#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' ) . '</li>' .
+                                        '<li>' . __( "In the <strong>In Response To</strong> 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.", 'buddypress' ) . '</li>' .
+                                '</ul>'
+                ) );
+
+                // Enqueue CSS and JavaScript
+                $dev = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? 'dev.' : '';
+                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(), '20111126' );
+        }
+
</ins><span class="cx">         // Help panel - sidebar links
</span><span class="cx">         get_current_screen()->set_help_sidebar(
</span><span class="cx">                 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
</span><span class="cx">                 '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
</span><span class="cx">         );
</span><span class="cx">
</span><del>-        $dev = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? 'dev.' : '';
-
-        // Enqueue CSS and JavaScript
-        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(), '20111126' );
-
-        // Create the Activity screen list table
-        $bp_activity_list_table = new BP_Activity_List_Table();
-
</del><span class="cx">         // Handle spam/un-spam/delete of activities
</span><span class="cx">         $doaction = $bp_activity_list_table->current_action();
</span><span class="cx">         if ( $doaction && 'edit' != $doaction ) {
</span><span class="lines">@@ -286,10 +305,38 @@
</span><span class="cx"> * Outputs the Activity component admin screens
</span><span class="cx"> *
</span><span class="cx"> * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
</span><ins>+ * @since 1.6
+ */
+function bp_activity_admin() {
+        global $bp_activity_list_table;
+
+        // Display the single activity edit screen
+        if ( 'edit' == $bp_activity_list_table->current_action() && !empty( $_GET['aid'] ) )
+                bp_activity_admin_edit();
+
+        // Otherwise, display the Activity index screen
+        else
+                bp_activity_admin_index();
+}
+
+/**
+ * Display the single activity edit screen
+ *
+ * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
+ * @since 1.6
+ */
+function bp_activity_admin_edit() {
+        global $bp_activity_list_table;
+}
+
+/**
+ * Display the Activity admin index screen, which contains a list of all the activities.
+ *
+ * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
</ins><span class="cx"> * @global string $plugin_page
</span><span class="cx"> * @since 1.6
</span><span class="cx"> */
</span><del>-function bp_activity_admin() {
</del><ins>+function bp_activity_admin_index() {
</ins><span class="cx">         global $bp_activity_list_table, $plugin_page;
</span><span class="cx">
</span><span class="cx">         $messages = array();
</span><span class="lines">@@ -313,10 +360,6 @@
</span><span class="cx">                 if ( $unspammed > 0 )
</span><span class="cx">                         $messages[] = sprintf( _n( '%s activity restored from the spam.', '%s activities restored from the spam.', $unspammed, 'buddypress' ), number_format_i18n( $unspammed ) );
</span><span class="cx">
</span><del>-        // Handle the edit screen
-        } elseif ( 'edit' == $bp_activity_list_table->current_action() && !empty( $_GET['aid'] ) ) {
-                echo '@TODO: Activity Edit screen.';
-                return;
</del><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         // Prepare the activity items for display
</span><span class="lines">@@ -327,9 +370,9 @@
</span><span class="cx">                 <?php screen_icon( 'buddypress' ); ?>
</span><span class="cx">                 <h2>
</span><span class="cx">                         <?php if ( !empty( $_REQUEST['aid'] ) ) : ?>
</span><del>-                                <?php printf( __( 'Activity (ID #%s)', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
</del><ins>+                                <?php printf( __( 'Activities related to ID #%s', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
</ins><span class="cx">                         <?php else : ?>
</span><del>-                                <?php _e( 'Activity', 'buddypress' ); ?>
</del><ins>+                                <?php _e( 'Activities', 'buddypress' ); ?>
</ins><span class="cx">                         <?php endif; ?>
</span><span class="cx">
</span><span class="cx">                         <?php if ( !empty( $_REQUEST['s'] ) ) : ?>
</span><span class="lines">@@ -810,35 +853,22 @@
</span><span class="cx">          * @since 1.6
</span><span class="cx">          */
</span><span class="cx">         function column_response( $item ) {
</span><del>-                // Get activity permalink
-                $activity_link = bp_activity_get_permalink( $item['id'], (object) $item );
</del><ins>+                // Is $item is a root activity?
+                if ( empty( $item['item_id'] ) ) {
+                        $comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
+                        $root_activity_url = network_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
</ins><span class="cx">
</span><del>-                // Get the root activity ID; this may be not be the same as $item['id'] for nested items (e.g. activity_comments)
-                if ( empty( $item['item_id'] ) || ! in_array( $item['type'], apply_filters( 'bp_activity_admin_root_activity_types', array( 'activity_comment' ), $item ) ) )
-                        $is_root_activity = true;
-                else
-                        $is_root_activity = false;
</del><ins>+                        // If the activity has comments, display a link to the activity's permalink, with its comment count in a speech bubble
+                        if ( $comment_count ) {
+                                $title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) );
+                                printf( '<a href="%1$s" title="%2$s" class="post-com-count"><span class="comment-count">%3$s</span></a>', esc_attr( $root_activity_url ), esc_attr( $title_attr ), number_format_i18n( $comment_count ) );
+                        }
</ins><span class="cx">
</span><del>-                $root_activity_id = $is_root_activity ? $item['id'] : $item['item_id'];
-                $root_activity_url = network_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $root_activity_id );
-
-                // Get comment count
-                if ( $is_root_activity )
-                        $comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
-                else
-                        $comment_count = count( BP_Activity_Activity::get_child_comments( $item['id'] ) );
-
-                if ( ! $is_root_activity ) {
-                        // Display link to the replied-to activity's author's profile
</del><ins>+                // For non-root activities, display a link to the replied-to activity's author's profile
+                } else {
</ins><span class="cx">                         echo '<strong>' . get_avatar( $this->get_activity_user_id( $item['item_id'] ), '32' ) . ' ' . bp_core_get_userlink( $this->get_activity_user_id( $item['item_id'] ) ) . '</strong><br />';
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                // If the activity has comments, display a link to the root activity's permalink, with its comment count in a speech bubble
-                if ( $comment_count ) {
-                        $title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) );
-                        printf( '<a href="%1$s" title="%2$s" class="post-com-count"><span class="comment-count">%3$s</span></a>', $root_activity_url, esc_attr( $title_attr ), number_format_i18n( $comment_count ) );
-                }
-
</del><span class="cx">                 // Activity permalink
</span><span class="cx">                 printf( __( '<a href="%1$s">View Activity</a>', 'buddypress' ), bp_activity_get_permalink( $item['id'], (object) $item ) );
</span><span class="cx">         }
</span></span></pre>
</div>
</div>
</body>
</html>