Skip to:
Content

BuddyPress.org

Changeset 5280


Ignore:
Timestamp:
11/05/2011 09:38:08 PM (13 years ago)
Author:
djpaul
Message:

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.

Location:
trunk
Files:
3 edited

Legend:

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

    r5262 r5280  
    3232
    3333    // Add our screen
    34     $hook = add_menu_page( __( 'Activity', 'buddypress' ), __( 'Activity', 'buddypress' ), 'manage_options', 'bp-activity-settings', 'bp_activity_admin' );
     34    $hook = add_menu_page( __( 'Activity', 'buddypress' ), __( 'Activity', 'buddypress' ), 'manage_options', 'bp-activity', 'bp_activity_admin' );
    3535
    3636    // Hook into early actions to load custom CSS and our init handler.
     
    521521
    522522        /* translators: 1: activity admin screen permalink, 2: activity ID */
    523         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'] );
     523        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'] );
    524524    }
    525525}?>
  • trunk/bp-activity/bp-activity-akismet.php

    r5276 r5280  
    5555
    5656        // Hook into the Activity wp-admin screen
    57         //add_action( 'bp_activity_admin_comment_row_actions', array( $this, 'add_activity_status_row' ), 10, 2 );
    58     }
     57        add_action( 'bp_activity_admin_comment_row_actions', array( $this, 'comment_row_action' ), 10, 2 );
     58    }
     59
     60    /**
     61     * Add a history item to the hover links in an activity's row.
     62     *
     63     * This function lifted with love from the Akismet WordPress plugin's
     64     * akismet_comment_row_action() function. Thanks!
     65     *
     66     * @param array $actions The hover links
     67     * @param array $activity The activity for the current row being processed
     68     * @return array The hover links
     69     * @since 1.6
     70     */
     71    function comment_row_action( $actions, $activity ) {
     72        $akismet_result = bp_activity_get_meta( $activity['id'], '_bp_akismet_result' );
     73        $user_result    = bp_activity_get_meta( $activity['id'], '_bp_akismet_user_result' );
     74        $desc           = '';
     75
     76        if ( !$user_result || $user_result == $akismet_result ) {
     77            // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
     78            if ( $akismet_result == 'true' && $activity['is_spam'] )
     79                $desc = __( 'Flagged as spam by Akismet', 'buddypress' );
     80
     81            elseif ( $akismet_result == 'false' && !$activity['is_spam'] )
     82                $desc = __( 'Cleared by Akismet', 'buddypress' );
     83
     84        } else {
     85            $who = bp_activity_get_meta( $activity['id'], '_bp_akismet_user' );
     86
     87            if ( $user_result == 'true' )
     88                $desc = sprintf( __( 'Flagged as spam by %s', 'buddypress' ), $who );
     89            else
     90                $desc = sprintf( __( 'Un-spammed by %s', 'buddypress' ), $who );
     91        }
     92
     93        // add a History item to the hover links, just after Edit
     94        if ( $akismet_result ) {
     95            $b = array();
     96            foreach ( $actions as $k => $item ) {
     97                $b[ $k ] = $item;
     98                if ( $k == 'edit' )
     99                    $b['history'] = '<a href="#"> '. __( 'History', 'buddypress' ) . '</a>';
     100            }
     101
     102            $actions = $b;
     103        }
     104
     105        if ( $desc )
     106            echo '<span class="akismet-status"><a href="#">' . htmlspecialchars( $desc ) . '</a></span>';
     107
     108        return apply_filters( 'bp_akismet_comment_row_action', $actions );
     109    }
     110
    59111
    60112    /**
     
    372424        $activity_data['blog_lang']    = get_locale();
    373425        $activity_data['referrer']     = $_SERVER['HTTP_REFERER'];
    374         $activity_data['user_agent']   = $_SERVER['HTTP_USER_AGENT'];
    375         $activity_data['user_ip']      = $_SERVER['REMOTE_ADDR'];
     426        $activity_data['user_agent']   = bp_core_current_user_ua();
     427        $activity_data['user_ip']      = bp_core_current_user_ip();
    376428
    377429        if ( akismet_test_mode() )
  • trunk/bp-core/bp-core-cssjs.php

    r5262 r5280  
    3131
    3232        /* Activity Icon */
    33         ul#adminmenu li.toplevel_page_bp-activity-settings .wp-menu-image a img { display: none; }
    34         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; }
    35         ul#adminmenu li.toplevel_page_bp-activity-settings:hover .wp-menu-image a,
    36         ul#adminmenu li.toplevel_page_bp-activity-settings.wp-has-current-submenu .wp-menu-image a {
     33        ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image a img { display: none; }
     34        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; }
     35        ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image a,
     36        ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image a {
    3737            background-position: -1px 0;
    3838        }
Note: See TracChangeset for help on using the changeset viewer.