Making WordPress.org

Ticket #2493: meta-2493.patch

File meta-2493.patch, 6.0 KB (added by SergeyBiryukov, 8 years ago)
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-user-moderation/inc/class-plugin.php

     
    1919        // Back-compat user option name.
    2020        const USER_META = 'is_bozo';
    2121
     22        const MODERATOR_META = '_wporg_bbp_moderator';
     23
    2224        /**
    2325         * Always return the same instance of this plugin.
    2426         *
     
    228230
    229231                if ( ! $this->is_user_flagged( $user_id ) ) {
    230232                        update_user_meta( $user_id, self::USER_META, true );
     233                        update_user_meta( $user_id, self::MODERATOR_META, wp_get_current_user()->user_login );
    231234                }
    232235                do_action( 'wporg_bbp_flag_user', $user_id );
    233236
     
    241244
    242245                if ( $this->is_user_flagged( $user_id ) ) {
    243246                        delete_user_meta( $user_id, self::USER_META );
     247                        update_user_meta( $user_id, self::MODERATOR_META, wp_get_current_user()->user_login );
    244248                }
    245249                do_action( 'wporg_bbp_unflag_user', $user_id );
    246250
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/bbpress/user-profile.php

     
    1111
    1212<div id="bbp-user-profile" class="bbp-user-profile">
    1313        <h2 class="entry-title"><?php esc_html_e( 'Profile', 'wporg-forums' ); ?></h2>
    14         <div class="bbp-user-section">
     14        <div class="bbp-user-section"><?php
     15                if ( class_exists( 'WordPressdotorg\Forums\User_Moderation\Plugin' ) ) {
     16                        $is_user_flagged = WordPressdotorg\Forums\User_Moderation\Plugin::get_instance()->is_user_flagged( bbp_get_displayed_user_id() );
     17                        $moderator       = get_user_meta( bbp_get_displayed_user_id(), '_wporg_bbp_moderator', true );
    1518
     19                        if ( $is_user_flagged && $moderator ) {
     20                                printf(
     21                                        '<div class="bbp-template-notice info"><p>%s</p></div>',
     22                                        /* translators: %s: moderator's username */
     23                                        sprintf( __( 'This user has been flagged by %s.', 'wporg-forums' ), $moderator )
     24                                );
     25                        }
     26                }
     27                ?>
     28
    1629                <?php if ( bbp_get_displayed_user_field( 'description' ) ) : ?>
    1730
    1831                        <p class="bbp-user-description"><?php bbp_displayed_user_field( 'description' ); ?></p>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

     
    235235        $is_moderator    = current_user_can( 'moderate' );
    236236        $is_user_blocked = ! current_user_can( 'spectate' );
    237237        $notice_class    = '';
    238         $notice          = '';
     238        $notices         = array();
    239239
    240240        if ( $is_moderator && in_array( $post_status, array( 'archived', 'pending', 'spam' ) ) ) :
    241241
     
    246246
    247247                        if ( $reporter ) {
    248248                                /* translators: %s: reporter's username */
    249                                 $notice = sprintf( __( 'This post has been flagged as spam by %s.', 'wporg-forums' ), $reporter );
     249                                $notices[] = sprintf( __( 'This post has been flagged as spam by %s.', 'wporg-forums' ), $reporter );
    250250                        } else {
    251                                 $notice = __( 'This post has been flagged as spam.', 'wporg-forums' );
     251                                $notices[] = __( 'This post has been flagged as spam.', 'wporg-forums' );
    252252                        }
    253253                } elseif ( 'archived' === $post_status ) {
    254                         $notice = __( 'This post is currently archived.', 'wporg-forums' );
     254                        $notices[] = __( 'This post is currently archived.', 'wporg-forums' );
    255255                } else {
    256                         $notice = __( 'This post is currently pending.', 'wporg-forums' );
     256                        $notices[] = __( 'This post is currently pending.', 'wporg-forums' );
    257257                }
    258258
     259                if ( class_exists( 'WordPressdotorg\Forums\User_Moderation\Plugin' ) ) :
     260                        $is_user_flagged = WordPressdotorg\Forums\User_Moderation\Plugin::get_instance()->is_user_flagged( get_post()->post_author );
     261                        $moderator       = get_user_meta( get_post()->post_author, '_wporg_bbp_moderator', true );
     262
     263                        if ( $is_user_flagged && $moderator ) {
     264                                /* translators: %s: moderator's username */
     265                                $notices[] = sprintf( __( 'This user has been flagged by %s.', 'wporg-forums' ), $moderator );
     266                        }
     267                endif;
     268
    259269        elseif ( in_array( $post_status, array( 'pending', 'spam' ) ) ) :
    260270
    261271                if ( $is_user_blocked ) {
    262272                        // Blocked users get a generic message with no call to action or moderation timeframe.
    263                         $notice = __( 'This post has been held for moderation by our automated system.', 'wporg-forums' );
     273                        $notices[] = __( 'This post has been held for moderation by our automated system.', 'wporg-forums' );
    264274                } elseif ( $hours_passed > 96 ) {
    265275                        $notice_class = 'warning';
    266                         $notice       = sprintf(
     276                        $notices[]    = sprintf(
    267277                                /* translators: %s: https://make.wordpress.org/chat/ */
    268278                                __( 'This post was held for moderation by our automated system but has taken longer than expected to get approved. Please come to the #forums channel on <a href="%s">WordPress Slack</a> and let us know. Provide a link to the post.', 'wporg-forums' ),
    269279                                'https://make.wordpress.org/chat/'
    270280                        );
    271281                } else {
    272                         $notice = sprintf(
     282                        $notices[] = sprintf(
    273283                                /* translators: %d: number of hours */
    274284                                _n( 'This post has been held for moderation by our automated system. It will be reviewed within %d hour.', 'This post has been held for moderation by our automated system. It will be reviewed within %d hours.', 72, 'wporg-forums' ),
    275285                                72
     
    278288
    279289        endif;
    280290
    281         if ( $notice ) {
     291        if ( $notices ) {
    282292                printf(
    283293                        '<div class="bbp-template-notice %s"><p>%s</p></div>',
    284294                        esc_attr( $notice_class ),
    285                         $notice
     295                        implode( '</p><p>', $notices )
    286296                );
    287297        }
    288298}