00001 <?php
00002
00003
00004
00005
00006
00007
00008 class CreateaccountConfirmationHandler 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) {
00021 $cmd = CommandsFactory::create_command($user, 'status', Users::STATUS_ACTIVE);
00022 $ret = $cmd->execute();
00023 $ret->merge(Users::confirm_email($user));
00024 if ($ret->is_ok()) {
00025 return new Message(tr('Your registration has been confirmed', 'users'));
00026 }
00027 else {
00028 return $ret;
00029 }
00030 }
00031 else {
00032 return new Status(tr('No matching user account was found', 'users'));
00033 }
00034 }
00035 else {
00036 return parent::do_confirm($confirmation, $success);
00037 }
00038 }
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 protected function do_created($confirmation) {
00049 $ret = new Status();
00050
00051 $user = Users::get($confirmation->id_item);
00052 if ($user) {
00053 Load::commands('generics/mail');
00054 $cmd = new MailCommand(
00055 tr('Your registration', 'users'),
00056 $user->email,
00057 'users/mail/register',
00058 array(
00059 'confirmation' => $confirmation,
00060 'user' => $user
00061 )
00062 );
00063 $ret->merge($cmd->execute());
00064 }
00065 else {
00066 $ret->append(tr('Unkown User set on register confirmation', 'users'));
00067 }
00068
00069 return $ret;
00070 }
00071 }