/[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 1086 by dpavlin, Sun Jun 28 14:21:10 2009 UTC revision 1104 by dpavlin, Mon Jun 29 12:11:14 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';
5  with 'Frey::Web';  
6  #with 'Frey::Storage';  use lib 'lib';
7    use Frey::PPI;
8    
9  has ime => (  has ime => (
10          is => 'rw',          is => 'rw',
# Line 72  has _confirmed => ( Line 73  has _confirmed => (
73          default => sub { 0 },          default => sub { 0 },
74  );  );
75    
76  sub as_markup {  sub BUILD {
77            my $self = shift;
78            die "e-mail not verified\n" unless $self->email eq $self->email_verify;
79    }
80    
81    my @cols = Frey::PPI->new( class => __PACKAGE__ )->attribute_order;
82    warn "# cols = ",join(',', @cols), $/;
83    
84    sub token {
85            my ( $self ) = @_;
86            my $self = shift;
87            my $sth = $self->dbh->prepare(qq{
88                    select md5( id || email ) from reservation where email = ?
89            });
90            $sth->execute( $self->email );
91            $sth->fetchrow_array;
92    }
93    
94    sub create_as_markup {
95          my ($self) = @_;          my ($self) = @_;
96    
97          $self->ime;          my @vals;
98            my @p;
99    
100            map {
101                    push @vals, $self->$_;
102                    push @p, '?';
103            } @cols;
104    
105            my $n = $#cols + 1;
106    
107            my $sql
108                    = 'insert into reservation ('
109                    . join(',', @cols)
110                    . ') values ('
111                    . join(',', map { '?' } @cols )
112                    . ')'
113                    ;
114    
115            warn "sql: $sql\n";
116    
117            my $sth = $self->dbh->prepare( $sql );
118            $sth->execute( @vals );
119    
120            return
121                    $self->ime . ' ' . $self->prezime
122                    . qq| we have accepted your registration!|
123                    . qq|
124                            <div style="color:red">
125                            You have to confirm your e-mail address and registration
126                            by clicking on link which should be in your e-mail INBOX shortly
127                            </div>
128                    |
129                    . qq|<a href="/App::RoomReservation::Reservation::Confirmation/verify_as_markup?token=|
130                    . $self->token
131                    . qq|">verify</a>|
132                    . ' or '
133                    . qq|<a href="/App::RoomReservation::Reservation::Confirmation/cancel_as_markup?token=|
134                    . $self->token
135                    . qq|">cancel</a>|
136                    ;
137  }  }
138    
139    
140  1;  1;

Legend:
Removed from v.1086  
changed lines
  Added in v.1104

  ViewVC Help
Powered by ViewVC 1.1.26