Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/23/2012 06:01:28 PM (13 years ago)
Author:
boonebgorges
Message:

Introduces template function bp_get_groups_current_create_step() to avoid direct calls to the bp global.
Replaces calls to bp->groups->current_create_step with bp_get_groups_current_create_step() throughout BP.
Adds current create step to body classes during group creation process. See #4095

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-actions.php

    r5729 r5941  
    3535    // If no current step is set, reset everything so we can start a fresh group creation
    3636    $bp->groups->current_create_step = bp_action_variable( 1 );
    37     if ( !$bp->groups->current_create_step ) {
     37    if ( !bp_get_groups_current_create_step() ) {
    3838        unset( $bp->groups->current_create_step );
    3939        unset( $bp->groups->completed_create_steps );
     
    4747
    4848    // If this is a creation step that is not recognized, just redirect them back to the first screen
    49     if ( !empty( $bp->groups->current_create_step ) && empty( $bp->groups->group_creation_steps[$bp->groups->current_create_step] ) ) {
     49    if ( bp_get_groups_current_create_step() && empty( $bp->groups->group_creation_steps[bp_get_groups_current_create_step()] ) ) {
    5050        bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' );
    5151        bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/' );
     
    6666
    6767        // Check the nonce
    68         check_admin_referer( 'groups_create_save_' . $bp->groups->current_create_step );
    69 
    70         if ( 'group-details' == $bp->groups->current_create_step ) {
     68        check_admin_referer( 'groups_create_save_' . bp_get_groups_current_create_step() );
     69
     70        if ( 'group-details' == bp_get_groups_current_create_step() ) {
    7171            if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) || !strlen( trim( $_POST['group-name'] ) ) || !strlen( trim( $_POST['group-desc'] ) ) ) {
    7272                bp_core_add_message( __( 'Please fill in all of the required fields', 'buddypress' ), 'error' );
    73                 bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . $bp->groups->current_create_step . '/' );
     73                bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/' );
    7474            }
    7575
     
    7878            if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug( sanitize_title( esc_attr( $_POST['group-name'] ) ) ), 'date_created' => bp_core_current_time(), 'status' => 'public' ) ) ) {
    7979                bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
    80                 bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . $bp->groups->current_create_step . '/' );
     80                bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/' );
    8181            }
    8282
     
    8585        }
    8686
    87         if ( 'group-settings' == $bp->groups->current_create_step ) {
     87        if ( 'group-settings' == bp_get_groups_current_create_step() ) {
    8888            $group_status = 'public';
    8989            $group_enable_forum = 1;
     
    105105            if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_forum' => $group_enable_forum ) ) ) {
    106106                bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
    107                 bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . $bp->groups->current_create_step . '/' );
     107                bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/' );
    108108            }
    109109
     
    116116        }
    117117
    118         if ( 'group-invites' == $bp->groups->current_create_step )
     118        if ( 'group-invites' == bp_get_groups_current_create_step() )
    119119            groups_send_invites( bp_loggedin_user_id(), $bp->groups->new_group_id );
    120120
    121         do_action( 'groups_create_group_step_save_' . $bp->groups->current_create_step );
     121        do_action( 'groups_create_group_step_save_' . bp_get_groups_current_create_step() );
    122122        do_action( 'groups_create_group_step_complete' ); // Mostly for clearing cache on a generic action name
    123123
     
    128128         */
    129129        $completed_create_steps = isset( $bp->groups->completed_create_steps ) ? $bp->groups->completed_create_steps : array();
    130         if ( !in_array( $bp->groups->current_create_step, $completed_create_steps ) )
    131             $bp->groups->completed_create_steps[] = $bp->groups->current_create_step;
     130        if ( !in_array( bp_get_groups_current_create_step(), $completed_create_steps ) )
     131            $bp->groups->completed_create_steps[] = bp_get_groups_current_create_step();
    132132
    133133        // Reset cookie info
     
    137137        // If we have completed all steps and hit done on the final step we
    138138        // can redirect to the completed group
    139         if ( count( $bp->groups->completed_create_steps ) == count( $bp->groups->group_creation_steps ) && $bp->groups->current_create_step == array_pop( array_keys( $bp->groups->group_creation_steps ) ) ) {
     139        if ( count( $bp->groups->completed_create_steps ) == count( $bp->groups->group_creation_steps ) && bp_get_groups_current_create_step() == array_pop( array_keys( $bp->groups->group_creation_steps ) ) ) {
    140140            unset( $bp->groups->current_create_step );
    141141            unset( $bp->groups->completed_create_steps );
     
    157157             */
    158158            foreach ( (array) $bp->groups->group_creation_steps as $key => $value ) {
    159                 if ( $key == $bp->groups->current_create_step ) {
     159                if ( $key == bp_get_groups_current_create_step() ) {
    160160                    $next = 1;
    161161                    continue;
     
    173173
    174174    // Group avatar is handled separately
    175     if ( 'group-avatar' == $bp->groups->current_create_step && isset( $_POST['upload'] ) ) {
     175    if ( 'group-avatar' == bp_get_groups_current_create_step() && isset( $_POST['upload'] ) ) {
    176176        if ( !empty( $_FILES ) && isset( $_POST['upload'] ) ) {
    177177            // Normally we would check a nonce here, but the group save nonce is used instead
Note: See TracChangeset for help on using the changeset viewer.