Subversion Repositories VORC

Rev

Rev 222 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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) {
243 - 43
#  $COLUMNS{id} = [qw(Change         5    number       static  )];
44
  $COLUMNS{id} = [qw(Change         5    number         )];
56 bgadell 45
}
46
 
47
my @whereClause;
48
 
49
# If we need to modify line item values, create a subroutine named "modify_$columnname"
50
#    It will receive a hashref to the object lineitem
51
 
52
sub modify_id {
53
  my $hr = shift;
54
  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;";
55
  my $extrawarning = $hr->{count} ? "\\nWARNING! It appears someone is signed up for it." : "";
56
  return join "&nbsp;", #$hr->{id},
57
         $h->a ({ href=>"view_game.pl?id=$hr->{id}&choice=Update", onClick=>$clicky }, "[Edit]"),
58
         $h->a ({ href=>"view_game.pl?id=$hr->{id}&choice=Copy" }, "[Copy]"),
59
         $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]")
60
  ;
61
};
62
 
63
sub modify_time {
64
  my $t = shift;
65
  return convertTime $t->{time};
66
}
67
 
68
sub modify_start_time {
69
  my $t = shift;
70
  return convertTime $t->{start_time};
71
}
72
 
73
sub modify_end_time {
74
  my $t = shift;
75
  return convertTime $t->{end_time};
76
}
77
 
196 - 78
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
79
#    It will receive two fields, the field name and the current filter value (if any)
56 bgadell 80
 
196 - 81
# Uncomment and update if we want to enable clicking on a row to open a new page.
82
#
83
sub addRowClick {
84
  my $t = shift;
85
  return "location.href='view_game.pl?id=$t->{id}&choice=View'"
56 bgadell 86
}
87
 
196 - 88
# Call the function to print the table view page (with available options)
89
printTablePage ({ Title   => $pageTitle,
90
                  Table   => $DBTABLE,
91
                  Columns => \%COLUMNS,
92
                  RCAuth  => $RCAUTH_cookie,
93
                  DisplayYearSelect => 1,
94
                  PersonalTimeButton => 1,
95
                  HeaderButton => { field  => "id",
222 - 96
                                    button => $h->input ({ type=>"button", value=>"Add", onClick=>"event.stopPropagation(); window.location.href='view_game.pl'" }) }
196 - 97
                 });