Making WordPress.org


Ignore:
Timestamp:
04/09/2017 06:00:28 AM (9 years ago)
Author:
SergeyBiryukov
Message:

Support Forums: Use post-specific moderate capability checks in Moderators::archive_handler() and ::get_archive_link().

See #2590.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-moderators.php

    r5293 r5294  
    152152
    153153        public function archive_handler( $action = '' ) {
    154                 if ( ! current_user_can( 'moderate' ) ) {
    155                         return;
    156                 }
    157                 $user_id = get_current_user_id();
    158 
    159154                if ( ! in_array( $action, $this->get_valid_actions() ) ) {
    160155                        return;
     
    165160                }
    166161
    167                 $post = get_post( absint( $_GET['post_id'] ) );
    168                 if ( ! $post ) {
    169                         return false;
     162                $user_id = get_current_user_id();
     163                $post_id = absint( $_GET['post_id'] );
     164
     165                $post = get_post( $post_id );
     166                if ( ! $post ) {
     167                        return;
     168                }
     169
     170                if ( ! current_user_can( 'moderate', $post->ID ) ) {
     171                        return;
    170172                }
    171173
     
    229231
    230232        public function get_archive_link( $args = array() ) {
    231                 if ( ! current_user_can( 'moderate' ) ) {
    232                         return false;
    233                 }
    234                 $user_id = get_current_user_id();
    235 
    236233                $r = bbp_parse_args( $args, array(
    237234                        'post_id' => get_the_ID(),
     
    239236                        'unarchive' => esc_html__( 'Unarchive', 'wporg-forums' ),
    240237                ), 'get_post_archive_link' );
     238
    241239                if ( empty( $r['post_id'] ) ) {
    242240                        return false;
    243241                }
     242
     243                $user_id = get_current_user_id();
    244244                $post_id = $r['post_id'];
    245245
    246246                $post = get_post( $post_id );
    247247                if ( ! $post ) {
     248                        return false;
     249                }
     250
     251                if ( ! current_user_can( 'moderate', $post->ID ) ) {
    248252                        return false;
    249253                }
Note: See TracChangeset for help on using the changeset viewer.