--- trunk/lib/App/RoomReservation/Reservation.pm 2009/06/30 09:42:37 1118 +++ trunk/lib/App/RoomReservation/Reservation.pm 2009/07/01 22:25:11 1152 @@ -11,6 +11,8 @@ extends 'App::RoomReservation'; +with 'App::RoomReservation::Email', 'App::RoomReservation::Messages'; + use lib 'lib'; use Frey::PPI; @@ -81,23 +83,31 @@ default => sub { 0 }, ); +has _seat_number => ( + is => 'rw', + isa => 'Int', +); + 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( $email ); + my ($registred) = $sth->fetchrow_array; + 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) = @_; @@ -124,24 +134,12 @@ my $sth = $self->dbh->prepare( $sql ); $sth->execute( @vals ); - 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 -
- | - . qq|verify| - . ' or ' - . qq|cancel| - ; + return $self->send_confirmation_message( email => $self->email ); + } +__PACKAGE__->meta->make_immutable; +no Moose; +no Moose::Util::TypeConstraints; 1;