/[Frey]/trunk/lib/App/RoomReservation/Messages.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

Annotation of /trunk/lib/App/RoomReservation/Messages.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1168 - (hide annotations)
Thu Jul 2 21:55:44 2009 UTC (14 years, 10 months ago) by dpavlin
File size: 2206 byte(s)
make url_mapping to short REST-style URLs
1 dpavlin 1151 package App::RoomReservation::Messages;
2     use Moose::Role;
3    
4     sub seat_confirmation_message {
5 dpavlin 1152 my ( $self, $col, $value ) = @_;
6 dpavlin 1151
7 dpavlin 1153 die "wrong column name $col = $value" unless $col =~ m{^(token|email)$};
8 dpavlin 1151
9 dpavlin 1153 $col =~ s{token}{md5(id||email)};
10    
11 dpavlin 1152 my $sth = $self->dbh->prepare(qq{
12     select
13     ime||' '||prezime,
14     _seat_number,
15     email,
16     md5(id||email) as token,
17 dpavlin 1155 _confirmed,
18     _canceled
19 dpavlin 1152 from reservation
20     where
21     $col = ?
22     });
23 dpavlin 1151
24 dpavlin 1152 $sth->execute( $value );
25    
26 dpavlin 1165 die qq|<error>Can't find user $col = $value</error>| if $sth->rows == 0;
27 dpavlin 1152
28 dpavlin 1155 my ( $name, $seat, $email, $token, $confirmed, $canceled ) = $sth->fetchrow_array;
29 dpavlin 1152
30 dpavlin 1155 if ( $confirmed && $canceled ) {
31 dpavlin 1152
32 dpavlin 1155 my $html =
33     qq|
34     $name, <em>you have canceled your reservation allready</em>
35     <br>
36     If you did that by mistake, and you want to attend this lecture, please
37     contact us via e-mail.
38     |;
39    
40     $self->send( $email,
41     "Lecture confirmation canceled",
42     $html
43     );
44    
45     return $html;
46    
47     } elsif ( $confirmed ) {
48    
49 dpavlin 1168 my $url = $self->url_for( 'Confirmation/cancel_as_markup?token=', $token );
50 dpavlin 1152
51     my $html =
52     qq|
53     $name, <em>reservation has been confirmed</em>
54     |
55     . ( $seat
56     ? qq|
57     and seat number <big>$seat</big> is waiting for you.
58     <br>
59     Please print this notice and show it when entering lecture.
60     | : qq|
61     we <big>currently don't have any seats available</big>,
62     but you will be notified if we get some vacancies for this lecture!
63     | )
64     ;
65    
66     $self->send( $email,
67 dpavlin 1155 "Lecture confirmation" . ( $seat ? " [seat $seat]" : " [wating for vacancy]" ),
68 dpavlin 1152 $html . <<__EMAIL__
69    
70 dpavlin 1151 If you wish to cancel your reservation please click on link below:
71    
72     $url
73    
74     __EMAIL__
75 dpavlin 1152 );
76 dpavlin 1151
77 dpavlin 1152 return $html;
78 dpavlin 1151
79 dpavlin 1152 } else { # not verified
80    
81 dpavlin 1168 my $url = $self->url_for( 'Confirmation/verify_as_markup?token=', $token );
82 dpavlin 1152
83     $self->send( $self->email,
84     'Confirm your reservation for lecture', <<__EMAIL__
85    
86     Please click following link to confirm your reservation for lecture
87     and get seat assigned to you.
88    
89     $url
90    
91     __EMAIL__
92     );
93    
94     return qq|
95    
96     $name we have accepted your registration!
97    
98     <div style="color:red">
99     You have to confirm your e-mail address and registration
100     by clicking on link which should be in your e-mail INBOX shortly
101     </div>
102     |;
103    
104     }
105    
106     }
107    
108 dpavlin 1151 1;

  ViewVC Help
Powered by ViewVC 1.1.26