Skip to:
Content

bbPress.org

Changeset 4673


Ignore:
Timestamp:
12/31/2012 02:26:17 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Rejig the post_status logic in bbp_has_topics() and bbp_has_replies() to use the 'perm' query variable when appropriate. This allows unfamiliar topic and reply statuses to work as intended. Also allows post authors to view their own private content. Fixes #2088.

Location:
trunk/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/replies/template-tags.php

    r4648 r4673  
    6969    /** Defaults **************************************************************/
    7070
    71     // What are the default allowed statuses (based on user caps)
    72     if ( bbp_get_view_all( 'edit_others_replies' ) ) {
    73         $post_statuses = array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id() );
    74     } else {
    75         $post_statuses = array( bbp_get_public_status_id(), bbp_get_closed_status_id() );
    76     }
    77 
    78     // Add support for private status
    79     if ( current_user_can( 'read_private_replies' ) ) {
    80         $post_statuses[] = bbp_get_private_status_id();
    81     }
    82 
     71    // Other defaults
    8372    $default_reply_search = !empty( $_REQUEST['rs'] ) ? $_REQUEST['rs'] : false;
    8473    $default_post_parent  = ( bbp_is_single_topic() ) ? bbp_get_topic_id() : 'any';
    8574    $default_post_type    = ( bbp_is_single_topic() && bbp_show_lead_topic() ) ? bbp_get_reply_post_type() : array( bbp_get_topic_post_type(), bbp_get_reply_post_type() );
    86     $default_post_status  = join( ',', $post_statuses );
    8775
    8876    // Default query args
     
    9078        'post_type'      => $default_post_type,         // Only replies
    9179        'post_parent'    => $default_post_parent,       // Of this topic
    92         'post_status'    => $default_post_status,       // Of this status
    9380        'posts_per_page' => bbp_get_replies_per_page(), // This many
    9481        'paged'          => bbp_get_paged(),            // On this page
     
    9784        's'              => $default_reply_search,      // Maybe search
    9885    );
     86
     87    // What are the default allowed statuses (based on user caps)
     88    if ( bbp_get_view_all() ) {
     89
     90        // Default view=all statuses
     91        $post_statuses = array(
     92            bbp_get_public_status_id(),
     93            bbp_get_closed_status_id(),
     94            bbp_get_spam_status_id(),
     95            bbp_get_trash_status_id()
     96        );
     97
     98        // Add support for private status
     99        if ( current_user_can( 'read_private_replies' ) ) {
     100            $post_statuses[] = bbp_get_private_status_id();
     101        }
     102
     103        // Join post statuses together
     104        $default['post_status'] = join( ',', $post_statuses );
     105
     106    // Lean on the 'perm' query var value of 'readable' to provide statuses
     107    } else {
     108        $default['perm'] = 'readable';
     109    }
    99110
    100111    /** Setup *****************************************************************/
  • trunk/includes/topics/template-tags.php

    r4647 r4673  
    8787    /** Defaults **************************************************************/
    8888
    89     // What are the default allowed statuses (based on user caps)
    90     if ( bbp_get_view_all() ) {
    91         $post_statuses = array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id() );
    92     } else {
    93         $post_statuses = array( bbp_get_public_status_id(), bbp_get_closed_status_id() );
    94     }
    95 
    96     // Add support for private status
    97     if ( current_user_can( 'read_private_topics' ) ) {
    98         $post_statuses[] = bbp_get_private_status_id();
    99     }
    100 
     89    // Other defaults
    10190    $default_topic_search  = !empty( $_REQUEST['ts'] ) ? $_REQUEST['ts'] : false;
    10291    $default_show_stickies = (bool) ( bbp_is_single_forum() || bbp_is_topic_archive() ) && ( false === $default_topic_search );
    10392    $default_post_parent   = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
    104     $default_post_status   = join( ',', $post_statuses );
    10593
    10694    // Default argument array
     
    10896        'post_type'      => bbp_get_topic_post_type(), // Narrow query down to bbPress topics
    10997        'post_parent'    => $default_post_parent,      // Forum ID
    110         'post_status'    => $default_post_status,      // Post Status
    11198        'meta_key'       => '_bbp_last_active_time',   // Make sure topic has some last activity time
    11299        'orderby'        => 'meta_value',              // 'meta_value', 'author', 'date', 'title', 'modified', 'parent', rand',
     
    118105        'max_num_pages'  => false,                     // Maximum number of pages to show
    119106    );
     107
     108    // What are the default allowed statuses (based on user caps)
     109    if ( bbp_get_view_all() ) {
     110
     111        // Default view=all statuses
     112        $post_statuses = array(
     113            bbp_get_public_status_id(),
     114            bbp_get_closed_status_id(),
     115            bbp_get_spam_status_id(),
     116            bbp_get_trash_status_id()
     117        );
     118
     119        // Add support for private status
     120        if ( current_user_can( 'read_private_topics' ) ) {
     121            $post_statuses[] = bbp_get_private_status_id();
     122        }
     123
     124        // Join post statuses together
     125        $default['post_status'] = join( ',', $post_statuses );
     126
     127    // Lean on the 'perm' query var value of 'readable' to provide statuses
     128    } else {
     129        $default['perm'] = 'readable';
     130    }
    120131
    121132    // Maybe query for topic tags
Note: See TracChangeset for help on using the changeset viewer.