# 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.setPostTerms'       => 'this:wp_setPostTerms',
 
 			// Blogger API
 			'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
@@ -1702,6 +1703,80 @@
 		return $formats;
 	}
 
+        /**
+         * Set post terms
+         *
+         * @uses wp_set_object_terms()
+         * @param array $args Method parameters. Contains:
+         *  - int     $blog_id
+         *  - string  $username
+         *  - string  $password
+         *  - int     $post_id
+         *  - array   $content_struct contains term_ids with taxonomy as keys
+         * @return boolean true
+         */
+        function wp_setPostTerms( $args ) {
+
+		$this->escape( $args );
+
+                $blog_ID            = (int) $args[0];
+                $username           = $args[1];
+                $password           = $args[2];
+                $post_ID            = (int) $args[3];
+                $content_struct     = $args[4];
+                $append             = $args[5] ? true : false;
+
+
+		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_post , $post_ID ) )
+                        return new IXR_Error( 401, __( 'Sorry, You are not allowed to edit this post.' ));
+
+                $post_type_taxonomies = get_object_taxonomies( $post['post_type'] );
+
+                $taxonomies = array_keys( $content_struct );
+
+                // validating term ids
+                foreach( $taxonomies as $taxonomy ) {
+                    
+                        if( ! in_array( $taxonomy , $post_type_taxonomies ) )
+                                return new IXR_Error( 401, __( 'Sorry, one of the given taxonomy is not supported by the post type.' ));
+    
+                        $term_ids = $content_struct[ $taxonomy ];
+                        foreach ( $term_ids as $term_id) {
+
+                                $term = get_term( $term_id, $taxonomy );
+
+                                if ( is_wp_error( $term ) )
+                                        return new IXR_Error( 500, $term->get_error_message() );
+
+                                if ( ! $term )
+                                        return new IXR_Error( 401, __( 'Invalid term ID' ) );
+
+                        }
+                        
+                }
+
+                foreach( $taxonomies as $taxonomy ) {
+
+                        $term_ids = $content_struct[ $taxonomy ];
+                        $term_ids = array_map( 'intval', $term_ids );
+                        $term_ids = array_unique( $term_ids );
+                        wp_set_object_terms( $post_ID , $term_ids, $taxonomy , $append);
+                        
+                }
+
+                return true;
+
+        }
+
 	/* Blogger API functions.
 	 * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
 	 */
