Make WordPress Core

Changeset 6714 for trunk/xmlrpc.php


Ignore:
Timestamp:
02/04/2008 06:35:05 PM (17 years ago)
Author:
ryan
Message:

More cap checks from josephscott. see #5313

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r6709 r6714  
    11291129            return $this->error;
    11301130        }
     1131        $user = set_current_user(0, $user_login);
    11311132
    11321133        do_action('xmlrpc_call', 'metaWeblog.newPost');
    11331134
    1134         $cap = ($publish) ? 'publish_posts' : 'edit_posts';
    1135         $user = set_current_user(0, $user_login);
    1136         if ( !current_user_can($cap) )
    1137             return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.'));
    1138 
    1139         // The post_type defaults to post, but could also be page.
    1140         $post_type = "post";
    1141         if(
    1142             !empty($content_struct["post_type"])
    1143             && ($content_struct["post_type"] == "page")
    1144         ) {
    1145             $post_type = "page";
     1135        $cap = ( $publish ) ? 'publish_posts' : 'edit_posts';
     1136        $error_message = __( 'Sorry, you are not allowed to publish posts on this blog.' );
     1137        $post_type = 'post';
     1138        if( !empty( $content_struct['post_type'] ) ) {
     1139            if( $content_struct['post_type'] == 'page' ) {
     1140                $cap = ( $publish ) ? 'publish_pages' : 'edit_pages';
     1141                $error_message = __( 'Sorry, you are not allowed to publish pages on this blog.' );
     1142                $post_type = 'page';
     1143            }
     1144            elseif( $content_type['post_type'] == 'post' ) {
     1145                // This is the default, no changes needed
     1146            }
     1147            else {
     1148                // No other post_type values are allowed here
     1149                return new IXR_Error( 401, __( 'Invalid post type.' ) );
     1150            }
     1151        }
     1152
     1153        if( !current_user_can( $cap ) ) {
     1154            return new IXR_Error( 401, $error_message );
    11461155        }
    11471156
     
    13691378            return $this->error;
    13701379        }
     1380        $user = set_current_user(0, $user_login);
    13711381
    13721382        do_action('xmlrpc_call', 'metaWeblog.editPost');
    13731383
    1374         $user = set_current_user(0, $user_login);
    1375 
    1376         // The post_type defaults to post, but could also be page.
    1377         $post_type = "post";
    1378         if(
    1379             !empty($content_struct["post_type"])
    1380             && ($content_struct["post_type"] == "page")
    1381         ) {
    1382             if( !current_user_can( 'edit_page', $post_ID ) ) {
    1383                 return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page.")));
    1384             }
    1385 
    1386             $post_type = "page";
    1387         }
    1388 
    1389         if ( ( 'post' == $post_type ) && !current_user_can('edit_post', $post_ID) )
    1390             return new IXR_Error(401, __('Sorry, you can not edit this post.'));
     1384        $cap = ( $publish ) ? 'publish_posts' : 'edit_posts';
     1385        $error_message = __( 'Sorry, you are not allowed to publish posts on this blog.' );
     1386        $post_type = 'post';
     1387        if( !empty( $content_struct['post_type'] ) ) {
     1388            if( $content_struct['post_type'] == 'page' ) {
     1389                $cap = ( $publish ) ? 'publish_pages' : 'edit_pages';
     1390                $error_message = __( 'Sorry, you are not allowed to publish pages on this blog.' );
     1391                $post_type = 'page';
     1392            }
     1393            elseif( $content_type['post_type'] == 'post' ) {
     1394                // This is the default, no changes needed
     1395            }
     1396            else {
     1397                // No other post_type values are allowed here
     1398                return new IXR_Error( 401, __( 'Invalid post type.' ) );
     1399            }
     1400        }
     1401
     1402        if( !current_user_can( $cap ) ) {
     1403            return new IXR_Error( 401, $error_message );
     1404        }
    13911405
    13921406        $postdata = wp_get_single_post($post_ID, ARRAY_A);
Note: See TracChangeset for help on using the changeset viewer.