? modules/simpletest/tests/343502.test Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.944 diff -u -p -r1.944 user.module --- modules/user/user.module 29 Nov 2008 09:33:51 -0000 1.944 +++ modules/user/user.module 7 Dec 2008 02:02:48 -0000 @@ -1517,16 +1517,28 @@ function user_edit_form(&$form_state, $u // Picture/avatar: if (variable_get('user_pictures', 0) && !$register) { - $form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1); $picture = theme('user_picture', (object)$edit); - if ($edit['picture']) { - $form['picture']['current_picture'] = array('#markup' => $picture); - $form['picture']['picture_delete'] = array('#type' => 'checkbox', '#title' => t('Delete picture'), '#description' => t('Check this box to delete your current picture.')); - } - else { - $form['picture']['picture_delete'] = array('#type' => 'hidden'); - } - $form['picture']['picture_upload'] = array('#type' => 'file', '#title' => t('Upload picture'), '#size' => 48, '#description' => t('Your virtual face or picture. Maximum dimensions are %dimensions and the maximum size is %size kB.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'), '%size' => variable_get('user_picture_file_size', '30'))) . ' ' . variable_get('user_picture_guidelines', '')); + $form['picture'] = array( + '#type' => 'fieldset', + '#title' => t('Picture'), + '#weight' => 1, + ); + $form['picture']['current_picture'] = array( + '#markup' => $picture, + '#access' => $edit['picture'], + ); + $form['picture']['picture_delete'] = array( + '#type' => 'checkbox', + '#title' => t('Delete picture'), + '#description' => t('Check this box to delete your current picture.'), + '#access' => $edit['picture'], + ); + $form['picture']['picture_upload'] = array( + '#type' => 'file', + '#title' => t('Upload picture'), + '#size' => 48, + '#description' => t('Your virtual face or picture. Maximum dimensions are %dimensions and the maximum size is %size kB.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'), '%size' => variable_get('user_picture_file_size', '30'))) . ' ' . variable_get('user_picture_guidelines', ''), + ); $form['#validate'][] = 'user_validate_picture'; } $form['#uid'] = $uid; @@ -1557,13 +1569,21 @@ function _user_edit_validate($uid, &$edi function _user_edit_submit($uid, &$edit) { $user = user_load(array('uid' => $uid)); - // Delete picture if requested, and if no replacement picture was given. - if (!empty($edit['picture_delete'])) { - if ($user->picture && file_exists($user->picture)) { - file_unmanaged_delete($user->picture); + + if (isset($edit['picture_delete'])) { + // Delete picture if requested, and if no replacement picture was given. + if ($edit['picture_delete']) { + if ($user->picture && file_exists($user->picture)) { + file_unmanaged_delete($user->picture); + } + $edit['picture'] = ''; } - $edit['picture'] = ''; + + // Unset these values so they are not saved into $user->data. + $edit['picture_delete'] = NULL; + $edit['picture_upload'] = NULL; } + if (isset($edit['roles'])) { $edit['roles'] = array_filter($edit['roles']); } @@ -2418,4 +2438,3 @@ function _user_forms(&$edit, $account, $ return empty($groups) ? FALSE : $groups; } -