diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 6a36f81a96a..4523916d854 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -91,7 +91,8 @@ if ($_POST["action"] == 'add' && $user->admin) $action="create"; // Go back to create page } - if (! $message) { + if (! $message) + { $edituser = new User($db,0); $edituser->nom = trim($_POST["nom"]); @@ -184,7 +185,7 @@ if ($_POST["action"] == 'update' && $user->admin) // Si une photo est fournie avec le formulaire if (! is_dir($conf->users->dir_output)) { - mkdir($conf->users->dir_output); + create_exdir($conf->users->dir_output); } if (is_dir($conf->users->dir_output)) { $newfile=$conf->users->dir_output . "/" . $edituser->id . ".jpg"; @@ -204,14 +205,30 @@ if ($_POST["action"] == 'update' && $user->admin) } -if ($_GET["action"] == 'password' && $user->admin) +if (($_GET["action"] == 'password' || $_GET["action"] == 'passwordsend') && $user->admin) { $edituser = new User($db, $_GET["id"]); $edituser->fetch(); - if ($edituser->password($user,'',$conf->password_encrypted)) + $newpassword=$edituser->password($user,'',$conf->password_encrypted); + if ($newpassword < 0) { - $message = '
'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'
'; + // Echec + $message = '
'.$langs->trans("ErrorFailedToSaveFile").'
'; + } + else + { + // Succes + if ($_GET["action"] == 'passwordsend') + { + $edituser->send_password($user,$newpassword); + $message = '
'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'
'; + //$message.=$newpassword; + } + else + { + $message = '
'.$langs->trans("PasswordChangedTo",$newpassword).'
'; + } } } @@ -428,22 +445,27 @@ else if ($user->admin) { - print ''.$langs->trans("Edit").''; + print ''.$langs->trans("Edit").''; } if ($user->id == $_GET["id"] or $user->admin) { - print ''.$langs->trans("SendNewPassword").''; + print ''.$langs->trans("ReinitPassword").''; + } + + if ($user->id == $_GET["id"] or $user->admin && $fuser->email) + { + print ''.$langs->trans("SendNewPassword").''; } if ($user->id <> $_GET["id"] && $user->admin) { - print ''.$langs->trans("DisableUser").''; + print ''.$langs->trans("DisableUser").''; } if ($user->id <> $_GET["id"] && $user->admin) { - print ''.$langs->trans("DeleteUser").''; + print ''.$langs->trans("DeleteUser").''; } print "\n";