| 58 |
bgadell |
1 |
#!/usr/bin/perl
|
|
|
2 |
|
|
|
3 |
# Redirect error messages to a log of my choosing. (it's annoying to filter for errors in the shared env)
|
|
|
4 |
my $error_log_path = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco/logs/" : "/tmp/";
|
|
|
5 |
close STDERR;
|
|
|
6 |
open STDERR, '>>', $error_log_path.'vorc_error.log' or warn "Failed to open redirected logfile ($0): $!";
|
|
|
7 |
#warn "Redirecting errors to ${error_log_path}vorc_error.log";
|
|
|
8 |
|
|
|
9 |
use strict;
|
|
|
10 |
use cPanelUserConfig;
|
|
|
11 |
use RollerCon;
|
|
|
12 |
use tableViewer;
|
|
|
13 |
use CGI qw/param cookie header start_html url/;
|
|
|
14 |
use HTML::Tiny;
|
|
|
15 |
my $h = HTML::Tiny->new( mode => 'html' );
|
| 61 |
bgadell |
16 |
$|=1;
|
| 58 |
bgadell |
17 |
|
|
|
18 |
my $cookie_string = authenticate(3) || die;
|
|
|
19 |
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
|
|
20 |
my $user = getUser($EML);
|
|
|
21 |
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
|
|
22 |
|
|
|
23 |
print header (-cookie=>$RCAUTH_cookie);
|
|
|
24 |
|
|
|
25 |
#foreach (sort keys %ENV) {
|
|
|
26 |
# print "$_: $ENV{$_}\n<br>";
|
|
|
27 |
#}
|
|
|
28 |
my $change = param ('change');
|
|
|
29 |
my $RCid = param ('RCid') // $user->{RCid};
|
|
|
30 |
my $MVPid = param ('MVPid');
|
|
|
31 |
|
| 61 |
bgadell |
32 |
my $targetUser = getUser $RCid;
|
|
|
33 |
|
| 58 |
bgadell |
34 |
print start_html (-title => "vORC Update MVP Ticket Match", -style => {'src' => "/style.css"}), $h->open ("body");
|
|
|
35 |
|
|
|
36 |
if ($change eq "lookup") {
|
|
|
37 |
|
|
|
38 |
print $h->form ({ action=>url }, [
|
|
|
39 |
$h->input ({ type=>"hidden", name=>"change", value=>"add" }),
|
|
|
40 |
$h->input ({ type=>"hidden", name=>"RCid", value=>$RCid }),
|
|
|
41 |
$h->p ("Match ticket to User ($RCid):"),
|
|
|
42 |
$h->input ({ type=>"text", name=>"MVPid", id=>"pickticket" }),
|
|
|
43 |
$h->input ({ type=>"submit", value=>"Save", onClick=>"if (document.getElementById('pickticket').value === '') { return false; }" }),
|
|
|
44 |
$h->button ({ onClick=>"window.close();" }, "Cancel")
|
|
|
45 |
]);
|
|
|
46 |
|
|
|
47 |
} else {
|
|
|
48 |
print $h->p ("Making an MVP Ticket change...");
|
|
|
49 |
|
| 61 |
bgadell |
50 |
my $target = $targetUser->{derby_name};
|
| 58 |
bgadell |
51 |
print $h->p ("So, <b>$user->{derby_name}</b>, you'd like to <b>$change</b> an MVP Ticket for <b>$target</b>: <b>$RCid</b>...");
|
|
|
52 |
|
|
|
53 |
my $change_err = changeTicket($change, $RCid, $MVPid);
|
|
|
54 |
my $closer;
|
|
|
55 |
if ($change_err) {
|
|
|
56 |
print $change_err;
|
|
|
57 |
if ($change_err =~ /^WARNING/) {
|
|
|
58 |
print $h->form ({ action=>url }, [
|
|
|
59 |
$h->input ({ type=>"hidden", name=>"change", value=>"override" }),
|
|
|
60 |
$h->input ({ type=>"hidden", name=>"MVPid", value=>$MVPid }),
|
|
|
61 |
$h->input ({ type=>"hidden", name=>"RCid", value=>$RCid }),
|
|
|
62 |
$h->input ({ type=>"submit", value=>"OVERRIDE", onClick=>"if (confirm('Are you sure you want to override the warning?')==true) { return true } else { return false }" }),
|
|
|
63 |
]);
|
|
|
64 |
}
|
|
|
65 |
print $h->br, $h->button ({ onClick=>"window.close();" }, "Close");
|
|
|
66 |
} else {
|
|
|
67 |
print "<br>This window will close automatically in 3 seconds.";
|
|
|
68 |
$closer = 'setTimeout(() => { window.close(); }, 3000);';
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
print<<tail;
|
|
|
72 |
<SCRIPT language="JavaScript">
|
|
|
73 |
<!--
|
|
|
74 |
function reloadParent() {
|
|
|
75 |
window.opener.location.reload();
|
|
|
76 |
$closer
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
reloadParent();
|
|
|
80 |
//-->
|
|
|
81 |
</SCRIPT>
|
|
|
82 |
tail
|
|
|
83 |
}
|
|
|
84 |
print $h->close ("body"), $h->close ("html");
|
|
|
85 |
|
|
|
86 |
sub changeTicket {
|
|
|
87 |
my $change = shift // "";
|
|
|
88 |
my $rcid = shift // "";
|
|
|
89 |
my $mvpid = shift // "";
|
|
|
90 |
return "ERROR: Missing Details to make the change" unless $change and $rcid and $mvpid;
|
|
|
91 |
|
|
|
92 |
my $dbh = getRCDBH;
|
|
|
93 |
my $sth;
|
|
|
94 |
|
|
|
95 |
if ($change eq "Delete" or $change eq "override") {
|
|
|
96 |
if ($change ne "override") {
|
|
|
97 |
my ($badidea) = $dbh->selectrow_array ("select id from v_ticket where RCid = ? and email = vorc_email and full_name = vorc_full_name", undef, $rcid);
|
|
|
98 |
return "WARNING: This user's email and full name match the MVP ticket. (It will likely re-match.)" if $badidea;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
$sth = $dbh->prepare ("delete from RCid_ticket_link where RCid = ? and MVPid = ?");
|
|
|
102 |
|
|
|
103 |
} else {
|
| 118 |
- |
104 |
my ($taken) = $dbh->selectrow_array ("select RCid from RCid_ticket_link where RCid_ticket_link.year = year(now()) and (MVPid = ? or RCid = ?)", undef, $mvpid, $rcid);
|
| 58 |
bgadell |
105 |
return "ERROR ($taken): Either that user or that ticket is already matched." if $taken;
|
|
|
106 |
|
|
|
107 |
my ($exists) = $dbh->selectrow_array ("select id from ticket where id = ?", undef, $mvpid);
|
|
|
108 |
return "ERROR: That MVP Ticket doesn't seem to exist ($mvpid)." unless $exists;
|
|
|
109 |
|
| 118 |
- |
110 |
$sth = $dbh->prepare ("insert into RCid_ticket_link (RCid, MVPid, year) values (?, ?, year(now()))");
|
| 58 |
bgadell |
111 |
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
if ($sth->execute ($rcid, $mvpid)) {
|
|
|
115 |
logit ($user->{RCid}, "Updated MVP Ticket: $rcid $change $mvpid");
|
|
|
116 |
logit ($rcid, "MVP Ticket Change: $user->{derby_name} $change");
|
|
|
117 |
print "SUCCESS!";
|
| 61 |
bgadell |
118 |
## Send the user an email...
|
|
|
119 |
sendEmail ($targetUser) if $change eq "add";
|
| 58 |
bgadell |
120 |
return;
|
|
|
121 |
} else {
|
|
|
122 |
return "ERROR: Something failed. Maybe this will help:". $sth->errstr();
|
|
|
123 |
}
|
| 61 |
bgadell |
124 |
}
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
sub sendEmail {
|
|
|
128 |
use RCMailer;
|
|
|
129 |
my $data = shift;
|
|
|
130 |
|
|
|
131 |
my $email = $data->{email};
|
|
|
132 |
my $subject = "RollerCon MVP Ticket Added to Account";
|
|
|
133 |
my $body = $h->p (
|
|
|
134 |
"Greetings,",
|
|
|
135 |
"Your account to sign up for MVP Classes at RollerCon with the following information:",
|
|
|
136 |
|
|
|
137 |
$h->ul ([
|
| 119 |
- |
138 |
$h->li ("Derby Name: $data->{derby_name}", "Full Name: $data->{real_name}", "Email Address: $data->{email}")
|
| 61 |
bgadell |
139 |
]),
|
|
|
140 |
|
|
|
141 |
"Has been activated!",
|
|
|
142 |
|
|
|
143 |
"You are now able to log in to view and sign up for classes (after June 16th)! YAAAAAYYYY!!!!! (Imagine Kermit the Frog doing muppet hands here.)",
|
|
|
144 |
|
|
|
145 |
$h->a ({ href=>"https://volunteers.rollercon.com/schedule/classes.pl" }, "Take me to the classes!"),
|
|
|
146 |
|
|
|
147 |
"Please note that you are limited to signing up for a limited number of classes.",
|
|
|
148 |
|
|
|
149 |
"If you've already signed up for your limit of classes, but another class REALLY strikes your fancy, try dropping one of your current classes. That should allow you to pick up a different one.",
|
|
|
150 |
|
|
|
151 |
"The number of classes you're allowed to sign up for starts at two, but may increase as we get closer to RollerCon.",
|
|
|
152 |
|
|
|
153 |
"If you're new to using vORC, you may want to read this:",
|
|
|
154 |
|
|
|
155 |
$h->a ({ href=>"https://rollercon.com/about/mvp-class-reg/how-to-vorc/" }, "How to VORC"),
|
|
|
156 |
|
|
|
157 |
"-RollerCon Management",
|
|
|
158 |
"(this is an automated message, please don't reply)"
|
|
|
159 |
);
|
|
|
160 |
|
|
|
161 |
# send the message
|
|
|
162 |
EmailUser($email, $subject, $body);
|
|
|
163 |
}
|