summaryrefslogtreecommitdiff
path: root/modules/user.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-02-09 07:43:43 +0000
committerDries Buytaert <dries@buytaert.net>2006-02-09 07:43:43 +0000
commitb28f48dc480e234d91257e3886f42de56b9d2097 (patch)
treee863ad07610d7d213b936ddc759508c8177928f1 /modules/user.module
parentda1d11935d3e25ce78af5b3621d36bc5422afb50 (diff)
downloadbrdo-b28f48dc480e234d91257e3886f42de56b9d2097.tar.gz
brdo-b28f48dc480e234d91257e3886f42de56b9d2097.tar.bz2
- Patch #44290 by Steve Dondley: fixed problem with user picture getting deleted after editing user account.
Diffstat (limited to 'modules/user.module')
-rw-r--r--modules/user.module20
1 files changed, 11 insertions, 9 deletions
diff --git a/modules/user.module b/modules/user.module
index 8c3173c73..db35fd027 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -256,24 +256,24 @@ function user_validate_picture($file, &$edit, $user) {
list($maxwidth, $maxheight) = explode('x', variable_get('user_picture_dimensions', '85x85'));
if (!$info || !$info['extension']) {
- form_set_error('picture', t('The uploaded file was not an image.'));
+ form_set_error('picture_upload', t('The uploaded file was not an image.'));
}
else if (image_get_toolkit()) {
image_scale($file->filepath, $file->filepath, $maxwidth, $maxheight);
}
else if (filesize($file->filepath) > (variable_get('user_picture_file_size', '30') * 1000)) {
- form_set_error('picture', t('The uploaded image is too large; the maximum file size is %size kB.', array('%size' => variable_get('user_picture_file_size', '30'))));
+ form_set_error('picture_upload', t('The uploaded image is too large; the maximum file size is %size kB.', array('%size' => variable_get('user_picture_file_size', '30'))));
}
else if ($info['width'] > $maxwidth || $info['height'] > $maxheight) {
- form_set_error('picture', t('The uploaded image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'))));
+ form_set_error('picture_upload', t('The uploaded image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'))));
}
if (!form_get_errors()) {
- if ($file = file_save_upload('picture', variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid . '.' . $info['extension'], 1)) {
+ if ($file = file_save_upload('picture_upload', variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid . '.' . $info['extension'], 1)) {
$form_values['picture'] = $file->filepath;
}
else {
- form_set_error('picture', t("Failed to upload the picture image; the %directory directory doesn't exist.", array('%directory' => '<em>'. variable_get('user_picture_path', 'pictures') .'</em>')));
+ form_set_error('picture_upload', t("Failed to upload the picture image; the %directory directory doesn't exist.", array('%directory' => '<em>'. variable_get('user_picture_path', 'pictures') .'</em>')));
}
}
}
@@ -472,7 +472,6 @@ function user_user($type, &$edit, &$user, $category = NULL) {
return array(t('History') => $items);
}
-
if ($type == 'form' && $category == 'account') {
return user_edit_form(arg(1), $edit);
}
@@ -1207,11 +1206,14 @@ function user_edit_form($uid, $edit) {
// Picture/avatar:
if (variable_get('user_pictures', 0)) {
$form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1);
- if ($edit['picture'] && ($picture = theme('user_picture', (object)$edit))) {
+ $picture = theme('user_picture', (object)$edit);
+ if ($picture) {
$form['picture']['current_picture'] = array('#type' => 'markup', '#value' => $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'] = 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']['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', ''));
}
return $form;
@@ -1244,7 +1246,7 @@ function _user_edit_validate($uid, &$edit) {
}
// If required, validate the uploaded picture.
- if ($file = file_check_upload('picture')) {
+ if ($file = file_check_upload('picture_upload')) {
user_validate_picture($file, $edit, $user);
}
}