Make WordPress Core


Ignore:
Timestamp:
06/26/2005 07:55:12 PM (21 years ago)
Author:
ryan
Message:

Comment updating cleanup. Add get_comment(), edit_comment(), get_comment_to_edit(), and wp_update_comment().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r2654 r2662  
    6464                $blog_ID = 1;
    6565
    66         $post_ID = $_POST['post_ID'];
     66        $post_ID = (int) $_POST['post_ID'];
    6767
    6868        if (!user_can_edit_post($user_ID, $post_ID, $blog_ID))
    … …  
    7070
    7171        // Rename.
    72         $_POST['ID'] = $_POST['post_ID'];
     72        $_POST['ID'] = (int) $_POST['post_ID'];
    7373        $_POST['post_content']  = $_POST['content'];
    7474        $_POST['post_excerpt']  = $_POST['excerpt'];
    … …  
    120120}
    121121
     122function edit_comment() {
     123        global $user_ID;
     124
     125        $comment_ID = (int) $_POST['comment_ID'];
     126        $comment_post_ID = (int) $_POST['comment_post_ID'];
     127
     128        if (!user_can_edit_post_comments($user_ID, $comment_post_ID))
     129                die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.') );
     130
     131        $_POST['comment_author'] = $_POST['newcomment_author'];
     132        $_POST['comment_author_email']  = $_POST['newcomment_author_email'];
     133        $_POST['comment_author_url'] = $_POST['newcomment_author_url'];
     134        $_POST['comment_approved'] = $_POST['comment_status'];
     135        $_POST['comment_content'] = $_POST['content'];
     136        $_POST['comment_ID'] = (int) $_POST['comment_ID'];
     137 
     138        if (user_can_edit_post_date($user_ID, $post_ID) && (!empty($_POST['edit_date']))) {
     139                $aa = $_POST['aa'];
     140                $mm = $_POST['mm'];
     141                $jj = $_POST['jj'];
     142                $hh = $_POST['hh'];
     143                $mn = $_POST['mn'];
     144                $ss = $_POST['ss'];
     145                $jj = ($jj > 31) ? 31 : $jj;
     146                $hh = ($hh > 23) ? $hh - 24 : $hh;
     147                $mn = ($mn > 59) ? $mn - 60 : $mn;
     148                $ss = ($ss > 59) ? $ss - 60 : $ss;
     149                $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
     150        }
     151
     152        wp_update_comment($_POST);
     153}
     154
    122155// Get an existing post and format it for editing.
    123156function get_post_to_edit($id) {
    … …  
    157190
    158191        return $post;
     192}
     193
     194function get_comment_to_edit($id) {
     195        $comment = get_comment($id);
     196
     197        $comment->comment_content = format_to_edit($comment->comment_content);
     198        $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content);
     199
     200        $comment->comment_author = format_to_edit($comment->comment_author);
     201        $comment->comment_author_email = format_to_edit($comment->comment_author_email);
     202        $comment->comment_author_url = format_to_edit($comment->comment_author_url);
     203
     204        return $comment;
    159205}
    160206
Note: See TracChangeset for help on using the changeset viewer.