Skip to:
Content

BuddyPress.org

Changeset 5426


Ignore:
Timestamp:
12/01/2011 04:34:49 PM (10 years ago)
Author:
djpaul
Message:

Activity admin iteration. See #3660.

  • 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-admin.php

    r5421 r5426  
    2929    global $bp;
    3030
    31     if ( !bp_current_user_can( 'bp_moderate' ) )
     31    if ( ! bp_current_user_can( 'bp_moderate' ) )
    3232        return;
    3333
    3434    // Add our screen
    35     $hook = add_menu_page( __( 'Activity', 'buddypress' ), __( 'Activity', 'buddypress' ), 'manage_options', 'bp-activity', 'bp_activity_admin' );
     35    $hook = add_menu_page( __( 'BuddyPress Activities', 'buddypress' ), __( 'Activities', 'buddypress' ), 'manage_options', 'bp-activity', 'bp_activity_admin' );
    3636
    3737    // Hook into early actions to load custom CSS and our init handler.
     
    142142    global $bp_activity_list_table;
    143143
    144     // per_page screen option
    145     add_screen_option( 'per_page', array( 'label' => _x( 'Activities', 'Activity items per page (screen options)', 'buddypress' )) );
    146 
    147     // Help panel - text
    148     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>' .
    149         '<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>' .
    150         '<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>' .
    151         '<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>'
    152     );
     144    // Create the Activity screen list table
     145    $bp_activity_list_table = new BP_Activity_List_Table();
     146
     147    // Edit screen
     148    if ( 'edit' == $bp_activity_list_table->current_action() && !empty( $_GET['aid'] ) ) {
     149        // @todo Contextual help for the edit screen
     150
     151    // Index screen
     152    } else {
     153        // per_page screen option
     154        add_screen_option( 'per_page', array( 'label' => _x( 'Activities', 'Activity items per page (screen options)', 'buddypress' )) );
     155
     156        // Help panel - overview text
     157        get_current_screen()->add_help_tab( array(
     158            'id'      => 'bp-activity-overview',
     159            'title'   => __( 'Overview', 'buddypress' ),
     160            'content' =>
     161                '<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>' .
     162                '<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>'
     163        ) );
     164
     165    // Help panel - moderation text
     166        get_current_screen()->add_help_tab( array(
     167            'id'        => 'bp-activity-moderating',
     168            'title'     => __( 'Moderating Activities', 'buddypress' ),
     169            'content'   =>
     170                '<ul>' .
     171                    '<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>' .
     172                    '<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>' .
     173                '</ul>'
     174        ) );
     175
     176        // Enqueue CSS and JavaScript
     177        $dev = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? 'dev.' : '';
     178        wp_enqueue_script( 'bp_activity_admin_js', BP_PLUGIN_URL . "bp-activity/admin/js/admin.{$dev}js", array( 'jquery', 'wp-ajax-response' ), '20111120' );
     179        wp_enqueue_style( 'bp_activity_admin_css', BP_PLUGIN_URL . "bp-activity/admin/css/admin.{$dev}css", array(), '20111126' );
     180    }
    153181
    154182    // Help panel - sidebar links
     
    157185        '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
    158186    );
    159 
    160     $dev = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? 'dev.' : '';
    161 
    162     // Enqueue CSS and JavaScript
    163     wp_enqueue_script( 'bp_activity_admin_js', BP_PLUGIN_URL . "bp-activity/admin/js/admin.{$dev}js", array( 'jquery', 'wp-ajax-response' ), '20111120' );
    164     wp_enqueue_style( 'bp_activity_admin_css', BP_PLUGIN_URL . "bp-activity/admin/css/admin.{$dev}css", array(), '20111126' );
    165 
    166     // Create the Activity screen list table
    167     $bp_activity_list_table = new BP_Activity_List_Table();
    168187
    169188    // Handle spam/un-spam/delete of activities
     
    287306 *
    288307 * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
     308 * @since 1.6
     309 */
     310function bp_activity_admin() {
     311    global $bp_activity_list_table;
     312
     313    // Display the single activity edit screen
     314    if ( 'edit' == $bp_activity_list_table->current_action() && !empty( $_GET['aid'] ) )
     315        bp_activity_admin_edit();
     316
     317    // Otherwise, display the Activity index screen
     318    else
     319        bp_activity_admin_index();
     320}
     321
     322/**
     323 * Display the single activity edit screen
     324 *
     325 * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
     326 * @since 1.6
     327 */
     328function bp_activity_admin_edit() {
     329    global $bp_activity_list_table;
     330}
     331
     332/**
     333 * Display the Activity admin index screen, which contains a list of all the activities.
     334 *
     335 * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
    289336 * @global string $plugin_page
    290337 * @since 1.6
    291338 */
    292 function bp_activity_admin() {
     339function bp_activity_admin_index() {
    293340    global $bp_activity_list_table, $plugin_page;
    294341
     
    314361            $messages[] = sprintf( _n( '%s activity restored from the spam.', '%s activities restored from the spam.', $unspammed, 'buddypress' ), number_format_i18n( $unspammed ) );
    315362
    316     // Handle the edit screen
    317     } elseif ( 'edit' == $bp_activity_list_table->current_action() && !empty( $_GET['aid'] ) ) {
    318         echo '@TODO: Activity Edit screen.';
    319         return;
    320363    }
    321364
     
    328371        <h2>
    329372            <?php if ( !empty( $_REQUEST['aid'] ) ) : ?>
    330                 <?php printf( __( 'Activity (ID #%s)', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
     373                <?php printf( __( 'Activities related to ID #%s', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
    331374            <?php else : ?>
    332                 <?php _e( 'Activity', 'buddypress' ); ?>
     375                <?php _e( 'Activities', 'buddypress' ); ?>
    333376            <?php endif; ?>
    334377
     
    811854     */
    812855    function column_response( $item ) {
    813         // Get activity permalink
    814         $activity_link = bp_activity_get_permalink( $item['id'], (object) $item );
    815 
    816         // Get the root activity ID; this may be not be the same as $item['id'] for nested items (e.g. activity_comments)
    817         if ( empty( $item['item_id'] ) || ! in_array( $item['type'], apply_filters( 'bp_activity_admin_root_activity_types', array( 'activity_comment' ), $item ) ) )
    818             $is_root_activity  = true;
    819         else
    820             $is_root_activity  = false;
    821 
    822         $root_activity_id  = $is_root_activity ? $item['id'] : $item['item_id'];
    823         $root_activity_url = network_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $root_activity_id );
    824 
    825         // Get comment count
    826         if ( $is_root_activity )
    827             $comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
    828         else
    829             $comment_count = count( BP_Activity_Activity::get_child_comments( $item['id'] ) );
    830 
    831         if ( ! $is_root_activity ) {
    832             // Display link to the replied-to activity's author's profile
     856        // Is $item is a root activity?
     857        if ( empty( $item['item_id'] ) ) {
     858            $comment_count     = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
     859            $root_activity_url = network_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
     860
     861            // If the activity has comments, display a link to the activity's permalink, with its comment count in a speech bubble
     862            if ( $comment_count ) {
     863                $title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) );
     864                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 ) );
     865            }
     866
     867        // For non-root activities, display a link to the replied-to activity's author's profile
     868        } else {
    833869            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 />';
    834         }
    835 
    836         // If the activity has comments, display a link to the root activity's permalink, with its comment count in a speech bubble
    837         if ( $comment_count ) {
    838             $title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) );
    839             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 ) );
    840870        }
    841871
Note: See TracChangeset for help on using the changeset viewer.