Make WordPress Core

Changeset 2714


Ignore:
Timestamp:
07/15/2005 02:16:45 AM (20 years ago)
Author:
ryan
Message:

More cap migration.

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r2709 r2714  
    445445// Dandy new recursive multiple category stuff.
    446446function cat_rows($parent = 0, $level = 0, $categories = 0) {
    447     global $wpdb, $class, $current_user;
    448 
    449     $user_level = $current_user->user_level;
     447    global $wpdb, $class;
    450448
    451449    if ( !$categories )
     
    458456                $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
    459457                $pad = str_repeat('— ', $level);
    460                 if ( $user_level > 3 )
     458                if ( current_user_can('manage_categories') )
    461459                    $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."), $wpdb->escape($category->cat_name)) . "')\" class='delete'>" .  __('Delete') . "</a>";
    462460                else
     
    478476
    479477function page_rows( $parent = 0, $level = 0, $pages = 0 ) {
    480     global $wpdb, $class, $user_level, $post;
     478    global $wpdb, $class, $post;
    481479    if (!$pages)
    482480        $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' ORDER BY menu_order");
  • trunk/wp-admin/categories.php

    r2695 r2714  
    2525case 'addcat':
    2626
    27     if ($user_level < 3)
     27    if ( !current_user_can('manage_categories') )
    2828        die (__('Cheatin&#8217; uh?'));
    2929   
     
    3737    check_admin_referer();
    3838
    39     if ( $user_level < 3 )
     39    if ( !current_user_can('manage_categories') )
    4040        die (__('Cheatin&#8217; uh?'));
    4141
     
    9494
    9595case 'editedcat':
    96     if ($user_level < 3)
     96    if ( !current_user_can('manage_categories') )
    9797        die (__('Cheatin&#8217; uh?'));
    9898   
     
    116116
    117117<div class="wrap">
    118 <?php if ( $user_level > 3 ) : ?>
     118<?php if ( current_user_can('manage_categories') ) : ?>
    119119    <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
    120120<?php else : ?>
     
    136136</div>
    137137
    138 <?php if ( $user_level > 3 ) : ?>
     138<?php if ( current_user_can('manage_categories') ) : ?>
    139139<div class="wrap">
    140140    <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete posts from that category, it will just set them back to the default category <strong>%s</strong>.'), get_catname(1)) ?>
  • trunk/wp-admin/edit-form-advanced.php

    r2709 r2714  
    9898</fieldset>
    9999
    100 <?php if ($user_level > 4) : ?>
     100<?php if ( current_user_can('edit_posts') ) : ?>
    101101<fieldset class="dbx-box">
    102102<h3 class="dbx-handle"><?php _e('Post Timestamp'); ?>:</h3>
  • trunk/wp-admin/edit-form-comment.php

    r2662 r2714  
    7272    </tr>
    7373
    74 <?php if ($user_level > 4) : ?>
     74<?php if ( current_user_can('edit_posts') ) : ?>
    7575    <tr>
    7676        <th scope="row"><?php _e('Edit time'); ?>:</th>
  • trunk/wp-admin/edit.php

    r2709 r2714  
    253253  <?php comment_time('g:m:s a') ?>
    254254  <?php
    255             if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) {
     255            if ( current_user_can('edit_post', $post->ID) ) {
    256256                echo "[ <a href=\"post.php?action=editcomment&amp;comment=".$comment->comment_ID."\">" .  __('Edit') . "</a>";
    257257                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> ";
  • trunk/wp-admin/link-categories.php

    r2699 r2714  
    2626  case 'addcat':
    2727  {
    28       if ($user_level < 5)
     28      if ( !current_user_can('manage_links') )
    2929          die (__("Cheatin' uh ?"));
    3030
     
    8686        die(sprintf(__("Can't delete the <strong>%s</strong> link category: this is the default one"), $cat_name));
    8787
    88     if ($user_level < 5)
     88    if ( !current_user_can('manage_links') )
    8989      die (__("Cheatin' uh ?"));
    9090
     
    199199  case "editedcat":
    200200  {
    201     if ($user_level < 5)
     201    if ( !current_user_can('manage_links') )
    202202      die (__("Cheatin' uh ?"));
    203203
     
    271271  {
    272272    include_once ("admin-header.php");
    273     if ($user_level < 5) {
     273    if ( !current_user_can('manage_links') )
    274274      die(__("You have do not have sufficient permissions to edit the link categories for this blog. :)"));
    275     }
    276275?>
    277276
  • trunk/wp-admin/link-import.php

    r2699 r2714  
    1616    {
    1717        include_once('admin-header.php');
    18         if ($user_level < 5)
     18        if ( !current_user_can('manage_links') )
    1919            die (__("Cheatin&#8217; uh?"));
    2020
     
    6666    case 1: {
    6767                include_once('admin-header.php');
    68                 if ($user_level < 5)
     68                if ( !current_user_can('manage_links') )
    6969                    die (__("Cheatin' uh ?"));
    7070?>
  • trunk/wp-admin/link-manager.php

    r2521 r2714  
    7575
    7676    // check the current user's level first.
    77     if ($user_level < 5)
     77    if ( !current_user_can('manage_links') )
    7878      die (__("Cheatin' uh ?"));
    7979
     
    8686    }
    8787    $all_links = join(',', $linkcheck);
    88     $results = $wpdb->get_results("SELECT link_id, link_owner, user_level FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)");
     88    $results = $wpdb->get_results("SELECT link_id, link_owner FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)");
    8989    foreach ($results as $row) {
    90       if (($user_level >= $row->user_level)) { // ok to proceed
    91         $ids_to_change[] = $row->link_id;
    92       }
     90       $ids_to_change[] = $row->link_id;
    9391    }
    9492
     
    105103
    106104    // check the current user's level first.
    107     if ($user_level < 5)
     105    if ( !current_user_can('manage_links') )
    108106      die (__("Cheatin' uh ?"));
    109107
     
    142140
    143141    // check the current user's level first.
    144     if ($user_level < 5)
     142    if ( !current_user_can('manage_links') )
    145143      die (__("Cheatin' uh ?"));
    146144
     
    176174    $auto_toggle = get_autotoggle($link_category);
    177175
    178     if ($user_level < 5)
     176    if ( !current_user_can('manage_links') )
    179177      die (__("Cheatin' uh ?"));
    180178
     
    224222      $auto_toggle = get_autotoggle($link_category);
    225223
    226       if ($user_level < 5)
     224      if ( !current_user_can('manage_links') )
    227225        die (__("Cheatin' uh ?"));
    228226
     
    254252    $link_id = (int) $_GET['link_id'];
    255253
    256     if ($user_level < 5)
     254    if ( !current_user_can('manage_links') )
    257255      die (__("Cheatin' uh ?"));
    258256
     
    275273    $xfn = true;
    276274    include_once ('admin-header.php');
    277     if ($user_level < 5)
     275    if ( !current_user_can('manage_links') )
    278276      die(__('You do not have sufficient permissions to edit the links for this blog.'));
    279277
     
    541539    setcookie('links_show_order_' . COOKIEHASH, $links_show_order, time()+600);
    542540    include_once ("./admin-header.php");
    543     if ($user_level < 5) {
     541    if ( !current_user_can('manage_links') )
    544542      die(__("You do not have sufficient permissions to edit the links for this blog."));
    545     }
    546543
    547544    switch ($order_by)
     
    647644    $sql = "SELECT link_url, link_name, link_image, link_description, link_visible,
    648645            link_category AS cat_id, cat_name AS category, $wpdb->users.user_login, link_id,
    649             link_rating, link_rel, $wpdb->users.user_level
     646            link_rating, link_rel
    650647            FROM $wpdb->links
    651648            LEFT JOIN $wpdb->linkcategories ON $wpdb->links.link_category = $wpdb->linkcategories.cat_id
     
    690687            $show_buttons = 1; // default
    691688
    692             if ($link->user_level > $user_level) {
    693               $show_buttons = 0;
    694             }
    695 
    696689            if ($show_buttons) {
    697690        echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&amp;action=linkedit" class="edit">' . __('Edit') . '</a></td>';
     
    717710          <?php _e('Assign ownership to:'); ?>
    718711<?php
    719     $results = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users WHERE user_level > 0 ORDER BY ID");
     712    $results = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY ID");
    720713    echo "          <select name=\"newowner\" size=\"1\">\n";
    721714    foreach ($results as $row) {
  • trunk/wp-admin/options.php

    r2624 r2714  
    2222}
    2323
    24 if ($user_level < 6)
     24if ( !current_user_can('manage_options') )
    2525    die ( __('Cheatin&#8217; uh?') );
    2626
     
    5151        $options = apply_filters( 'options_to_update' , $options );
    5252        foreach ($options as $option) {
    53             // should we even bother checking?
    54             if ($user_level >= $option->option_admin_level) {
    55                 $old_val = $option->option_value;
    56                 $new_val = trim($_POST[$option->option_name]);
    57                 if( in_array($option->option_name, $nonbools) && ( $new_val == '0' || $new_val == '') )
    58                     $new_val = 'closed';
    59                 if ($new_val !== $old_val) {
    60                     $result = $wpdb->query("UPDATE $wpdb->options SET option_value = '$new_val' WHERE option_name = '$option->option_name'");
    61                     $any_changed++;
    62                 }
    63             }
     53            $old_val = $option->option_value;
     54            $new_val = trim($_POST[$option->option_name]);
     55            if( in_array($option->option_name, $nonbools) && ( $new_val == '0' || $new_val == '') )
     56                $new_val = 'closed';
     57            if ($new_val !== $old_val) {
     58                $result = $wpdb->query("UPDATE $wpdb->options SET option_value = '$new_val' WHERE option_name = '$option->option_name'");
     59                $any_changed++;
     60            }
    6461        }
    6562        unset($cache_settings); // so they will be re-read
  • trunk/wp-admin/page-new.php

    r2652 r2714  
    44$parent_file = 'post.php';
    55require_once('admin-header.php');
    6 
    7 get_currentuserinfo();
    86?>
    97
     
    1311
    1412<?php
    15 if ($user_level > 0) {
     13if ( current_user_can('edit_pages') ) {
    1614    $action = 'post';
    1715    get_currentuserinfo();
  • trunk/wp-admin/plugin-editor.php

    r2372 r2714  
    3535case 'update':
    3636
    37     if ($user_level < 5) {
     37    if ( !current_user_can('edit_plugins') )
    3838        die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>'));
    39     }
    4039
    4140    $newcontent = stripslashes($_POST['newcontent']);
     
    5655   
    5756    require_once('admin-header.php');
    58     if ($user_level <= 5) {
     57    if ( !current_user_can('edit_plugins') )
    5958        die(__('<p>You have do not have sufficient permissions to edit plugins for this blog.</p>'));
    60     }
    6159
    6260    update_recently_edited("wp-content/plugins/$file");
  • trunk/wp-admin/theme-editor.php

    r2553 r2714  
    4646case 'update':
    4747
    48     if ($user_level < 5) {
     48    if ( !current_user_can('edit_themes') )
    4949        die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>'));
    50     }
    5150
    5251    $newcontent = stripslashes($_POST['newcontent']);
     
    6867   
    6968    require_once('admin-header.php');
    70     if ($user_level <= 5) {
     69    if ( !current_user_can('edit_themes') )
    7170        die(__('<p>You have do not have sufficient permissions to edit themes for this blog.</p>'));
    72     }
    7371
    7472    update_recently_edited($file);
  • trunk/wp-includes/capabilities.php

    r2713 r2714  
    124124        $this->cap_key = $table_prefix . 'capabilities';
    125125        $this->caps = &$this->data->{$this->cap_key};
     126        if ( ! is_array($this->caps) )
     127            $this->caps = array();
    126128        $this->get_role_caps();
    127129    }
Note: See TracChangeset for help on using the changeset viewer.