-
+ 925FC35AEFE98838CEC79236F68EB0B305662566C2944B261A4FFA150619116B6F6E1ADD761F1ACF461656742447B64E72BD255AE7D505CBFDE2972D4DEBFBBCmp-wp/wp-admin/includes/comment.php(0 . 0)(1 . 164)
31992 <?php
31993 /**
31994 * WordPress Comment Administration API.
31995 *
31996 * @package WordPress
31997 * @subpackage Administration
31998 */
31999
32000 /**
32001 * {@internal Missing Short Description}}
32002 *
32003 * @since unknown
32004 * @uses $wpdb
32005 *
32006 * @param string $comment_author
32007 * @param string $comment_date
32008 * @return mixed Comment ID on success.
32009 */
32010 function comment_exists($comment_author, $comment_date) {
32011 global $wpdb;
32012
32013 return $wpdb->get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments
32014 WHERE comment_author = %s AND comment_date = %s", $comment_author, $comment_date) );
32015 }
32016
32017 /**
32018 * {@internal Missing Short Description}}
32019 *
32020 * @since unknown
32021 */
32022 function edit_comment() {
32023
32024 $comment_post_ID = (int) $_POST['comment_post_ID'];
32025
32026 if (!current_user_can( 'edit_post', $comment_post_ID ))
32027 wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.' ));
32028
32029 $_POST['comment_author'] = $_POST['newcomment_author'];
32030 $_POST['comment_author_email'] = $_POST['newcomment_author_email'];
32031 $_POST['comment_author_url'] = $_POST['newcomment_author_url'];
32032 $_POST['comment_approved'] = $_POST['comment_status'];
32033 $_POST['comment_content'] = $_POST['content'];
32034 $_POST['comment_ID'] = (int) $_POST['comment_ID'];
32035
32036 foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
32037 if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
32038 $_POST['edit_date'] = '1';
32039 break;
32040 }
32041 }
32042
32043 if (!empty ( $_POST['edit_date'] ) ) {
32044 $aa = $_POST['aa'];
32045 $mm = $_POST['mm'];
32046 $jj = $_POST['jj'];
32047 $hh = $_POST['hh'];
32048 $mn = $_POST['mn'];
32049 $ss = $_POST['ss'];
32050 $jj = ($jj > 31 ) ? 31 : $jj;
32051 $hh = ($hh > 23 ) ? $hh -24 : $hh;
32052 $mn = ($mn > 59 ) ? $mn -60 : $mn;
32053 $ss = ($ss > 59 ) ? $ss -60 : $ss;
32054 $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
32055 }
32056
32057 wp_update_comment( $_POST);
32058 }
32059
32060 /**
32061 * {@internal Missing Short Description}}
32062 *
32063 * @since unknown
32064 *
32065 * @param unknown_type $id
32066 * @return unknown
32067 */
32068 function get_comment_to_edit( $id ) {
32069 if ( !$comment = get_comment($id) )
32070 return false;
32071
32072 $comment->comment_ID = (int) $comment->comment_ID;
32073 $comment->comment_post_ID = (int) $comment->comment_post_ID;
32074
32075 $comment->comment_content = format_to_edit( $comment->comment_content );
32076 $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content);
32077
32078 $comment->comment_author = format_to_edit( $comment->comment_author );
32079 $comment->comment_author_email = format_to_edit( $comment->comment_author_email );
32080 $comment->comment_author_url = clean_url($comment->comment_author_url);
32081 $comment->comment_author_url = format_to_edit( $comment->comment_author_url );
32082
32083 return $comment;
32084 }
32085
32086 /**
32087 * {@internal Missing Short Description}}
32088 *
32089 * @since unknown
32090 * @uses $wpdb
32091 *
32092 * @param int $post_id Post ID
32093 * @return unknown
32094 */
32095 function get_pending_comments_num( $post_id ) {
32096 global $wpdb;
32097
32098 $single = false;
32099 if ( !is_array($post_id) ) {
32100 $post_id = (array) $post_id;
32101 $single = true;
32102 }
32103 $post_id = array_map('intval', $post_id);
32104 $post_id = "'" . implode("', '", $post_id) . "'";
32105
32106 $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_N );
32107
32108 if ( empty($pending) )
32109 return 0;
32110
32111 if ( $single )
32112 return $pending[0][1];
32113
32114 $pending_keyed = array();
32115 foreach ( $pending as $pend )
32116 $pending_keyed[$pend[0]] = $pend[1];
32117
32118 return $pending_keyed;
32119 }
32120
32121 /**
32122 * Add avatars to relevant places in admin, or try to.
32123 *
32124 * @since unknown
32125 * @uses $comment
32126 *
32127 * @param string $name User name.
32128 * @return string Avatar with Admin name.
32129 */
32130 function floated_admin_avatar( $name ) {
32131 global $comment;
32132
32133 $id = $avatar = false;
32134 if ( $comment->comment_author_email )
32135 $id = $comment->comment_author_email;
32136 if ( $comment->user_id )
32137 $id = $comment->user_id;
32138
32139 if ( $id )
32140 $avatar = get_avatar( $id, 32 );
32141
32142 return "$avatar $name";
32143 }
32144
32145 function enqueue_comment_hotkeys_js() {
32146 if ( 'true' == get_user_option( 'comment_shortcuts' ) )
32147 wp_enqueue_script( 'jquery-table-hotkeys' );
32148 }
32149
32150 if ( is_admin() && ('edit-comments.php' == $pagenow || 'edit.php' == $pagenow) ) {
32151 if ( get_option('show_avatars') )
32152 add_filter( 'comment_author', 'floated_admin_avatar' );
32153 }
32154
32155 ?>