Skip to:
Content

bbPress.org

Ticket #2645: 2645.6.diff

File 2645.6.diff, 12.7 KB (added by netweb, 9 years ago)
  • src/includes/admin/replies.php

     
    803803                                $actions['approved']   = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this reply',   'bbpress' ) . '">' . _x( 'Approve',   'Approve reply',   'bbpress' ) . '</a>';
    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 ) ) {
    809810                                        $actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark the reply as not spam', 'bbpress' ) . '">' . esc_html__( 'Not spam', 'bbpress' ) . '</a>';
  • src/includes/admin/topics.php

     
    157157                        'content'       =>
    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                ) );
    169170
     
    449450                                background-color: #faeaea;
    450451                        }
    451452
     453                        .status-pending {
     454                                background-color: #fef7f1;
     455                        }
     456
    452457                /*]]>*/
    453458                </style>
    454459
     
    491496                }
    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
    502507                        if ( empty( $topic ) ) {
     
    509514                        }
    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 );
    514532
     
    594612                }
    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?
    600618                        $is_failure = !empty( $_GET['failed'] ) ? true : false; // Was that a failure?
     
    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 );
    656674                                        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 );
     686                                        break;
    657687                        }
    658688
    659689                        // Do additional topic toggle notice filters (admin side)
     
    842872                // Only show the actions if the user is capable of viewing them :)
    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
    847887                        if ( in_array( $topic->post_status, array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ) ) {
     
    853893                                }
    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 ) ) {
     896                        // Dont show sticky if topic links is spam, trash or pending
     897                        if ( ! bbp_is_topic_spam( $topic->ID ) && ! bbp_is_topic_trash( $topic->ID ) && ! bbp_is_topic_pending( $topic->ID ) ) {
    858898
    859899                                // Sticky
    860900                                $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 );
  • src/includes/core/actions.php

     
    237237add_action( 'bbp_delete_topic', 'bbp_unstick_topic' );
    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
    254258add_action( 'bbp_new_topic',     'bbp_increase_user_topic_count' );
     
    332336// Maybe convert the users password
    333337add_action( 'bbp_login_form_login', 'bbp_user_maybe_convert_pass' );
    334338
    335 add_action( 'bbp_activation', 'bbp_add_activation_redirect' );
    336  No newline at end of file
     339add_action( 'bbp_activation', 'bbp_add_activation_redirect' );