--- trunk/lib/App/RoomReservation/Reservation.pm 2009/07/01 17:35:48 1147 +++ trunk/lib/App/RoomReservation/Reservation.pm 2009/07/01 22:25:11 1152 @@ -11,7 +11,7 @@ extends 'App::RoomReservation'; -with 'App::RoomReservation::Email'; +with 'App::RoomReservation::Email', 'App::RoomReservation::Messages'; use lib 'lib'; use Frey::PPI; @@ -90,27 +90,24 @@ sub BUILD { my $self = shift; - die "e-mail not verified\n" unless $self->email eq $self->email_verify; + my $email = $self->email; + die "e-mail not verified\n" unless $email eq $self->email_verify; my $sth = $self->dbh->prepare(qq{ select count(*) from reservation where email = ? }); - $sth->execute( $self->email ); + $sth->execute( $email ); my ($registred) = $sth->fetchrow_array; - die "e-mail address ", $self->email, " allready registred\n" if $registred; + if ( $registred ) { + die qq| + e-mail address $email allready registred + | . $self->seat_confirmation_message( email => $email ) + ; + } } my @cols = Frey::PPI->new( class => __PACKAGE__ )->attribute_order; warn "# cols = ",join(',', @cols), $/; -sub token { - my $self = shift; - my $sth = $self->dbh->prepare(qq{ - select md5( id || email ) from reservation where email = ? - }); - $sth->execute( $self->email ); - $sth->fetchrow_array; -} - sub create_as_markup { my ($self) = @_; @@ -137,27 +134,8 @@ my $sth = $self->dbh->prepare( $sql ); $sth->execute( @vals ); - my $url = $self->url_for( 'Confirmation/verify_as_markup?token=' . $self->token ); + return $self->send_confirmation_message( email => $self->email ); - $self->send( $self->email, - 'Confirm your reservation for lecture', <<__EMAIL__ -Please click following link to confirm your reservation for lecture -and get seat assigned to you. - -$url -__EMAIL__ - ); - - return - $self->ime . ' ' . $self->prezime - . qq| we have accepted your registration!| - . qq| -
- You have to confirm your e-mail address and registration - by clicking on link which should be in your e-mail INBOX shortly -
- | - ; } __PACKAGE__->meta->make_immutable;