Make WordPress Core

Changeset 2846


Ignore:
Timestamp:
09/07/2005 12:20:04 AM (19 years ago)
Author:
ryan
Message:

Capability updates for xmlrpc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r2742 r2846  
    367367        return $this->error;
    368368      }
    369 
    370       $user_data = get_userdatabylogin($user_login);
    371       if (!user_can_create_post($user_data->ID, $blog_ID)) {
     369     
     370      $cap = ($publish) ? 'publish_posts' : 'edit_posts';
     371
     372      $user = new WP_User($user_login);
     373      if ( !$user->has_cap($cap) )
    372374        return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
    373       }
    374375
    375376      $post_status = ($publish) ? 'publish' : 'draft';
    376377
    377       $post_author = $user_data->ID;
     378      $post_author = $user->ID;
    378379
    379380      $post_title = xmlrpc_getposttitle($content);
     
    425426        $this->escape($actual_post);
    426427
    427       $post_author_data = get_userdata($actual_post['post_author']);
    428       $user_data = get_userdatabylogin($user_login);
    429 
    430       if (!user_can_edit_post($user_data->ID, $post_ID)) {
     428      $user = new WP_User($user_login);
     429      if ( !$user->has_cap('edit_post', $post_ID) )
    431430        return new IXR_Error(401, 'Sorry, you do not have the right to edit this post.');
    432       }
    433431
    434432      extract($actual_post);
     
    476474      }
    477475
    478       $user_data = get_userdatabylogin($user_login);
    479 
    480       if (!user_can_delete_post($user_data->ID, $post_ID)) {
     476      $user = new WP_User($user_login);
     477      if ( !$user->has_cap('edit_post', $post_ID) )
    481478        return new IXR_Error(401, 'Sorry, you do not have the right to delete this post.');
    482       }
    483479
    484480      $result = wp_delete_post($post_ID);
     
    514510      }
    515511
    516       $user_data = get_userdatabylogin($user_login);
    517       if (!user_can_create_post($user_data->ID, $blog_ID)) {
     512      $user = new WP_User($user_login);
     513      if ( !$user->has_cap('publish_posts', $post_ID) )
    518514        return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
    519       }
    520 
    521       $post_author = $user_data->ID;
     515
     516      $post_author = $user->ID;
    522517
    523518      $post_title = $content_struct['title'];
     
    595590      }
    596591
    597       $user_data = get_userdatabylogin($user_login);
    598       if (!user_can_edit_post($user_data->ID, $post_ID)) {
     592      $user = new WP_User($user_login);
     593      if ( !$user->has_cap('edit_post', $post_ID) )
    599594        return new IXR_Error(401, 'Sorry, you can not edit this post.');
    600       }
    601595
    602596      $postdata = wp_get_single_post($post_ID, ARRAY_A);
     
    10151009      }
    10161010
    1017       $user_data = get_userdatabylogin($user_login);
    1018       if (!user_can_edit_post($user_data->ID, $post_ID)) {
     1011      $user = new WP_User($user_login);
     1012      if ( !$user->has_cap('edit_post', $post_ID) )
    10191013        return new IXR_Error(401, 'Sorry, you can not edit this post.');
    1020       }
    10211014
    10221015      foreach($categories as $cat) {
     
    10981091      }
    10991092
    1100       $user_data = get_userdatabylogin($user_login);
    1101       if (!user_can_edit_post($user_data->ID, $post_ID)) {
     1093      $user = new WP_User($user_login);
     1094      if ( !$user->has_cap('edit_post', $post_ID) )
    11021095        return new IXR_Error(401, 'Sorry, you can not edit this post.');
    1103       }
    11041096
    11051097      $postdata = wp_get_single_post($post_ID,ARRAY_A);
Note: See TracChangeset for help on using the changeset viewer.