# 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.editTerm'           => 'this:wp_editTerm',
 
 			// Blogger API
 			'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
@@ -1702,6 +1703,104 @@
 		return $formats;
 	}
 
+        /**
+         * Edit a term
+         *
+         * @uses wp_update_term()
+         * @param array $args Method parameters. Contains:
+         *  - int     $blog_id
+         *  - string  $username
+         *  - string  $password
+         *  - int     $term_id
+         *  - array   $content_struct.
+         *      The $content_struct must contain:
+         *      - 'taxonomy'
+         *      Also, it can optionally contain:
+         *      - 'name'
+         *      - 'parent'
+         *      - 'description'
+         *      - 'slug'
+         *  - boolean $send_mail optional. Defaults to false
+         * @return int term_id
+         */
+        function wp_editTerm( $args ) {
+
+		$this->escape( $args );
+
+                $blog_ID            = (int) $args[0];
+                $username           = $args[1];
+                $password           = $args[2];
+                $term_ID            = (int)$args[3];
+                $content_struct     = $args[4];
+
+		if ( ! $user = $this->login( $username, $password ) )
+			return $this->error;
+
+                if ( ! taxonomy_exists( $content_struct['taxonomy'] ) )
+                        return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
+
+                $taxonomy = get_taxonomy( $content_struct['taxonomy'] );
+
+                if( ! current_user_can( $taxonomy->cap->edit_terms ) )
+                        return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy' ) );
+
+                $taxonomy   = (array)$taxonomy;
+                
+                // hold the data of the term
+                $term_data  = array();
+
+                $term = get_term( $term_ID , $content_struct['taxonomy'] );
+
+                if ( is_wp_error( $term ) )
+                            return new IXR_Error(500, $term->get_error_message());
+
+                if ( ! $term )
+                            return new IXR_Error(500, __('The term ID does not exists'));
+
+                if( isset ( $content_struct['name'] ) ) {
+
+                        $term_data['name'] = trim( $content_struct['name'] );
+                        if( empty ( $term_data['name'] ) )
+                                return new IXR_Error( 403, __( 'The term name cannot be empty' ) );
+
+                }
+
+                if( isset ( $content_struct['parent'] ) ) {
+
+                        if( ! $taxonomy['hierarchical'] )
+                                return new IXR_Error( 403, __( 'This taxonomy is not hieararchical' ) );
+
+                        $parent_term_id = (int)$content_struct['parent'];
+                        $parent_term = get_term( $parent_term_id , $taxonomy['name'] );
+
+                        if ( is_wp_error( $parent_term) )
+                            return new IXR_Error(500, $term->get_error_message());
+
+                        if ( ! $parent_term )
+                            return new IXR_Error(500, __('Parent term does not exists'));
+
+                        $term_data['parent'] =  $content_struct['parent'];
+
+                }
+
+                if( isset ( $content_struct['description'] ) )
+                        $term_data['description'] = $content_struct['description'];
+
+                if( isset ( $content_struct['slug'] ) )
+                        $term_data['slug'] = $content_struct['slug'];
+
+                $term_ID = wp_update_term( $term_ID , $taxonomy['name'] , $term_data );
+
+                if ( is_wp_error( $term_ID ) )
+                        return new IXR_Error(500, $term_ID->get_error_message());
+
+                if ( ! $term_ID )
+                        return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
+
+                return $term_ID;
+                
+        }
+
 	/* Blogger API functions.
 	 * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
 	 */
