Skip to:
Content

bbPress.org

Changes between Initial Version and Version 3 of Ticket #1535


Ignore:
Timestamp:
05/25/2011 08:40:37 AM (15 years ago)
Author:
johnjamesjacoby
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1535

    • Property Status changed from new to closed
    • Property Resolution changed from to fixed
  • Ticket #1535 – Description

    initial v3  
    11When one makes a separate page where the user can create a new topic in any of the open forums, the form is not accessible to non-admins as bbPress expects it to be located on a single forum page. bbPress should correctly show the forum to all users who are allowed to create new topics, and hide all private forums in the forums drop down list.
    2 
    3 As a temporary solution I've made the following edits to bbp-user-template.php, but my changes expect all forums to be pulic and the new topic page using the slug 'new':
    4 
    5 
    6 {{{
    7 /**
    8  * Performs a series of checks to ensure the current user can create topics.
    9  *
    10  * @since bbPress (r3127)
    11  *
    12  * @uses bbp_is_topic_edit()
    13  * @uses current_user_can()
    14  * @uses bbp_get_topic_id()
    15  * @uses bbp_allow_anonymous()
    16  * @uses is_user_logged_in()
    17  *
    18  * @return bool
    19  */
    20 function bbp_current_user_can_access_create_topic_form() {
    21 
    22         // Always allow super admins
    23         if ( is_super_admin() )
    24                 return true;
    25 
    26         // Users need to earn access
    27         $retval = false;
    28 
    29         /*  NihongoUp START
    30         ***************************************/
    31         /*
    32 
    33         // Looking at a single forum
    34         if ( bbp_is_forum() ) {
    35 
    36                 // What is the visibility of this forum
    37                 switch ( bbp_get_forum_visibility() ) {
    38 
    39                         // Public
    40                         case 'publish' :
    41 
    42                                 // User cannot publish topics
    43                                 if ( current_user_can( 'publish_topics' ) )
    44                                         $retval = true;
    45 
    46                                 // Anonymous posting is allowed
    47                                 if ( bbp_allow_anonymous() && !is_user_logged_in() )
    48                                         $retval = true;
    49 
    50                                 break;
    51 
    52                         // Private forums
    53                         case 'private' :
    54                                 if ( current_user_can( 'read_private_forums' ) )
    55                                         $retval = true;
    56 
    57                                 break;
    58 
    59                         // Hidden forums
    60                         case 'hidden'  :
    61                                 if ( current_user_can( 'read_hidden_forums' ) )
    62                                         $retval = true;
    63 
    64                                 break;
    65                 }
    66 
    67         // Editing a single topic
    68         } elseif ( bbp_is_topic_edit() ) {
    69 
    70                 // User can edit edit this topic
    71                 if ( current_user_can( 'edit_topic', bbp_get_topic_id() ) )
    72                         $retval = true;
    73         }
    74         */
    75 
    76         // Looking at a single forum
    77         if ( bbp_is_forum() || is_page('new') ) {
    78 
    79                 // User can publish topics
    80                 if ( current_user_can( 'publish_topics' ) )
    81                         $retval = true;
    82 
    83         // Editing a single topic
    84         } elseif ( bbp_is_topic_edit() ) {
    85 
    86                 // User can edit edit this topic
    87                 if ( current_user_can( 'edit_topic', bbp_get_topic_id() ) )
    88                         $retval = true;
    89         }
    90 
    91         /*  NihongoUp END
    92         ***************************************/
    93 
    94         // Allow access to be filtered
    95         return apply_filters( 'bbp_current_user_can_access_create_topic_form', $retval );
    96 }
    97 
    98 /**
    99  * Performs a series of checks to ensure the current user can create topics in
    100  * this specific forum or scope.
    101  *
    102  * @since bbPress (r3127)
    103  *
    104  * @uses bbp_is_forum_category()
    105  * @uses bbp_is_forum_closed()
    106  * @uses current_user_can()
    107  * @uses bbp_get_topic_forum_id()
    108  * @uses bbp_is_topic_edit()
    109  *
    110  * @return bool
    111  */
    112 function bbp_current_user_can_create_topic_in_forum() {
    113 
    114         // Always allow super admins
    115         if ( is_super_admin() )
    116                 return true;
    117 
    118         // Users need to earn access
    119         $retval = false;
    120 
    121         /*  NihongoUp START
    122         ***************************************/
    123         /*
    124 
    125         // Looking at a single forum
    126         if ( bbp_is_forum() ) {
    127 
    128                 // Forum is not a category
    129                 if ( !bbp_is_forum_category() ) {
    130 
    131                         // Forum is open
    132                         $retval = (bool) bbp_is_forum_open();
    133                 }
    134 
    135         // Editing a single topic
    136         } elseif ( bbp_is_topic_edit() ) {
    137 
    138                 // If you can edit this forum, you can edit topics in this forum
    139                 if ( current_user_can( 'edit_forum', bbp_get_topic_forum_id() ) )
    140                         $retval = true;
    141         }
    142         */
    143 
    144         // Looking at a single forum
    145         if ( bbp_is_forum() || is_page('new') ) {
    146 
    147                 $retval = true;
    148 
    149         // Editing a single topic
    150         } elseif ( bbp_is_topic_edit() ) {
    151 
    152                 // If you can edit this forum, you can edit topics in this forum
    153                 if ( current_user_can( 'edit_forum', bbp_get_topic_forum_id() ) )
    154                         $retval = true;
    155         }
    156 
    157         /*  NihongoUp END
    158         ***************************************/
    159 
    160         // Allow access to be filtered
    161         return apply_filters( 'bbp_current_user_can_create_topic_in_forum', $retval );
    162 }
    163 }}}