Skip to:
Content

bbPress.org

Changeset 3125


Ignore:
Timestamp:
05/09/2011 06:51:40 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Prevent forum and topic ID's from being poisoned by functions that attempt to make calculations out of turn. Also prevent incorrect assignment of parent topic and forum ID's when posting from admin area. Fixes #1433.

Location:
branches/plugin
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-admin/bbp-replies.php

    r3120 r3125  
    568568
    569569                // Output forum name
    570                 bbp_topic_title( $topic_id );
    571 
    572                 // Link information
    573                 $actions = apply_filters( 'reply_topic_row_actions', array (
    574                     'edit' => '<a href="' . add_query_arg( array( 'post' => $topic_id, 'action' => 'edit' ), admin_url( '/post.php' ) ) . '">' . __( 'Edit', 'bbpress' ) . '</a>',
    575                     'view' => '<a href="' . bbp_get_topic_permalink( $topic_id ) . '">' . __( 'View', 'bbpress' ) . '</a>'
    576                 ) );
    577 
    578                 // Output forum post row links
    579                 foreach ( $actions as $action => $link )
    580                     $formatted_actions[] = '<span class="' . $action . '">' . $link . '</span>';
    581 
    582                 //echo '<div class="row-actions">' . implode( ' | ', $formatted_actions ) . '</div>';
     570                if ( !empty( $topic_id ) ) {
     571                    bbp_topic_title( $topic_id );
     572
     573                    // Link information
     574                    $actions = apply_filters( 'reply_topic_row_actions', array (
     575                        'edit' => '<a href="' . add_query_arg( array( 'post' => $topic_id, 'action' => 'edit' ), admin_url( '/post.php' ) ) . '">' . __( 'Edit', 'bbpress' ) . '</a>',
     576                        'view' => '<a href="' . bbp_get_topic_permalink( $topic_id ) . '">' . __( 'View', 'bbpress' ) . '</a>'
     577                    ) );
     578
     579                    // Output forum post row links
     580                    foreach ( $actions as $action => $link )
     581                        $formatted_actions[] = '<span class="' . $action . '">' . $link . '</span>';
     582
     583                    if ( !empty( $topic_id ) )
     584                        echo '<div class="row-actions">' . implode( ' | ', $formatted_actions ) . '</div>';
     585
     586                // Reply has no topic
     587                } else {
     588                    _e( '(No Topic)', 'bbpress' );
     589                }
    583590
    584591                break;
     
    591598
    592599                // Output forum name
    593                 bbp_forum_title( $forum_id );
    594 
    595                 // Link information
    596                 $actions = apply_filters( 'reply_topic_forum_row_actions', array (
    597                     'edit' => '<a href="' . add_query_arg( array( 'post' => $forum_id, 'action' => 'edit' ), admin_url( '/post.php' ) ) . '">' . __( 'Edit', 'bbpress' ) . '</a>',
    598                     'view' => '<a href="' . bbp_get_forum_permalink( $forum_id ) . '">' . __( 'View', 'bbpress' ) . '</a>'
    599                 ) );
    600 
    601                 // Output forum post row links
    602                 foreach ( $actions as $action => $link )
    603                     $formatted_actions[] = '<span class="' . $action . '">' . $link . '</span>';
    604 
    605                 //echo '<div class="row-actions">' . implode( ' | ', $formatted_actions ) . '</div>';
     600                if ( !empty( $forum_id ) ) {
     601                    bbp_forum_title( $forum_id );
     602
     603                    // Link information
     604                    $actions = apply_filters( 'reply_topic_forum_row_actions', array (
     605                        'edit' => '<a href="' . add_query_arg( array( 'post' => $forum_id, 'action' => 'edit' ), admin_url( '/post.php' ) ) . '">' . __( 'Edit', 'bbpress' ) . '</a>',
     606                        'view' => '<a href="' . bbp_get_forum_permalink( $forum_id ) . '">' . __( 'View', 'bbpress' ) . '</a>'
     607                    ) );
     608
     609                    // Output forum post row links
     610                    foreach ( $actions as $action => $link )
     611                        $formatted_actions[] = '<span class="' . $action . '">' . $link . '</span>';
     612
     613                    // Show forum actions
     614                    if ( !empty( $forum_id ) )
     615                        echo '<div class="row-actions">' . implode( ' | ', $formatted_actions ) . '</div>';
     616
     617                // Reply has no forum
     618                } else {
     619                    _e( '(No Forum)', 'bbpress' );
     620                }
    606621
    607622                break;
  • branches/plugin/bbp-admin/bbp-topics.php

    r3120 r3125  
    653653                        $formatted_actions[] = '<span class="' . $action . '">' . $link . '</span>';
    654654
    655                     //echo '<div class="row-actions">' . implode( ' | ', $formatted_actions ) . '</div>';
     655                    echo '<div class="row-actions">' . implode( ' | ', $formatted_actions ) . '</div>';
    656656                } else {
    657657                    _e( '(No Forum)', 'bbpress' );
  • branches/plugin/bbp-includes/bbp-reply-functions.php

    r3124 r3125  
    383383            // Check that actions match what we need
    384384            'editpost'                    === $_POST['action']           &&
     385            'publish'                     === $_POST['post_status']      &&
    385386            bbp_get_reply_post_type()     === $_POST['post_type']
     387
    386388    ) {
    387389
  • branches/plugin/bbp-includes/bbp-reply-template.php

    r3101 r3125  
    10711071    function bbp_get_reply_topic_id( $reply_id = 0 ) {
    10721072
     1073        // Assume there is no topic id
     1074        $topic_id = 0;
     1075
    10731076        // Check that reply_id is valid
    1074         if ( $reply_id = bbp_get_reply_id( $reply_id ) ) {
     1077        if ( $reply_id = bbp_get_reply_id( $reply_id ) )
    10751078
    10761079            // Get topic_id from reply
    1077             $topic_id = get_post_meta( $reply_id, '_bbp_topic_id', true );
    1078             $topic_id = bbp_get_topic_id( $topic_id );
    1079 
    1080         // reply_id is not valid, so no topic exists
    1081         } else {
    1082             $topic_id = 0;
    1083         }
     1080            if ( $topic_id = get_post_meta( $reply_id, '_bbp_topic_id', true ) )
     1081
     1082                // Validate the topic_id
     1083                $topic_id = bbp_get_topic_id( $topic_id );
    10841084
    10851085        return apply_filters( 'bbp_get_reply_topic_id', (int) $topic_id, $reply_id );
     
    11111111    function bbp_get_reply_forum_id( $reply_id = 0 ) {
    11121112
     1113        // Assume there is no forum
     1114        $forum_id = 0;
     1115
    11131116        // Check that reply_id is valid
    1114         if ( $reply_id = bbp_get_reply_id( $reply_id ) ) {
     1117        if ( $reply_id = bbp_get_reply_id( $reply_id ) )
    11151118
    11161119            // Get forum_id from reply
    1117             $forum_id = get_post_meta( $reply_id, '_bbp_forum_id', true );
    1118             $forum_id = bbp_get_forum_id( $forum_id );
    1119 
    1120         // reply_id is not valid, so no forum exists
    1121         } else {
    1122             $forum_id = 0;
    1123         }
     1120            if ( $forum_id = get_post_meta( $reply_id, '_bbp_forum_id', true ) )
     1121
     1122                // Validate the forum_id
     1123                $forum_id = bbp_get_forum_id( $forum_id );
    11241124
    11251125        return apply_filters( 'bbp_get_reply_forum_id', (int) $forum_id, $reply_id );
  • branches/plugin/bbp-includes/bbp-topic-functions.php

    r3124 r3125  
    392392            // Check that actions match what we need
    393393            'editpost'                    === $_POST['action']           &&
     394            'publish'                     === $_POST['post_status']      &&
    394395            bbp_get_topic_post_type()     === $_POST['post_type']
    395396    ) {
  • branches/plugin/bbp-includes/bbp-topic-template.php

    r3113 r3125  
    12651265        $forum_id = get_post_meta( $topic_id, '_bbp_forum_id', true );
    12661266
    1267         // Fallback to post_parent if no meta exists, and set post meta
    1268         if ( '' === $forum_id ) {
    1269             $forum_id = get_post_field( 'post_parent', $topic_id );
    1270             bbp_update_topic_forum_id( $topic_id, $forum_id );
    1271         }
    1272 
    12731267        return apply_filters( 'bbp_get_topic_forum_id', (int) $forum_id, $topic_id );
    12741268    }
Note: See TracChangeset for help on using the changeset viewer.