| 56 |
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 |
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
|
|
|
10 |
|
| 196 |
- |
11 |
use strict;
|
| 56 |
bgadell |
12 |
use cPanelUserConfig;
|
|
|
13 |
use CGI qw/param cookie header start_html url/;
|
|
|
14 |
use HTML::Tiny;
|
|
|
15 |
use tableViewer;
|
|
|
16 |
use RollerCon;
|
|
|
17 |
our $h = HTML::Tiny->new( mode => 'html' );
|
|
|
18 |
|
|
|
19 |
my $cookie_string = authenticate (RollerCon::USER) || die;
|
|
|
20 |
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
|
|
21 |
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
|
|
22 |
|
|
|
23 |
my $pageTitle = "Games";
|
|
|
24 |
our $DBTABLE = 'v_games';
|
|
|
25 |
my %COLUMNS = (
|
|
|
26 |
# colname => [qw(DisplayName N type status)], status -> static | default | <blank>
|
| 196 |
- |
27 |
# id => [qw(Change 5 none static )],
|
|
|
28 |
teams => [qw(Teams 10 text default )],
|
|
|
29 |
date => [qw(Date 15 date default )],
|
|
|
30 |
dayofweek => [qw(Day 20 select )],
|
|
|
31 |
time => [qw(Time 25 text default )],
|
|
|
32 |
start_time => [qw(Start 30 text )],
|
|
|
33 |
end_time => [qw(End 35 text )],
|
|
|
34 |
volhours => [qw(Length 40 number )],
|
|
|
35 |
track => [qw(Track 45 select default )],
|
|
|
36 |
level => [qw(Level 50 select default )],
|
|
|
37 |
restrictions => [qw(R 60 select default )],
|
|
|
38 |
gtype => [qw(Type 65 select default )],
|
|
|
39 |
notes => [qw(Notes 70 text )],
|
| 56 |
bgadell |
40 |
);
|
|
|
41 |
|
|
|
42 |
if ($LVL >= RollerCon::ADMIN) {
|
| 196 |
- |
43 |
$COLUMNS{id} = [qw(Change 5 number static )];
|
| 56 |
bgadell |
44 |
}
|
|
|
45 |
|
|
|
46 |
my @whereClause;
|
|
|
47 |
|
|
|
48 |
# If we need to modify line item values, create a subroutine named "modify_$columnname"
|
|
|
49 |
# It will receive a hashref to the object lineitem
|
|
|
50 |
|
|
|
51 |
sub modify_id {
|
|
|
52 |
my $hr = shift;
|
|
|
53 |
my $clicky = $hr->{count} ? "event.stopPropagation(); if (confirm('WARNING!\\nYou are modifying a class that someone has signed up for.')==true) {return true;} else {return false;}" : "return true;";
|
|
|
54 |
my $extrawarning = $hr->{count} ? "\\nWARNING! It appears someone is signed up for it." : "";
|
|
|
55 |
return join " ", #$hr->{id},
|
|
|
56 |
$h->a ({ href=>"view_game.pl?id=$hr->{id}&choice=Update", onClick=>$clicky }, "[Edit]"),
|
|
|
57 |
$h->a ({ href=>"view_game.pl?id=$hr->{id}&choice=Copy" }, "[Copy]"),
|
|
|
58 |
$h->a ({ href=>"view_game.pl?id=$hr->{id}&choice=Delete", onClick=>"event.stopPropagation(); if (confirm('Are you sure you want to DELETE this game?$extrawarning')==true) {return true;} else {return false;}" }, "[Delete]")
|
|
|
59 |
;
|
|
|
60 |
};
|
|
|
61 |
|
|
|
62 |
sub modify_time {
|
|
|
63 |
my $t = shift;
|
|
|
64 |
return convertTime $t->{time};
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
sub modify_start_time {
|
|
|
68 |
my $t = shift;
|
|
|
69 |
return convertTime $t->{start_time};
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
sub modify_end_time {
|
|
|
73 |
my $t = shift;
|
|
|
74 |
return convertTime $t->{end_time};
|
|
|
75 |
}
|
|
|
76 |
|
| 196 |
- |
77 |
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
|
|
|
78 |
# It will receive two fields, the field name and the current filter value (if any)
|
| 56 |
bgadell |
79 |
|
| 196 |
- |
80 |
# Uncomment and update if we want to enable clicking on a row to open a new page.
|
|
|
81 |
#
|
|
|
82 |
sub addRowClick {
|
|
|
83 |
my $t = shift;
|
|
|
84 |
return "location.href='view_game.pl?id=$t->{id}&choice=View'"
|
| 56 |
bgadell |
85 |
}
|
|
|
86 |
|
| 196 |
- |
87 |
# Call the function to print the table view page (with available options)
|
|
|
88 |
printTablePage ({ Title => $pageTitle,
|
|
|
89 |
Table => $DBTABLE,
|
|
|
90 |
Columns => \%COLUMNS,
|
|
|
91 |
RCAuth => $RCAUTH_cookie,
|
|
|
92 |
DisplayYearSelect => 1,
|
|
|
93 |
PersonalTimeButton => 1,
|
|
|
94 |
HeaderButton => { field => "id",
|
| 222 |
- |
95 |
button => $h->input ({ type=>"button", value=>"Add", onClick=>"event.stopPropagation(); window.location.href='view_game.pl'" }) }
|
| 196 |
- |
96 |
});
|