Subversion Repositories PEEPS

Rev

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

Rev Author Line No. Line
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
use strict;
10
use PEEPS;
11
use CGI qw/param header start_html url/;
12
use CGI::Cookie;
13
our $h = HTML::Tiny->new( mode => 'html' );
14
my $dbh = getRCDBH ();
15
 
16
my $cookie_string = authenticate (1) || die;
17
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
18
my $user = $ORCUSER;
19
#my $activated = $ORCUSER->{access};
20
 
21
print header (-cookie=>CGI::Cookie->new(-name=>'PEEPSAUTH',-value=>"$cookie_string"));
22
 
23
#foreach (sort keys %ENV) {
24
#	warn "$_: $ENV{$_}";
25
#}
26
 
27
use DateTime;
28
my $dt = DateTime->today;
29
$dt =~ s/T00\:00\:00$//;
30
 
31
my @announcements;
38 - 32
push @announcements, $h->div ({class=>"error"}, "You're logged in as a WFTDA System Admin!".$h->br.$h->br) if $user->{SYSADMIN};
2 - 33
 
38 - 34
my @roles = @{ $dbh->selectall_arrayref ("select member_org_id, id from role where person_id = ? and role = ?", undef, $user->{id}, "Pending") };
35
my %roles = map { $_->[0] => $_->[1] } @roles;
36
if (scalar @roles) {
37
  push @announcements, $h->div ("You have a Pending request to join: ".join (", ", map { getLeagueName ($_) } keys %roles));
38
}
39
 
40
 
2 - 41
my @everyone;
42
push @everyone, $h->li ("Your Member ID is ".$user->{id});
12 - 43
push @everyone, $h->li ($h->a ( { href=>"view_user" }, "View your user information."));
40 - 44
push @everyone, $h->li ($h->a ( { href=>"people" }, "Look at a list of people." )) if ($user->{SYSADMIN} or $user->{SANCTIONING} or scalar @{isLeagueAdmin ($user->{person_id})});
14 - 45
push @everyone, $h->li ($h->a ( { href=>"organizations" }, "Leagues / Organizations in PEEPS." ));# if ($user->{SYSADMIN} or scalar @{isLeagueAdmin ($user->{person_id})});
2 - 46
my @leads;
47
 
48
my @insurance;
49
$user->{policy} = isPersonCovered ($user->{id});
50
if ($user->{policy}) {
51
  my $daysremaining = remainingPolicyDays ($user->{id}, $user->{policy});
52
  push @insurance, $h->li ("You are currently covered by Policy ID: $user->{policy}");
53
  push @insurance, $h->li ("You have $daysremaining days remaining in coverage.");
54
  if ($daysremaining <= 90) {
22 - 55
    push @insurance, $h->li ($h->a ( { href=>"attestation?policy=1" }, "You're eligible to renew." ));
2 - 56
  }
57
 
58
} else {
22 - 59
  push @insurance, $h->li ($h->a ( { href=>"attestation?policy=1" }, "Purchase Insurance." ));
2 - 60
}
61
push @insurance, $h->li ($h->a ( { href=>"insurance" }, "View Insurance History." ));
62
push @insurance, $h->li ($h->a ( { href=>"verify_insurance" }, "Verify Someone's Insurance Coverage." ));
63
 
64
 
8 - 65
my @league_admin;
66
foreach (@{isLeagueAdmin ($user->{person_id})}) {
67
  push @league_admin, $h->li ($h->a ( { href=>"view_league?id=".$_ }, "View ".getLeagueName ($_) ));
36 - 68
  my ($pending) = $dbh->selectrow_array ("select count(id) from full_person where league_id = ? and role = ?", undef, $_, "Pending");
69
  if ($pending) {
70
    my $lid = $_;
71
    push @league_admin, $h->li ($h->a ( { href=>"/people?filter-league_id=$lid&filter-role=Pending" }, "There are Pending Member Request(s)." ));
72
    push @league_admin, $h->ul ([map { $h->li ($h->a ({href=>"/manage_role?league_id=$lid&person_id=$_->[0]"}, $_->[1])) } @{$dbh->selectall_arrayref ("select id, derby_name from full_person where league_id = ? and role = ?", undef, $_, "Pending")}]);
73
  }
74
 
8 - 75
}
76
 
2 - 77
my @managers;
78
 
79
my @sysadmins;
8 - 80
if ($user->{SYSADMIN}) {
81
  push @sysadmins, $h->li ($h->a ( { href=>"org_log" }, "View Org Change Logs." ));
82
}
2 - 83
 
84
my @activity_log;
85
my $alog = $dbh->prepare("select timestamp, event from log where person_id = ? order by timestamp desc limit 10");
86
$alog->execute($user->{person_id});
87
while (my @logs = $alog->fetchrow_array) {
88
	my ($d, $t) = split /\s+/, $logs[0];
89
	push @activity_log, $h->li ({ class=>"shaded" }, join " ", @logs);
90
}
91
 
92
my @reference;
93
 
94
printRCHeader("Home");
95
print $h->close ("table");
96
 
97
print $h->form ({ name => "Req", action => url });
98
 
99
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Announcement:"), $h->ul ([ @announcements ]) ]) if (scalar @announcements);
100
 
101
#print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Note:"), "<b>Your account is being reviewed.</b>", $h->br, "You won't have access to view or sign-up for things until you've been approved / added to a department.", $h->br, "Please watch your email for notifications." ]) unless $activated;
102
 
103
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do:"), $h->ul ([ @everyone ]) ]);
104
 
105
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Personal Insurance:"), $h->ul ([ @insurance ]) ]);
106
 
8 - 107
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "League Business:"), $h->ul ([ @league_admin ]) ]) if (scalar @league_admin);
2 - 108
 
3 - 109
#print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Manager:"), $h->ul ([ @managers ]) ]) if ($LVL > 2);
2 - 110
 
111
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a SysAdmin:"), $h->ul ([ @sysadmins ]) ]) if ($LVL >= 5);
112
 
9 - 113
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Your Latest Activity:"), $h->ul ([ @activity_log ]), $h->h5 ($h->a ({ href=>"log" }, "[Your entire log history]")) ]);
2 - 114
 
12 - 115
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Reference:"), $h->ul ([ @reference ]) ]) if (scalar @reference);
2 - 116
 
117
print $h->close ("body"), $h->close ("html");
118
 
119
 
5 - 120