| | 832 | function wp_getComment($args) { |
| | 833 | $this->escape($args); |
| | 834 | |
| | 835 | $blog_id = (int) $args[0]; |
| | 836 | $username = $args[1]; |
| | 837 | $password = $args[2]; |
| | 838 | $comment_id = (int) $args[3]; |
| | 839 | |
| | 840 | if ( !$this->login_pass_ok( $username, $password ) ) |
| | 841 | return $this->error; |
| | 842 | |
| | 843 | set_current_user( 0, $username ); |
| | 844 | if ( !current_user_can( 'moderate_comments' ) ) |
| | 845 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) ); |
| | 846 | |
| | 847 | if ( ! $comment = get_comment($comment_id) ) |
| | 848 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| | 849 | |
| | 850 | // Format page date. |
| | 851 | $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date); |
| | 852 | $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt); |
| | 853 | |
| | 854 | if ( 0 == $comment->comment_status ) |
| | 855 | $comment_status = 'hold'; |
| | 856 | else if ( 'spam' == $comment->comment_status ) |
| | 857 | $comment_status = 'spam'; |
| | 858 | else |
| | 859 | $comment_status = 'approve'; |
| | 860 | |
| | 861 | $link = get_comment_link($comment); |
| | 862 | |
| | 863 | $comment_struct = array( |
| | 864 | "dateCreated" => new IXR_Date($comment_date), |
| | 865 | "userid" => $comment->user_id, |
| | 866 | "comment_id" => $comment->comment_ID, |
| | 867 | "comment_status" => $comment_status, |
| | 868 | "description" => $comment->content, |
| | 869 | "link" => $link, |
| | 870 | "permaLink" => $link, |
| | 871 | "author" => $author->display_name, |
| | 872 | "post_id" => $comment->comment_post_ID, |
| | 873 | "post_title" => $todo, |
| | 874 | "author" => $comment->comment_author, |
| | 875 | "date_created_gmt" => new IXR_Date($comment_date_gmt), |
| | 876 | ); |
| | 877 | |
| | 878 | return $comment_struct; |
| | 879 | } |
| | 880 | |
| | 881 | function wp_getComments($args) { |
| | 882 | |
| | 883 | } |
| | 884 | |
| | 885 | function wp_deleteComment($args) { |
| | 886 | |
| | 887 | } |
| | 888 | |
| | 889 | function wp_editComment($args) { |
| | 890 | |
| | 891 | } |
| | 892 | |
| | 893 | function wp_newComment($args) { |
| | 894 | |
| | 895 | } |
| | 896 | |
| | 897 | function wp_getCommentStatusList($args) { |
| | 898 | $this->escape( $args ); |
| | 899 | |
| | 900 | $blog_id = (int) $args[0]; |
| | 901 | $username = $args[1]; |
| | 902 | $password = $args[2]; |
| | 903 | |
| | 904 | if ( !$this->login_pass_ok( $username, $password ) ) |
| | 905 | return $this->error; |
| | 906 | |
| | 907 | set_current_user( 0, $username ); |
| | 908 | if ( !current_user_can( 'moderate_comments' ) ) |
| | 909 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
| | 910 | |
| | 911 | do_action('xmlrpc_call', 'wp.getCommentStatusList'); |
| | 912 | |
| | 913 | return get_comment_statuses( ); |
| | 914 | } |
| | 915 | |
| | 916 | function wp_setCommentStatus($args) { |
| | 917 | $this->escape($args); |
| | 918 | |
| | 919 | $blog_id = (int) $args[0]; |
| | 920 | $username = $args[1]; |
| | 921 | $password = $args[2]; |
| | 922 | $comment_id = (int) $args[3]; |
| | 923 | $status = $args[4]; |
| | 924 | |
| | 925 | if ( !$this->login_pass_ok( $username, $password ) ) |
| | 926 | return $this->error; |
| | 927 | |
| | 928 | set_current_user( 0, $username ); |
| | 929 | if ( !current_user_can( 'moderate_comments' ) ) |
| | 930 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) ); |
| | 931 | |
| | 932 | $statuses = get_comment_status(); |
| | 933 | $statuses = array_keys($statuses); |
| | 934 | |
| | 935 | if ( ! in_array($statuses, $status) ) |
| | 936 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| | 937 | |
| | 938 | if ( ! get_comment($comment_id) ) |
| | 939 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| | 940 | |
| | 941 | return wp_set_comment_status($comment_id, $status); |
| | 942 | } |
| | 943 | |