/[Frey]/trunk/lib/App/RoomReservation/Reservation.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/App/RoomReservation/Reservation.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1095 by dpavlin, Sun Jun 28 18:51:49 2009 UTC revision 1098 by dpavlin, Sun Jun 28 22:14:22 2009 UTC
# Line 1  Line 1 
1  package App::RoomReservation::Reservation;  package App::RoomReservation::Reservation;
2  use Moose;  use Moose;
3    
4  extends 'Frey';  extends 'App::RoomReservation';
 with 'Frey::Web';  
5    
 use DBI;  
6  use lib 'lib';  use lib 'lib';
7  use Frey::PPI;  use Frey::PPI;
8    
# Line 75  has _confirmed => ( Line 73  has _confirmed => (
73          default => sub { 0 },          default => sub { 0 },
74  );  );
75    
 sub dsn { 'DBI:Pg:dbname=room-reservation' }  
   
76  my @cols = Frey::PPI->new( class => __PACKAGE__ )->attribute_order;  my @cols = Frey::PPI->new( class => __PACKAGE__ )->attribute_order;
77  warn "# cols = ",join(',', @cols), $/;  warn "# cols = ",join(',', @cols), $/;
78    
79    sub token {
80            my ( $self ) = @_;
81            my $self = shift;
82            my $sth = $self->dbh->prepare(qq{
83                    select md5( id || email ) from reservation where email = ?
84            });
85            $sth->execute( $self->email );
86            $sth->fetchrow_array;
87    }
88    
89  sub create_as_markup {  sub create_as_markup {
90          my ($self) = @_;          my ($self) = @_;
91    
         my $dbh = DBI->connect( $self->dsn, '', '', { RaiseError => 1 } ) || die $DBI::errstr;  
         $dbh->do( qq{ set client_encoding='utf-8' } ) if $self->dsn =~ m{pg}i;  
   
92          my @vals;          my @vals;
93          my @p;          my @p;
94    
# Line 106  sub create_as_markup { Line 109  sub create_as_markup {
109    
110          warn "sql: $sql\n";          warn "sql: $sql\n";
111    
112          my $sth = $dbh->prepare( $sql );          my $sth = $self->dbh->prepare( $sql );
113          $sth->execute( @vals );          $sth->execute( @vals );
114    
115          $sth->rows;          return
116                    $self->ime . ' ' . $self->prezime
117                    . qq| we have accepted your registration!|
118                    . qq|
119                            <div style="color:red">
120                            You have to confirm your e-mail address and registration
121                            by clicking on link which should be in your e-mail INBOX shortly
122                            </div>
123                    |
124                    . qq|<a href="/App::RoomReservation::Reservation::Confirmation/verify_as_markup?token=|
125                    . $self->token
126                    . qq|">verify</a>|
127                    . ' or '
128                    . qq|<a href="/App::RoomReservation::Reservation::Confirmation/cancel_as_markup?token=|
129                    . $self->token
130                    . qq|">cancel</a>|
131                    ;
132  }  }
133    
134    
135  1;  1;

Legend:
Removed from v.1095  
changed lines
  Added in v.1098

  ViewVC Help
Powered by ViewVC 1.1.26