Skip to:
Content

BuddyPress.org

Changeset 2370


Ignore:
Timestamp:
01/19/2010 08:38:20 PM (17 years ago)
Author:
apeatling
Message:

Better activity delete usability.

Location:
trunk
Files:
3 edited

Legend:

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

    r2361 r2370  
    473473                                /* Delete link */
    474474                                if ( is_site_admin() || $bp->loggedin_user->id == $comment->user_id )
    475                                         $content .= ' &middot; <a href="' . wp_nonce_url( $bp->activity->id . '/delete/?cid=' . $comment->id, 'delete_activity_comment' ) . '" class="delete acomment-delete">' . __( 'Delete', 'buddypress' ) . '</a>';
     475                                        $content .= ' &middot; <a href="' . wp_nonce_url( $bp->activity->id . '/delete/?cid=' . $comment->id, 'bp_activity_delete_link' ) . '" class="delete acomment-delete">' . __( 'Delete', 'buddypress' ) . '</a>';
    476476
    477477                                $content .= '</div>';
  • trunk/bp-themes/bp-default/_inc/ajax.php

    r2369 r2370  
    145145add_action( 'wp_ajax_new_activity_comment', 'bp_dtheme_new_activity_comment' );
    146146
    147 function bp_dtheme_delete_activity_comment() {
     147function bp_dtheme_delete_activity() {
    148148        /* Check the nonce */
    149         check_admin_referer( 'delete_activity_comment' );
     149        check_admin_referer( 'bp_activity_delete_link' );
    150150
    151151        if ( !is_user_logged_in() ) {
     
    154154        }
    155155
    156         if ( empty( $_POST['comment_id'] ) || !is_numeric( $_POST['comment_id'] ) || !bp_activity_delete_by_activity_id( $_POST['comment_id'] ) ) {
    157                 echo '-1<div class="error"><p>' . __( 'There was a problem deleting that comment. Please try again.', 'buddypress' ) . '</p></div>';
     156        if ( empty( $_POST['id'] ) || !is_numeric( $_POST['id'] ) || !bp_activity_delete_by_activity_id( $_POST['id'] ) ) {
     157                echo '-1<div class="error"><p>' . __( 'There was a problem when deleting. Please try again.', 'buddypress' ) . '</p></div>';
    158158                return false;
    159159        }
     
    161161        return true;
    162162}
    163 add_action( 'wp_ajax_delete_activity_comment', 'bp_dtheme_delete_activity_comment' );
     163add_action( 'wp_ajax_delete_activity_comment', 'bp_dtheme_delete_activity' );
     164add_action( 'wp_ajax_delete_activity', 'bp_dtheme_delete_activity' );
    164165
    165166function bp_dtheme_activity_loop( $type = 'all', $filter = false, $query_string = false, $per_page = 20, $page = 1 ) {
  • trunk/bp-themes/bp-default/_inc/global.js

    r2367 r2370  
    180180                                if ( 'activity-favorites' == j( 'div.item-list-tabs li.selected').attr('id') )
    181181                                        target.parent().parent().parent().slideUp(100);
     182                        });
     183
     184                        return false;
     185                }
     186
     187                /* Delete activity stream items */
     188                if ( target.hasClass('delete-activity') ) {
     189                        var li = target.parents('div.activity ul li');
     190                        var id = li.attr('id').substr( 9, li.attr('id').length );
     191                        var link_href = target.attr('href');
     192
     193                        var nonce = link_href.split('_wpnonce=');
     194                                nonce = nonce[1];
     195
     196                        target.addClass('loading');
     197
     198                        j.post( ajaxurl, {
     199                                action: 'delete_activity',
     200                                'cookie': encodeURIComponent(document.cookie),
     201                                'id': id,
     202                                '_wpnonce': nonce
     203                        },
     204                        function(response) {
     205                                target.removeClass('loading');
     206
     207                                if ( response[0] + response[1] == '-1' ) {
     208                                        li.prepend( response.substr( 2, response.length ) );
     209                                        li.children('div#message').hide().fadeIn(200);
     210                                } else {
     211                                        li.slideUp(200);
     212                                }
    182213                        });
    183214
     
    396427
    397428                        j.post( ajaxurl, {
    398                                 action: 'delete_activity_comment',
     429                                action: 'delete_activity',
    399430                                'cookie': encodeURIComponent(document.cookie),
    400431                                '_wpnonce': nonce,
    401                                 'comment_id': comment_id
     432                                'id': comment_id
    402433                        },
    403434                        function(response)
Note: See TracChangeset for help on using the changeset viewer.