[wp-cvs] wordpress/wp-admin admin-functions.php, 1.54, 1.55 categories.php, 1.42, 1.43 moderation.php, 1.20, 1.21

Matthew Mullenweg saxmatt at users.sourceforge.net
Thu Nov 18 19:51:33 UTC 2004


Update of /cvsroot/cafelog/wordpress/wp-admin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25118/wp-admin

Modified Files:
	admin-functions.php categories.php moderation.php 
Log Message:
Fail more gracefully for lower level users

Index: categories.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/categories.php,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** categories.php	19 Oct 2004 03:03:03 -0000	1.42
--- categories.php	18 Nov 2004 19:51:31 -0000	1.43
***************
*** 113,120 ****
  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')));
!     }
  $messages[1] = __('Category added.');
  $messages[2] = __('Category deleted.');
--- 113,118 ----
  default:
  
! require_once ('admin-header.php');
! 
  $messages[1] = __('Category added.');
  $messages[2] = __('Category deleted.');
***************
*** 127,131 ****
  
  <div class="wrap">
!      <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
  <table width="100%" cellpadding="3" cellspacing="3">
  	<tr>
--- 125,133 ----
  
  <div class="wrap">
! <?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>
***************
*** 143,146 ****
--- 145,149 ----
  </div>
  
+ <?php if ( $user_level > 3 ) : ?>
  <div class="wrap">
      <p><?php printf(__('<strong>Note:</strong><br />
***************
*** 166,171 ****
      </form>
  </div>
  
!     <?php
  break;
  }
--- 169,175 ----
      </form>
  </div>
+ <?php endif; ?>
  
! <?php
  break;
  }

Index: admin-functions.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/admin-functions.php,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** admin-functions.php	17 Nov 2004 03:15:13 -0000	1.54
--- admin-functions.php	18 Nov 2004 19:51:30 -0000	1.55
***************
*** 107,114 ****
  // Dandy new recursive multiple category stuff.
  function cat_rows($parent = 0, $level = 0, $categories = 0) {
! 	global $wpdb, $bgcolor;
! 	if (!$categories) {
  		$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
! 	}
  	if ($categories) {
  		foreach ($categories as $category) {
--- 107,114 ----
  // Dandy new recursive multiple category stuff.
  function cat_rows($parent = 0, $level = 0, $categories = 0) {
! 	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) {
***************
*** 117,126 ****
  				$count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
  				$pad = str_repeat('&#8212; ', $level);
! 
  				$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&amp;cat_ID=$category->cat_ID' class='edit'>" . __('Edit') . "</a></td><td><a href='categories.php?action=Delete&amp;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>
  				</tr>";
  				cat_rows($category->cat_ID, $level + 1);
--- 117,130 ----
  				$count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
  				$pad = str_repeat('&#8212; ', $level);
! 				if ( $user_level > 3 )
! 					$edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>" . __('Edit') . "</a></td><td><a href='categories.php?action=Delete&amp;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>$edit</td>
  				</tr>";
  				cat_rows($category->cat_ID, $level + 1);

Index: moderation.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/moderation.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** moderation.php	19 Oct 2004 03:03:04 -0000	1.20
--- moderation.php	18 Nov 2004 19:51:31 -0000	1.21
***************
*** 75,82 ****
  	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>";
--- 75,78 ----
***************
*** 108,113 ****
  	
  <div class="wrap">
  <?php
! $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0'");
  
  if ($comments) {
--- 104,113 ----
  	
  <div class="wrap">
+ 
  <?php
! if ($user_level > 3)
! 	$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0'");
! else
! 	$comments = '';
  
  if ($comments) {
***************
*** 153,157 ****
  } else {
      // nothing to approve
!     echo __("<p>Currently there are no comments to be approved.</p>") . "\n";
  }
  ?>
--- 153,157 ----
  } else {
      // nothing to approve
!     echo __("<p>Currently there are no comments for you to moderate.</p>") . "\n";
  }
  ?>




More information about the cvs mailing list