/[Frey]/branches/zimbardo/lib/App/RoomReservation/Confirmation.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 /branches/zimbardo/lib/App/RoomReservation/Confirmation.pm

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

trunk/lib/App/RoomReservation/Confirmation.pm revision 1134 by dpavlin, Tue Jun 30 15:59:41 2009 UTC branches/zimbardo/lib/App/RoomReservation/Confirmation.pm revision 1173 by dpavlin, Sun Jul 5 21:40:54 2009 UTC
# Line 3  use Moose; Line 3  use Moose;
3    
4  extends 'App::RoomReservation';  extends 'App::RoomReservation';
5    
6  with 'App::RoomReservation::Email';  with 'App::RoomReservation::Email', 'App::RoomReservation::Messages';
7    
8  has token => (  has token => (
9          is => 'ro',          is => 'ro',
# Line 30  sub verify_as_markup { Line 30  sub verify_as_markup {
30                                  order by seat.nr asc                                  order by seat.nr asc
31                                  limit 1                                  limit 1
32                          )                          )
33                  where md5(id||email) = ? and _confirmed is false                  where
34                            md5(id||email) = ?
35                            and _confirmed is false
36                            and _canceled is false
37          });          });
38    
39          $sth->execute( $self->token );          my $token = $self->token;
40    
41          if ( $sth->rows == 1 ) {          $sth->execute( $token );
42    
43            if ( $sth->rows == 0 ) {
44                    warn "can't confirm ", $self->token, " check if it's allready confirmed";
45                  $sth = $dbh->prepare(qq{                  $sth = $dbh->prepare(qq{
46                          select ime||' '||prezime,_seat_number,email                          select 1
47                          from reservation                          from reservation
48                          where md5(id||email) = ? and _confirmed is true and _seat_number is not null                          where
49                                    md5(id||email) = ?
50                                    and _confirmed is true
51                  });                  });
52                    $sth->execute( $token );
53            }
54    
55                  $sth->execute( $self->token );          if ( $sth->rows == 1 ) {
                 my ($name, $seat, $email) = $sth->fetchrow_array;  
   
                 my $html =  
                 qq|  
                         $name, <em>reservation has been confirmed</em> and seat number <big>$seat</big> is waiting for you.  
                         <br>  
                         Please print this notice and show it when entering lecture.  
                 |;  
56    
57                  my $token = $self->token;                  die qq|<error>can't find account associated with $token</error>| unless $sth->rows == 1;
                 $self->send( $email,  
                         "Lecture seat $seat is assigned to you",  
                         $html . <<__EMAIL__  
   
 If you wish to cancel your reservation please click on link below:  
   
 http://FREY_HOSTNAME/App::RoomReservation::Confirmation/cancel_as_markup?token=$token  
 __EMAIL__  
                 );  
58    
59                  return $html;                  return $self->seat_confirmation_message( token => $token );
60    
61          } else {          } else {
62                  die "Problem with confirmation.\n";                  die qq|<error>Can't find confirmation $token<br>
63                            Did you copy-pasted whole URL in your browser?</error>|;
64          }          }
65  }  }
66    
# Line 79  sub cancel_as_markup { Line 72  sub cancel_as_markup {
72          my $sth = $dbh->prepare(qq{          my $sth = $dbh->prepare(qq{
73                  update reservation                  update reservation
74                  set                  set
75                          _confirmed = false,                          _canceled = true,
76                          _seat_number = null                          _seat_number = null
77                  where md5(id||email) = ? and _confirmed is true                  where
78                            md5(id||email) = ?
79    --                      and _confirmed is true
80          });          });
81          $sth->execute( $self->token );          $sth->execute( $self->token );
82    
83          if ( $sth->rows == 1 ) {          if ( $sth->rows == 1 ) {
84                  qq|Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else|;                  qq|
85                            Vaš <em>dolazak je odjavljen</em>.
86    
87                            Hvala što ste omogućili dolazak nekom drugom!
88                    |;
89          } else {          } else {
90                  die "Problem with cancelation.\n";                  die qq|<error>Can't find reservation which you are trying to cancel.<br>
91                            Did you copy-pasted whole URL in your browser?</error>|;
92          }          }
93  }  }
94    

Legend:
Removed from v.1134  
changed lines
  Added in v.1173

  ViewVC Help
Powered by ViewVC 1.1.26