Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/02/2011 07:22:58 PM (15 years ago)
Author:
johnjamesjacoby
Message:

Fix issues with creating/editing topics and replies from within wp-admin. Fixes #1544.

File:
1 edited

Legend:

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

    r3286 r3295  
    231231            return $reply_id;
    232232
     233        // Check action exists
     234        if ( empty( $_POST['action'] ) )
     235            return $reply_id;
     236
     237        // Bail if post_type is not a topic or reply
     238        if ( get_post_type( $reply_id ) != $this->post_type )
     239            return;
     240
    233241        // Current user cannot edit this reply
    234242        if ( !current_user_can( 'edit_reply', $reply_id ) )
    235243            return $reply_id;
    236244
    237         // Load the reply
    238         if ( !$reply = bbp_get_reply( $reply_id ) )
    239             return $reply_id;
    240 
    241         // OK, we're authenticated: we need to find and save the data
    242         $parent_id = isset( $reply->parent_id ) ? $reply->parent_id : 0;
    243 
    244         do_action( 'bbp_reply_attributes_metabox_save', $reply_id, $parent_id );
    245 
    246         return $parent_id;
     245        // Get the reply meta post values
     246        $topic_id = !empty( $_POST['parent_id']    ) ? (int) $_POST['parent_id']    : 0;
     247        $forum_id = !empty( $_POST['bbp_forum_id'] ) ? (int) $_POST['bbp_forum_id'] : bbp_get_topic_forum_id( $topic_id );
     248
     249        // Formally update the reply
     250        bbp_update_reply( $reply_id, $topic_id, $forum_id );
     251
     252        // Allow other fun things to happen
     253        do_action( 'bbp_reply_attributes_metabox_save', $reply_id, $topic_id, $forum_id );
     254
     255        return $reply_id;
    247256    }
    248257
     
    585594                    echo $topic_title;
    586595
    587                     // Show actions if topic exists
    588                     if ( $topic_title != __( 'No Topic', 'bbpress' ) ) {
    589 
    590                         // Link information
    591                         $actions = apply_filters( 'reply_topic_row_actions', array (
    592                             'edit' => '<a href="' . add_query_arg( array( 'post' => $topic_id, 'action' => 'edit' ), admin_url( '/post.php' ) ) . '">' . __( 'Edit', 'bbpress' ) . '</a>',
    593                             'view' => '<a href="' . bbp_get_topic_permalink( $topic_id ) . '">' . __( 'View', 'bbpress' ) . '</a>'
    594                         ) );
    595 
    596                         // Output forum post row links
    597                         foreach ( $actions as $action => $link )
    598                             $formatted_actions[] = '<span class="' . $action . '">' . $link . '</span>';
    599 
    600                         echo '<div class="row-actions">' . implode( ' | ', $formatted_actions ) . '</div>';
    601                     }
    602 
    603596                // Reply has no topic
    604597                } else {
     
    611604            case 'bbp_reply_forum' :
    612605
    613                 // Get Forum ID
    614                 $forum_id = bbp_get_topic_forum_id( $topic_id );
     606                // Get Forum ID's
     607                $reply_forum_id = bbp_get_reply_forum_id( $reply_id );
     608                $topic_forum_id = bbp_get_topic_forum_id( $topic_id );
    615609
    616610                // Output forum name
    617                 if ( !empty( $forum_id ) ) {
     611                if ( !empty( $reply_forum_id ) ) {
    618612
    619613                    // Forum Title
    620                     if ( !$forum_title = bbp_get_forum_title( $forum_id ) )
     614                    if ( !$forum_title = bbp_get_forum_title( $reply_forum_id ) )
    621615                        $forum_title = __( 'No Forum', 'bbpress' );
     616
     617                    // Alert capable users of reply forum mismatch
     618                    if ( $reply_forum_id != $topic_forum_id ) {
     619                        if ( current_user_can( 'edit_others_replies' ) || current_user_can( 'moderate' ) ) {
     620                            $forum_title .= '<div class="attention">' . __( '(Mismatch)', 'bbpress' ) . '</div>';
     621                        }
     622                    }
    622623
    623624                    // Output the title
    624625                    echo $forum_title;
    625 
    626                     // Show actions if forum exists
    627                     if ( $forum_title != __( 'No Forum', 'bbpress' ) ) {
    628 
    629                         // Link information
    630                         $actions = apply_filters( 'reply_topic_forum_row_actions', array (
    631                             'edit' => '<a href="' . add_query_arg( array( 'post' => $forum_id, 'action' => 'edit' ), admin_url( '/post.php' ) ) . '">' . __( 'Edit', 'bbpress' ) . '</a>',
    632                             'view' => '<a href="' . bbp_get_forum_permalink( $forum_id ) . '">' . __( 'View', 'bbpress' ) . '</a>'
    633                         ) );
    634 
    635                         // Output forum post row links
    636                         foreach ( $actions as $action => $link )
    637                             $formatted_actions[] = '<span class="' . $action . '">' . $link . '</span>';
    638 
    639                         // Show forum actions
    640                         echo '<div class="row-actions">' . implode( ' | ', $formatted_actions ) . '</div>';
    641                     }
    642 
     626                   
    643627                // Reply has no forum
    644628                } else {
Note: See TracChangeset for help on using the changeset viewer.