Skip to:
Content

BuddyPress.org

Ticket #4854: 4854.diff

File 4854.diff, 13.9 KB (added by imath, 12 years ago)
  • bp-core/bp-core-filters.php

     
    9191        if ( !empty( $bp->pages->register ) )
    9292                $pages[] = $bp->pages->register->id;
    9393
    94         if ( !empty( $bp->pages->forums ) )
     94        if ( !empty( $bp->pages->forums ) && ( !bp_is_active( 'forums' ) || ( bp_is_active( 'forums' ) && bp_forums_has_directory() && !bp_forums_is_installed_correctly() ) ) )
    9595                $pages[] = $bp->pages->forums->id;
    9696
    9797        return apply_filters( 'bp_core_exclude_pages', $pages );
  • bp-templates/bp-legacy/buddypress/forums/index.php

     
    1 <?php do_action( 'bp_before_directory_forums' ); ?>
     1<div id="buddypress">
     2       
     3        <?php do_action( 'bp_before_directory_forums' ); ?>
    24
    3 <form action="" method="post" id="forums-search-form" class="dir-form">
     5        <form action="" method="post" id="forums-search-form" class="dir-form">
    46
    5         <?php do_action( 'bp_before_directory_forums_content' ); ?>
     7                <?php do_action( 'bp_before_directory_forums_content' ); ?>
    68
    7         <div id="forums-dir-search" class="dir-search" role="search">
     9                <div id="forums-dir-search" class="dir-search" role="search">
    810
    9                 <?php bp_directory_forums_search_form(); ?>
     11                        <?php bp_directory_forums_search_form(); ?>
    1012
    11         </div>
    12 </form>
     13                </div>
     14        </form>
    1315
    14 <?php do_action( 'bp_before_topics' ); ?>
     16        <?php do_action( 'bp_before_topics' ); ?>
    1517
    16 <form action="" method="post" id="forums-directory-form" class="dir-form">
     18        <form action="" method="post" id="forums-directory-form" class="dir-form">
    1719
    18         <div class="item-list-tabs" role="navigation">
    19                 <ul>
    20                         <li class="selected" id="forums-all"><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() ); ?>"><?php printf( __( 'All Topics <span>%s</span>', 'buddypress' ), bp_get_forum_topic_count() ); ?></a></li>
     20                <div class="item-list-tabs" role="navigation">
     21                        <ul>
     22                                <li class="selected" id="forums-all"><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() ); ?>"><?php printf( __( 'All Topics <span>%s</span>', 'buddypress' ), bp_get_forum_topic_count() ); ?></a></li>
    2123
    22                         <?php if ( is_user_logged_in() && bp_get_forum_topic_count_for_user( bp_loggedin_user_id() ) ) : ?>
     24                                <?php if ( is_user_logged_in() && bp_get_forum_topic_count_for_user( bp_loggedin_user_id() ) ) : ?>
    2325
    24                                 <li id="forums-personal"><a href="<?php echo trailingslashit( bp_loggedin_user_domain() . bp_get_forums_slug() . '/topics' ); ?>"><?php printf( __( 'My Topics <span>%s</span>', 'buddypress' ), bp_get_forum_topic_count_for_user( bp_loggedin_user_id() ) ); ?></a></li>
     26                                        <li id="forums-personal"><a href="<?php echo trailingslashit( bp_loggedin_user_domain() . bp_get_forums_slug() . '/topics' ); ?>"><?php printf( __( 'My Topics <span>%s</span>', 'buddypress' ), bp_get_forum_topic_count_for_user( bp_loggedin_user_id() ) ); ?></a></li>
    2527
    26                         <?php endif; ?>
     28                                <?php endif; ?>
    2729
    28                         <?php do_action( 'bp_forums_directory_group_types' ); ?>
     30                                <?php do_action( 'bp_forums_directory_group_types' ); ?>
    2931
    30                 </ul>
    31         </div>
     32                        </ul>
     33                </div>
    3234
    33         <div class="item-list-tabs" id="subnav" role="navigation">
    34                 <ul>
     35                <div class="item-list-tabs" id="subnav" role="navigation">
     36                        <ul>
    3537
    36                         <?php do_action( 'bp_forums_directory_group_sub_types' ); ?>
     38                                <?php do_action( 'bp_forums_directory_group_sub_types' ); ?>
    3739
    38                         <li id="forums-order-select" class="last filter">
     40                                <li id="forums-order-select" class="last filter">
    3941
    40                                 <label for="forums-order-by"><?php _e( 'Order By:', 'buddypress' ); ?></label>
    41                                 <select id="forums-order-by">
    42                                         <option value="active"><?php _e( 'Last Active', 'buddypress' ); ?></option>
    43                                         <option value="popular"><?php _e( 'Most Posts', 'buddypress' ); ?></option>
    44                                         <option value="unreplied"><?php _e( 'Unreplied', 'buddypress' ); ?></option>
     42                                        <label for="forums-order-by"><?php _e( 'Order By:', 'buddypress' ); ?></label>
     43                                        <select id="forums-order-by">
     44                                                <option value="active"><?php _e( 'Last Active', 'buddypress' ); ?></option>
     45                                                <option value="popular"><?php _e( 'Most Posts', 'buddypress' ); ?></option>
     46                                                <option value="unreplied"><?php _e( 'Unreplied', 'buddypress' ); ?></option>
    4547
    46                                         <?php do_action( 'bp_forums_directory_order_options' ); ?>
     48                                                <?php do_action( 'bp_forums_directory_order_options' ); ?>
    4749
    48                                 </select>
    49                         </li>
    50                 </ul>
    51         </div>
     50                                        </select>
     51                                </li>
     52                        </ul>
     53                </div>
    5254
    53         <div id="forums-dir-list" class="forums dir-list" role="main">
     55                <div id="forums-dir-list" class="forums dir-list" role="main">
    5456
    55                 <?php bp_get_template_part( 'forums/forums-loop' ); ?>
     57                        <?php bp_get_template_part( 'forums/forums-loop' ); ?>
    5658
    57         </div>
     59                </div>
    5860
    59         <?php do_action( 'bp_directory_forums_content' ); ?>
     61                <?php do_action( 'bp_directory_forums_content' ); ?>
    6062
    61         <?php wp_nonce_field( 'directory_forums', '_wpnonce-forums-filter' ); ?>
     63                <?php wp_nonce_field( 'directory_forums', '_wpnonce-forums-filter' ); ?>
    6264
    63 </form>
     65        </form>
    6466
    65 <?php do_action( 'bp_after_directory_forums' ); ?>
     67        <?php do_action( 'bp_after_directory_forums' ); ?>
    6668
    67 <?php do_action( 'bp_before_new_topic_form' ); ?>
     69        <?php do_action( 'bp_before_new_topic_form' ); ?>
    6870
    69 <div id="new-topic-post">
     71        <div id="new-topic-post">
    7072
    71         <?php if ( is_user_logged_in() ) : ?>
     73                <?php if ( is_user_logged_in() ) : ?>
    7274
    73                 <?php if ( bp_is_active( 'groups' ) && bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100' ) ) : ?>
     75                        <?php if ( bp_is_active( 'groups' ) && bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100' ) ) : ?>
    7476
    75                         <form action="" method="post" id="forum-topic-form" class="standard-form">
     77                                <form action="" method="post" id="forum-topic-form" class="standard-form">
    7678
    77                                 <?php do_action( 'groups_forum_new_topic_before' ); ?>
     79                                        <?php do_action( 'groups_forum_new_topic_before' ); ?>
    7880
    79                                 <a name="post-new"></a>
    80                                 <h5><?php _e( 'Create New Topic:', 'buddypress' ); ?></h5>
     81                                        <a name="post-new"></a>
     82                                        <h5><?php _e( 'Create New Topic:', 'buddypress' ); ?></h5>
    8183
    82                                 <?php do_action( 'template_notices' ); ?>
     84                                        <?php do_action( 'template_notices' ); ?>
    8385
    84                                 <label><?php _e( 'Title:', 'buddypress' ); ?></label>
    85                                 <input type="text" name="topic_title" id="topic_title" value="" maxlength="100" />
     86                                        <label><?php _e( 'Title:', 'buddypress' ); ?></label>
     87                                        <input type="text" name="topic_title" id="topic_title" value="" maxlength="100" />
    8688
    87                                 <label><?php _e( 'Content:', 'buddypress' ); ?></label>
    88                                 <textarea name="topic_text" id="topic_text"></textarea>
     89                                        <label><?php _e( 'Content:', 'buddypress' ); ?></label>
     90                                        <textarea name="topic_text" id="topic_text"></textarea>
    8991
    90                                 <label><?php _e( 'Tags (comma separated):', 'buddypress' ); ?></label>
    91                                 <input type="text" name="topic_tags" id="topic_tags" value="" />
     92                                        <label><?php _e( 'Tags (comma separated):', 'buddypress' ); ?></label>
     93                                        <input type="text" name="topic_tags" id="topic_tags" value="" />
    9294
    93                                 <label><?php _e( 'Post In Group Forum:', 'buddypress' ); ?></label>
    94                                 <select id="topic_group_id" name="topic_group_id">
     95                                        <label><?php _e( 'Post In Group Forum:', 'buddypress' ); ?></label>
     96                                        <select id="topic_group_id" name="topic_group_id">
    9597
    96                                         <option value=""><?php /* translators: no option picked in select box */ _e( '----', 'buddypress' ); ?></option>
     98                                                <option value=""><?php /* translators: no option picked in select box */ _e( '----', 'buddypress' ); ?></option>
    9799
    98                                         <?php while ( bp_groups() ) : bp_the_group(); ?>
     100                                                <?php while ( bp_groups() ) : bp_the_group(); ?>
    99101
    100                                                 <?php if ( bp_group_is_forum_enabled() && ( bp_current_user_can( 'bp_moderate' ) || 'public' == bp_get_group_status() || bp_group_is_member() ) ) : ?>
     102                                                        <?php if ( bp_group_is_forum_enabled() && ( bp_current_user_can( 'bp_moderate' ) || 'public' == bp_get_group_status() || bp_group_is_member() ) ) : ?>
    101103
    102                                                         <option value="<?php bp_group_id(); ?>"><?php bp_group_name(); ?></option>
     104                                                                <option value="<?php bp_group_id(); ?>"><?php bp_group_name(); ?></option>
    103105
    104                                                 <?php endif; ?>
     106                                                        <?php endif; ?>
    105107
    106                                         <?php endwhile; ?>
     108                                                <?php endwhile; ?>
    107109
    108                                 </select><!-- #topic_group_id -->
     110                                        </select><!-- #topic_group_id -->
    109111
    110                                 <?php do_action( 'groups_forum_new_topic_after' ); ?>
     112                                        <?php do_action( 'groups_forum_new_topic_after' ); ?>
    111113
    112                                 <div class="submit">
    113                                         <input type="submit" name="submit_topic" id="submit" value="<?php _e( 'Post Topic', 'buddypress' ); ?>" />
    114                                         <input type="button" name="submit_topic_cancel" id="submit_topic_cancel" value="<?php _e( 'Cancel', 'buddypress' ); ?>" />
    115                                 </div>
     114                                        <div class="submit">
     115                                                <input type="submit" name="submit_topic" id="submit" value="<?php _e( 'Post Topic', 'buddypress' ); ?>" />
     116                                                <input type="button" name="submit_topic_cancel" id="submit_topic_cancel" value="<?php _e( 'Cancel', 'buddypress' ); ?>" />
     117                                        </div>
    116118
    117                                 <?php wp_nonce_field( 'bp_forums_new_topic' ); ?>
     119                                        <?php wp_nonce_field( 'bp_forums_new_topic' ); ?>
    118120
    119                         </form><!-- #forum-topic-form -->
     121                                </form><!-- #forum-topic-form -->
    120122
    121                 <?php elseif ( bp_is_active( 'groups' ) ) : ?>
     123                        <?php elseif ( bp_is_active( 'groups' ) ) : ?>
    122124
    123                         <div id="message" class="info">
     125                                <div id="message" class="info">
    124126
    125                                 <p><?php printf( __( "You are not a member of any groups so you don't have any group forums you can post in. To start posting, first find a group that matches the topic subject you'd like to start. If this group does not exist, why not <a href='%s'>create a new group</a>? Once you have joined or created the group you can post your topic in that group's forum.", 'buddypress' ), site_url( bp_get_groups_root_slug() . '/create/' ) ); ?></p>
     127                                        <p><?php printf( __( "You are not a member of any groups so you don't have any group forums you can post in. To start posting, first find a group that matches the topic subject you'd like to start. If this group does not exist, why not <a href='%s'>create a new group</a>? Once you have joined or created the group you can post your topic in that group's forum.", 'buddypress' ), site_url( bp_get_groups_root_slug() . '/create/' ) ); ?></p>
    126128
    127                         </div>
     129                                </div>
    128130
     131                        <?php endif; ?>
     132
    129133                <?php endif; ?>
     134        </div><!-- #new-topic-post -->
    130135
    131         <?php endif; ?>
    132 </div><!-- #new-topic-post -->
     136        <?php do_action( 'bp_after_new_topic_form' ); ?>
    133137
    134 <?php do_action( 'bp_after_new_topic_form' ); ?>
    135 
    136 <?php do_action( 'bp_after_directory_forums_content' ); ?>
    137  No newline at end of file
     138        <?php do_action( 'bp_after_directory_forums_content' ); ?>
     139       
     140</div>
     141 No newline at end of file
  • bp-forums/bp-forums-screens.php

     
    118118        bp_core_load_template( apply_filters( 'bp_forums_screen_single_topic', 'forums/single/topic' ) );
    119119}
    120120add_action( 'bp_screens', 'bp_forums_screen_single_topic' );
     121
     122
     123/** Theme Compatability *******************************************************/
     124
     125/**
     126 * The main theme compat class for BuddyPress "old" forums
     127 *
     128 * This class sets up the necessary theme compatability actions to safely output
     129 * old forum template parts to the_title and the_content areas of a theme.
     130 *
     131 * @since BuddyPress (1.7)
     132 */
     133class BP_bbForum_Theme_Compat {
     134
     135        /**
     136         * Setup the old forums component theme compatibility
     137         *
     138         * @since BuddyPress (1.7)
     139         */
     140        public function __construct() {
     141                add_action( 'bp_setup_theme_compat', array( $this, 'is_bb_forum' ) );
     142        }
     143
     144        /**
     145         * Are we looking at something that needs old forum theme compatability?
     146         *
     147         * @since BuddyPress (1.7)
     148         */
     149        public function is_bb_forum() {
     150
     151                // Bail if not looking at a group
     152                if ( ! bp_is_forums_component() )
     153                        return;
     154
     155                // forum Directory
     156                if ( ( !bp_current_action() || ( 'tag' == bp_current_action() && bp_action_variables() ) ) && !bp_current_item() ) {
     157                       
     158                        if ( !bp_forums_has_directory() )
     159                                return false;
     160
     161                        if ( !bp_forums_is_installed_correctly() ) {
     162                                bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );
     163                                bp_core_redirect( bp_get_root_domain() );
     164                        }
     165                       
     166                        bp_update_is_directory( true, 'forums' );
     167
     168                        do_action( 'bp_forums_directory_forums_setup' );
     169
     170                        add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) );
     171                        add_filter( 'bp_replace_the_content',                    array( $this, 'directory_content'    ) );
     172
     173                }
     174               
     175        }
     176
     177        /** Directory *************************************************************/
     178
     179        /**
     180         * Update the global $post with directory data
     181         *
     182         * @since BuddyPress (1.7)
     183         */
     184        public function directory_dummy_post() {
     185
     186                // Title based on ability to create groups
     187                if ( is_user_logged_in() ) {
     188                        $title = __( 'Forums Directory', 'buddypress' ) . '&nbsp;<a class="button show-hide-new bp-title-button" href="#new-topic" id="new-topic-button">' . __( 'New Topic', 'buddypress' ) . '</a>';
     189                } else {
     190                        $title = __( 'Forums Directory', 'buddypress' );
     191                }
     192
     193                bp_theme_compat_reset_post( array(
     194                        'ID'             => 0,
     195                        'post_title'     => $title,
     196                        'post_author'    => 0,
     197                        'post_date'      => 0,
     198                        'post_content'   => '',
     199                        'post_type'      => 'bp_forum',
     200                        'post_status'    => 'publish',
     201                        'is_archive'     => true,
     202                        'comment_status' => 'closed'
     203                ) );
     204        }
     205
     206        /**
     207         * Filter the_content with the old forum index template part
     208         *
     209         * @since BuddyPress (1.7)
     210         */
     211        public function directory_content() {
     212                bp_buffer_template_part( 'forums/index' );
     213        }
     214}
     215new BP_bbForum_Theme_Compat();
     216 No newline at end of file