don't get or set post_lock if you can't edit the post/page. Props mdawaffe

git-svn-id: http://svn.automattic.com/wordpress/trunk@7781 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-04-22 23:54:13 +00:00
parent fe4cab3d1f
commit 5d839715d5
2 changed files with 24 additions and 18 deletions

View File

@ -83,15 +83,18 @@ case 'edit':
wp_enqueue_script('editor');
wp_enqueue_script('thickbox');
wp_enqueue_script('media-upload');
if ( $last = wp_check_post_lock( $post->ID ) ) {
$last_user = get_userdata( $last );
$last_user_name = $last_user ? $last_user->display_name : __('Somebody');
$message = sprintf( __( 'Warning: %s is currently editing this page' ), wp_specialchars( $last_user_name ) );
$message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
add_action('admin_notices', create_function( '', "echo '$message';" ) );
} else {
wp_set_post_lock( $post->ID );
wp_enqueue_script('autosave');
if ( current_user_can('edit_page', $page_ID) ) {
if ( $last = wp_check_post_lock( $post->ID ) ) {
$last_user = get_userdata( $last );
$last_user_name = $last_user ? $last_user->display_name : __('Somebody');
$message = sprintf( __( 'Warning: %s is currently editing this page' ), wp_specialchars( $last_user_name ) );
$message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
add_action('admin_notices', create_function( '', "echo '$message';" ) );
} else {
wp_set_post_lock( $post->ID );
wp_enqueue_script('autosave');
}
}
require_once('admin-header.php');

View File

@ -90,15 +90,18 @@ case 'edit':
wp_enqueue_script('editor');
wp_enqueue_script('thickbox');
wp_enqueue_script('media-upload');
if ( $last = wp_check_post_lock( $post->ID ) ) {
$last_user = get_userdata( $last );
$last_user_name = $last_user ? $last_user->display_name : __('Somebody');
$message = sprintf( __( 'Warning: %s is currently editing this post' ), wp_specialchars( $last_user_name ) );
$message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
add_action('admin_notices', create_function( '', "echo '$message';" ) );
} else {
wp_set_post_lock( $post->ID );
wp_enqueue_script('autosave');
if ( current_user_can('edit_post', $post_ID) ) {
if ( $last = wp_check_post_lock( $post->ID ) ) {
$last_user = get_userdata( $last );
$last_user_name = $last_user ? $last_user->display_name : __('Somebody');
$message = sprintf( __( 'Warning: %s is currently editing this post' ), wp_specialchars( $last_user_name ) );
$message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
add_action('admin_notices', create_function( '', "echo '$message';" ) );
} else {
wp_set_post_lock( $post->ID );
wp_enqueue_script('autosave');
}
}
require_once('admin-header.php');