Migrate to caps.

git-svn-id: http://svn.automattic.com/wordpress/trunk@2709 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2005-07-13 22:26:26 +00:00
parent 88183ca9eb
commit 02523f59d3
4 changed files with 13 additions and 17 deletions

View File

@ -497,8 +497,8 @@ function page_rows( $parent = 0, $level = 0, $pages = 0 ) {
<td><?php the_author() ?></td>
<td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td>
<td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
<td><?php if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
<td><?php if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), the_title('','',0)) . "')\">" . __('Delete') . "</a>"; } ?></td>
<td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
<td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), the_title('','',0)) . "')\">" . __('Delete') . "</a>"; } ?></td>
</tr>
<?php

View File

@ -155,7 +155,7 @@ edCanvas = document.getElementById('content');
<?php
if ('publish' != $post_status || 0 == $post_ID) {
?>
<?php if ( user_can_create_post($user_ID) ) : ?>
<?php if ( current_user_can('publish_posts') ) : ?>
<input name="publish" type="submit" id="publish" tabindex="10" value="<?php _e('Publish') ?>" />
<?php endif; ?>
<?php

View File

@ -198,13 +198,13 @@ foreach($posts_columns as $column_name=>$column_display_name) {
case 'control_edit':
?>
<td><?php if ( user_can_edit_post($user_ID,$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
<td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
<?php
break;
case 'control_delete':
?>
<td><?php if ( user_can_edit_post($user_ID,$post->ID) ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), wp_specialchars(get_the_title('', ''), 1) ) . "')\">" . __('Delete') . "</a>"; } ?></td>
<td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), wp_specialchars(get_the_title('', ''), 1) ) . "')\">" . __('Delete') . "</a>"; } ?></td>
<?php
break;

View File

@ -69,9 +69,6 @@ case 'edit':
if ( !current_user_can('edit_post', $post_ID) )
die ( __('You are not allowed to edit this post.') );
if ( !user_can_edit_post($user_ID, $post_ID) )
die ( __('You are not allowed to view other users\' private posts.') );
$post = get_post_to_edit($post_ID);
if ($post->post_status == 'static')
@ -120,9 +117,8 @@ case 'delete':
$post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
if (!user_can_delete_post($user_ID, $post_id)) {
if ( !current_user_can('edit_post', $post_id) )
die( __('You are not allowed to delete this post.') );
}
if (! wp_delete_post($post_id))
die( __('Error in deleting...') );
@ -145,7 +141,7 @@ case 'editcomment':
if ( ! $comment = get_comment($comment) )
die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)'));
if ( !user_can_edit_post_comments($user_ID, $comment->comment_post_ID) )
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
die( __('You are not allowed to edit comments on this post.') );
$comment = get_comment_to_edit($comment);
@ -164,7 +160,7 @@ case 'confirmdeletecomment':
if ( ! $comment = get_comment($comment) )
die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( !user_can_delete_post_comments($user_ID, $comment->comment_post_ID) )
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
die( __('You are not allowed to delete comments on this post.') );
echo "<div class='wrap'>\n";
@ -207,7 +203,7 @@ case 'deletecomment':
if ( ! $comment = get_comment($comment) )
die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'post.php'));
if (!user_can_delete_post_comments($user_ID, $commentdata['comment_post_ID']))
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
die( __('You are not allowed to edit comments on this post.') );
wp_set_comment_status($comment->comment_ID, "delete");
@ -238,7 +234,7 @@ case 'unapprovecomment':
if ( ! $comment = get_comment($comment) )
die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( !user_can_edit_post_comments($user_ID, $comment->comment_post_ID) )
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
wp_set_comment_status($comment->comment_ID, "hold");
@ -258,7 +254,7 @@ case 'mailapprovecomment':
if ( ! $comment = get_comment($comment) )
die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( !user_can_edit_post_comments($user_ID, $comment->comment_post_ID) )
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
if ('1' != $comment->comment_approved) {
@ -284,7 +280,7 @@ case 'approvecomment':
if ( ! $comment = get_comment($comment) )
die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( !user_can_edit_post_comments($user_ID, $commentdata['comment_post_ID']))
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
wp_set_comment_status($comment->comment_ID, "approve");
@ -322,7 +318,7 @@ default:
<div class="updated"><p><?php printf(__('Post saved. <a href="%s">View site &raquo;</a>'), get_bloginfo('home')); ?></p></div>
<?php endif; ?>
<?php
if ( user_can_create_draft($user_ID) ) {
if ( current_user_can('edit_posts') ) {
$action = 'post';
get_currentuserinfo();
if ( $drafts = get_users_drafts( $user_ID ) ) {