Fail more gracefully for lower level users
git-svn-id: http://svn.automattic.com/wordpress/trunk@1862 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d1ddb156ec
commit
8615d77651
|
@ -106,22 +106,26 @@ function dropdown_categories($default = 0) {
|
|||
|
||||
// Dandy new recursive multiple category stuff.
|
||||
function cat_rows($parent = 0, $level = 0, $categories = 0) {
|
||||
global $wpdb, $bgcolor;
|
||||
if (!$categories) {
|
||||
global $wpdb, $bgcolor, $user_level;
|
||||
if (!$categories)
|
||||
$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
|
||||
}
|
||||
|
||||
if ($categories) {
|
||||
foreach ($categories as $category) {
|
||||
if ($category->category_parent == $parent) {
|
||||
$category->cat_name = htmlspecialchars($category->cat_name);
|
||||
$count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
|
||||
$pad = str_repeat('— ', $level);
|
||||
|
||||
if ( $user_level > 3 )
|
||||
$edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>" . __('Edit') . "</a></td><td><a href='categories.php?action=Delete&cat_ID=$category->cat_ID' onclick=\"return confirm('". sprintf(__("You are about to delete the category \'%s\'. All of its posts will go to the default category.\\n \'OK\' to delete, \'Cancel\' to stop."), addslashes($category->cat_name)) . "')\" class='delete'>" . __('Delete') . "</a>";
|
||||
else
|
||||
$edit = '';
|
||||
|
||||
$class = ('alternate' == $class) ? '' : 'alternate';
|
||||
echo "<tr class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td>
|
||||
<td>$category->category_description</td>
|
||||
<td>$count</td>
|
||||
<td><a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>" . __('Edit') . "</a></td><td><a href='categories.php?action=Delete&cat_ID=$category->cat_ID' onclick=\"return confirm('". sprintf(__("You are about to delete the category \'%s\'. All of its posts will go to the default category.\\n \'OK\' to delete, \'Cancel\' to stop."), addslashes($category->cat_name)) . "')\" class='delete'>" . __('Delete') . "</a></td>
|
||||
<td>$edit</td>
|
||||
</tr>";
|
||||
cat_rows($category->cat_ID, $level + 1);
|
||||
}
|
||||
|
|
|
@ -112,10 +112,8 @@ break;
|
|||
|
||||
default:
|
||||
|
||||
require_once ('admin-header.php');
|
||||
if ($user_level < 3) {
|
||||
die(sprintf(__("You have no right to edit the categories for this blog.<br />Ask for a promotion to your <a href='mailto:%s'>blog admin</a>. :)"), get_settings('admin_email')));
|
||||
}
|
||||
require_once ('admin-header.php');
|
||||
|
||||
$messages[1] = __('Category added.');
|
||||
$messages[2] = __('Category deleted.');
|
||||
$messages[3] = __('Category updated.');
|
||||
|
@ -126,7 +124,11 @@ $messages[3] = __('Category updated.');
|
|||
<?php endif; ?>
|
||||
|
||||
<div class="wrap">
|
||||
<h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
|
||||
<?php if ( $user_level > 3 ) : ?>
|
||||
<h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
|
||||
<?php else : ?>
|
||||
<h2><?php _e('Categories') ?> </h2>
|
||||
<?php endif; ?>
|
||||
<table width="100%" cellpadding="3" cellspacing="3">
|
||||
<tr>
|
||||
<th scope="col"><?php _e('ID') ?></th>
|
||||
|
@ -142,6 +144,7 @@ cat_rows();
|
|||
|
||||
</div>
|
||||
|
||||
<?php if ( $user_level > 3 ) : ?>
|
||||
<div class="wrap">
|
||||
<p><?php printf(__('<strong>Note:</strong><br />
|
||||
Deleting a category does not delete posts from that category, it will just
|
||||
|
@ -165,8 +168,9 @@ set them back to the default category <strong>%s</strong>.'), get_catname(1)) ?>
|
|||
<p class="submit"><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="<?php _e('Add Category »') ?>" /></p>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,10 +74,6 @@ default:
|
|||
|
||||
require_once('admin-header.php');
|
||||
|
||||
if ($user_level <= 3) {
|
||||
die(__('<p>Your level is not high enough to moderate comments.</p>'));
|
||||
}
|
||||
|
||||
if (isset($deleted) || isset($approved) || isset($ignored)) {
|
||||
echo "<div class='updated'>\n<p>";
|
||||
if ($approved) {
|
||||
|
@ -107,8 +103,12 @@ if (isset($deleted) || isset($approved) || isset($ignored)) {
|
|||
?>
|
||||
|
||||
<div class="wrap">
|
||||
|
||||
<?php
|
||||
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0'");
|
||||
if ($user_level > 3)
|
||||
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0'");
|
||||
else
|
||||
$comments = '';
|
||||
|
||||
if ($comments) {
|
||||
// list all comments that are waiting for approval
|
||||
|
@ -152,7 +152,7 @@ echo " <a href=\"post.php?action=deletecomment&p=".$comment->comment_post_ID
|
|||
<?php
|
||||
} else {
|
||||
// nothing to approve
|
||||
echo __("<p>Currently there are no comments to be approved.</p>") . "\n";
|
||||
echo __("<p>Currently there are no comments for you to moderate.</p>") . "\n";
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
Loading…
Reference in New Issue