Skip to:
Content

BuddyPress.org

Changeset 4232


Ignore:
Timestamp:
04/22/2011 02:51:12 PM (14 years ago)
Author:
djpaul
Message:

Fix logic when posting a topic from the forum directory, so that validation errors are shown. Show post form automatically if form validation failed.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums/bp-forums-screens.php

    r4137 r4232  
    2121            check_admin_referer( 'bp_forums_new_topic' );
    2222
    23             if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
     23            $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) );
     24            if ( !empty( $bp->groups->current_group->id ) ) {
    2425                // Auto join this user if they are not yet a member of this group
    2526                if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
     
    2728
    2829                $error_message = '';
    29                 if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) {
     30
     31                $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' );
     32                if ( !empty( $forum_id ) ) {
    3033                    if ( empty( $_POST['topic_title'] ) )
    3134                        $error_message = __( 'Please provide a title for your forum topic.', 'buddypress' );
     
    5053                } else {
    5154                    bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );
     55                    bp_core_redirect( add_query_arg( 'new', '', bp_get_forum_directory_permalink() ) );
    5256                }
     57
     58            }    else {
     59                bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );
     60                bp_core_redirect( add_query_arg( 'new', '', bp_get_forum_directory_permalink() ) );
    5361            }
    5462        }
  • trunk/bp-themes/bp-default/_inc/global.js

    r4218 r4232  
    99
    1010    /* Hide Forums Post Form */
    11     if ( jq('div.forums').length )
     11    if ( '-1' == window.location.search.indexOf('new') && jq('div.forums').length )
    1212        jq('div#new-topic-post').hide();
     13    else
     14        jq('div#new-topic-post').show();
    1315
    1416    /* Activity filter and scope set */
  • trunk/bp-themes/bp-default/forums/index.php

    r4009 r4232  
    8888            <?php do_action( 'bp_before_new_topic_form' ); ?>
    8989
    90             <div id="new-topic-post" style="display: none;">
     90            <div id="new-topic-post">
    9191
    9292                <?php if ( is_user_logged_in() ) : ?>
     
    100100                            <a name="post-new"></a>
    101101                            <h5><?php _e( 'Create New Topic:', 'buddypress' ); ?></h5>
     102
     103                            <?php do_action( 'template_notices' ); ?>
    102104
    103105                            <label><?php _e( 'Title:', 'buddypress' ); ?></label>
Note: See TracChangeset for help on using the changeset viewer.