# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /var/www/GSoC/wordtrunk/wp-includes
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: class-wp-xmlrpc-server.php
--- class-wp-xmlrpc-server.php Base (BASE)
+++ class-wp-xmlrpc-server.php Locally Modified (Based On LOCAL)
@@ -64,6 +64,7 @@
 			'wp.getMediaItem'		=> 'this:wp_getMediaItem',
 			'wp.getMediaLibrary'	=> 'this:wp_getMediaLibrary',
 			'wp.getPostFormats'     => 'this:wp_getPostFormats',
+                        'wp.getPost'            => 'this:wp_getPost',
 
 			// Blogger API
 			'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
@@ -1702,6 +1703,169 @@
 		return $formats;
 	}
 
+        /**
+         * Retrieve  post
+         *
+         * @uses wp_get_single_post()
+         * @param array $args Method parameters. Contains:
+         *  - int     $post_id
+         *  - string  $username
+         *  - string  $password
+         * @return array contains:
+         *  - 'postid'
+         *  - 'title'
+         *  - 'description'
+         *  - 'mt_excerpt'
+         *  - 'post_status'
+         *  - 'post_type'
+         *  - 'wp_slug'
+         *  - 'wp_password'
+         *  - 'wp_page_order'
+         *  - 'wp_page_parent_id'
+         *  - 'wp_author_id'
+         *  - 'mt_allow_comments'
+         *  - 'mt_allow_pings'
+         *  - 'dateCreated'
+         *  - 'date_created_gmt'
+         *  - 'userid'
+         *  - 'sticky'
+         *  - 'custom_fields'
+         *  - 'terms'
+         *  - 'link'
+         *  - 'permaLink'
+         *  - 'categories'
+         *  - 'mt_keywords'
+         *  - 'wp_post_format'
+         */
+        function wp_getPost( $args ) {
+
+		$this->escape( $args );
+
+                $post_ID            = (int) $args[0];
+                $username           = $args[1];
+                $password           = $args[2];
+
+		if ( ! $user = $this->login( $username, $password ) )
+			return $this->error;
+
+                $post = wp_get_single_post( $post_ID, ARRAY_A );
+		if ( empty( $post["ID"] ) )
+			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
+
+                $post_type = get_post_type_object( $post['post_type'] );
+                if( ! current_user_can( $post_type->cap->edit_posts, $post_ID ) )
+                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type' ));
+
+                //return $post;
+
+                $post_date = mysql2date( 'Ymd\TH:i:s', $post['post_date'], false );
+                $post_date_gmt = mysql2date( 'Ymd\TH:i:s', $post['post_date_gmt'], false );
+
+                // For drafts use the GMT version of the post date
+                if ( $post['post_status'] == 'draft' )
+                        $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $post['post_date'] ), 'Ymd\TH:i:s' );
+
+                $post_content = get_extended( $post['post_content'] );
+                $link = post_permalink( $post['ID'] );
+
+                // Consider future posts as published
+                if ( $post['post_status'] === 'future' )
+                        $post['post_status'] = 'publish';
+
+                // Get post format
+                $post_format = get_post_format( $post_ID );
+                if ( empty( $post_format ) )
+                        $post_format = 'standard';
+
+                $sticky = null;
+                if( $post['post_type'] == 'post' ) {
+
+                        $sticky = false;
+                        if ( is_sticky( $post_ID ) )
+                                $sticky = true;
+
+                }
+
+
+                $post_type_taxonomies = get_object_taxonomies( $post['post_type'] , 'names');
+                $terms = wp_get_object_terms( $post_ID, $post_type_taxonomies );
+
+                $enclosure = array();
+                foreach ( (array) get_post_custom($post_ID) as $key => $val) {
+                        if ($key == 'enclosure') {
+                                foreach ( (array) $val as $enc ) {
+                                        $encdata = split("\n", $enc);
+                                        $enclosure['url'] = trim(htmlspecialchars($encdata[0]));
+                                        $enclosure['length'] = (int) trim($encdata[1]);
+                                        $enclosure['type'] = trim($encdata[2]);
+                                        break 2;
+                                }
+                        }
+                }
+
+
+                // backward compatiblity
+                $categories = array();
+                $catids = wp_get_post_categories($post_ID);
+                foreach($catids as $catid) {
+                        $categories[] = get_cat_name($catid);
+                }
+                
+                $tagnames = array();
+                $tags = wp_get_post_tags( $post_ID );
+                if ( !empty( $tags ) ) {
+                        foreach ( $tags as $tag )
+                                $tagnames[] = $tag->name;
+                        $tagnames = implode( ', ', $tagnames );
+                } else {
+                        $tagnames = '';
+                }
+
+                $struct = array(
+                            'postid'            => $post['ID'],
+                            'title'             => $post['post_title'],
+                            'description'       => $post_content['main'],
+                            'mt_excerpt'        => $post['post_excerpt'],
+
+                            'post_status'       => $post['post_status'],
+                            'post_type'         => $post['post_type'],
+                            'wp_slug'           => $post['post_name'],
+                            'wp_password'       => $post['post_password'],
+                    
+                            'wp_page_order'     => $post['menu_order'],
+                            'wp_page_parent_id' => $post['post_parent'],
+
+                            'wp_author_id'      => $post['post_author'],
+
+                            'mt_allow_comments' => $post['comment_status'],
+                            'mt_allow_pings'    => $post['ping_status'],
+                    
+                            'dateCreated'       => new IXR_Date($post_date),
+                            'date_created_gmt'  => new IXR_Date($post_date_gmt),
+                    
+                            'userid'            => $post['post_author'],
+                            'sticky'            => $sticky,
+                            'custom_fields'     => $wp_xmlrpc_server->get_custom_fields( $post_ID ),
+                            'terms'             => $terms,
+
+                            'link'              => $link,
+                            'permaLink'         => $link,
+                    
+                            // backward compatibility
+                            'categories'	=> $categories,
+                            'mt_keywords'       => $tagnames,
+                            'wp_post_format'    => $post_format,
+
+                );
+
+                if ( ! empty( $enclosure ) )
+                        $resp['enclosure'] = $enclosure;
+
+                return $struct;
+
+
+        }
+        
 	/* Blogger API functions.
 	 * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
 	 */
