Subversion Repositories VORC

Rev

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

Rev Author Line No. Line
2 - 1
#!/usr/bin/perl
2
 
56 bgadell 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
 
2 - 9
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
10
 
196 - 11
use strict;
8 - 12
use cPanelUserConfig;
35 - 13
use CGI qw/param cookie header start_html url/;
14
use HTML::Tiny;
15
use tableViewer;
2 - 16
use RollerCon;
35 - 17
our $h = HTML::Tiny->new( mode => 'html' );
2 - 18
 
19
my $secure = "";
65 bgadell 20
if ($ENV{SCRIPT_NAME}  =~ /^\/scores.pl/) {
196 - 21
  $secure = 0;
2 - 22
} else {
196 - 23
  $secure = 1;
2 - 24
}
25
 
26
my $cookie_string;
35 - 27
our ($EML, $PWD, $LVL);
2 - 28
my $RCAUTH_cookie;
29
 
30
if ($secure) {
196 - 31
  $cookie_string = authenticate(2) || die;
32
  ($EML, $PWD, $LVL) = split /&/, $cookie_string;
33
  $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
2 - 34
}
35
 
35 - 36
my $pageTitle = "Game Scores";
2 - 37
our $DBTABLE = 'v_scores';
35 - 38
my %COLUMNS = (
39
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
196 - 40
  id          => [qw(ID            5    number            )],
41
  date        => [qw(Date         10    date              )],
42
  dayofweek   => [qw(Day          15    select    default )],
43
  track       => [qw(Track        20    select    default )],
44
  type        => [qw(Type         25    select            )],
45
  time        => [qw(Time         30    text      default )],
46
  team1       => [qw(Team1        35    text      static )],
47
  team2       => [qw(Team2        40    text      static )]
35 - 48
);
49
 
50
# Set any custom "where" DB filters here...
51
my @whereClause;
52
 
53
# If we need to modify line item values, create a subroutine named "modify_$columnname"
54
#    It will receive a hashref to the object lineitem
55
 
56
sub modify_id {
57
  my $t = shift;
196 - 58
  if ($secure) {
59
    if ($t->{team1_score} or $t->{team2_score}) {
60
      $t->{id} .= " <A HREF='#' onClick=\"window.open('update_score.pl?GID=$t->{id}','Enter Score','resizable,height=260,width=370'); return false;\">[update score]</a>";
61
    } else {
62
      $t->{id} .= " <A HREF='#' onClick=\"window.open('update_score.pl?GID=$t->{id}','Enter Score','resizable,height=260,width=370'); return false;\">[enter score]</a>";
63
    }
64
  }
35 - 65
  return $t->{id};
66
}
67
 
68
sub modify_team1 {
69
  my $t = shift;
196 - 70
  $t->{team1} .= " ($t->{team1_score})" unless !defined $t->{team1_score};
71
  $t->{team2} .= " ($t->{team2_score})" unless !defined $t->{team2_score};;
35 - 72
 
196 - 73
  if ($t->{team1_score} > 0 or $t->{team2_score} > 0) { #SPIKE SEZ DO SOMETHING HERE RE GAME SCORE OF 0
74
    if ($t->{team1_score} > $t->{team2_score}) { $t->{team1} = "<b>$t->{team1}</b>"; } else { $t->{team2} = "<b>$t->{team2}</b>"; }
35 - 75
  }
196 - 76
  return $t->{team1};
35 - 77
}
78
 
50 bgadell 79
sub modify_time {
80
  my $t = shift;
81
  return convertTime $t->{time};
82
}
35 - 83
 
196 - 84
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
85
#    It will receive two fields, the field name and the current filter value (if any)
35 - 86
 
196 - 87
# Uncomment and update if we want to enable clicking on a row to open a new page.
88
#
89
#sub addRowClick {
90
#  my $t = shift;
91
#  return "location.href='view_thing.pl?field=$t->{field}&choice=View'";
92
#}
35 - 93
 
196 - 94
# Call the function to print the table view page (with available options)
95
printTablePage ({ Title   => $pageTitle,
96
                  Table   => $DBTABLE,
97
                  Columns => \%COLUMNS,
98
                  RCAuth  => $RCAUTH_cookie,
99
                  Where   => join (" and ", @whereClause),
100
                  DisplayYearSelect => 1,
101
                 });