Skip to:
Content

BuddyPress.org

Changeset 6


Ignore:
Timestamp:
04/01/2008 10:55:22 PM (17 years ago)
Author:
apeatling
Message:

Andy P: fixed validation on radio button fields that don't post a value and are required

Location:
trunk
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp_default_theme

    • Property eol-style:native set to bp_core.php
  • trunk/bp_default_theme/archive.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/archives.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/attachment.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/blog.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/comments-popup.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/comments.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/footer.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/functions.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/header.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/images

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/index.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/links.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/page.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/rtl.css

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/screenshot.png

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/search.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/searchform.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/sidebar.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/single.php

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/style.css

    • Property eol-style:native set to 404.php
  • trunk/bp_default_theme/tweaked_style.css

    • Property eol-style:native set to 404.php
  • trunk/bp_friends.php

    • Property eol-style:native set to bp_core.php
  • trunk/bp_groups

    • Property eol-style:native set to bp_core.php
  • trunk/bp_groups.php

    • Property eol-style:native set to bp_core.php
  • trunk/bp_messages

    • Property eol-style:native set to bp_core.php
  • trunk/bp_messages.php

    • Property eol-style:native set to bp_core.php
  • trunk/bp_xprofile

    • Property eol-style:native set to bp_core.php
  • trunk/bp_xprofile.php

    • Property eol-style:native set to bp_core.php
    r5 r6  
    218218
    219219        <?php
    220        
     220           
    221221            if($group->fields)
    222222            {
     
    227227                {   
    228228                    $field = new BP_XProfile_Field($group->fields[$j]->id);
     229                    $field_ids[] = $group->fields[$j]->id;
    229230                   
    230231                    if(isset($_GET['mode']) && $_GET['mode'] == "save")
    231232                    {
    232233                        $post_field_string = ( $group->fields[$j]->type == 'datebox' ) ? '_day' : null;
    233                         $current_field = $_POST['field_' . $group->fields[$j]->id . $post_field_string];
    234                    
    235                         if(isset($current_field) /*&& ($field->data->value != $current_field)*/)
     234                        $posted_fields = explode(",", $_POST['field_ids']);
     235                        $current_field = $_POST['field_' . $posted_fields[$j] . $post_field_string];
     236
     237                        if(($field->is_required && !isset($current_field)) ||
     238                           ($field->is_required && $current_field == ''))
    236239                        {
    237                             if($field->is_required && $current_field == '')
     240                            // Validate the field.
     241                            $field->message = __($field->name . ' cannot be left blank.');
     242                            $errors[] = $field->message . "<br />";
     243                        }
     244                        else if(!$field->is_required && $current_field == '')
     245                        {
     246                            // data removed, so delete the field data from the DB.                             
     247                            $profile_data = new BP_Xprofile_ProfileData($group->fields[$j]->id);
     248                            $profile_data->delete();
     249                            $field->data->value = null;
     250                        }
     251                        else
     252                        {
     253                            // Field validates, save.
     254                            $profile_data = new BP_Xprofile_ProfileData;
     255                            $profile_data->field_id = $group->fields[$j]->id;
     256                            $profile_data->user_id = $userdata->ID;
     257                            $profile_data->last_updated = time();
     258
     259                            if($post_field_string != null)
    238260                            {
    239                                 // Validate the field.
    240                                 $field->message = __($field->name . ' cannot be left blank.');
    241                                 $errors[] = $field->message . "<br />";
     261                                $date_value = $_POST['field_' . $group->fields[$j]->id . '_day'] .
     262                                              $_POST['field_' . $group->fields[$j]->id . '_month'] .
     263                                              $_POST['field_' . $group->fields[$j]->id . '_year'];
     264
     265                                $profile_data->value = strtotime($date_value);
    242266                            }
    243                             else if(!$field->is_required && $current_field == '')
     267                            else
    244268                            {
    245                                 // data removed, so delete the field data from the DB.                             
    246                                 $profile_data = new BP_Xprofile_ProfileData($group->fields[$j]->id);
    247                                 $profile_data->delete();
    248                                 $field->data->value = null;
     269                                $profile_data->value = $current_field;
     270                            }
     271
     272                            if(!$profile_data->save())
     273                            {
     274                                $field->message = __('There was a problem saving changes to this field, please try again.');
    249275                            }
    250276                            else
    251277                            {
    252                                 // Field validates, save.
    253                                 $profile_data = new BP_Xprofile_ProfileData;
    254                                 $profile_data->field_id = $group->fields[$j]->id;
    255                                 $profile_data->user_id = $userdata->ID;
    256                                 $profile_data->last_updated = time();
    257 
    258                                 if($post_field_string != null)
    259                                 {
    260                                     $date_value = $_POST['field_' . $group->fields[$j]->id . '_day'] .
    261                                                   $_POST['field_' . $group->fields[$j]->id . '_month'] .
    262                                                   $_POST['field_' . $group->fields[$j]->id . '_year'];
    263 
    264                                     $profile_data->value = strtotime($date_value);
    265                                 }
    266                                 else
    267                                 {
    268                                     $profile_data->value = $current_field;
    269                                 }
    270 
    271                                 if(!$profile_data->save())
    272                                 {
    273                                     $field->message = __('There was a problem saving changes to this field, please try again.');
    274                                 }
    275                                 else
    276                                 {
    277                                     $field->data->value = $profile_data->value;
    278                                 }
     278                                $field->data->value = $profile_data->value;
    279279                            }
    280280                        }
     
    322322
    323323        <form action="admin.php?page=<?php echo $_GET['page'] ?>&amp;mode=save" method="post">
    324 
     324        <?php $field_ids = implode(",", $field_ids); ?>
     325        <input type="hidden" name="field_ids" id="field_ids" value="<?php echo $field_ids; ?>" />
     326       
    325327        <?php echo $list_html; ?>
    326328
  • trunk/bp_xprofile/bp_xprofile.classes.php

    • Property eol-style:native set to bp_xprofile.admin.php
    r5 r6  
    611611    {
    612612        $options = $this->get_children();
     613
    613614    ?>
    614615   
     
    616617       
    617618        <h2><?php _e("Profile Settings") ?> &raquo; <?php _e('Add Field') ?></h2>
    618                    
    619         <p>You are adding a new field to the group "<?php echo $this->name; ?>".</p>
    620619
    621620        <?php if($message != '') { ?>
  • trunk/bp_xprofile/bp_xprofile.cssjs.php

    • Property eol-style:native set to bp_xprofile.admin.php
  • trunk/bp_xprofile/bp_xprofile.setup.php

    • Property eol-style:native set to bp_xprofile.admin.php
  • trunk/bp_xprofile/bp_xprofile.signup.php

    • Property eol-style:native set to bp_xprofile.admin.php
  • trunk/bp_xprofile/images

    • Property eol-style:native set to bp_xprofile.admin.php
Note: See TracChangeset for help on using the changeset viewer.