Skip to:
Content

bbPress.org

Changeset 5583


Ignore:
Timestamp:
12/07/2014 08:42:18 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Administrative support for for un/approving topics.

Props netweb, thebrandonallen. Fixes #2645.

Location:
trunk/src/includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/replies.php

    r5509 r5583  
    804804            }
    805805
    806             if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_spam_status_id() ) ) ) {
     806            // Show the 'spam' link on published and pending replies and 'not spam' on spammed replies
     807            if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_pending_status_id(), bbp_get_spam_status_id() ) ) ) {
    807808                $spam_uri  = wp_nonce_url( add_query_arg( array( 'reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_spam' ), remove_query_arg( array( 'bbp_reply_toggle_notice', 'reply_id', 'failed', 'super' ) ) ), 'spam-reply_'  . $reply->ID );
    808809                if ( bbp_is_reply_spam( $reply->ID ) ) {
  • trunk/src/includes/admin/topics.php

    r5496 r5583  
    158158                '<p>' . __( 'Hovering over a row in the topics list will display action links that allow you to manage your topic. You can perform the following actions:', 'bbpress' ) . '</p>' .
    159159                '<ul>' .
    160                     '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that topic. You can also reach that screen by clicking on the topic title.',                                                                                 'bbpress' ) . '</li>' .
    161                     '<li>' . __( '<strong>Trash</strong> removes your topic from this list and places it in the trash, from which you can permanently delete it.',                                                                                       'bbpress' ) . '</li>' .
    162                     '<li>' . __( '<strong>Spam</strong> removes your topic from this list and places it in the spam queue, from which you can permanently delete it.',                                                                                   'bbpress' ) . '</li>' .
    163                     '<li>' . __( '<strong>Preview</strong> will show you what your draft topic will look like if you publish it. View will take you to your live site to view the topic. Which link is available depends on your topic&#8217;s status.', 'bbpress' ) . '</li>' .
    164                     '<li>' . __( '<strong>Close</strong> will mark the selected topic as &#8217;closed&#8217; and disable the option to post new replies to the topic.',                                                                                 'bbpress' ) . '</li>' .
    165                     '<li>' . __( '<strong>Stick</strong> will keep the selected topic &#8217;pinned&#8217; to the top the parent forum topic list.',                                                                                                     'bbpress' ) . '</li>' .
    166                     '<li>' . __( '<strong>Stick <em>(to front)</em></strong> will keep the selected topic &#8217;pinned&#8217; to the top of ALL forums and be visable in any forums topics list.',                                                      'bbpress' ) . '</li>' .
     160                    '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that topic. You can also reach that screen by clicking on the topic title.',                            'bbpress' ) . '</li>' .
     161                    '<li>' . __( '<strong>Trash</strong> removes your topic from this list and places it in the trash, from which you can permanently delete it.',                                  'bbpress' ) . '</li>' .
     162                    '<li>' . __( '<strong>Spam</strong> removes your topic from this list and places it in the spam queue, from which you can permanently delete it.',                              'bbpress' ) . '</li>' .
     163                    '<li>' . __( '<strong>View</strong> will take you to your live site to view the topic.',                                                                                        'bbpress' ) . '</li>' .
     164                    '<li>' . __( '<strong>Approve</strong> will change the status from pending to publish.',                                                                                        'bbpress' ) . '</li>' .
     165                    '<li>' . __( '<strong>Close</strong> will mark the selected topic as &#8217;closed&#8217; and disable the option to post new replies to the topic.',                            'bbpress' ) . '</li>' .
     166                    '<li>' . __( '<strong>Stick</strong> will keep the selected topic &#8217;pinned&#8217; to the top the parent forum topic list.',                                                'bbpress' ) . '</li>' .
     167                    '<li>' . __( '<strong>Stick <em>(to front)</em></strong> will keep the selected topic &#8217;pinned&#8217; to the top of ALL forums and be visable in any forums topics list.', 'bbpress' ) . '</li>' .
    167168                '</ul>'
    168169        ) );
     
    448449            .status-spam {
    449450                background-color: #faeaea;
     451            }
     452
     453            .status-pending {
     454                background-color: #fef7f1;
    450455            }
    451456
     
    492497
    493498        // Only proceed if GET is a topic toggle action
    494         if ( bbp_is_get_request() && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_topic_close', 'bbp_toggle_topic_stick', 'bbp_toggle_topic_spam' ) ) && !empty( $_GET['topic_id'] ) ) {
     499        if ( bbp_is_get_request() && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_topic_close', 'bbp_toggle_topic_stick', 'bbp_toggle_topic_spam', 'bbp_toggle_topic_approve' ) ) && !empty( $_GET['topic_id'] ) ) {
    495500            $action    = $_GET['action'];            // What action is taking place?
    496501            $topic_id  = (int) $_GET['topic_id'];    // What's the topic id?
    497502            $success   = false;                      // Flag
    498503            $post_data = array( 'ID' => $topic_id ); // Prelim array
    499             $topic     = bbp_get_topic( $topic_id );
     504            $topic     = bbp_get_topic( $topic_id ); // Verify the topic id
    500505
    501506            // Bail if topic is missing
     
    510515
    511516            switch ( $action ) {
     517                case 'bbp_toggle_topic_approve' :
     518                    check_admin_referer( 'approve-topic_' . $topic_id );
     519
     520                    $is_approve = bbp_is_topic_pending( $topic_id );
     521                    $message    = ( true === $is_approve )
     522                        ? 'approved'
     523                        : 'unapproved';
     524                    $success    = ( true === $is_approve )
     525                        ? bbp_approve_topic( $topic_id )
     526                        : bbp_unapprove_topic( $topic_id );
     527
     528                    break;
     529
    512530                case 'bbp_toggle_topic_close' :
    513531                    check_admin_referer( 'close-topic_' . $topic_id );
     
    595613
    596614        // Only proceed if GET is a topic toggle action
    597         if ( bbp_is_get_request() && !empty( $_GET['bbp_topic_toggle_notice'] ) && in_array( $_GET['bbp_topic_toggle_notice'], array( 'opened', 'closed', 'super_sticky', 'stuck', 'unstuck', 'spammed', 'unspammed' ) ) && !empty( $_GET['topic_id'] ) ) {
     615        if ( bbp_is_get_request() && ! empty( $_GET['bbp_topic_toggle_notice'] ) && in_array( $_GET['bbp_topic_toggle_notice'], array( 'opened', 'closed', 'super_sticky', 'stuck', 'unstuck', 'spammed', 'unspammed', 'approved', 'unapproved' ) ) && ! empty( $_GET['topic_id'] ) ) {
    598616            $notice     = $_GET['bbp_topic_toggle_notice'];         // Which notice?
    599617            $topic_id   = (int) $_GET['topic_id'];                  // What's the topic id?
     
    654672                        ? sprintf( __( 'There was a problem unmarking the topic "%1$s" as spam.', 'bbpress' ), $topic_title )
    655673                        : sprintf( __( 'Topic "%1$s" successfully unmarked as spam.',             'bbpress' ), $topic_title );
     674                    break;
     675
     676                case 'approved'   :
     677                    $message = ( $is_failure === true )
     678                        ? sprintf( __( 'There was a problem approving the topic "%1$s".', 'bbpress' ), $topic_title )
     679                        : sprintf( __( 'Topic "%1$s" successfully approved.',             'bbpress' ), $topic_title );
     680                    break;
     681
     682                case 'unapproved' :
     683                    $message = ( $is_failure === true )
     684                        ? sprintf( __( 'There was a problem unapproving the topic "%1$s".', 'bbpress' ), $topic_title )
     685                        : sprintf( __( 'Topic "%1$s" successfully unapproved.',             'bbpress' ), $topic_title );
    656686                    break;
    657687            }
     
    843873        if ( current_user_can( 'moderate', $topic->ID ) ) {
    844874
     875            // Pending
     876            // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only
     877            $approve_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_approve' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'approve-topic_' . $topic->ID );
     878            if ( bbp_is_topic_published( $topic->ID ) ) {
     879                $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this topic', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove Topic', 'bbpress' ) . '</a>';
     880            } elseif ( ! bbp_is_topic_private( $topic->ID ) ) {
     881                $actions['approved']   = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this topic',   'bbpress' ) . '">' . _x( 'Approve',   'Approve Topic',   'bbpress' ) . '</a>';
     882                $actions['view']       = '<a href="' . esc_url( bbp_get_topic_permalink( $topic->ID ) ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>';
     883            }
     884
    845885            // Close
    846886            // Show the 'close' and 'open' link on published and closed posts only
     
    854894            }
    855895
    856             // Dont show sticky if topic links is spam or trash
    857             if ( !bbp_is_topic_spam( $topic->ID ) && !bbp_is_topic_trash( $topic->ID ) ) {
    858 
    859                 // Sticky
    860                 $stick_uri  = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_'  . $topic->ID );
     896            // Sticky
     897            // Dont show sticky if topic links is spam, trash or pending
     898            if ( ! bbp_is_topic_spam( $topic->ID ) && ! bbp_is_topic_trash( $topic->ID ) && ! bbp_is_topic_pending( $topic->ID ) ) {
     899                $stick_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_'  . $topic->ID );
    861900                if ( bbp_is_topic_sticky( $topic->ID ) ) {
    862901                    $actions['stick'] = '<a href="' . esc_url( $stick_uri ) . '" title="' . esc_attr__( 'Unstick this topic', 'bbpress' ) . '">' . esc_html__( 'Unstick', 'bbpress' ) . '</a>';
     
    868907
    869908            // Spam
    870             $spam_uri  = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'spam-topic_'  . $topic->ID );
     909            $spam_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'spam-topic_'  . $topic->ID );
    871910            if ( bbp_is_topic_spam( $topic->ID ) ) {
    872911                $actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark the topic as not spam', 'bbpress' ) . '">' . esc_html__( 'Not spam', 'bbpress' ) . '</a>';
  • trunk/src/includes/core/actions.php

    r5500 r5583  
    238238
    239239// Update topic branch
    240 add_action( 'bbp_trashed_topic',   'bbp_update_topic_walker' );
    241 add_action( 'bbp_untrashed_topic', 'bbp_update_topic_walker' );
    242 add_action( 'bbp_deleted_topic',   'bbp_update_topic_walker' );
    243 add_action( 'bbp_spammed_topic',   'bbp_update_topic_walker' );
    244 add_action( 'bbp_unspammed_topic', 'bbp_update_topic_walker' );
     240add_action( 'bbp_trashed_topic',    'bbp_update_topic_walker' );
     241add_action( 'bbp_untrashed_topic',  'bbp_update_topic_walker' );
     242add_action( 'bbp_deleted_topic',    'bbp_update_topic_walker' );
     243add_action( 'bbp_spammed_topic',    'bbp_update_topic_walker' );
     244add_action( 'bbp_unspammed_topic',  'bbp_update_topic_walker' );
     245add_action( 'bbp_approved_topic',   'bbp_update_topic_walker' );
     246add_action( 'bbp_unapproved_topic', 'bbp_update_topic_walker' );
    245247
    246248// Update reply branch
    247 add_action( 'bbp_trashed_reply',   'bbp_update_reply_walker' );
    248 add_action( 'bbp_untrashed_reply', 'bbp_update_reply_walker' );
    249 add_action( 'bbp_deleted_reply',   'bbp_update_reply_walker' );
    250 add_action( 'bbp_spammed_reply',   'bbp_update_reply_walker' );
    251 add_action( 'bbp_unspammed_reply', 'bbp_update_reply_walker' );
     249add_action( 'bbp_trashed_reply',    'bbp_update_reply_walker' );
     250add_action( 'bbp_untrashed_reply',  'bbp_update_reply_walker' );
     251add_action( 'bbp_deleted_reply',    'bbp_update_reply_walker' );
     252add_action( 'bbp_spammed_reply',    'bbp_update_reply_walker' );
     253add_action( 'bbp_unspammed_reply',  'bbp_update_reply_walker' );
     254add_action( 'bbp_approved_reply',   'bbp_update_reply_walker' );
     255add_action( 'bbp_unapproved_reply', 'bbp_update_reply_walker' );
    252256
    253257// Users topic & reply counts
Note: See TracChangeset for help on using the changeset viewer.