Skip to content

Commit 268fc9f

Browse files
committed
Cap migration.
git-svn-id: https://develop.svn.wordpress.org/trunk@2720 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 21a150e commit 268fc9f

10 files changed

Lines changed: 16 additions & 36 deletions

File tree

wp-admin/bookmarklet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$mode = 'bookmarklet';
33
require_once('admin.php');
44

5-
if ($user_level == 0)
5+
if ( ! current_user_can('edit_posts') )
66
die ("Cheatin' uh?");
77

88
if ('b' == $a) {

wp-admin/edit-pages.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,13 @@
33
$title = __('Pages');
44
$parent_file = 'edit.php';
55
require_once('admin-header.php');
6-
7-
get_currentuserinfo();
86
?>
97

108
<div class="wrap">
119
<h2><?php _e('Page Management'); ?></h2>
1210

1311
<?php
14-
/*
15-
if (isset($user_ID) && ('' != intval($user_ID))) {
16-
$posts = $wpdb->get_results("
17-
SELECT $wpdb->posts.*, $wpdb->users.user_level FROM $wpdb->posts
18-
INNER JOIN $wpdb->users ON ($wpdb->posts.post_author = $wpdb->users.ID)
19-
WHERE $wpdb->posts.post_status = 'static'
20-
AND ($wpdb->users.user_level < $user_level OR $wpdb->posts.post_author = $user_ID)
21-
");
22-
} else { */
23-
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'");
24-
// } FIXME
12+
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'");
2513

2614
if ($posts) {
2715
?>

wp-admin/edit.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
$_GET['m'] = (int) $_GET['m'];
99

10-
get_currentuserinfo();
11-
1210
$drafts = get_users_drafts( $user_ID );
1311
$other_drafts = get_others_drafts( $user_ID);
1412

@@ -255,7 +253,7 @@
255253
if ( current_user_can('edit_post', $post->ID) ) {
256254
echo "[ <a href=\"post.php?action=editcomment&amp;comment=".$comment->comment_ID."\">" . __('Edit') . "</a>";
257255
echo " - <a href=\"post.php?action=deletecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), $comment->comment_author) . "')\">" . __('Delete') . "</a> ";
258-
if ( ('none' != $comment_status) && ($user_level >= 3) ) {
256+
if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
259257
if ('approved' == wp_get_comment_status($comment->comment_ID)) {
260258
echo " - <a href=\"post.php?action=unapprovecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\">" . __('Unapprove') . "</a> ";
261259
} else {

wp-admin/menu-header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
foreach ($menu as $item) {
99
$class = '';
1010

11-
// 0 = name, 1 = user_level, 2 = file
11+
// 0 = name, 1 = capability, 2 = file
1212
if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
1313

1414
if ( current_user_can($item[1]) ) {

wp-admin/moderation.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@
3131

3232
case 'update':
3333

34-
if ($user_level < 3) {
34+
if ( ! current_user_can('moderate_comments') )
3535
die(__('<p>Your level is not high enough to moderate comments.</p>'));
36-
}
3736

3837
$item_ignored = 0;
3938
$item_deleted = 0;
@@ -119,7 +118,7 @@
119118
<div class="wrap">
120119

121120
<?php
122-
if ($user_level > 3)
121+
if ( current_user_can('moderate_comments') )
123122
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0'");
124123
else
125124
$comments = '';

wp-admin/profile.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858

5959
case 'update':
6060

61-
get_currentuserinfo();
62-
6361
/* checking the nickname has been typed */
6462
if (empty($_POST["newuser_nickname"])) {
6563
die (__("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)"));
@@ -276,7 +274,7 @@
276274
</div>
277275

278276

279-
<?php if ($is_gecko && $profiledata->user_level != 0) { ?>
277+
<?php if ( $is_gecko && current_user_can('edit_posts') ) { ?>
280278
<div class="wrap">
281279
<script type="text/javascript">
282280
//<![CDATA[

wp-admin/sidebar.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
require_once('admin.php');
55

6-
get_currentuserinfo();
7-
8-
if ($user_level == 0)
6+
if ( ! current_user_can('edit_posts') )
97
die ("Cheatin' uh ?");
108

119
if ('b' == $_GET['a']) {

wp-admin/templates.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@
3636

3737
case 'update':
3838

39-
if ($user_level < 5) {
39+
if ( ! current_user_can('edit_files') )
4040
die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>'));
41-
}
4241

4342
$newcontent = stripslashes($_POST['newcontent']);
4443
if (is_writeable($real_file)) {
@@ -57,7 +56,8 @@
5756
default:
5857

5958
require_once('./admin-header.php');
60-
if ( $user_level <= 5 )
59+
60+
if ( ! current_user_can('edit_files') )
6161
die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>'));
6262

6363
if ( strstr( $file, 'wp-config.php' ) )

wp-admin/upgrade-schema.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ function populate_roles() {
244244
'edit_published_posts' => true,
245245
'publish_posts' => true,
246246
'edit_pages' => true,
247+
'moderate_comments' => true,
247248
'manage_categories' => true,
248249
'manage_links' => true,
249250
'upload_files' => true,
@@ -276,9 +277,10 @@ function populate_roles() {
276277
'edit_published_posts' => true,
277278
'publish_posts' => true,
278279
'edit_pages' => true,
280+
'moderate_comments' => true,
279281
'manage_categories' => true,
280282
'manage_links' => true,
281-
'upload_images' => true,
283+
'upload_files' => true,
282284
'read' => true,
283285
'level_7' => true,
284286
'level_6' => true,
@@ -295,7 +297,7 @@ function populate_roles() {
295297
'capabilities' => array(
296298
'edit_posts' => true,
297299
'publish_posts' => true,
298-
'upload_images' => true,
300+
'upload_files' => true,
299301
'read' => true,
300302
'level_2' => true,
301303
'level_1' => true,

wp-admin/upload.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55

66
require_once('admin-header.php');
77

8-
if ($user_level == 0) //Checks to see if user has logged in
9-
die (__("Cheatin' uh ?"));
10-
118
if (!get_settings('use_fileupload')) //Checks if file upload is enabled in the config
129
die (__("The admin disabled this function"));
1310

14-
if ( !get_settings('fileupload_minlevel') )
11+
if ( ! current_user_can('upload_files') )
1512
die (__("You are not allowed to upload files"));
1613

1714
$allowed_types = explode(' ', trim(strtolower(get_settings('fileupload_allowedtypes'))));

0 commit comments

Comments
 (0)