Skip to:
Content

bbPress.org

Changeset 6341


Ignore:
Timestamp:
03/02/2017 04:46:00 AM (5 years ago)
Author:
johnjamesjacoby
Message:

Moderation: Use the appropriate _edit_ post meta when editing a forum/topic/reply.

This first pass does not introduce any theme-side edit-locking interface, but it will warn any user within wp-admin if another user is editing something theme-side.

See #3073.

Location:
trunk/src
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bbpress.php

    r6339 r6341  
    334334        require $this->includes_dir . 'common/formatting.php';
    335335        require $this->includes_dir . 'common/locale.php';
     336        require $this->includes_dir . 'common/locks.php';
    336337        require $this->includes_dir . 'common/template.php';
    337338        require $this->includes_dir . 'common/widgets.php';
  • trunk/src/includes/core/theme-compat.php

    r6314 r6341  
    578578        ) );
    579579
     580        // Lock the forum from other edits
     581        bbp_set_post_lock( bbp_get_forum_id() );
     582
    580583    } elseif ( bbp_is_single_forum() ) {
    581584
     
    644647
    645648        // Edit
    646         } elseif ( bbp_is_topic_edit() ) {
     649        } elseif ( bbp_is_topic_edit() ) {         
    647650            $new_content = $bbp_shortcodes->display_topic_form();
     651
     652            // Lock the topic from other edits
     653            bbp_set_post_lock( bbp_get_topic_id() );
    648654
    649655        // Single
     
    694700            $new_content = $bbp_shortcodes->display_reply_form();
    695701
     702            // Lock the topic from other edits
     703            bbp_set_post_lock( bbp_get_reply_id() );
     704
    696705        // Single
    697706        } else {
  • trunk/src/includes/forums/functions.php

    r6219 r6341  
    528528    $forum_id = wp_update_post( $forum_data );
    529529
    530     /** Revisions *************************************************************/
    531 
    532     /**
    533      * @todo omitted for 2.1
    534     // Revision Reason
    535     if ( ! empty( $_POST['bbp_forum_edit_reason'] ) )
    536         $forum_edit_reason = sanitize_text_field( $_POST['bbp_forum_edit_reason'] );
    537 
    538     // Update revision log
    539     if ( ! empty( $_POST['bbp_log_forum_edit'] ) && ( "1" === $_POST['bbp_log_forum_edit'] ) && ( $revision_id = wp_save_post_revision( $forum_id ) ) ) {
    540         bbp_update_forum_revision_log( array(
    541             'forum_id'    => $forum_id,
    542             'revision_id' => $revision_id,
    543             'author_id'   => bbp_get_current_user_id(),
    544             'reason'      => $forum_edit_reason
    545         ) );
    546     }
    547      */
    548 
    549530    /** No Errors *************************************************************/
    550531
     
    563544        ) );
    564545
     546        /** Revisions *********************************************************/
     547
     548        // Update locks
     549        update_post_meta( $forum_id, '_edit_last', bbp_get_current_user_id() );
     550        delete_post_meta( $forum_id, '_edit_lock' );
     551
     552        /**
     553         * @todo omitted for now
     554        // Revision Reason
     555        if ( ! empty( $_POST['bbp_forum_edit_reason'] ) )
     556            $forum_edit_reason = sanitize_text_field( $_POST['bbp_forum_edit_reason'] );
     557
     558        // Update revision log
     559        if ( ! empty( $_POST['bbp_log_forum_edit'] ) && ( "1" === $_POST['bbp_log_forum_edit'] ) && ( $revision_id = wp_save_post_revision( $forum_id ) ) ) {
     560            bbp_update_forum_revision_log( array(
     561                'forum_id'    => $forum_id,
     562                'revision_id' => $revision_id,
     563                'author_id'   => bbp_get_current_user_id(),
     564                'reason'      => $forum_edit_reason
     565            ) );
     566        }
     567
    565568        // If the new forum parent id is not equal to the old forum parent
    566569        // id, run the bbp_move_forum action and pass the forum's parent id
    567         // as the first arg and new forum parent id as the second.
     570        // as the first argument and new forum parent id as the second.
    568571        // @todo implement
    569         //if ( $forum_id !== $forum->post_parent )
    570         //  bbp_move_forum_handler( $forum_parent_id, $forum->post_parent, $forum_id );
     572        if ( $forum_id !== $forum->post_parent ) {
     573            bbp_move_forum_handler( $forum_parent_id, $forum->post_parent, $forum_id );
     574        }
     575
     576        */
    571577
    572578        /** Additional Actions (After Save) ***********************************/
  • trunk/src/includes/replies/functions.php

    r6330 r6341  
    728728    }
    729729
    730     // Insert topic
     730    // Insert reply
    731731    $reply_id = wp_update_post( $reply_data );
    732732
     
    750750    }
    751751
    752     /** Revisions *************************************************************/
    753 
    754     // Revision Reason
    755     if ( ! empty( $_POST['bbp_reply_edit_reason'] ) ) {
    756         $reply_edit_reason = sanitize_text_field( $_POST['bbp_reply_edit_reason'] );
    757     }
    758 
    759     // Update revision log
    760     if ( ! empty( $_POST['bbp_log_reply_edit'] ) && ( "1" === $_POST['bbp_log_reply_edit'] ) ) {
    761         $revision_id = wp_save_post_revision( $reply_id );
    762         if ( ! empty( $revision_id ) ) {
    763             bbp_update_reply_revision_log( array(
    764                 'reply_id'    => $reply_id,
    765                 'revision_id' => $revision_id,
    766                 'author_id'   => bbp_get_current_user_id(),
    767                 'reason'      => $reply_edit_reason
    768             ) );
    769         }
    770     }
    771 
    772752    /** No Errors *************************************************************/
    773753
     
    776756        // Update counts, etc...
    777757        do_action( 'bbp_edit_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author , true, $reply_to );
     758
     759        /** Revisions *********************************************************/
     760
     761        // Update locks
     762        update_post_meta( $reply_id, '_edit_last', bbp_get_current_user_id() );
     763        delete_post_meta( $reply_id, '_edit_lock' );
     764
     765        // Revision Reason
     766        if ( ! empty( $_POST['bbp_reply_edit_reason'] ) ) {
     767            $reply_edit_reason = sanitize_text_field( $_POST['bbp_reply_edit_reason'] );
     768        }
     769
     770        // Update revision log
     771        if ( ! empty( $_POST['bbp_log_reply_edit'] ) && ( "1" === $_POST['bbp_log_reply_edit'] ) ) {
     772            $revision_id = wp_save_post_revision( $reply_id );
     773            if ( ! empty( $revision_id ) ) {
     774                bbp_update_reply_revision_log( array(
     775                    'reply_id'    => $reply_id,
     776                    'revision_id' => $revision_id,
     777                    'author_id'   => bbp_get_current_user_id(),
     778                    'reason'      => $reply_edit_reason
     779                ) );
     780            }
     781        }
    778782
    779783        /** Additional Actions (After Save) ***********************************/
  • trunk/src/includes/topics/functions.php

    r6330 r6341  
    705705        /** Revisions *********************************************************/
    706706
     707        // Update locks
     708        update_post_meta( $topic_id, '_edit_last', bbp_get_current_user_id() );
     709        delete_post_meta( $topic_id, '_edit_lock' );
     710
    707711        // Revision Reason
    708712        if ( ! empty( $_POST['bbp_topic_edit_reason'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.