Making WordPress.org

Ticket #2590: 2590.2.diff

File 2590.2.diff, 6.2 KB (added by SergeyBiryukov, 9 years ago)
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-moderators.php

     
    131131        }
    132132
    133133        public function archive_handler( $action = '' ) {
    134                 if ( ! current_user_can( 'moderate' ) ) {
    135                         return;
    136                 }
    137                 $user_id = get_current_user_id();
    138 
    139134                if ( ! in_array( $action, $this->get_valid_actions() ) ) {
    140135                        return;
    141136                }
     
    144139                        return;
    145140                }
    146141
    147                 $post = get_post( absint( $_GET['post_id'] ) );
     142                $user_id = get_current_user_id();
     143                $post_id = absint( $_GET['post_id'] );
     144
     145                $post = get_post( $post_id );
    148146                if ( ! $post ) {
    149147                        return false;
    150148                }
    151149
     150                if ( ! current_user_can( 'moderate', $post->ID ) ) {
     151                        return;
     152                }
     153
    152154                // Check for empty post id.
    153155                if ( ! $post ) {
    154156                        bbp_add_error( 'wporg_bbp_archive_post_id', __( '<strong>ERROR</strong>: No post was found! Which post are you archiving?', 'wporg-forums' ) );
     
    208210        }
    209211
    210212        public function get_archive_link( $args = array() ) {
    211                 if ( ! current_user_can( 'moderate' ) ) {
    212                         return false;
    213                 }
    214                 $user_id = get_current_user_id();
    215 
    216213                $r = bbp_parse_args( $args, array(
    217214                        'post_id' => get_the_ID(),
    218215                        'archive' => esc_html__( 'Archive', 'wporg-forums' ),
    219216                        'unarchive' => esc_html__( 'Unarchive', 'wporg-forums' ),
    220217                ), 'get_post_archive_link' );
     218
    221219                if ( empty( $r['post_id'] ) ) {
    222220                        return false;
    223221                }
     222
     223                $user_id = get_current_user_id();
    224224                $post_id = $r['post_id'];
    225225
    226226                $post = get_post( $post_id );
     
    228228                        return false;
    229229                }
    230230
     231                if ( ! current_user_can( 'moderate', $post->ID ) ) {
     232                        return false;
     233                }
     234
    231235                if ( $this->is_post_archived( $post->ID ) ) {
    232236                        $text = $r['unarchive'];
    233237                        $query_args = array( 'action' => 'wporg_bbp_unarchive_post', 'post_id' => $post->ID );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-stickies-compat.php

     
    207207
    208208                if ( $user && $topic && $term ) {
    209209                        // Moderators.
    210                         if ( user_can( $user->ID, 'moderate' ) ) {
     210                        if ( user_can( $user->ID, 'moderate', $topic->ID ) ) {
    211211                                $retval = true;
    212212                        }
    213213
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-topic-resolution/inc/class-plugin.php

     
    505505                        $post = get_post( $topic_id );
    506506                }
    507507
    508                 if ( $user_id && $post && ( user_can( $user_id, 'moderate' ) || $user_id == $post->post_author ) ) {
     508                if ( $user_id && $post && ( user_can( $user_id, 'moderate', $topic_id ) || $user_id == $post->post_author ) ) {
    509509                        $retval = true;
    510510                } else {
    511511                        $retval = false;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-user-badges/inc/class-plugin.php

     
    426426         * of badging them. Use the $strict argument to check that the user is a
    427427         * moderator without considering if they are a keymaster.
    428428         *
    429          * @param string $user_id Optional. User ID. Assumes current reply author ID
     429         * @param string $user_id Optional. User ID. Assumes current post author ID
    430430         *                        if not provided.
    431431         * @param bool   $strict  Optional. True if user should strictly be checked
    432432         *                        for being a moderator, false will also check if they
     
    435435         */
    436436        public function is_user_moderator( $user_id = '', $strict = false ) {
    437437                if ( ! $user_id ) {
    438                         $user_id = bbp_get_reply_author_id();
     438                        $user_id = get_post_field( 'post_author' );
    439439                }
    440440
    441                 return ( user_can( $user_id, 'moderate' ) || ( ! $strict && bbp_is_user_keymaster( $user_id ) ) );
     441                return ( user_can( $user_id, 'moderate', get_the_ID() ) || ( ! $strict && bbp_is_user_keymaster( $user_id ) ) );
    442442        }
    443443}
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/bbpress/form-topic.php

     
    159159
    160160                                        <?php endif; ?>
    161161
    162                                         <?php if ( current_user_can( 'moderate' ) ) : ?>
     162                                        <?php if ( current_user_can( 'moderate', bbp_get_topic_id() ) ) : ?>
    163163
    164164                                                <?php do_action( 'bbp_theme_before_topic_form_type' ); ?>
    165165
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

     
    268268        $seconds_passed  = current_time( 'timestamp' ) - $post_time;
    269269        $hours_passed    = (int) ( $seconds_passed / HOUR_IN_SECONDS );
    270270        $post_status     = get_post_status();
    271         $is_moderator    = current_user_can( 'moderate' );
     271        $is_moderator    = current_user_can( 'moderate', get_the_ID() );
    272272        $is_user_blocked = ! current_user_can( 'spectate' );
    273273        $notice_class    = '';
    274274        $notices         = array();