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
 
7 - 11
use strict;
8 - 12
use cPanelUserConfig;
7 - 13
use CGI qw/param cookie header start_html url/;
14
use HTML::Tiny;
15
use tableViewer;
2 - 16
use RollerCon;
7 - 17
our $h = HTML::Tiny->new( mode => 'html' );
2 - 18
 
7 - 19
my $cookie_string = authenticate (1) || die;
20
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
2 - 21
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
22
 
7 - 23
my $pageTitle = "Log Viewer";
2 - 24
our $DBTABLE = 'v_log';
7 - 25
my %COLUMNS = (
26
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
196 - 27
  eventid     => [qw(EventID       5    number      default )],
28
  timestamp   => [qw(Timestamp    10    date        default )],
29
  event       => [qw(Event        15    text        default )],
30
  RCid        => [qw(RCID         20    number      default )],
31
  derby_name  => [qw(DerbyName    25    select      default )],
32
  email       => [qw(Email        30    text                )],
33
  real_name   => [qw(FullName     35    text                )],
34
  access      => [qw(Role         40    select              )]
7 - 35
);
196 - 36
 
7 - 37
my @whereClause;
196 - 38
# Unless they're a manager or higher, users should only see their own logs.
39
push @whereClause, "RCid = $ORCUSER->{RCid}" unless $LVL > 2;
7 - 40
 
41
# If we need to modify line item values, create a subroutine named "modify_$columnname"
42
#    It will receive a hashref to the object lineitem
43
 
44
sub modify_derby_name {
45
  my $li = shift;
56 bgadell 46
  return $h->a ({ href=>"view_user.pl?RCid=$li->{RCid}" }, $li->{derby_name});
7 - 47
}
48
 
196 - 49
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
50
#    It will receive two fields, the field name and the current filter value (if any)
7 - 51
 
196 - 52
# Uncomment and update if we want to enable clicking on a row to open a new page.
53
#
54
#sub addRowClick {
55
#  my $t = shift;
56
#  return "location.href='view_thing.pl?field=$t->{field}&choice=View'";
57
#}
7 - 58
 
196 - 59
# Call the function to print the table view page (with available options)
60
printTablePage ({ Title   => $pageTitle,
61
                  Table   => $DBTABLE,
62
                  Columns => \%COLUMNS,
63
                  RCAuth  => $RCAUTH_cookie,
64
                  Where   => join (" and ", @whereClause),
65
                  DisplayYearSelect => 0,
66
                 });