Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/21/2010 11:34:12 AM (16 years ago)
Author:
apeatling
Message:

Merging 1.2 branch with trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-signup.php

    r2925 r2946  
    5454                $bp->signup->email = $_POST['signup_email'];
    5555
    56                 if ( !empty( $_POST['signup_profile_field_ids'] ) && function_exists( 'xprofile_check_is_required_field' ) ) {
    57                         /* Now we've checked account details, we can check profile information */
    58                         $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
    59 
    60                         /* Loop through the posted fields formatting any datebox values then validate the field */
    61                         foreach ( (array) $profile_field_ids as $field_id ) {
    62                                 if ( !isset( $_POST['field_' . $field_id] ) ) {
    63                                         if ( isset( $_POST['field_' . $field_id . '_day'] ) )
    64                                                 $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
     56                /* Now we've checked account details, we can check profile information */
     57                if ( function_exists( 'xprofile_check_is_required_field' ) ) {
     58
     59                        /* Make sure hidden field is passed and populated */
     60                        if ( isset( $_POST['signup_profile_field_ids'] ) && !empty( $_POST['signup_profile_field_ids'] ) ) {
     61
     62                                /* Let's compact any profile field info into an array */
     63                                $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
     64
     65                                /* Loop through the posted fields formatting any datebox values then validate the field */
     66                                foreach ( (array) $profile_field_ids as $field_id ) {
     67                                        if ( !isset( $_POST['field_' . $field_id] ) ) {
     68                                                if ( isset( $_POST['field_' . $field_id . '_day'] ) )
     69                                                        $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
     70                                        }
     71
     72                                        /* Create errors for required fields without values */
     73                                        if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) )
     74                                                $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' );
    6575                                }
    6676
    67                                 if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) )
    68                                         $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' );
     77                        /* This situation doesn't naturally occur so bounce to website root */
     78                        } else {
     79                                bp_core_redirect( $bp->root_domain );
    6980                        }
    7081                }
    … …  
    252263
    253264        if ( empty( $user_name ) )
    254                 $errors->add( 'user_name', __( 'Please enter a username', 'buddypress' ) );
     265                $errors->add( 'user_name', __( 'Please enter a username', 'buddypress' ) );
    255266
    256267        $maybe = array();
    … …  
    260271        $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', BP_GROUPS_SLUG, $bp->members->slug, BP_FORUMS_SLUG, BP_BLOGS_SLUG, BP_REGISTER_SLUG, BP_ACTIVATION_SLUG ) );
    261272
    262         $illegal_names = array_merge( (array)$db_illegal_names, (array)$filtered_illegal_names );
     273        /* Safely merge our illegal names into existing site_option */
     274        $common_names                   = array_intersect( (array)$db_illegal_names, (array)$filtered_illegal_names );
     275        $diff_names                             = array_diff( (array)$db_illegal_names, (array)$filtered_illegal_names );
     276        $illegal_names                  = array_merge( (array)$diff_names, (array)$common_names );
     277
    263278        update_site_option( 'illegal_names', $illegal_names );
    264279
    … …  
    267282
    268283        if ( !validate_username( $user_name ) || $user_name != $maybe[0] )
    269             $errors->add( 'user_name', __( 'Only lowercase letters and numbers allowed', 'buddypress' ) );
     284                $errors->add( 'user_name', __( 'Only lowercase letters and numbers allowed', 'buddypress' ) );
    270285
    271286        if( strlen( $user_name ) < 4 )
    272             $errors->add( 'user_name',  __( 'Username must be at least 4 characters', 'buddypress' ) );
     287                $errors->add( 'user_name',  __( 'Username must be at least 4 characters', 'buddypress' ) );
    273288
    274289        if ( strpos( ' ' . $user_name, '_' ) != false )
    … …  
    385400
    386401function bp_core_activate_signup( $key ) {
    387         global $wpdb;
     402        global $bp, $wpdb;
    388403
    389404        $user = false;
    … …  
    558573
    559574        if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) )
    560                 wp_redirect( bp_get_root_domain() . '/' . BP_REGISTER_SLUG . '/' );
     575                bp_core_redirect( bp_get_root_domain() . '/' . BP_REGISTER_SLUG . '/' );
    561576}
    562577if ( bp_core_is_multisite() )
Note: See TracChangeset for help on using the changeset viewer.