00001 <?php
00002
00003
00004
00005
00006
00007
00008 class ChangepasswordConfirmationHandler extends ConfirmationHandlerBase {
00009
00010
00011
00012
00013
00014
00015
00016
00017 protected function do_confirm($confirmation, $success) {
00018 if ($success == self::SUCCESS) {
00019 $user = Users::get($confirmation->id_item);
00020 if ($user && $user->is_active()) {
00021 $cmd = CommandsFactory::create_command($user, 'confirmpassword', $confirmation->data);
00022 $ret = $cmd->execute();
00023 if ($ret->is_ok()) {
00024 return new Message(tr('Your password has been changed', 'users'));
00025 } else {
00026 return $ret;
00027 }
00028 }
00029 else {
00030 return new Status(tr('No matching user account was found', 'users'));
00031 }
00032 }
00033 else {
00034 return parent::do_confirm($confirmation, $success);
00035 }
00036 }
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 protected function do_created($confirmation) {
00048 $ret = new Status();
00049
00050 $user = Users::get($confirmation->id_item);
00051 if ($user) {
00052 Load::commands('generics/mail');
00053 $cmd = new MailCommand(
00054 tr('Confirm new password', 'users'),
00055 $user->email,
00056 'users/mail/changepwd',
00057 array('confirmation' => $confirmation)
00058 );
00059 $ret->merge($cmd->execute());
00060 }
00061 else {
00062 $ret->append(tr('Unkown User set on email change confirmation', 'users'));
00063 }
00064
00065 return $ret;
00066 }
00067 }