| 2 |
- |
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 |
|
|
|
11 |
use strict;
|
|
|
12 |
use CGI qw/param cookie header start_html url/;
|
|
|
13 |
use HTML::Tiny;
|
|
|
14 |
use tableViewer;
|
|
|
15 |
use PEEPS;
|
|
|
16 |
our $h = HTML::Tiny->new( mode => 'html' );
|
| 4 |
- |
17 |
$ENV{HTTPS} = 'ON' if $ENV{SERVER_NAME} =~ /^peeps/;
|
| 2 |
- |
18 |
|
|
|
19 |
my $cookie_string = authenticate (1) || die;
|
|
|
20 |
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
|
|
21 |
my $PEEPSAUTH_cookie = CGI::Cookie->new(-name=>'PEEPSAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
|
|
22 |
|
|
|
23 |
my $pageTitle = "Log Viewer";
|
|
|
24 |
our $DBTABLE = 'v_log';
|
|
|
25 |
my %COLUMNS = (
|
|
|
26 |
# colname => [qw(DisplayName N type status)], status -> static | default | <blank>
|
|
|
27 |
eventid => [qw(EventID 5 number default )],
|
|
|
28 |
timestamp => [qw(Timestamp 10 date default )],
|
|
|
29 |
event => [qw(Event 15 text default )],
|
|
|
30 |
person_id => [qw(PEEPSID 20 number default )],
|
|
|
31 |
);
|
|
|
32 |
|
|
|
33 |
my @leagues = @{ isLeagueAdmin ($ORCUSER->{person_id}) };
|
|
|
34 |
|
|
|
35 |
$COLUMNS{derby_name} = [qw(DerbyName 25 select default )] if ($ORCUSER->{SYSADMIN} or scalar @leagues);
|
|
|
36 |
|
|
|
37 |
# Set any custom "where" DB filters here...
|
|
|
38 |
my @whereClause;
|
|
|
39 |
|
|
|
40 |
if (!$ORCUSER->{SYSADMIN}) {
|
|
|
41 |
if (scalar @leagues) {
|
|
|
42 |
push @whereClause, "person_id in (select id from full_person where league_id in (".join (", ", @leagues)."))";
|
|
|
43 |
} else {
|
|
|
44 |
push @whereClause, "person_id = $ORCUSER->{person_id}";
|
|
|
45 |
}
|
|
|
46 |
}
|
|
|
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 |
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
|
|
|
52 |
# It will receive two fields, the field name and the current filter value (if any)
|
|
|
53 |
|
|
|
54 |
if ($ORCUSER->{SYSADMIN} or scalar @leagues) {
|
|
|
55 |
*filter_derby_name = sub {
|
|
|
56 |
my $colName = shift;
|
|
|
57 |
my $filter = shift;
|
|
|
58 |
my $dbh = getDBConnection ();
|
|
|
59 |
|
|
|
60 |
if (defined $filter) {
|
|
|
61 |
if ($filter eq "<-blank->") {
|
|
|
62 |
return "$colName = \"\" or isnull($colName) = 1";
|
|
|
63 |
} else {
|
|
|
64 |
return "$colName = \"$filter\"";
|
|
|
65 |
}
|
|
|
66 |
} else {
|
|
|
67 |
my $Options = $ORCUSER->{SYSADMIN} ?
|
|
|
68 |
$h->option ("", "<-blank->", @{ $dbh->selectall_arrayref ("select distinct derby_name from $DBTABLE where derby_name <> '' order by derby_name") })
|
|
|
69 |
: $h->option ("", @{ $dbh->selectall_arrayref ("select distinct derby_name from $DBTABLE where person_id in (select id from full_person where league_id in (".join (", ", @leagues).")) order by derby_name") });
|
|
|
70 |
|
|
|
71 |
my $tmpfilter = getFilterValue ($colName);
|
|
|
72 |
|
|
|
73 |
$Options =~ s/>($tmpfilter)/ selected>$1/;
|
|
|
74 |
return "<SELECT name=filter-${colName} onChange='page.value = 1; submit();'>$Options</SELECT>";
|
|
|
75 |
}
|
|
|
76 |
};
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
|
|
|
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_thing.pl?field=$t->{field}&choice=View'";
|
|
|
85 |
#}
|
|
|
86 |
|
|
|
87 |
# Call the function to print the table view page (with available options)
|
|
|
88 |
printTablePage ({ Title => $pageTitle,
|
|
|
89 |
# Prefs => $prefscookie,
|
|
|
90 |
Table => $DBTABLE,
|
|
|
91 |
Columns => \%COLUMNS,
|
|
|
92 |
RCAuth => $PEEPSAUTH_cookie,
|
|
|
93 |
Where => join (" and ", @whereClause),
|
|
|
94 |
DisplayYearSelect => 0,
|
|
|
95 |
ShowMyShifts => 0,
|
|
|
96 |
PersonalTimeButton => 0,
|
|
|
97 |
HighlightShifts => 0,
|
|
|
98 |
# HeaderButton => { field => "id",
|
|
|
99 |
# button => $h->input ({ type=>"button", value=>"Add", onClick=>"window.location.href='view_game.pl'" }) }
|
|
|
100 |
});
|
|
|
101 |
|