Add user id to lock. Props duck_. see #15130
git-svn-id: http://svn.automattic.com/wordpress/trunk@16901 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3949ce12d0
commit
07d2164984
|
@ -1201,13 +1201,17 @@ function wp_check_post_lock( $post_id ) {
|
||||||
if ( !$post = get_post( $post_id ) )
|
if ( !$post = get_post( $post_id ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$lock = get_post_meta( $post->ID, '_edit_lock', true );
|
if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) )
|
||||||
$last = get_post_meta( $post->ID, '_edit_last', true );
|
return false;
|
||||||
|
|
||||||
|
$lock = explode( ':', $lock );
|
||||||
|
$time = $lock[0];
|
||||||
|
$user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
|
||||||
|
|
||||||
$time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 );
|
$time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 );
|
||||||
|
|
||||||
if ( $lock && $lock > time() - $time_window && $last != get_current_user_id() )
|
if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
|
||||||
return $last;
|
return $user;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1222,12 +1226,13 @@ function wp_check_post_lock( $post_id ) {
|
||||||
function wp_set_post_lock( $post_id ) {
|
function wp_set_post_lock( $post_id ) {
|
||||||
if ( !$post = get_post( $post_id ) )
|
if ( !$post = get_post( $post_id ) )
|
||||||
return false;
|
return false;
|
||||||
if ( 0 == get_current_user_id() )
|
if ( 0 == ($user_id = get_current_user_id()) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$now = time();
|
$now = time();
|
||||||
|
$lock = "$now:$user_id";
|
||||||
|
|
||||||
update_post_meta( $post->ID, '_edit_lock', $now );
|
update_post_meta( $post->ID, '_edit_lock', $lock );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1238,7 +1243,10 @@ function wp_set_post_lock( $post_id ) {
|
||||||
*/
|
*/
|
||||||
function _admin_notice_post_locked() {
|
function _admin_notice_post_locked() {
|
||||||
global $post;
|
global $post;
|
||||||
$last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) );
|
|
||||||
|
$lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) );
|
||||||
|
$user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
|
||||||
|
$last_user = get_userdata( $user );
|
||||||
$last_user_name = $last_user ? $last_user->display_name : __('Somebody');
|
$last_user_name = $last_user ? $last_user->display_name : __('Somebody');
|
||||||
|
|
||||||
switch ($post->post_type) {
|
switch ($post->post_type) {
|
||||||
|
|
Loading…
Reference in New Issue