Skip to:
Content

Changeset 2423


Ignore:
Timestamp:
05/03/10 20:27:41 (4 years ago)
Author:
mdawaffe
Message:

if the only post of a topic is deleted, redirect to topic_url?view=all. See #1150

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-admin/admin-ajax.php

    r2147 r2423  
    119119        die('1'); // We're already there 
    120120 
    121     if ( bb_delete_post( $id, $status ) ) 
     121    if ( bb_delete_post( $id, $status ) ) { 
     122        $topic = get_topic( $bb_post->topic_id ); 
     123        if ( 0 == $topic->topic_posts ) { 
     124            // If we deleted the only post, send back a WP_Ajax_Response object with a URL to redirect to 
     125            if ( $ref = wp_get_referer() ) { 
     126                $ref_topic = bb_get_topic_from_uri( $ref ); 
     127                if ( $ref_topic && $ref_topic->topic_id == $topic->topic_id ) 
     128                    $ref = add_query_arg( 'view', 'all', $ref ); 
     129                if ( false === strpos( $ref, '#' ) ) 
     130                    $ref .= "#post-{$bb_post->post_id}"; 
     131            } else { 
     132                $ref = add_query_arg( 'view', 'all', get_post_link( $topic->topic_id ) ); 
     133            } 
     134            $x = new WP_Ajax_Response( array( 
     135                'what' => 'post', 
     136                'id' => $bb_post->post_id, 
     137                'data' => $ref, 
     138            ) ); 
     139            $x->send(); 
     140        } 
    122141        die('1'); 
     142    } 
    123143    break; 
    124144/* 
  • trunk/bb-admin/delete-post.php

    r2249 r2423  
    6868    $sendto = remove_query_arg( 'message', $sendto ); 
    6969    $sendto = add_query_arg( 'message', $message, $sendto ); 
    70 } elseif ( $topic->topic_posts == 0 ) { 
     70    $send_to_topic = bb_get_topic_from_uri( $sendto ); 
     71    if ( $send_to_topic && $topic->topic_id == $send_to_topic->topic_id ) 
     72        $sendto = add_query_arg( 'view', 'all', $sendto ); 
     73} else if ( $topic->topic_posts == 0 ) { 
    7174    $sendto = get_forum_link( $topic->forum_id ); 
    7275} else { 
  • trunk/bb-includes/js/topic.js

    r2406 r2423  
    5656    }; 
    5757 
    58     $('#thread').addClass( 'list:post' ).wpList( { alt: 'alt', altOffset: 1, confirm: postConfirm } ); 
     58    $('#thread').addClass( 'list:post' ).wpList( { alt: 'alt', altOffset: 1, confirm: postConfirm, delAfter: function( r, s ) { 
     59        try { 
     60            // If we deleted the only post, we got an WP AJAX Response object back with a URL to redirect to 
     61            document.location = s.parsed.responses[0].data; 
     62        } catch ( e ) {} 
     63    } } ); 
    5964} ); 
Note: See TracChangeset for help on using the changeset viewer.