Changeset 11763
- Timestamp:
- 12/08/2017 12:22:09 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 deleted
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.jshintignore
r11009 r11763 1 // Deprecated2 src/bp-forums/bbpress/**/*3 4 1 // 3rd party libraries 5 2 src/bp-core/js/vendor/**/* -
trunk/Gruntfile.js
r11690 r11763 19 19 20 20 BP_EXCLUDED_MISC = [ 21 '!bp-forums/bbpress/**/*'22 21 ], 23 22 … … 257 256 }, 258 257 exec: { 259 bbpress: {260 command: 'svn export --force https://bbpress.svn.wordpress.org/tags/1.2 bbpress',261 cwd: BUILD_DIR + 'bp-forums',262 stdout: false263 },264 258 bpdefault: { 265 259 command: 'svn export --force https://github.com/buddypress/BP-Default.git/trunk bp-themes/bp-default', … … 304 298 grunt.registerTask( 'commit', ['src', 'checktextdomain', 'imagemin'] ); 305 299 grunt.registerTask( 'build', ['commit', 'clean:all', 'copy:files', 'uglify', 'jsvalidate:build', 'cssmin', 'makepot', 'exec:bpdefault'] ); 306 grunt.registerTask( 'release', ['build' , 'exec:bbpress'] );300 grunt.registerTask( 'release', ['build'] ); 307 301 308 302 // Testing tasks. -
trunk/composer.json
r11615 r11763 6 6 "activity", 7 7 "community", 8 "forum",9 8 "friends", 10 9 "groups", -
trunk/package.json
r11679 r11763 35 35 "activity", 36 36 "community", 37 "forum",38 37 "friends", 39 38 "groups", -
trunk/src/bp-activity/bp-activity-filters.php
r11592 r11763 97 97 98 98 add_filter( 'pre_comment_content', 'bp_activity_at_name_filter' ); 99 add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' );100 add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' );101 99 add_filter( 'the_content', 'bp_activity_at_name_filter' ); 102 100 add_filter( 'bp_activity_get_embed_excerpt', 'bp_activity_at_name_filter' ); -
trunk/src/bp-core/admin/bp-core-admin-components.php
r10934 r11763 81 81 $required_components = bp_core_admin_get_components( 'required' ); 82 82 $retired_components = bp_core_admin_get_components( 'retired' ); 83 84 // Don't show Forums component in optional components if it's disabled.85 if ( ! bp_is_active( 'forums' ) ) {86 unset( $optional_components['forums'] );87 }88 83 89 84 // Merge optional and required together. -
trunk/src/bp-core/admin/bp-core-admin-functions.php
r11513 r11763 287 287 $orphaned_components[] = $component['name']; 288 288 } 289 }290 291 // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is292 // not correctly set up, don't show a nag. (In these cases, it's probably the case that the293 // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292.294 if ( isset( $bp->forums->name ) && in_array( $bp->forums->name, $orphaned_components ) && !bp_forums_is_installed_correctly() ) {295 $forum_key = array_search( $bp->forums->name, $orphaned_components );296 unset( $orphaned_components[$forum_key] );297 $orphaned_components = array_values( $orphaned_components );298 289 } 299 290 … … 440 431 ), 441 432 ); 442 443 // If forums component is active, add additional tab.444 if ( bp_is_active( 'forums' ) && class_exists( 'BP_Forums_Component' ) ) {445 446 // Enqueue thickbox.447 wp_enqueue_script( 'thickbox' );448 wp_enqueue_style( 'thickbox' );449 450 $tabs['3'] = array(451 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bb-forums-setup' ), 'admin.php' ) ),452 'name' => __( 'Forums', 'buddypress' )453 );454 }455 433 456 434 /** -
trunk/src/bp-core/admin/bp-core-admin-settings.php
r11606 r11763 248 248 } 249 249 250 /** Forums Section ************************************************************/251 252 /**253 * Forums settings section description for the settings page.254 *255 * @since 1.6.0256 */257 function bp_admin_setting_callback_bbpress_section() { }258 259 /**260 * The bb-config.php location field.261 *262 * @since 1.6.0263 *264 */265 function bp_admin_setting_callback_bbpress_configuration() {266 267 $config_location = bp_get_option( 'bb-config-location' );268 $file_exists = (bool) ( file_exists( $config_location ) || is_file( $config_location ) ); ?>269 270 <input name="bb-config-location" type="text" id="bb-config-location" value="<?php bp_form_option( 'bb-config-location', '' ); ?>" class="medium-text" style="width: 300px;" />271 272 <?php if ( false === $file_exists ) : ?>273 274 <a class="button" href="<?php bp_admin_url( 'admin.php?page=bb-forums-setup&repair=1' ); ?>"><?php _e( 'Repair', 'buddypress' ) ?></a>275 <span class="attention"><?php _e( 'File does not exist', 'buddypress' ); ?></span>276 277 <?php endif; ?>278 279 <p class="description"><?php _e( 'Absolute path to your bbPress configuration file.', 'buddypress' ); ?></p>280 281 <?php282 }283 284 250 /** Settings Page *************************************************************/ 285 251 -
trunk/src/bp-core/admin/css/common-rtl.css
r11711 r11763 524 524 } 525 525 526 .settings_page_bp-components tr.forums td.plugin-title span:before {527 content: "\f452";528 }529 530 526 .settings_page_bp-components tr.blogs td.plugin-title span:before { 531 527 content: "\f120"; -
trunk/src/bp-core/admin/css/common.css
r11711 r11763 524 524 } 525 525 526 .settings_page_bp-components tr.forums td.plugin-title span:before {527 content: "\f452";528 }529 530 526 .settings_page_bp-components tr.blogs td.plugin-title span:before { 531 527 content: "\f120"; -
trunk/src/bp-core/bp-core-filters.php
r11698 r11763 101 101 if ( !empty( $bp->pages->register ) ) 102 102 $pages[] = $bp->pages->register->id; 103 104 if ( !empty( $bp->pages->forums ) && ( !bp_is_active( 'forums' ) || ( bp_is_active( 'forums' ) && bp_forums_has_directory() && !bp_forums_is_installed_correctly() ) ) )105 $pages[] = $bp->pages->forums->id;106 103 107 104 /** -
trunk/src/bp-core/bp-core-functions.php
r11698 r11763 446 446 } 447 447 448 449 /** 450 * Return the parent forum ID for the Legacy Forums abstraction layer. 451 * 452 * @since 1.5.0 453 * @since 3.0.0 Supported for compatibility with bbPress 2. 454 * 455 * @return int Forum ID. 456 */ 457 function bp_forums_parent_forum_id() { 458 459 /** 460 * Filters the parent forum ID for the bbPress abstraction layer. 461 * 462 * @since 1.5.0 463 * 464 * @param int BP_FORUMS_PARENT_FORUM_ID The Parent forum ID constant. 465 */ 466 return apply_filters( 'bp_forums_parent_forum_id', BP_FORUMS_PARENT_FORUM_ID ); 467 } 468 448 469 /** Directory *****************************************************************/ 449 470 … … 467 488 'notifications', 468 489 ); 469 470 // Only add legacy forums if it is enabled471 // prevents conflicts with bbPress, which also uses the same 'forums' id.472 if ( class_exists( 'BP_Forums_Component' ) ) {473 $components[] = 'forums';474 }475 490 476 491 return $components; … … 1731 1746 1732 1747 /** 1733 * Are oembeds allowed in forum posts?1734 *1735 * @since 1.5.01736 *1737 * @return bool False when forum post embed support is disabled; true when1738 * enabled. Default: true.1739 */1740 function bp_use_embed_in_forum_posts() {1741 1742 /**1743 * Filters whether or not oEmbeds are allowed in forum posts.1744 *1745 * @since 1.5.01746 *1747 * @param bool $value Whether or not oEmbeds are allowed.1748 */1749 return apply_filters( 'bp_use_embed_in_forum_posts', !defined( 'BP_EMBED_DISABLE_FORUM_POSTS' ) || !BP_EMBED_DISABLE_FORUM_POSTS );1750 }1751 1752 /**1753 1748 * Are oembeds allowed in private messages? 1754 1749 * … … 2356 2351 break; 2357 2352 2358 case 'forums':2359 $slug = bp_is_active( 'forums' ) ? bp_get_forums_root_slug() : '';2360 $query_string = '/?fs=';2361 break;2362 2363 2353 case 'groups': 2364 2354 $slug = bp_is_active( 'groups' ) ? bp_get_groups_root_slug() : ''; … … 2464 2454 2465 2455 $retired_components = array( 2466 'forums' => array(2467 'title' => __( 'Group Forums', 'buddypress' ),2468 'description' => sprintf( __( 'BuddyPress Forums are retired. Use %s.', 'buddypress' ), '<a href="https://bbpress.org/">bbPress</a>' )2469 ),2470 2456 ); 2471 2457 … … 2498 2484 'title' => __( 'User Groups', 'buddypress' ), 2499 2485 'description' => __( 'Groups allow your users to organize themselves into specific public, private or hidden sections with separate activity streams and member listings.', 'buddypress' ) 2500 ),2501 'forums' => array(2502 'title' => __( 'Group Forums (Legacy)', 'buddypress' ),2503 'description' => __( 'Group forums allow for focused, bulletin-board style conversations.', 'buddypress' )2504 2486 ), 2505 2487 'blogs' => array( -
trunk/src/bp-core/bp-core-options.php
r11695 r11763 29 29 30 30 'bp-deactivated-components' => array(), 31 32 /* bbPress ***********************************************************/33 34 // Legacy bbPress config location.35 'bb-config-location' => ABSPATH . 'bb-config.php',36 31 37 32 /* XProfile **********************************************************/ … … 695 690 696 691 /** 697 * Output the group forums root parent forum id.698 *699 * @since 1.6.0700 *701 * @param bool|string $default Optional. Default: '0'.702 */703 function bp_group_forums_root_id( $default = '0' ) {704 echo bp_get_group_forums_root_id( $default );705 }706 /**707 * Return the group forums root parent forum id.708 *709 * @since 1.6.0710 *711 * @param bool|string $default Optional. Default: '0'.712 * @return int The ID of the group forums root forum.713 */714 function bp_get_group_forums_root_id( $default = '0' ) {715 716 /**717 * Filters the group forums root parent forum id.718 *719 * @since 1.6.0720 *721 * @param int $value The group forums root parent forum id.722 */723 return (int) apply_filters( 'bp_get_group_forums_root_id', (int) bp_get_option( '_bp_group_forums_root_id', $default ) );724 }725 726 /**727 * Check whether BuddyPress Group Forums are enabled.728 *729 * @since 1.6.0730 *731 * @param bool $default Optional. Fallback value if not found in the database.732 * Default: true.733 * @return bool True if group forums are active, otherwise false.734 */735 function bp_is_group_forums_active( $default = true ) {736 737 /**738 * Filters whether or not BuddyPress Group Forums are enabled.739 *740 * @since 1.6.0741 *742 * @param bool $value Whether or not BuddyPress Group Forums are enabled.743 */744 return (bool) apply_filters( 'bp_is_group_forums_active', (bool) bp_get_option( '_bp_enable_group_forums', $default ) );745 }746 747 /**748 692 * Check whether Akismet is enabled. 749 693 * -
trunk/src/bp-core/bp-core-template.php
r11605 r11763 549 549 if ( bp_is_active( 'blogs' ) && is_multisite() ) { 550 550 $options['blogs'] = _x( 'Blogs', 'search form', 'buddypress' ); 551 }552 553 if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() && bp_forums_has_directory() ) {554 $options['forums'] = _x( 'Forums', 'search form', 'buddypress' );555 551 } 556 552 … … 2200 2196 * 2201 2197 * @since 1.5.0 2198 * @since 3.0.0 Required for bbPress 2 integration. 2202 2199 * 2203 2200 * @return bool True if the current page is part of the Forums component. … … 2474 2471 2475 2472 /** 2476 * Is this a user's forums page?2477 *2478 * Eg http://example.com/members/joe/forums/ (or a subpage thereof).2479 *2480 * @since 1.5.02481 *2482 * @return bool True if the current page is a user's forums page.2483 */2484 function bp_is_user_forums() {2485 2486 if ( ! bp_is_active( 'forums' ) ) {2487 return false;2488 }2489 2490 if ( bp_is_user() && bp_is_forums_component() ) {2491 return true;2492 }2493 2494 return false;2495 }2496 2497 /**2498 * Is this a user's "Topics Started" page?2499 *2500 * Eg http://example.com/members/joe/forums/topics/.2501 *2502 * @since 1.5.02503 *2504 * @return bool True if the current page is a user's Topics Started page.2505 */2506 function bp_is_user_forums_started() {2507 return (bool) ( bp_is_user_forums() && bp_is_current_action( 'topics' ) );2508 }2509 2510 /**2511 * Is this a user's "Replied To" page?2512 *2513 * Eg http://example.com/members/joe/forums/replies/.2514 *2515 * @since 1.5.02516 *2517 * @return bool True if the current page is a user's Replied To forums page.2518 */2519 function bp_is_user_forums_replied_to() {2520 return (bool) ( bp_is_user_forums() && bp_is_current_action( 'replies' ) );2521 }2522 2523 /**2524 2473 * Is the current page part of a user's Groups page? 2525 2474 * … … 2756 2705 2757 2706 /** 2758 * Is the current page a group's forum page?2759 *2760 * Only applies to legacy bbPress forums.2761 *2762 * @since 1.1.02763 *2764 * @return bool True if the current page is a group forum page.2765 */2766 function bp_is_group_forum() {2767 $retval = false;2768 2769 // At a forum URL.2770 if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) ) {2771 $retval = true;2772 2773 // If at a forum URL, set back to false if forums are inactive, or not2774 // installed correctly.2775 if ( ! bp_is_active( 'forums' ) || ! bp_forums_is_installed_correctly() ) {2776 $retval = false;2777 }2778 }2779 2780 return $retval;2781 }2782 2783 /**2784 2707 * Is the current page a group's activity page? 2785 2708 * … … 2805 2728 * Is the current page a group forum topic? 2806 2729 * 2807 * Only applies to legacy bbPress (1.x) forums.2808 *2809 2730 * @since 1.1.0 2731 * @since 3.0.0 Required for bbPress 2 integration. 2810 2732 * 2811 2733 * @return bool True if the current page is part of a group forum topic. … … 2818 2740 * Is the current page a group forum topic edit page? 2819 2741 * 2820 * Only applies to legacy bbPress (1.x) forums.2821 *2822 2742 * @since 1.2.0 2743 * @since 3.0.0 Required for bbPress 2 integration. 2823 2744 * 2824 2745 * @return bool True if the current page is part of a group forum topic edit page. … … 3415 3336 if ( bp_is_group_members() ) { 3416 3337 $bp_classes[] = 'group-members'; 3417 }3418 3419 if ( bp_is_group_forum_topic() ) {3420 $bp_classes[] = 'group-forum-topic';3421 }3422 3423 if ( bp_is_group_forum_topic_edit() ) {3424 $bp_classes[] = 'group-forum-topic-edit';3425 }3426 3427 if ( bp_is_group_forum() ) {3428 $bp_classes[] = 'group-forum';3429 3338 } 3430 3339 … … 3526 3435 } elseif ( bp_is_activation_page() ) { 3527 3436 $bp_classes[] = 'bp_activate'; 3528 3529 } elseif ( bp_is_forums_component() && bp_is_directory() ) {3530 $bp_classes[] = 'bp_forum';3531 3437 } 3532 3438 -
trunk/src/bp-core/classes/class-bp-admin.php
r11648 r11763 442 442 register_setting( 'buddypress', 'bp-disable-group-cover-image-uploads', 'intval' ); 443 443 } 444 }445 446 /* Forums ************************************************************/447 448 if ( bp_is_active( 'forums' ) ) {449 450 // Add the main section.451 add_settings_section( 'bp_forums', __( 'Legacy Group Forums', 'buddypress' ), 'bp_admin_setting_callback_bbpress_section', 'buddypress' );452 453 // Allow subscriptions setting.454 add_settings_field( 'bb-config-location', __( 'bbPress Configuration', 'buddypress' ), 'bp_admin_setting_callback_bbpress_configuration', 'buddypress', 'bp_forums' );455 register_setting( 'buddypress', 'bb-config-location', '' );456 444 } 457 445 -
trunk/src/bp-core/classes/class-bp-core.php
r11361 r11763 66 66 * @param array $value Array of included and optional components. 67 67 */ 68 $bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'f orums', 'friends', 'groups', 'messages', 'notifications', 'settings', 'xprofile' ) );68 $bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'friends', 'groups', 'messages', 'notifications', 'settings', 'xprofile' ) ); 69 69 70 70 /** -
trunk/src/bp-core/classes/class-bp-embed.php
r10825 r11763 44 44 add_filter( 'bp_get_activity_content', array( &$this, 'autoembed' ), 8 ); 45 45 add_filter( 'bp_get_activity_content', array( &$this, 'run_shortcode' ), 7 ); 46 }47 48 if ( bp_use_embed_in_forum_posts() ) {49 add_filter( 'bp_get_the_topic_post_content', array( &$this, 'autoembed' ), 8 );50 add_filter( 'bp_get_the_topic_post_content', array( &$this, 'run_shortcode' ), 7 );51 46 } 52 47 -
trunk/src/bp-core/deprecated/1.5.php
r11447 r11763 398 398 return BP_Core_Notification::delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id ); 399 399 } 400 401 /**402 * In BP 1.5, these functions were renamed for greater consistency403 * @deprecated 1.5.0404 */405 function bp_forum_directory_permalink() {406 _deprecated_function( __FUNCTION__, '1.5', 'bp_forums_directory_permalink()' );407 bp_forums_directory_permalink();408 }409 function bp_get_forum_directory_permalink() {410 _deprecated_function( __FUNCTION__, '1.5', 'bp_get_forums_directory_permalink()' );411 return bp_get_forums_directory_permalink();412 }413 400 414 401 /** -
trunk/src/bp-groups/bp-groups-actions.php
r11761 r11763 195 195 if ( !isset($_POST['group-show-forum']) ) { 196 196 $group_enable_forum = 0; 197 } else {198 // Create the forum if enable_forum = 1.199 if ( bp_is_active( 'forums' ) && !groups_get_groupmeta( $bp->groups->new_group_id, 'forum_id' ) ) {200 groups_new_group_forum();201 }202 197 } 203 198 -
trunk/src/bp-groups/bp-groups-activity.php
r11557 r11763 54 54 array( 'activity', 'group', 'member', 'member_groups' ) 55 55 ); 56 57 // These actions are for the legacy forums58 // Since the bbPress plugin also shares the same 'forums' identifier, we also59 // check for the legacy forums loader class to be extra cautious.60 if ( bp_is_active( 'forums' ) && class_exists( 'BP_Forums_Component' ) ) {61 bp_activity_set_action(62 $bp->groups->id,63 'new_forum_topic',64 __( 'New group forum topic', 'buddypress' ),65 false,66 __( 'Forum Topics', 'buddypress' ),67 array( 'activity', 'group', 'member', 'member_groups' )68 );69 70 bp_activity_set_action(71 $bp->groups->id,72 'new_forum_post',73 __( 'New group forum post', 'buddypress' ),74 false,75 __( 'Forum Replies', 'buddypress' ),76 array( 'activity', 'group', 'member', 'member_groups' )77 );78 }79 56 80 57 /** … … 405 382 add_action( 'groups_leave_group', 'groups_update_last_activity' ); 406 383 add_action( 'groups_created_group', 'groups_update_last_activity' ); 407 add_action( 'groups_new_forum_topic', 'groups_update_last_activity' );408 add_action( 'groups_new_forum_topic_post', 'groups_update_last_activity' );409 384 410 385 /** -
trunk/src/bp-groups/bp-groups-filters.php
r11703 r11763 45 45 add_filter( 'bp_get_group_member_name', 'stripslashes' ); 46 46 add_filter( 'bp_get_group_member_link', 'stripslashes' ); 47 48 add_filter( 'groups_new_group_forum_desc', 'bp_create_excerpt' );49 47 50 48 add_filter( 'groups_group_name_before_save', 'force_balance_tags' ); … … 121 119 } 122 120 123 /** Legacy group forums (bbPress 1.x) *****************************************/124 125 /**126 * Filter bbPress query SQL when on group pages or on forums directory.127 *128 * @since 1.1.0129 */130 function groups_add_forum_privacy_sql() {131 add_filter( 'get_topics_fields', 'groups_add_forum_fields_sql' );132 add_filter( 'get_topics_join', 'groups_add_forum_tables_sql' );133 add_filter( 'get_topics_where', 'groups_add_forum_where_sql' );134 }135 add_filter( 'bbpress_init', 'groups_add_forum_privacy_sql' );136 137 /**138 * Add fields to bbPress query for group-specific data.139 *140 * @since 1.1.0141 *142 * @param string $sql SQL statement to amend.143 * @return string144 */145 function groups_add_forum_fields_sql( $sql = '' ) {146 $sql = 't.*, g.id as object_id, g.name as object_name, g.slug as object_slug';147 return $sql;148 }149 150 /**151 * Add JOINed tables to bbPress query for group-specific data.152 *153 * @since 1.1.0154 *155 * @param string $sql SQL statement to amend.156 * @return string157 */158 function groups_add_forum_tables_sql( $sql = '' ) {159 $bp = buddypress();160 161 $sql .= 'JOIN ' . $bp->groups->table_name . ' AS g LEFT JOIN ' . $bp->groups->table_name_groupmeta . ' AS gm ON g.id = gm.group_id ';162 163 return $sql;164 }165 166 /**167 * Add WHERE clauses to bbPress query for group-specific data and access protection.168 *169 * @since 1.1.0170 *171 * @param string $sql SQL Statement to amend.172 * @return string173 */174 function groups_add_forum_where_sql( $sql = '' ) {175 176 // Define locale variable.177 $parts = array();178 179 // Set this for groups.180 $parts['groups'] = "(gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id)";181 182 // Restrict to public...183 $parts['private'] = "g.status = 'public'";184 185 /**186 * ...but do some checks to possibly remove public restriction.187 *188 * Decide if private are visible189 */190 191 // Are we in our own profile?192 if ( bp_is_my_profile() )193 unset( $parts['private'] );194 195 // Are we a super admin?196 elseif ( bp_current_user_can( 'bp_moderate' ) )197 unset( $parts['private'] );198 199 // No need to filter on a single item.200 elseif ( bp_is_single_item() )201 unset( $parts['private'] );202 203 // Check the SQL filter that was passed.204 if ( !empty( $sql ) )205 $parts['passed'] = $sql;206 207 // Assemble Voltron.208 $parts_string = implode( ' AND ', $parts );209 210 $bp = buddypress();211 212 // Set it to the global filter.213 $bp->groups->filter_sql = $parts_string;214 215 // Return the global filter.216 return $bp->groups->filter_sql;217 }218 219 /**220 * Modify bbPress caps for bp-forums.221 *222 * @since 1.1.0223 *224 * @param bool $value Original value for current_user_can check.225 * @param string $cap Capability checked.226 * @param array $args Arguments for the caps.227 * @return bool228 */229 function groups_filter_bbpress_caps( $value, $cap, $args ) {230 231 if ( bp_current_user_can( 'bp_moderate' ) )232 return true;233 234 if ( 'add_tag_to' === $cap ) {235 $bp = buddypress();236 237 if ( $bp->groups->current_group->user_has_access ) {238 return true;239 }240 }241 242 if ( 'manage_forums' == $cap && is_user_logged_in() )243 return true;244 245 return $value;246 }247 add_filter( 'bb_current_user_can', 'groups_filter_bbpress_caps', 10, 3 );248 249 /**250 * Amends the forum directory's "last active" bbPress SQL query to stop it fetching information we aren't going to use.251 *252 * This speeds up the query.253 *254 * @since 1.5.0255 *256 * @see BB_Query::_filter_sql()257 *258 * @param string $sql SQL statement.259 * @return string260 */261 function groups_filter_forums_root_page_sql( $sql ) {262 263 /**264 * Filters the forum directory's "last active" bbPress SQL query.265 *266 * This filter is used to prevent fetching information that is not used.267 *268 * @since 1.5.0269 *270 * @param string $value SQL string to specify fetching just topic_id.271 */272 return apply_filters( 'groups_filter_bbpress_root_page_sql', 't.topic_id' );273 }274 add_filter( 'get_latest_topics_fields', 'groups_filter_forums_root_page_sql' );275 276 121 /** 277 122 * Should BuddyPress load the mentions scripts and related assets, including results to prime the -
trunk/src/bp-groups/bp-groups-functions.php
r11762 r11763 355 355 if ( !$group->save() ) 356 356 return false; 357 358 // If forums have been enabled, and a forum does not yet exist, we need to create one.359 if ( $group->enable_forum ) {360 if ( bp_is_active( 'forums' ) && !groups_get_groupmeta( $group->id, 'forum_id' ) ) {361 groups_new_group_forum( $group->id, $group->name, $group->description );362 }363 }364 357 365 358 // Set the invite status. -
trunk/src/bp-groups/bp-groups-screens.php
r11556 r11763 167 167 */ 168 168 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); 169 }170 171 /**172 * This screen function handles actions related to group forums.173 *174 * @since 1.0.0175 */176 function groups_screen_group_forum() {177 178 if ( !bp_is_active( 'forums' ) || !bp_forums_is_installed_correctly() )179 return false;180 181 if ( bp_action_variable( 0 ) && !bp_is_action_variable( 'topic', 0 ) ) {182 bp_do_404();183 return;184 }185 186 $bp = buddypress();187 188 if ( !$bp->groups->current_group->user_has_access ) {189 bp_core_no_access();190 return;191 }192 193 if ( ! bp_is_single_item() )194 return false;195 196 // Fetch the details we need.197 $topic_slug = (string)bp_action_variable( 1 );198 $topic_id = bp_forums_get_topic_id_from_slug( $topic_slug );199 $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' );200 $user_is_banned = false;201 202 if ( !bp_current_user_can( 'bp_moderate' ) && groups_is_user_banned( bp_loggedin_user_id(), $bp->groups->current_group->id ) )203 $user_is_banned = true;204 205 if ( !empty( $topic_slug ) && !empty( $topic_id ) ) {206 207 // Posting a reply.208 if ( !$user_is_banned && !bp_action_variable( 2 ) && isset( $_POST['submit_reply'] ) ) {209 // Check the nonce.210 check_admin_referer( 'bp_forums_new_reply' );211 212 // Auto join this user if they are not yet a member of this group.213 if ( bp_groups_auto_join() && !bp_current_user_can( 'bp_moderate' ) && 'public' == $bp->groups->current_group->status && !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {214 groups_join_group( $bp->groups->current_group->id, bp_loggedin_user_id() );215 }216 217 $topic_page = isset( $_GET['topic_page'] ) ? $_GET['topic_page'] : false;218 219 // Don't allow reply flooding.220 if ( bp_forums_reply_exists( $_POST['reply_text'], $topic_id, bp_loggedin_user_id() ) ) {221 bp_core_add_message( __( 'It looks like you\'ve already said that!', 'buddypress' ), 'error' );222 } else {223 if ( !$post_id = groups_new_group_forum_post( $_POST['reply_text'], $topic_id, $topic_page ) ) {224 bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' );225 } else {226 bp_core_add_message( __( 'Your reply was posted successfully', 'buddypress') );227 }228 }229 230 $query_vars = isset( $_SERVER['QUERY_STRING'] ) ? '?' . $_SERVER['QUERY_STRING'] : '';231 232 $redirect = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic_slug . '/' . $query_vars;233 234 if ( !empty( $post_id ) ) {235 $redirect .= '#post-' . $post_id;236 }237 238 bp_core_redirect( $redirect );239 }240 241 // Sticky a topic.242 elseif ( bp_is_action_variable( 'stick', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {243 // Check the nonce.244 check_admin_referer( 'bp_forums_stick_topic' );245 246 if ( !bp_forums_sticky_topic( array( 'topic_id' => $topic_id ) ) ) {247 bp_core_add_message( __( 'There was an error when making that topic a sticky', 'buddypress' ), 'error' );248 } else {249 bp_core_add_message( __( 'The topic was made sticky successfully', 'buddypress' ) );250 }251 252 /**253 * Fires after a group forum topic has been stickied.254 *255 * @since 1.1.0256 *257 * @param int $topic_id ID of the topic being stickied.258 */259 do_action( 'groups_stick_forum_topic', $topic_id );260 bp_core_redirect( wp_get_referer() );261 }262 263 // Un-Sticky a topic.264 elseif ( bp_is_action_variable( 'unstick', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {265 // Check the nonce.266 check_admin_referer( 'bp_forums_unstick_topic' );267 268 if ( !bp_forums_sticky_topic( array( 'topic_id' => $topic_id, 'mode' => 'unstick' ) ) ) {269 bp_core_add_message( __( 'There was an error when unsticking that topic', 'buddypress'), 'error' );270 } else {271 bp_core_add_message( __( 'The topic was unstuck successfully', 'buddypress') );272 }273 274 /**275 * Fires after a group forum topic has been un-stickied.276 *277 * @since 1.1.0278 *279 * @param int $topic_id ID of the topic being un-stickied.280 */281 do_action( 'groups_unstick_forum_topic', $topic_id );282 bp_core_redirect( wp_get_referer() );283 }284 285 // Close a topic.286 elseif ( bp_is_action_variable( 'close', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {287 // Check the nonce.288 check_admin_referer( 'bp_forums_close_topic' );289 290 if ( !bp_forums_openclose_topic( array( 'topic_id' => $topic_id ) ) ) {291 bp_core_add_message( __( 'There was an error when closing that topic', 'buddypress'), 'error' );292 } else {293 bp_core_add_message( __( 'The topic was closed successfully', 'buddypress') );294 }295 296 /**297 * Fires after a group forum topic has been closed.298 *299 * @since 1.1.0300 *301 * @param int $topic_id ID of the topic being closed.302 */303 do_action( 'groups_close_forum_topic', $topic_id );304 bp_core_redirect( wp_get_referer() );305 }306 307 // Open a topic.308 elseif ( bp_is_action_variable( 'open', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {309 // Check the nonce.310 check_admin_referer( 'bp_forums_open_topic' );311 312 if ( !bp_forums_openclose_topic( array( 'topic_id' => $topic_id, 'mode' => 'open' ) ) ) {313 bp_core_add_message( __( 'There was an error when opening that topic', 'buddypress'), 'error' );314 } else {315 bp_core_add_message( __( 'The topic was opened successfully', 'buddypress') );316 }317 318 /**319 * Fires after a group forum topic has been opened.320 *321 * @since 1.1.0322 *323 * @param int $topic_id ID of the topic being opened.324 */325 do_action( 'groups_open_forum_topic', $topic_id );326 bp_core_redirect( wp_get_referer() );327 }328 329 // Delete a topic.330 elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'delete', 2 ) && !bp_action_variable( 3 ) ) {331 // Fetch the topic.332 $topic = bp_forums_get_topic_details( $topic_id );333 334 /* Check the logged in user can delete this topic */335 if ( ! bp_is_item_admin() && ! bp_is_item_mod() && ( (int) bp_loggedin_user_id() != (int) $topic->topic_poster ) ) {336 bp_core_redirect( wp_get_referer() );337 }338 339 // Check the nonce.340 check_admin_referer( 'bp_forums_delete_topic' );341 342 /**343 * Fires before a group forum topic is deleted.344 *345 * @since 1.5.0346 *347 * @param int $topic_id ID of the topic being deleted.348 */349 do_action( 'groups_before_delete_forum_topic', $topic_id );350 351 if ( !groups_delete_group_forum_topic( $topic_id ) ) {352 bp_core_add_message( __( 'There was an error deleting the topic', 'buddypress' ), 'error' );353 } else {354 bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress' ) );355 }356 357 /**358 * Fires after a group forum topic has been deleted.359 *360 * @since 1.5.0361 *362 * @param int $topic_id ID of the topic being deleted.363 */364 do_action( 'groups_delete_forum_topic', $topic_id );365 bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'forum/' );366 }367 368 // Editing a topic.369 elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'edit', 2 ) && !bp_action_variable( 3 ) ) {370 // Fetch the topic.371 $topic = bp_forums_get_topic_details( $topic_id );372 373 // Check the logged in user can edit this topic.374 if ( ! bp_is_item_admin() && ! bp_is_item_mod() && ( (int) bp_loggedin_user_id() != (int) $topic->topic_poster ) ) {375 bp_core_redirect( wp_get_referer() );376 }377 378 if ( isset( $_POST['save_changes'] ) ) {379 // Check the nonce.380 check_admin_referer( 'bp_forums_edit_topic' );381 382 $topic_tags = !empty( $_POST['topic_tags'] ) ? $_POST['topic_tags'] : false;383 384 if ( !groups_update_group_forum_topic( $topic_id, $_POST['topic_title'], $_POST['topic_text'], $topic_tags ) ) {385 bp_core_add_message( __( 'There was an error when editing that topic', 'buddypress'), 'error' );386 } else {387 bp_core_add_message( __( 'The topic was edited successfully', 'buddypress') );388 }389 390 /**391 * Fires after a group forum topic has been edited.392 *393 * @since 1.1.0394 *395 * @param int $topic_id ID of the topic being edited.396 */397 do_action( 'groups_edit_forum_topic', $topic_id );398 bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic_slug . '/' );399 }400 401 /**402 * Filters the template to load for a topic edit page.403 *404 * @since 1.1.0405 *406 * @param string $value Path to a topic edit template.407 */408 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/home' ) );409 410 // Delete a post.411 } elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'delete', 2 ) && $post_id = bp_action_variable( 4 ) ) {412 // Fetch the post.413 $post = bp_forums_get_post( $post_id );414 415 // Check the logged in user can edit this topic.416 if ( ! bp_is_item_admin() && ! bp_is_item_mod() && ( (int) bp_loggedin_user_id() != (int) $post->poster_id ) ) {417 bp_core_redirect( wp_get_referer() );418 }419 420 // Check the nonce.421 check_admin_referer( 'bp_forums_delete_post' );422 423 /**424 * Fires before the deletion of a group forum post.425 *426 * @since 1.5.0427 *428 * @param int $post_id ID of the forum post being deleted.429 */430 do_action( 'groups_before_delete_forum_post', $post_id );431 432 if ( !groups_delete_group_forum_post( $post_id ) ) {433 bp_core_add_message( __( 'There was an error deleting that post', 'buddypress'), 'error' );434 } else {435 bp_core_add_message( __( 'The post was deleted successfully', 'buddypress') );436 }437 438 /**439 * Fires after the deletion of a group forum post.440 *441 * @since 1.1.0442 *443 * @param int $post_id ID of the forum post being deleted.444 */445 do_action( 'groups_delete_forum_post', $post_id );446 bp_core_redirect( wp_get_referer() );447 448 // Editing a post.449 } elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'edit', 2 ) && $post_id = bp_action_variable( 4 ) ) {450 451 // Fetch the post.452 $post = bp_forums_get_post( $post_id );453 454 // Check the logged in user can edit this topic.455 if ( ! bp_is_item_admin() && ! bp_is_item_mod() && ( (int) bp_loggedin_user_id() != (int) $post->poster_id ) ) {456 bp_core_redirect( wp_get_referer() );457 }458 459 if ( isset( $_POST['save_changes'] ) ) {460 // Check the nonce.461 check_admin_referer( 'bp_forums_edit_post' );462 463 $topic_page = isset( $_GET['topic_page'] ) ? $_GET['topic_page'] : false;464 465 if ( !$post_id = groups_update_group_forum_post( $post_id, $_POST['post_text'], $topic_id, $topic_page ) ) {466 bp_core_add_message( __( 'There was an error when editing that post', 'buddypress'), 'error' );467 } else {468 bp_core_add_message( __( 'The post was edited successfully', 'buddypress') );469 }470 471 if ( $_SERVER['QUERY_STRING'] ) {472 $query_vars = '?' . $_SERVER['QUERY_STRING'];473 }474 475 /**476 * Fires after the editing of a group forum post.477 *478 * @since 1.1.0479 *480 * @param int $post_id ID of the forum post being edited.481 */482 do_action( 'groups_edit_forum_post', $post_id );483 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id );484 }485 486 /** This filter is documented in bp-groups/bp-groups-screens.php */487 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/home' ) );488 489 // Standard topic display.490 } else {491 if ( !empty( $user_is_banned ) ) {492 bp_core_add_message( __( "You have been banned from this group.", 'buddypress' ) );493 }494 495 /**496 * Filters the template to load for a topic page.497 *498 * @since 1.1.0499 *500 * @param string $value Path to a topic template.501 */502 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/single/home' ) );503 }504 505 // Forum topic does not exist.506 } elseif ( !empty( $topic_slug ) && empty( $topic_id ) ) {507 bp_do_404();508 return;509 510 } else {511 // Posting a topic.512 if ( isset( $_POST['submit_topic'] ) && bp_is_active( 'forums' ) ) {513 514 // Check the nonce.515 check_admin_referer( 'bp_forums_new_topic' );516 517 if ( $user_is_banned ) {518 $error_message = __( "You have been banned from this group.", 'buddypress' );519 520 } elseif ( bp_groups_auto_join() && !bp_current_user_can( 'bp_moderate' ) && 'public' == $bp->groups->current_group->status && !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {521 // Auto join this user if they are not yet a member of this group.522 groups_join_group( $bp->groups->current_group->id, bp_loggedin_user_id() );523 }524 525 if ( empty( $_POST['topic_title'] ) ) {526 $error_message = __( 'Please provide a title for your forum topic.', 'buddypress' );527 } elseif ( empty( $_POST['topic_text'] ) ) {528 $error_message = __( 'Forum posts cannot be empty. Please enter some text.', 'buddypress' );529 }530 531 if ( empty( $forum_id ) ) {532 $error_message = __( 'This group does not have a forum setup yet.', 'buddypress' );533 }534 535 if ( isset( $error_message ) ) {536 bp_core_add_message( $error_message, 'error' );537 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';538 } else {539 if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) {540 bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );541 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';542 } else {543 bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );544 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';545 }546 }547 548 bp_core_redirect( $redirect );549 }550 551 /**552 * Fires at the end of the group forum screen loading process.553 *554 * @since 1.0.0555 *556 * @param int $topic_id ID of the topic being displayed.557 * @param int $forum_id ID of the forum being displayed.558 */559 do_action( 'groups_screen_group_forum', $topic_id, $forum_id );560 561 /**562 * Filters the template to load for a group forum page.563 *564 * @since 1.0.0565 *566 * @param string $value Path to a group forum template.567 */568 bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/home' ) );569 }570 169 } 571 170 -
trunk/src/bp-groups/bp-groups-template.php
r11761 r11763 2025 2025 2026 2026 /** 2027 * Output the URL of the Forum page of the current group in the loop.2028 *2029 * @since 1.0.02030 */2031 function bp_group_forum_permalink() {2032 echo bp_get_group_forum_permalink();2033 }2034 /**2035 * Generate the URL of the Forum page of a group.2036 *2037 * @since 1.0.02038 *2039 * @param object|bool $group Optional. Group object.2040 * Default: current group in loop.2041 * @return string2042 */2043 function bp_get_group_forum_permalink( $group = false ) {2044 global $groups_template;2045 2046 if ( empty( $group ) ) {2047 $group =& $groups_template->group;2048 }2049 2050 /**2051 * Filters the URL of the Forum page of a group.2052 *2053 * @since 1.0.02054 * @since 2.5.0 Added the `$group` parameter.2055 *2056 * @param string $value URL permalink for the Forum Page.2057 * @param object $group Group object.2058 */2059 return apply_filters( 'bp_get_group_forum_permalink', trailingslashit( bp_get_group_permalink( $group ) . 'forum' ), $group );2060 }2061 2062 /**2063 * Output the topic count for a group forum.2064 *2065 * @since 1.2.02066 *2067 * @param array|string $args See {@link bp_get_group_forum_topic_count()}.2068 */2069 function bp_group_forum_topic_count( $args = '' ) {2070 echo bp_get_group_forum_topic_count( $args );2071 }2072 /**2073 * Generate the topic count string for a group forum.2074 *2075 * @since 1.2.02076 *2077 * @param array|string $args {2078 * Array of arguments.2079 * @type bool $showtext Optional. If true, result will be formatted as "x topics".2080 * If false, just a number will be returned.2081 * Default: false.2082 * }2083 * @return string|int2084 */2085 function bp_get_group_forum_topic_count( $args = '' ) {2086 global $groups_template;2087 2088 $defaults = array(2089 'showtext' => false2090 );2091 2092 $r = wp_parse_args( $args, $defaults );2093 extract( $r, EXTR_SKIP );2094 2095 if ( !$forum_id = groups_get_groupmeta( $groups_template->group->id, 'forum_id' ) ) {2096 return false;2097 }2098 2099 if ( !bp_is_active( 'forums' ) ) {2100 return false;2101 }2102 2103 if ( !$groups_template->group->forum_counts ) {2104 $groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int) $forum_id );2105 }2106 2107 if ( (bool) $showtext ) {2108 if ( 1 == (int) $groups_template->group->forum_counts[0]->topics ) {2109 $total_topics = sprintf( __( '%d topic', 'buddypress' ), (int) $groups_template->group->forum_counts[0]->topics );2110 } else {2111 $total_topics = sprintf( __( '%d topics', 'buddypress' ), (int) $groups_template->group->forum_counts[0]->topics );2112 }2113 } else {2114 $total_topics = (int) $groups_template->group->forum_counts[0]->topics;2115 }2116 2117 /**2118 * Filters the topic count string for a group forum.2119 *2120 * @since 1.2.02121 *2122 * @param string $total_topics Total topic count string.2123 * @param bool $showtext Whether or not to return as formatted string.2124 */2125 return apply_filters( 'bp_get_group_forum_topic_count', $total_topics, (bool)$showtext );2126 }2127 2128 /**2129 * Output the post count for a group forum.2130 *2131 * @since 1.2.02132 *2133 * @param array|string $args See {@link bp_get_group_forum_post_count()}.2134 */2135 function bp_group_forum_post_count( $args = '' ) {2136 echo bp_get_group_forum_post_count( $args );2137 }2138 /**2139 * Generate the post count string for a group forum.2140 *2141 * @since 1.2.02142 *2143 * @param array|string $args {2144 * Array of arguments.2145 * @type bool $showtext Optional. If true, result will be formatted as "x posts".2146 * If false, just a number will be returned.2147 * Default: false.2148 * }2149 * @return string|int2150 */2151 function bp_get_group_forum_post_count( $args = '' ) {2152 global $groups_template;2153 2154 $defaults = array(2155 'showtext' => false2156 );2157 2158 $r = wp_parse_args( $args, $defaults );2159 extract( $r, EXTR_SKIP );2160 2161 if ( !$forum_id = groups_get_groupmeta( $groups_template->group->id, 'forum_id' ) ) {2162 return false;2163 }2164 2165 if ( !bp_is_active( 'forums' ) ) {2166 return false;2167 }2168 2169 if ( !$groups_template->group->forum_counts ) {2170 $groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int) $forum_id );2171 }2172 2173 if ( (bool) $showtext ) {2174 if ( 1 == (int) $groups_template->group->forum_counts[0]->posts ) {2175 $total_posts = sprintf( __( '%d post', 'buddypress' ), (int) $groups_template->group->forum_counts[0]->posts );2176 } else {2177 $total_posts = sprintf( __( '%d posts', 'buddypress' ), (int) $groups_template->group->forum_counts[0]->posts );2178 }2179 } else {2180 $total_posts = (int) $groups_template->group->forum_counts[0]->posts;2181 }2182 2183 /**2184 * Filters the post count string for a group forum.2185 *2186 * @since 1.2.02187 *2188 * @param string $total_posts Total post count string.2189 * @param bool $showtext Whether or not to return as formatted string.2190 */2191 return apply_filters( 'bp_get_group_forum_post_count', $total_posts, (bool)$showtext );2192 }2193 2194 /**2195 2027 * Determine whether forums are enabled for a group. 2196 2028 * … … 3381 3213 return true; 3382 3214 } 3383 3384 /**3385 * Output a 'New Topic' button for a group.3386 *3387 * @since 1.2.73388 *3389 * @param BP_Groups_Group|bool $group The BP Groups_Group object if passed,3390 * boolean false if not passed.3391 */3392 function bp_group_new_topic_button( $group = false ) {3393 echo bp_get_group_new_topic_button( $group );3394 }3395 3396 /**3397 * Returns a 'New Topic' button for a group.3398 *3399 * @since 1.2.73400 *3401 * @param BP_Groups_Group|bool $group The BP Groups_Group object if3402 * passed, boolean false if not passed.3403 * @return false|string HTML code for the button.3404 */3405 function bp_get_group_new_topic_button( $group = false ) {3406 global $groups_template;3407 3408 if ( empty( $group ) ) {3409 $group =& $groups_template->group;3410 }3411 3412 if ( !is_user_logged_in() || bp_group_is_user_banned() || !bp_is_group_forum() || bp_is_group_forum_topic() ) {3413 return false;3414 }3415 3416 $button = array(3417 'id' => 'new_topic',3418 'component' => 'groups',3419 'must_be_logged_in' => true,3420 'block_self' => true,3421 'wrapper_class' => 'group-button',3422 'link_href' => '#post-new',3423 'link_class' => 'group-button show-hide-new',3424 'link_id' => 'new-topic-button',3425 'link_text' => __( 'New Topic', 'buddypress' ),3426 );3427 3428 /**3429 * Filters the HTML button for creating a new topic in a group.3430 *3431 * @since 1.5.03432 * @since 2.5.0 Added the `$group` parameter.3433 *3434 * @param string $button HTML button for a new topic.3435 * @param object $group Group object.3436 */3437 return bp_get_button( apply_filters( 'bp_get_group_new_topic_button', $button, $group ) );3438 }3439 3215 3440 3216 /** -
trunk/src/bp-groups/classes/class-bp-groups-component.php
r11559 r11763 124 124 $includes = array( 125 125 'cache', 126 'forums',127 126 'actions', 128 127 'filters', -
trunk/src/bp-groups/classes/class-bp-groups-group.php
r11762 r11763 79 79 80 80 /** 81 * Should (legacy) bbPress forums be enabled for this group? 82 * 83 * @since 1.6.0 81 * Controls whether the group has a forum enabled. 82 * 83 * @since 1.6.0 84 * @since 3.0.0 Previously, this referred to Legacy Forums. It's still used by bbPress 2 for integration. 85 * 84 86 * @var int 85 87 */ … … 1457 1459 1458 1460 /** 1459 * Get a list of groups, sorted by those that have the most legacy forum topics. 1461 * Convert the 'orderby' param into a proper SQL term/column. 1462 * 1463 * @since 1.8.0 1464 * 1465 * @param string $orderby Orderby term as passed to get(). 1466 * @return string $order_by_term SQL-friendly orderby term. 1467 */ 1468 protected static function convert_orderby_to_order_by_term( $orderby ) { 1469 $order_by_term = ''; 1470 1471 switch ( $orderby ) { 1472 case 'date_created' : 1473 default : 1474 $order_by_term = 'g.date_created'; 1475 break; 1476 1477 case 'last_activity' : 1478 $order_by_term = 'gm_last_activity.meta_value'; 1479 break; 1480 1481 case 'total_member_count' : 1482 $order_by_term = 'CONVERT(gm_total_member_count.meta_value, SIGNED)'; 1483 break; 1484 1485 case 'name' : 1486 $order_by_term = 'g.name'; 1487 break; 1488 1489 case 'random' : 1490 $order_by_term = 'rand()'; 1491 break; 1492 1493 case 'meta_id' : 1494 $order_by_term = buddypress()->groups->table_name_groupmeta . '.id'; 1495 break; 1496 } 1497 1498 return $order_by_term; 1499 } 1500 1501 /** 1502 * Get a list of groups whose names start with a given letter. 1503 * 1504 * @since 1.6.0 1505 * 1506 * @param string $letter The letter. 1507 * @param int|null $limit Optional. The max number of results to return. 1508 * Default: null (no limit). 1509 * @param int|null $page Optional. The page offset of results to return. 1510 * Default: null (no limit). 1511 * @param bool $populate_extras Deprecated. 1512 * @param string|array|bool $exclude Optional. Array or comma-separated list of group 1513 * IDs to exclude from results. 1514 * @return false|array { 1515 * @type array $groups Array of group objects returned by the 1516 * paginated query. 1517 * @type int $total Total count of all groups matching non- 1518 * paginated query params. 1519 * } 1520 */ 1521 public static function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true, $exclude = false ) { 1522 global $wpdb; 1523 1524 $pag_sql = $hidden_sql = $exclude_sql = ''; 1525 1526 // Multibyte compliance. 1527 if ( function_exists( 'mb_strlen' ) ) { 1528 if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) { 1529 return false; 1530 } 1531 } else { 1532 if ( strlen( $letter ) > 1 || is_numeric( $letter ) || !$letter ) { 1533 return false; 1534 } 1535 } 1536 1537 $args = array( 1538 'per_page' => $limit, 1539 'page' => $page, 1540 'search_terms' => $letter . '*', 1541 'search_columns' => array( 'name' ), 1542 'exclude' => $exclude, 1543 ); 1544 1545 return BP_Groups_Group::get( $args ); 1546 } 1547 1548 /** 1549 * Get a list of random groups. 1550 * 1551 * Use BP_Groups_Group::get() with 'type' = 'random' instead. 1460 1552 * 1461 1553 * @since 1.6.0 … … 1480 1572 * } 1481 1573 */ 1482 public static function get_by_most_forum_topics( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {1483 global $wpdb, $bbdb;1484 1485 if ( empty( $bbdb ) ) {1486 1487 /** This action is documented in bp-forums/bp-forums-screens */1488 do_action( 'bbpress_init' );1489 }1490 1491 if ( !empty( $limit ) && !empty( $page ) ) {1492 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );1493 }1494 1495 if ( !is_user_logged_in() || ( !bp_current_user_can( 'bp_moderate' ) && ( $user_id != bp_loggedin_user_id() ) ) )1496 $hidden_sql = " AND g.status != 'hidden'";1497 1498 if ( !empty( $search_terms ) ) {1499 $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';1500 $search_sql = $wpdb->prepare( ' AND ( g.name LIKE %s OR g.description LIKE %s ) ', $search_terms_like, $search_terms_like );1501 }1502 1503 if ( !empty( $exclude ) ) {1504 $exclude = implode( ',', wp_parse_id_list( $exclude ) );1505 $exclude_sql = " AND g.id NOT IN ({$exclude})";1506 }1507 1508 $bp = buddypress();1509 1510 if ( !empty( $user_id ) ) {1511 $user_id = absint( esc_sql( $user_id ) );1512 $paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} ORDER BY f.topics DESC {$pag_sql}" );1513 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql}" );1514 } else {1515 $paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} {$exclude_sql} ORDER BY f.topics DESC {$pag_sql}" );1516 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} {$exclude_sql}" );1517 }1518 1519 if ( !empty( $populate_extras ) ) {1520 foreach ( (array) $paged_groups as $group ) {1521 $group_ids[] = $group->id;1522 }1523 $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, 'newest' );1524 }1525 1526 return array( 'groups' => $paged_groups, 'total' => $total_groups );1527 }1528 1529 /**1530 * Convert the 'orderby' param into a proper SQL term/column.1531 *1532 * @since 1.8.01533 *1534 * @param string $orderby Orderby term as passed to get().1535 * @return string $order_by_term SQL-friendly orderby term.1536 */1537 protected static function convert_orderby_to_order_by_term( $orderby ) {1538 $order_by_term = '';1539 1540 switch ( $orderby ) {1541 case 'date_created' :1542 default :1543 $order_by_term = 'g.date_created';1544 break;1545 1546 case 'last_activity' :1547 $order_by_term = 'gm_last_activity.meta_value';1548 break;1549 1550 case 'total_member_count' :1551 $order_by_term = 'CONVERT(gm_total_member_count.meta_value, SIGNED)';1552 break;1553 1554 case 'name' :1555 $order_by_term = 'g.name';1556 break;1557 1558 case 'random' :1559 $order_by_term = 'rand()';1560 break;1561 1562 case 'meta_id' :1563 $order_by_term = buddypress()->groups->table_name_groupmeta . '.id';1564 break;1565 }1566 1567 return $order_by_term;1568 }1569 1570 /**1571 * Get a list of groups, sorted by those that have the most legacy forum posts.1572 *1573 * @since 1.6.01574 *1575 * @param int|null $limit Optional. The max number of results to return.1576 * Default: null (no limit).1577 * @param int|null $page Optional. The page offset of results to return.1578 * Default: null (no limit).1579 * @param string|bool $search_terms Optional. Limit groups to those whose name1580 * or description field contain the search string.1581 * @param bool $populate_extras Optional. Whether to fetch extra1582 * information about the groups. Default: true.1583 * @param string|array|bool $exclude Optional. Array or comma-separated list of group1584 * IDs to exclude from results.1585 * @return array {1586 * @type array $groups Array of group objects returned by the1587 * paginated query.1588 * @type int $total Total count of all groups matching non-1589 * paginated query params.1590 * }1591 */1592 public static function get_by_most_forum_posts( $limit = null, $page = null, $search_terms = false, $populate_extras = true, $exclude = false ) {1593 global $wpdb, $bbdb;1594 1595 if ( empty( $bbdb ) ) {1596 1597 /** This action is documented in bp-forums/bp-forums-screens */1598 do_action( 'bbpress_init' );1599 }1600 1601 if ( !empty( $limit ) && !empty( $page ) ) {1602 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );1603 }1604 1605 if ( !is_user_logged_in() || ( !bp_current_user_can( 'bp_moderate' ) && ( $user_id != bp_loggedin_user_id() ) ) )1606 $hidden_sql = " AND g.status != 'hidden'";1607 1608 if ( !empty( $search_terms ) ) {1609 $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';1610 $search_sql = $wpdb->prepare( ' AND ( g.name LIKE %s OR g.description LIKE %s ) ', $search_terms_like, $search_terms_like );1611 }1612 1613 if ( !empty( $exclude ) ) {1614 $exclude = implode( ',', wp_parse_id_list( $exclude ) );1615 $exclude_sql = " AND g.id NOT IN ({$exclude})";1616 }1617 1618 $bp = buddypress();1619 1620 if ( !empty( $user_id ) ) {1621 $user_id = esc_sql( $user_id );1622 $paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} ORDER BY f.posts ASC {$pag_sql}" );1623 $total_groups = $wpdb->get_results( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.posts > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} " );1624 } else {1625 $paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.posts > 0 {$hidden_sql} {$search_sql} {$exclude_sql} ORDER BY f.posts ASC {$pag_sql}" );1626 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) {$hidden_sql} {$search_sql} {$exclude_sql}" );1627 }1628 1629 if ( !empty( $populate_extras ) ) {1630 foreach ( (array) $paged_groups as $group ) {1631 $group_ids[] = $group->id;1632 }1633 $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, 'newest' );1634 }1635 1636 return array( 'groups' => $paged_groups, 'total' => $total_groups );1637 }1638 1639 /**1640 * Get a list of groups whose names start with a given letter.1641 *1642 * @since 1.6.01643 *1644 * @param string $letter The letter.1645 * @param int|null $limit Optional. The max number of results to return.1646 * Default: null (no limit).1647 * @param int|null $page Optional. The page offset of results to return.1648 * Default: null (no limit).1649 * @param bool $populate_extras Deprecated.1650 * @param string|array|bool $exclude Optional. Array or comma-separated list of group1651 * IDs to exclude from results.1652 * @return false|array {1653 * @type array $groups Array of group objects returned by the1654 * paginated query.1655 * @type int $total Total count of all groups matching non-1656 * paginated query params.1657 * }1658 */1659 public static function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true, $exclude = false ) {1660 global $wpdb;1661 1662 $pag_sql = $hidden_sql = $exclude_sql = '';1663 1664 // Multibyte compliance.1665 if ( function_exists( 'mb_strlen' ) ) {1666 if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) {1667 return false;1668 }1669 } else {1670 if ( strlen( $letter ) > 1 || is_numeric( $letter ) || !$letter ) {1671 return false;1672 }1673 }1674 1675 $args = array(1676 'per_page' => $limit,1677 'page' => $page,1678 'search_terms' => $letter . '*',1679 'search_columns' => array( 'name' ),1680 'exclude' => $exclude,1681 );1682 1683 return BP_Groups_Group::get( $args );1684 }1685 1686 /**1687 * Get a list of random groups.1688 *1689 * Use BP_Groups_Group::get() with 'type' = 'random' instead.1690 *1691 * @since 1.6.01692 *1693 * @param int|null $limit Optional. The max number of results to return.1694 * Default: null (no limit).1695 * @param int|null $page Optional. The page offset of results to return.1696 * Default: null (no limit).1697 * @param int $user_id Optional. If present, groups will be limited to1698 * those of which the specified user is a member.1699 * @param string|bool $search_terms Optional. Limit groups to those whose name1700 * or description field contain the search string.1701 * @param bool $populate_extras Optional. Whether to fetch extra1702 * information about the groups. Default: true.1703 * @param string|array|bool $exclude Optional. Array or comma-separated list of group1704 * IDs to exclude from results.1705 * @return array {1706 * @type array $groups Array of group objects returned by the1707 * paginated query.1708 * @type int $total Total count of all groups matching non-1709 * paginated query params.1710 * }1711 */1712 1574 public static function get_random( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) { 1713 1575 $args = array( … … 1794 1656 1795 1657 /** 1796 * Get global count of forum topics in public groups (legacy forums).1797 *1798 * @since 1.6.01799 *1800 * @param string $type Optional. If 'unreplied', count will be limited to1801 * those topics that have received no replies.1802 * @return int Forum topic count.1803 */1804 public static function get_global_forum_topic_count( $type ) {1805 global $bbdb, $wpdb;1806 1807 $bp = buddypress();1808 1809 if ( 'unreplied' == $type )1810 $bp->groups->filter_sql = ' AND t.topic_posts = 1';1811 1812 /**1813 * Filters the portion of the SQL related to global count of forum topics in public groups.1814 *1815 * See https://buddypress.trac.wordpress.org/ticket/4306.1816 *1817 * @since 1.6.01818 *1819 * @param string $filter_sql SQL portion for the query.1820 * @param string $type Type of forum topics to query for.1821 */1822 $extra_sql = apply_filters( 'get_global_forum_topic_count_extra_sql', $bp->groups->filter_sql, $type );1823 1824 // Make sure the $extra_sql begins with an AND.1825 if ( 'AND' != substr( trim( strtoupper( $extra_sql ) ), 0, 3 ) )1826 $extra_sql = ' AND ' . $extra_sql;1827 1828 return $wpdb->get_var( "SELECT COUNT(t.topic_id) FROM {$bbdb->topics} AS t, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND t.topic_status = '0' AND t.topic_sticky != '2' {$extra_sql} " );1829 }1830 1831 /**1832 1658 * Get the member count for a group. 1833 1659 * … … 1843 1669 1844 1670 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id ) ); 1845 }1846 1847 /**1848 * Get a total count of all topics of a given status, across groups/forums.1849 *1850 * @since 1.5.01851 *1852 * @param string $status Which group type to count. 'public', 'private',1853 * 'hidden', or 'all'. Default: 'public'.1854 * @param string|bool $search_terms Provided search terms.1855 * @return int The topic count1856 */1857 public static function get_global_topic_count( $status = 'public', $search_terms = false ) {1858 global $bbdb, $wpdb;1859 1860 switch ( $status ) {1861 case 'all' :1862 $status_sql = '';1863 break;1864 1865 case 'hidden' :1866 $status_sql = "AND g.status = 'hidden'";1867 break;1868 1869 case 'private' :1870 $status_sql = "AND g.status = 'private'";1871 break;1872 1873 case 'public' :1874 default :1875 $status_sql = "AND g.status = 'public'";1876 break;1877 }1878 1879 $bp = buddypress();1880 1881 $sql = array();1882 1883 $sql['select'] = "SELECT COUNT(t.topic_id)";1884 $sql['from'] = "FROM {$bbdb->topics} AS t INNER JOIN {$bp->groups->table_name_groupmeta} AS gm ON t.forum_id = gm.meta_value INNER JOIN {$bp->groups->table_name} AS g ON gm.group_id = g.id";1885 $sql['where'] = "WHERE gm.meta_key = 'forum_id' {$status_sql} AND t.topic_status = '0' AND t.topic_sticky != '2'";1886 1887 if ( !empty( $search_terms ) ) {1888 $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';1889 $sql['where'] .= $wpdb->prepare( " AND ( t.topic_title LIKE %s )", $search_terms_like );1890 }1891 1892 return $wpdb->get_var( implode( ' ', $sql ) );1893 1671 } 1894 1672 -
trunk/src/bp-templates/bp-legacy/buddypress/groups/create.php
r11591 r11763 194 194 <h4><?php _e( 'Group Forums', 'buddypress' ); ?></h4> 195 195 196 <?php if ( bp_forums_is_installed_correctly() ) : ?> 197 198 <p><?php _e( 'Should this group have a forum?', 'buddypress' ); ?></p> 199 200 <div class="checkbox"> 201 <label for="group-show-forum"><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php checked( bp_get_new_group_enable_forum(), true, true ); ?> /> <?php _e( 'Enable discussion forum', 'buddypress' ); ?></label> 202 </div> 203 <?php elseif ( is_super_admin() ) : ?> 204 205 <p><?php printf( __( '<strong>Attention Site Admin:</strong> Group forums require the <a href="%s">correct setup and configuration</a> of a bbPress installation.', 'buddypress' ), bp_core_do_network_admin() ? network_admin_url( 'settings.php?page=bb-forums-setup' ) : admin_url( 'admin.php?page=bb-forums-setup' ) ); ?></p> 206 207 <?php endif; ?> 196 <p><?php _e( 'Should this group have a forum?', 'buddypress' ); ?></p> 197 198 <div class="checkbox"> 199 <label for="group-show-forum"><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php checked( bp_get_new_group_enable_forum(), true, true ); ?> /> <?php _e( 'Enable discussion forum', 'buddypress' ); ?></label> 200 </div> 208 201 209 202 <?php endif; ?> -
trunk/src/bp-templates/bp-legacy/buddypress/groups/single/admin/group-settings.php
r11591 r11763 22 22 <?php if ( bp_is_active( 'forums' ) ) : ?> 23 23 24 <?php if ( bp_forums_is_installed_correctly() ) : ?> 24 <div class="checkbox"> 25 <label for="group-show-forum"><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php bp_group_show_forum_setting(); ?> /> <?php _e( 'Enable discussion forum', 'buddypress' ); ?></label> 26 </div> 25 27 26 <div class="checkbox"> 27 <label for="group-show-forum"><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php bp_group_show_forum_setting(); ?> /> <?php _e( 'Enable discussion forum', 'buddypress' ); ?></label> 28 </div> 29 30 <hr /> 31 32 <?php endif; ?> 28 <hr /> 33 29 34 30 <?php endif; ?> -
trunk/src/bp-templates/bp-legacy/buddypress/groups/single/home.php
r11128 r11763 120 120 elseif ( bp_is_group_invites() ) : bp_get_template_part( 'groups/single/send-invites' ); 121 121 122 // Old group forums123 elseif ( bp_is_group_forum() ) : bp_get_template_part( 'groups/single/forum' );124 125 122 // Membership request 126 123 elseif ( bp_is_group_membership_request() ) : bp_get_template_part( 'groups/single/request-membership' ); -
trunk/src/bp-templates/bp-legacy/buddypress/members/single/home.php
r11128 r11763 86 86 bp_get_template_part( 'members/single/profile' ); 87 87 88 elseif ( bp_is_user_forums() ) :89 bp_get_template_part( 'members/single/forums' );90 91 88 elseif ( bp_is_user_notifications() ) : 92 89 bp_get_template_part( 'members/single/notifications' ); -
trunk/src/bp-templates/bp-legacy/js/buddypress.js
r11619 r11763 13 13 /**** Page Load Actions *******************************************************/ 14 14 15 /* Hide Forums Post Form */16 if ( '-1' === window.location.search.indexOf('new') && jq('div.forums').length ) {17 jq('#new-topic-post').hide();18 } else {19 jq('#new-topic-post').show();20 }21 22 15 /* Activity filter and scope set */ 23 16 bp_init_activity(); 24 17 25 var objects = [ 'members', 'groups', 'blogs', ' forums', 'group_members' ],18 var objects = [ 'members', 'groups', 'blogs', 'group_members' ], 26 19 $whats_new = jq('#whats-new'); 27 20 … … 1045 1038 } 1046 1039 1047 });1048 1049 /**** New Forum Directory Post **************************************/1050 1051 /* Hit the "New Topic" button on the forums directory page */1052 jq('a.show-hide-new').on( 'click', function() {1053 if ( !jq('#new-topic-post').length ) {1054 return false;1055 }1056 1057 if ( jq('#new-topic-post').is(':visible') ) {1058 jq('#new-topic-post').slideUp(200);1059 } else {1060 jq('#new-topic-post').slideDown(200, function() {1061 jq('#topic_title').focus();1062 } );1063 }1064 1065 return false;1066 });1067 1068 /* Cancel the posting of a new forum topic */1069 jq('#submit_topic_cancel').on( 'click', function() {1070 if ( !jq('#new-topic-post').length ) {1071 return false;1072 }1073 1074 jq('#new-topic-post').slideUp(200);1075 return false;1076 });1077 1078 /* Clicking a forum tag */1079 jq('#forum-directory-tags a').on( 'click', function() {1080 bp_filter_request( 'forums', 'tags', jq.cookie('bp-forums-scope'), 'div.forums', jq(this).html().replace( / /g, '-' ), 1, jq.cookie('bp-forums-extras') );1081 return false;1082 1040 }); 1083 1041 -
trunk/src/class-buddypress.php
r11717 r11763 234 234 if ( ! defined( 'BP_PLUGIN_URL' ) ) { 235 235 define( 'BP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 236 } 237 238 // Legacy forum constant - supported for compatibility with bbPress 2. 239 if ( ! defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) { 240 define( 'BP_FORUMS_PARENT_FORUM_ID', 1 ); 241 } 242 243 // Legacy forum constant - supported for compatibility with bbPress 2. 244 if ( ! defined( 'BP_FORUMS_SLUG' ) ) { 245 define( 'BP_FORUMS_SLUG', 'forums' ); 236 246 } 237 247 -
trunk/src/readme.txt
r11745 r11763 1 1 === BuddyPress === 2 2 Contributors: johnjamesjacoby, DJPaul, boonebgorges, r-a-y, imath, mercime, tw2113, dcavins, hnla 3 Tags: social networking, activity, profiles, messaging, friends, groups, forums,notifications, settings, social, community, networks, networking3 Tags: social networking, activity, profiles, messaging, friends, groups, notifications, settings, social, community, networks, networking 4 4 Requires at least: 4.5 5 5 Tested up to: 4.9 -
trunk/tests/phpunit/testcases/admin/functions.php
r11737 r11763 84 84 $this->assertEquals( bp_core_admin_get_active_components_from_submitted_settings( $submitted2 ), array( 'activity' => 1, 'groups' => 1, 'members' => 1, 'messages' => 1, 'settings' => 1, 'xprofile' => 1 ) ); 85 85 86 // Activating from the Retired screen87 $_GET['action'] = 'retired';88 buddypress()->active_components = array(89 'activity' => 1,90 'members' => 1,91 'messages' => 1,92 'settings' => 1,93 'xprofile' => 1,94 );95 96 $submitted3 = array(97 'forums' => 1,98 );99 100 $this->assertEquals( bp_core_admin_get_active_components_from_submitted_settings( $submitted3 ), array( 'activity' => 1, 'forums' => 1, 'members' => 1, 'messages' => 1, 'settings' => 1, 'xprofile' => 1 ) );101 102 86 // Deactivating from the Retired screen 103 87 $_GET['action'] = 'retired'; 104 88 buddypress()->active_components = array( 105 89 'activity' => 1, 106 'forums' => 1,107 90 'members' => 1, 108 91 'messages' => 1,
Note: See TracChangeset
for help on using the changeset viewer.