/** * wp.editComment * * @see http://codex.wordpress.org/XML-RPC_wp#wp.editComment * * Leave the second and third parameter blank to send anonymous comments * * @param xmlrpcmsg XML-RPC Message * 0 blogid (int): Unique identifier of the blog. * 1 username (string): User login. * 2 password (string): Password for said username. * 3 comment_id (int): Target post ID * 4 params (struct): * - status (string) * - date_created_gmt (string) * - content (string) * - author (string) * - author_url (string) * - author_email (string) */ function wp_editcomment($m) { // CHECK LOGIN: /** * @var User */ if (!($current_User =& xmlrpcs_login($m, 1, 2))) { // Login failed, return (last) error: return xmlrpcs_resperror(); } // GET BLOG: /** * @var Blog */ if (!($Blog =& xmlrpcs_get_Blog($m, 0))) { // Blog not found return xmlrpcs_resperror(); } /** * @var Comment */ if (!($edited_Comment =& xmlrpcs_get_Comment($m, 3))) { // Return (last) error: return xmlrpcs_resperror(); } if (!$current_User->check_perm('comment!CURSTATUS', 'edit', false, $edited_Comment)) { // Permission denied return xmlrpcs_resperror(3); } $options = $m->getParam(4); $options = xmlrpc_decode_recurse($options); //logIO( 'Params: '.var_export($options, true) ); $params = array('status' => wp_or_b2evo_comment_status($options['status'], 'b2evo'), 'date' => _mw_decode_date($options), 'content' => $options['content'], 'author' => isset($options['author']) ? $options['author'] : '', 'author_url' => isset($options['author_url']) ? $options['author_url'] : '', 'author_email' => isset($options['author_email']) ? $options['author_email'] : ''); return xmlrpcs_edit_comment($params, $edited_Comment); }
/** * metaWeblog.editPost * * @see http://www.xmlrpc.com/metaWeblogApi#basicEntrypoints * * @param xmlrpcmsg XML-RPC Message * 0 postid (string): Unique identifier of the post to edit * 1 username (string): Login for a Blogger user who has permission to edit the given * post (either the user who originally created it or an admin of the blog). * 2 password (string): Password for said username. * 3 struct (struct) * 4 publish (bool) * @param string item type 'post' or 'page' */ function mw_editpost($m, $item_type = 'post') { // CHECK LOGIN: /** * @var User */ if (!($current_User =& xmlrpcs_login($m, 1, 2))) { // Login failed, return (last) error: return xmlrpcs_resperror(); } // GET POST: /** * @var Item */ if (!($edited_Item =& xmlrpcs_get_Item($m, 0))) { // Failed, return (last) error: return xmlrpcs_resperror(); } // We need to be able to edit this post: if (!$current_User->check_perm('item_post!CURSTATUS', 'edit', false, $edited_Item)) { return xmlrpcs_resperror(3); // Permission denied } $xcontent = $m->getParam(3); $contentstruct = xmlrpc_decode_recurse($xcontent); logIO('Decoded xcontent'); if (isset($m->params[4])) { // getParam(4) is a flag for publish or draft $xstatus = $m->getParam(4); $xstatus = $xstatus->scalarval(); $status = $xstatus ? 'published' : 'draft'; // might be overrided later } $cat_IDs = _mw_get_cat_IDs($contentstruct, $edited_Item->get_Blog(), true); $date = _mw_decode_date($contentstruct); if (!empty($contentstruct['post_type']) && $contentstruct['post_type'] != $item_type) { // Overwrite from struct $item_type = $contentstruct['post_type']; } // Don't overwrite if not set $tags = isset($contentstruct['mt_keywords']) ? $contentstruct['mt_keywords'] : NULL; $content = isset($contentstruct['description']) ? $contentstruct['description'] : NULL; $excerpt = isset($contentstruct['mt_excerpt']) ? $contentstruct['mt_excerpt'] : NULL; $urltitle = isset($contentstruct['wp_slug']) ? $contentstruct['wp_slug'] : NULL; $parent_ID = isset($contentstruct['wp_page_parent_id']) ? $contentstruct['wp_page_parent_id'] : NULL; $author_ID = isset($contentstruct['wp_author_id']) ? $contentstruct['wp_author_id'] : NULL; $featured = isset($contentstruct['sticky']) ? $contentstruct['sticky'] : NULL; $order = isset($contentstruct['wp_page_order']) ? $contentstruct['wp_page_order'] : NULL; $custom_fields = isset($contentstruct['custom_fields']) ? $contentstruct['custom_fields'] : NULL; $item_typ_ID = isset($contentstruct['wp_post_format']) ? $contentstruct['wp_post_format'] : NULL; if (isset($contentstruct[$item_type . '_status'])) { $status = wp_or_b2evo_item_status($contentstruct[$item_type . '_status'], 'b2evo'); } if (isset($content_struct['mt_text_more'])) { // Add content extension $content .= '<!--more-->' . $content_struct['mt_text_more']; } //logIO( "Item content:\n".$content ); if (!empty($content_struct['enclosure']) && is_array($content_struct['enclosure'])) { // Add content extension $enclosure = $content_struct['enclosure']; if (isset($enclosure['url']) && isset($enclosure['length']) && isset($enclosure['type'])) { logIO("Item enclosure\n" . var_export($enclosure, true)); // TODO: sam2kb> Handle enclosures } } $comment_status = ''; // Don't overwrite if not set if (isset($contentstruct['mt_allow_comments'])) { if (!$contentstruct['mt_allow_comments'] || in_array($contentstruct['mt_allow_comments'], array(2, 'closed'))) { // Comments disabled $comment_status = 'disabled'; } else { $comment_status = 'open'; } } $params = array('title' => $contentstruct['title'], 'content' => $content, 'cat_IDs' => $cat_IDs, 'status' => $status, 'date' => $date, 'tags' => $tags, 'excerpt' => $excerpt, 'item_typ_ID' => $item_typ_ID, 'comment_status' => $comment_status, 'urltitle' => $urltitle, 'parent_ID' => $parent_ID, 'author_ID' => $author_ID, 'featured' => $featured, 'order' => $order, 'custom_fields' => $custom_fields); // COMPLETE VALIDATION & INSERT: return xmlrpcs_edit_item($edited_Item, $params); /* // Time to perform trackbacks NB NOT WORKING YET // // NB Requires a change to the _trackback library // // function trackbacks( $post_trackbacks, $content, $post_title, $post_ID ) // first extract these from posting as post_trackbacks array, then rest is easy // <member> // <name>mt_tb_ping_urls</name> // <value><array><data> // <value><string>http://archive.scripting.com/2005/04/17</string></value> // </data></array></value> // </member> // First check that trackbacks are allowed - mt_allow_pings $trackback_ok = 0; $trackbacks = array(); $trackback_ok = $contentstruct['mt_allow_pings']; logIO("Trackback OK ...".$trackback_ok); if ($trackback_ok == 1) { $trackbacks = $contentstruct['mt_tb_ping_urls']; logIO("Trackback url 0 ...".$trackbacks[0]); $no_of_trackbacks = count($trackbacks); logIO("Number of Trackbacks ...".$no_of_trackbacks); if ($no_of_trackbacks > 0) { logIO("Calling Trackbacks ..."); load_funcs('comments/_trackback.funcs.php'); $result = trackbacks( $trackbacks, $content, $post_title, $post_ID ); logIO("Returned from Trackbacks ..."); } } */ }