Make WordPress Core


Ignore:
Timestamp:
09/27/2011 08:52:07 PM (14 years ago)
Author:
nacin
Message:

Release a user's post lock when the user leaves a post. see #18515.

File:
1 edited

Legend:

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

    r18767 r18796  
    989989    }
    990990
    991     if ( $do_lock && empty( $_POST['auto_draft'] ) && $id && is_numeric( $id ) )
    992         wp_set_post_lock( $id );
     991    if ( $do_lock && empty( $_POST['auto_draft'] ) && $id && is_numeric( $id ) ) {
     992        $lock_result = wp_set_post_lock( $id );
     993        $supplemental['active-post-lock'] = implode( ':', $lock_result );
     994    }
    993995
    994996    if ( $nonce_age == 2 ) {
     
    15521554    die();
    15531555    break;
     1556case 'wp-remove-post-lock' :
     1557    if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) )
     1558        die( '0' );
     1559    $post_id = (int) $_POST['post_ID'];
     1560    if ( ! $post = get_post( $post_id ) )
     1561        die( '0' );
     1562
     1563    check_ajax_referer( 'update-' . $post->post_type . '_' . $post_id );
     1564
     1565    if ( ! current_user_can( 'edit_post', $post_id ) )
     1566        die( '-1' );
     1567
     1568    $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
     1569    if ( $active_lock[1] != get_current_user_id() )
     1570        die( '0' );
     1571
     1572    $new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ) + 5 ) . ':' . $active_lock[1];
     1573    update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) );
     1574    die( '1' );
     1575
    15541576default :
    15551577    do_action( 'wp_ajax_' . $_POST['action'] );
Note: See TracChangeset for help on using the changeset viewer.