Ticket #7446: 7446.diff

File 7446.diff, 4.7 KB (added by ryan, 4 years ago)

Incomplete and untested preview

  • wp-includes/comment.php

     
    206206} 
    207207 
    208208/** 
     209 * Retrieve all of the WordPress supported comment statuses. 
     210 * 
     211 * Comments have a limited set of valid status values, this provides the 
     212 * comment status values and descriptions. 
     213 * 
     214 * @package WordPress 
     215 * @subpackage Post 
     216 * @since 2.7 
     217 * 
     218 * @return array List of comment statuses. 
     219 */ 
     220function get_comment_statuses( ) { 
     221        $status = array( 
     222                'hold'                  => __('Unapproved'), 
     223                'approve'               => __('Approved'), 
     224                'spam'          => __('Spam'), 
     225        ); 
     226 
     227        return $status; 
     228} 
     229 
     230 
     231/** 
    209232 * The date the last comment was modified. 
    210233 * 
    211234 * {@internal Missing Long Description}} 
  • wp-includes/comment-template.php

     
    320320 * @since 1.5 
    321321 * @uses $comment 
    322322 * 
     323 * @param object|string|int $comment Comment to retrieve. 
    323324 * @return string The permalink to the current comment 
    324325 */ 
    325 function get_comment_link() { 
    326         global $comment; 
     326function get_comment_link($comment = null) { 
     327        $comment = get_comment($comment); 
    327328        return get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID; 
    328329} 
    329330 
  • xmlrpc.php

     
    829829                return($category_suggestions); 
    830830        } 
    831831 
     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 
    832944        function wp_getCommentCount( $args ) { 
    833945                $this->escape($args); 
    834946 
     
    857969                ); 
    858970        } 
    859971 
    860  
    861972        function wp_getPostStatusList( $args ) { 
    862973                $this->escape( $args ); 
    863974