Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 11807)
+++ wp-includes/post.php	(working copy)
@@ -1264,7 +1264,7 @@
 
 	do_action('untrash_post', $postid);
 
-	$post['post_status'] = 'draft';
+	$post['post_status'] = ($post->post_type == 'attachment') ? 'inherit' : 'draft';
 
 	$trash_meta = get_option('wp_trash_meta');
 	if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) {
Index: wp-includes/js/swfupload/handlers.dev.js
===================================================================
--- wp-includes/js/swfupload/handlers.dev.js	(revision 11807)
+++ wp-includes/js/swfupload/handlers.dev.js	(working copy)
@@ -78,7 +78,7 @@
 		// Tell the server to delete it. TODO: handle exceptions
 		jQuery.ajax({url:'admin-ajax.php',type:'post',success:deleteSuccess,error:deleteError,id:fileObj.id,data:{
 			id : this.id.replace(/[^0-9]/g,''),
-			action : 'delete-post',
+			action : 'trash-post',
 			_ajax_nonce : this.href.replace(/^.*wpnonce=/,'')}
 			});
 		return false;
Index: wp-includes/capabilities.php
===================================================================
--- wp-includes/capabilities.php	(revision 11807)
+++ wp-includes/capabilities.php	(working copy)
@@ -775,6 +775,11 @@
 			// If the post is published...
 			if ( 'publish' == $post->post_status )
 				$caps[] = 'delete_published_posts';
+			elseif ( 'trash' == $post->post_status ) {
+				$trash_meta = get_option('wp_trash_meta');
+				if (is_array($trash_meta) && isset($trash_meta['posts'][$post->ID]['status']) && $trash_meta['posts'][$post->ID]['status'] == 'publish')
+					$caps[] = 'delete_published_posts';
+			}
 			else
 				// If the post is draft...
 				$caps[] = 'delete_posts';
@@ -799,6 +804,11 @@
 			// If the page is published...
 			if ( $page->post_status == 'publish' )
 				$caps[] = 'delete_published_pages';
+			elseif ( 'trash' == $page->post_status ) {
+				$trash_meta = get_option('wp_trash_meta');
+				if (is_array($trash_meta) && isset($trash_meta['posts'][$page->ID]['status']) && $trash_meta['posts'][$page->ID]['status'] == 'publish')
+					$caps[] = 'delete_published_pages';
+			}
 			else
 				// If the page is draft...
 				$caps[] = 'delete_pages';
@@ -829,6 +839,11 @@
 			// If the post is published...
 			if ( 'publish' == $post->post_status )
 				$caps[] = 'edit_published_posts';
+			elseif ( 'trash' == $post->post_status ) {
+				$trash_meta = get_option('wp_trash_meta');
+				if (is_array($trash_meta) && isset($trash_meta['posts'][$post->ID]['status']) && $trash_meta['posts'][$post->ID]['status'] == 'publish')
+					$caps[] = 'edit_published_posts';
+			}
 			else
 				// If the post is draft...
 				$caps[] = 'edit_posts';
@@ -853,6 +868,11 @@
 			// If the page is published...
 			if ( 'publish' == $page->post_status )
 				$caps[] = 'edit_published_pages';
+			elseif ( 'trash' == $page->post_status ) {
+				$trash_meta = get_option('wp_trash_meta');
+				if (is_array($trash_meta) && isset($trash_meta['posts'][$page->ID]['status']) && $trash_meta['posts'][$page->ID]['status'] == 'publish')
+					$caps[] = 'edit_published_pages';
+			}
 			else
 				// If the page is draft...
 				$caps[] = 'edit_pages';
Index: wp-admin/edit-comments.php
===================================================================
--- wp-admin/edit-comments.php	(revision 11807)
+++ wp-admin/edit-comments.php	(working copy)
@@ -303,7 +303,7 @@
 
 if ( ( 'spam' == $comment_status || 'trash' == $comment_status) && current_user_can ('moderate_comments') ) {
 	wp_nonce_field('bulk-destroy', '_destroy_nonce');
-    if ( 'spam' == $comment_status ) { ?>
+    if ( 'spam' == $comment_status && current_user_can('moderate_comments') ) { ?>
 		<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" />
 <?php } elseif ( 'trash' == $comment_status && current_user_can('moderate_comments') ) { ?>
 		<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
@@ -375,7 +375,7 @@
 </select>
 <input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
 
-<?php if ( 'spam' == $comment_status ) { ?>
+<?php if ( 'spam' == $comment_status && current_user_can('moderate_comments') ) { ?>
 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" />
 <?php } elseif ( 'trash' == $comment_status && current_user_can('moderate_comments') ) { ?>
 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
Index: wp-admin/admin-ajax.php
===================================================================
--- wp-admin/admin-ajax.php	(revision 11807)
+++ wp-admin/admin-ajax.php	(working copy)
@@ -312,6 +312,19 @@
 	else
 		die('0');
 	break;
+case 'trash-post' :
+	check_ajax_referer( "{$action}_$id" );
+	if ( !current_user_can( 'delete_post', $id ) )
+		die('-1');
+
+	if ( !get_post( $id ) )
+		die('1');
+
+	if ( wp_trash_post( $id ) )
+		die('1');
+	else
+		die('0');
+	break;
 case 'delete-page' :
 	check_ajax_referer( "{$action}_$id" );
 	if ( !current_user_can( 'delete_page', $id ) )
Index: wp-admin/includes/template.php
===================================================================
--- wp-admin/includes/template.php	(revision 11807)
+++ wp-admin/includes/template.php	(working copy)
@@ -1439,9 +1439,11 @@
 				the_excerpt();
 
 			$actions = array();
-			if ( 'trash' == $post->post_status && current_user_can('delete_post', $post->ID) ) {
-				$actions['untrash'] = "<a title='" . esc_attr(__('Remove this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=untrash&amp;post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
-				$actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
+			if ('trash' == $post->post_status) {
+				if (current_user_can('delete_post', $post->ID)) {
+					$actions['untrash'] = "<a title='" . esc_attr(__('Remove this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=untrash&amp;post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
+					$actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
+				}
 			} else {
 				if ( current_user_can('edit_post', $post->ID) ) {
 					$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
Index: wp-admin/includes/media.php
===================================================================
--- wp-admin/includes/media.php	(revision 11807)
+++ wp-admin/includes/media.php	(working copy)
@@ -1062,9 +1062,12 @@
 	}
 
 	$output = '';
-	foreach ( (array) $attachments as $id => $attachment )
+	foreach ( (array) $attachments as $id => $attachment ) {
+		if ( $attachment->post_status == 'trash' )
+			continue;
 		if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
 			$output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress'><div class='bar'></div></div><div id='media-upload-error-$id'></div><div class='filename'></div>$item\n</div>";
+	}
 
 	return $output;
 }
@@ -1166,11 +1169,11 @@
 		'extra_rows' => array(),
 	);
 
-	$delete_href = wp_nonce_url("post.php?action=trash&amp;post=$attachment_id", 'delete-post_' . $attachment_id);
+	$delete_href = wp_nonce_url("post.php?action=trash&amp;post=$attachment_id", 'trash-post_' . $attachment_id);
 	if ( $send )
 		$send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />";
 	if ( $delete )
-		$delete = "<a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>";
+		$delete = current_user_can('delete_post', $attachment_id) ? "<a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>" : "";
 	if ( ( $send || $delete ) && !isset($form_fields['buttons']) )
 		$form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete</td></tr>\n");
 
Index: wp-admin/edit-attachment-rows.php
===================================================================
--- wp-admin/edit-attachment-rows.php	(revision 11807)
+++ wp-admin/edit-attachment-rows.php	(working copy)
@@ -59,7 +59,7 @@
 
 	case 'cb':
 		?>
-		<th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /></th>
+		<th scope="row" class="check-column"><?php if (current_user_can('edit_post', $post->ID)) { ?><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /><?php } ?></th>
 		<?php
 		break;
 
@@ -89,9 +89,11 @@
 		<p>
 		<?php
 		$actions = array();
-		if ( $is_trash && current_user_can('delete_post', $post->ID) ) {
-			$actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=untrash&amp;post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
-			$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
+		if ($is_trash) {
+			if (current_user_can('delete_post', $post->ID)) {
+				$actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=untrash&amp;post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
+				$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
+			}
 		} else {
 			if ( current_user_can('edit_post', $post->ID) )
 				$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
Index: wp-admin/upload.php
===================================================================
--- wp-admin/upload.php	(revision 11807)
+++ wp-admin/upload.php	(working copy)
@@ -321,7 +321,7 @@
 
 <?php if ( isset($_GET['detached']) ) { ?>
 	<input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" />
-<?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' ) { ?>
+<?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts')) { ?>
 	<input type="submit" id="delete_all" name="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
 <?php } ?>
 
@@ -362,7 +362,7 @@
 			$att_title = esc_html( _draft_or_post_title($post->ID) );
 ?>
 	<tr id='post-<?php echo $post->ID; ?>' class='<?php echo $class; ?>' valign="top">
-		<th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php echo esc_attr($post->ID); ?>" /></th>
+		<th scope="row" class="check-column"><?php if (current_user_can('edit_post', $post->ID)) { ?><input type="checkbox" name="media[]" value="<?php echo esc_attr($post->ID); ?>" /><?php } ?></th>
 
 		<td class="media-icon"><?php
 		if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) { ?>
@@ -446,7 +446,7 @@
 </select>
 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
 
-<?php if ( isset($_GET['status']) && $_GET['status'] == 'trash' ) { ?>
+<?php if ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts')) { ?>
 	<input type="submit" id="delete_all2" name="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
 <?php } ?>
 </div>
Index: wp-admin/edit-form-comment.php
===================================================================
--- wp-admin/edit-form-comment.php	(revision 11807)
+++ wp-admin/edit-form-comment.php	(working copy)
@@ -68,7 +68,7 @@
 
 <div id="major-publishing-actions">
 <div id="delete-action">
-<?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=deletecomment&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "'>" . __('Move to Trash') . "</a>\n"; ?>
+<?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=trashcomment&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode(wp_get_referer()), 'trash-comment_' . $comment->comment_ID) . "'>" . __('Move to Trash') . "</a>\n"; ?>
 </div>
 <div id="publishing-action">
 <input type="submit" name="save" value="<?php esc_attr_e('Update Comment'); ?>" tabindex="4" class="button-primary" />

