]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - xmlrpc.php
Wordpress 2.9
[autoinstalls/wordpress.git] / xmlrpc.php
index e8d8a2e8357e0f6afed587789fd51c0594fd38b4..8e683b7569e145c6a019faba68d712fd2cb39d5b 100644 (file)
@@ -201,6 +201,9 @@ class wp_xmlrpc_server extends IXR_Server {
 
                $this->initialise_blog_option_info( );
                $this->methods = apply_filters('xmlrpc_methods', $this->methods);
 
                $this->initialise_blog_option_info( );
                $this->methods = apply_filters('xmlrpc_methods', $this->methods);
+       }
+
+       function serve_request() {
                $this->IXR_Server($this->methods);
        }
 
                $this->IXR_Server($this->methods);
        }
 
@@ -419,6 +422,11 @@ class wp_xmlrpc_server extends IXR_Server {
                                'desc'                  => __( 'Time Format' ),
                                'readonly'              => false,
                                'option'                => 'time_format'
                                'desc'                  => __( 'Time Format' ),
                                'readonly'              => false,
                                'option'                => 'time_format'
+                       ),
+                       'users_can_register'    => array(
+                               'desc'                  => __( 'Allow new users to sign up' ),
+                               'readonly'              => false,
+                               'option'                => 'users_can_register'
                        )
                );
 
                        )
                );
 
@@ -526,6 +534,11 @@ class wp_xmlrpc_server extends IXR_Server {
                        $page_date = mysql2date("Ymd\TH:i:s", $page->post_date, false);
                        $page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt, false);
 
                        $page_date = mysql2date("Ymd\TH:i:s", $page->post_date, false);
                        $page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt, false);
 
+                       // For drafts use the GMT version of the date
+                       if ( $page->post_status == 'draft' ) {
+                               $page_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page->post_date ), 'Ymd\TH:i:s' );
+                       }
+
                        // Pull the categories info together.
                        $categories = array();
                        foreach(wp_get_post_categories($page->ID) as $cat_id) {
                        // Pull the categories info together.
                        $categories = array();
                        foreach(wp_get_post_categories($page->ID) as $cat_id) {
@@ -588,7 +601,7 @@ class wp_xmlrpc_server extends IXR_Server {
                $blog_id        = (int) $args[0];
                $username       = $args[1];
                $password       = $args[2];
                $blog_id        = (int) $args[0];
                $username       = $args[1];
                $password       = $args[2];
-               $num_pages      = (int) $args[3];
+               $num_pages      = isset($args[3]) ? (int) $args[3] : 10;
 
                if ( !$user = $this->login($username, $password) ) {
                        return $this->error;
 
                if ( !$user = $this->login($username, $password) ) {
                        return $this->error;
@@ -599,12 +612,7 @@ class wp_xmlrpc_server extends IXR_Server {
 
                do_action('xmlrpc_call', 'wp.getPages');
 
 
                do_action('xmlrpc_call', 'wp.getPages');
 
-               $page_limit = 10;
-               if( isset( $num_pages ) ) {
-                       $page_limit = $num_pages;
-               }
-
-               $pages = get_posts( array('post_type' => 'page', 'post_status' => 'all', 'numberposts' => $page_limit) );
+               $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) );
                $num_pages = count($pages);
 
                // If we have pages, put together their info.
                $num_pages = count($pages);
 
                // If we have pages, put together their info.
@@ -790,7 +798,8 @@ class wp_xmlrpc_server extends IXR_Server {
                                post_title page_title,
                                post_parent page_parent_id,
                                post_date_gmt,
                                post_title page_title,
                                post_parent page_parent_id,
                                post_date_gmt,
-                               post_date
+                               post_date,
+                               post_status
                        FROM {$wpdb->posts}
                        WHERE post_type = 'page'
                        ORDER BY ID
                        FROM {$wpdb->posts}
                        WHERE post_type = 'page'
                        ORDER BY ID
@@ -805,8 +814,15 @@ class wp_xmlrpc_server extends IXR_Server {
                        $page_list[$i]->dateCreated = new IXR_Date($post_date);
                        $page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt);
 
                        $page_list[$i]->dateCreated = new IXR_Date($post_date);
                        $page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt);
 
+                       // For drafts use the GMT version of the date
+                       if ( $page_list[$i]->post_status == 'draft' ) {
+                               $page_list[$i]->date_created_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page_list[$i]->post_date ), 'Ymd\TH:i:s' );
+                               $page_list[$i]->date_created_gmt = new IXR_Date( $page_list[$i]->date_created_gmt );
+                       }
+
                        unset($page_list[$i]->post_date_gmt);
                        unset($page_list[$i]->post_date);
                        unset($page_list[$i]->post_date_gmt);
                        unset($page_list[$i]->post_date);
+                       unset($page_list[$i]->post_status);
                }
 
                return($page_list);
                }
 
                return($page_list);
@@ -1050,11 +1066,11 @@ class wp_xmlrpc_server extends IXR_Server {
                $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false);
                $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false);
 
                $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false);
                $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false);
 
-               if ( 0 == $comment->comment_approved )
+               if ( '0' == $comment->comment_approved )
                        $comment_status = 'hold';
                else if ( 'spam' == $comment->comment_approved )
                        $comment_status = 'spam';
                        $comment_status = 'hold';
                else if ( 'spam' == $comment->comment_approved )
                        $comment_status = 'spam';
-               else if ( 1 == $comment->comment_approved )
+               else if ( '1' == $comment->comment_approved )
                        $comment_status = 'approve';
                else
                        $comment_status = $comment->comment_approved;
                        $comment_status = 'approve';
                else
                        $comment_status = $comment->comment_approved;
@@ -1551,9 +1567,6 @@ class wp_xmlrpc_server extends IXR_Server {
 
                foreach( $options as $o_name => $o_value ) {
                        $option_names[] = $o_name;
 
                foreach( $options as $o_name => $o_value ) {
                        $option_names[] = $o_name;
-                       if( empty( $o_value ) )
-                               continue;
-
                        if( !array_key_exists( $o_name, $this->blog_options ) )
                                continue;
 
                        if( !array_key_exists( $o_name, $this->blog_options ) )
                                continue;
 
@@ -2079,7 +2092,7 @@ class wp_xmlrpc_server extends IXR_Server {
                }
 
                $post_title = $content_struct['title'];
                }
 
                $post_title = $content_struct['title'];
-               $post_content = apply_filters( 'content_save_pre', $content_struct['description'] );
+               $post_content = $content_struct['description'];
 
                $post_status = $publish ? 'publish' : 'draft';
 
 
                $post_status = $publish ? 'publish' : 'draft';
 
@@ -2269,7 +2282,7 @@ class wp_xmlrpc_server extends IXR_Server {
                global $wpdb;
 
                // find any unattached files
                global $wpdb;
 
                // find any unattached files
-               $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '-1' AND post_type = 'attachment'" );
+               $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );
                if( is_array( $attachments ) ) {
                        foreach( $attachments as $file ) {
                                if( strpos( $post_content, $file->guid ) !== false ) {
                if( is_array( $attachments ) ) {
                        foreach( $attachments as $file ) {
                                if( strpos( $post_content, $file->guid ) !== false ) {
@@ -2446,7 +2459,7 @@ class wp_xmlrpc_server extends IXR_Server {
                }
 
                $post_title = $content_struct['title'];
                }
 
                $post_title = $content_struct['title'];
-               $post_content = apply_filters( 'content_save_pre', $content_struct['description'] );
+               $post_content = $content_struct['description'];
                $catnames = $content_struct['categories'];
 
                $post_category = array();
                $catnames = $content_struct['categories'];
 
                $post_category = array();
@@ -2576,9 +2589,7 @@ class wp_xmlrpc_server extends IXR_Server {
 
                        // For drafts use the GMT version of the post date
                        if ( $postdata['post_status'] == 'draft' ) {
 
                        // For drafts use the GMT version of the post date
                        if ( $postdata['post_status'] == 'draft' ) {
-                               $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_date'] ) );
-                               $post_date_gmt = preg_replace( '|\-|', '', $post_date_gmt );
-                               $post_date_gmt = preg_replace( '| |', 'T', $post_date_gmt );
+                               $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_date'] ), 'Ymd\TH:i:s' );
                        }
 
                        $categories = array();
                        }
 
                        $categories = array();
@@ -2697,6 +2708,11 @@ class wp_xmlrpc_server extends IXR_Server {
                        $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
                        $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
 
                        $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
                        $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
 
+                       // For drafts use the GMT version of the date
+                       if ( $entry['post_status'] == 'draft' ) {
+                               $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' );
+                       }
+
                        $categories = array();
                        $catids = wp_get_post_categories($entry['ID']);
                        foreach($catids as $catid) {
                        $categories = array();
                        $catids = wp_get_post_categories($entry['ID']);
                        foreach($catids as $catid) {
@@ -2873,8 +2889,8 @@ class wp_xmlrpc_server extends IXR_Server {
                        return new IXR_Error(500, $errorString);
                }
                // Construct the attachment array
                        return new IXR_Error(500, $errorString);
                }
                // Construct the attachment array
-               // attach to post_id -1
-               $post_id = -1;
+               // attach to post_id 0
+               $post_id = 0;
                $attachment = array(
                        'post_title' => $name,
                        'post_content' => '',
                $attachment = array(
                        'post_title' => $name,
                        'post_content' => '',
@@ -2932,6 +2948,11 @@ class wp_xmlrpc_server extends IXR_Server {
                        $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
                        $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
 
                        $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
                        $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
 
+                       // For drafts use the GMT version of the date
+                       if ( $entry['post_status'] == 'draft' ) {
+                               $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' );
+                       }
+
                        $struct[] = array(
                                'dateCreated' => new IXR_Date($post_date),
                                'userid' => $entry['post_author'],
                        $struct[] = array(
                                'dateCreated' => new IXR_Date($post_date),
                                'userid' => $entry['post_author'],
@@ -3403,5 +3424,5 @@ class wp_xmlrpc_server extends IXR_Server {
 }
 
 $wp_xmlrpc_server = new wp_xmlrpc_server();
 }
 
 $wp_xmlrpc_server = new wp_xmlrpc_server();
-
+$wp_xmlrpc_server->serve_request();
 ?>
 ?>