Index: resizer.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/resizer/resizer.module,v
retrieving revision 1.1
diff -u -r1.1 resizer.module
--- resizer.module 13 Sep 2007 12:07:15 -0000 1.1
+++ resizer.module 9 Feb 2009 20:21:23 -0000
@@ -18,12 +18,18 @@
$pic = $_POST['tmp_picture'];
$picname = $_POST['tmp_picture_name'];
$newpic = $_POST['newImage'];
- if(isset($_POST['step'])) {
+ if ($edit['picture_delete']) {
+ $step = 3;
+ }
+ else if(isset($_POST['step'])) {
$step = $_POST['step'] + 1;
- } else {
+ }
+ else {
$step = 1;
}
- $form['avatar'] = array(
+
+
+ $form['avatar'] = array(
'#type' => 'fieldset',
);
@@ -43,6 +49,10 @@
'#value' => theme('user_picture', $account),
'#prefix' => '
'.t('Your current picture').'
',
);
+ $form['avatar']['picture_delete'] = array(
+ '#type' => 'checkbox',
+ '#title' => 'Delete this picture',
+ );
$form['avatar']['picture_upload'] = array(
'#type' => 'file',
'#title' => t('Upload a new picture'),
@@ -111,7 +121,11 @@
$form['#redirect'] = array(
'user',
'destnation=node'
- );
+ );
+ case 4:
+ $form['#redirect'] = array(
+ 'user/'.$account->uid.'/edit/avatar'
+ );
}
return $form;
@@ -125,7 +139,15 @@
if($op == 'submit' && $category == 'avatar') {
//submit code here, then
$step = $_POST['step'];
- resizer_submit_user_picture($edit, $account, $form, $step);
+ if ($_POST['picture_delete']) {
+ if ($account->picture && file_exists($account->picture)) {
+ file_delete($account->picture);
+ }
+ $edit['picture'] = '';
+ }
+ else {
+ resizer_submit_user_picture($edit, $account, $form, $step);
+ }
}
}
@@ -199,26 +221,23 @@
global $form_values;
switch($step) {
case 1:
- if ($file = file_check_upload('picture_upload')) {
+ if ((!$edit['picture_delete']) && ($file = file_check_upload('picture_upload'))) {
resizer_validate_picture($file,$form);
}
break;
case 2:
break;
-
}
}
function avatar_form_validate($form_id, $form_values,$form) {
-
switch($form_values['step']) {
case 1:
if ($file = file_check_upload('picture_upload')) {
resizer_validate_picture($file,$form);
}
break;
-
}
}