| Line 10... |
Line 10... |
| 10 |
use WebDB;
|
10 |
use WebDB;
|
| Line 11... |
Line 11... |
| 11 |
|
11 |
|
| 12 |
$SIG{__WARN__} = sub { warn sprintf("[%s] ", scalar localtime), @_ };
|
12 |
$SIG{__WARN__} = sub { warn sprintf("[%s] ", scalar localtime), @_ };
|
| Line 13... |
Line 13... |
| 13 |
$SIG{__DIE__} = sub { die sprintf("[%s] ", scalar localtime), @_ };
|
13 |
$SIG{__DIE__} = sub { die sprintf("[%s] ", scalar localtime), @_ };
|
| Line 14... |
Line 14... |
| 14 |
|
14 |
|
| 15 |
our @EXPORT = qw( $ORCUSER $SYSTEM_EMAIL getRCDBH getAccessLevels authDB max authenticate canView getShiftDepartment getClassID getDepartments convertDepartments convertTime getSchedule getRCid getSetting getUser getUserEmail getUserDerbyName getYears printRCHeader changeShift modShiftTime signUpCount signUpEligible findConflict changeLeadShift sendNewUserEMail logit);
|
15 |
our @EXPORT = qw( $ORCUSER $SYSTEM_EMAIL getRCDBH getAccessLevels authDB max authenticate canView getShiftDepartment getClassID getDepartments convertDepartments convertTime getSchedule getRCid getSetting getUser getUserEmail getUserDerbyName getYears printRCHeader changeShift modShiftTime signUpCount signUpEligible findConflict changeLeadShift sendNewUserEMail logit validate_emt);
|
| 16 |
|
16 |
|
| 17 |
my $dbh = WebDB->connect ();
|
17 |
my $dbh = WebDB->connect ();
|
| Line 146... |
Line 146... |
| 146 |
# my @depts = map { s/-\d// } split /:/, $RCDBIDHASH->{department};
|
146 |
# my @depts = map { s/-\d// } split /:/, $RCDBIDHASH->{department};
|
| 147 |
# my @depts = split /:/, $RCDBIDHASH->{department};
|
147 |
# my @depts = split /:/, $RCDBIDHASH->{department};
|
| Line 148... |
Line 148... |
| 148 |
|
148 |
|
| 149 |
$ORCUSER = $RCDBIDHASH;
|
149 |
$ORCUSER = $RCDBIDHASH;
|
| - |
|
150 |
$ORCUSER->{MVPid} = getUser($ORCUSER->{RCid})->{MVPid};
|
| 150 |
$ORCUSER->{MVPid} = getUser($ORCUSER->{RCid})->{MVPid};
|
151 |
$ORCUSER->{emt_verified} = getUser($ORCUSER->{RCid})->{emt_verified};
|
| 151 |
}
|
152 |
}
|
| 152 |
return $result;
|
153 |
return $result;
|
| Line 153... |
Line 154... |
| 153 |
}
|
154 |
}
|
| Line 874... |
Line 875... |
| 874 |
} else {
|
875 |
} else {
|
| 875 |
if ($user->{department}->{$dept} < 1) { return 0; }
|
876 |
if ($user->{department}->{$dept} < 1) { return 0; }
|
| 876 |
}
|
877 |
}
|
| 877 |
if (lc $t->{type} eq "lead" and $user->{department}->{$dept} < 2) { return 0; }
|
878 |
if (lc $t->{type} eq "lead" and $user->{department}->{$dept} < 2) { return 0; }
|
| 878 |
if (lc $t->{type} eq "manager" and $user->{department}->{$dept} < 3) { return 0; }
|
879 |
if (lc $t->{type} eq "manager" and $user->{department}->{$dept} < 3) { return 0; }
|
| - |
|
880 |
if ($dept eq "EMT" and $user->{emt_verified} == 0) { return 0; }
|
| 879 |
if (lc $t->{type} !~ /^selected/ and $user->{$limitkey} < $limit) {
|
881 |
if (lc $t->{type} !~ /^selected/ and $user->{$limitkey} < $limit) {
|
| 880 |
return 1;
|
882 |
return 1;
|
| 881 |
} else {
|
883 |
} else {
|
| 882 |
return 0;
|
884 |
return 0;
|
| 883 |
}
|
885 |
}
|
| Line 1024... |
Line 1026... |
| 1024 |
# send the message
|
1026 |
# send the message
|
| 1025 |
EmailUser ($email, $subject, $body);
|
1027 |
EmailUser ($email, $subject, $body);
|
| Line 1026... |
Line 1028... |
| 1026 |
|
1028 |
|
| Line -... |
Line 1029... |
| - |
|
1029 |
}
|
| - |
|
1030 |
|
| - |
|
1031 |
sub validate_emt {
|
| - |
|
1032 |
my $target = shift // "";
|
| - |
|
1033 |
my $change = shift // "";
|
| - |
|
1034 |
|
| - |
|
1035 |
if (!$target or !$change) {
|
| - |
|
1036 |
warn "ERROR: validate_emt() called without a required parameter! target: $target, change: $change";
|
| - |
|
1037 |
return -1;
|
| - |
|
1038 |
}
|
| - |
|
1039 |
|
| - |
|
1040 |
my $uservalidate = getUser $target;
|
| - |
|
1041 |
if (!exists $uservalidate->{RCid}) {
|
| - |
|
1042 |
warn "ERROR: validate_emt() called on a non-existant user! target: $target, change: $change";
|
| - |
|
1043 |
return -1;
|
| - |
|
1044 |
}
|
| - |
|
1045 |
|
| - |
|
1046 |
if ($change eq "add") {
|
| - |
|
1047 |
if ($uservalidate->{emt_verified}) {
|
| - |
|
1048 |
warn "ERROR: validate_emt() called to add on a user already verified: $target, change: $change";
|
| - |
|
1049 |
return -1;
|
| - |
|
1050 |
} else {
|
| - |
|
1051 |
$dbh->do ("insert into emt_credential_verified (RCid, date, verified_by) values (?, date(now()), ?)", undef, $target, $ORCUSER->{RCid}) or warn $dbh->errstr;
|
| - |
|
1052 |
logit ($target, "EMT Credentials Verified");
|
| - |
|
1053 |
logit ($ORCUSER->{RCid}, "Verified EMT Credentials for $uservalidate->{derby_name} [$target]");
|
| - |
|
1054 |
}
|
| - |
|
1055 |
} elsif ($change eq "del") {
|
| - |
|
1056 |
if (!$uservalidate->{emt_verified}) {
|
| - |
|
1057 |
warn "ERROR: validate_emt() called to del on a user that isn't verified: $target, change: $change";
|
| - |
|
1058 |
return -1;
|
| - |
|
1059 |
} else {
|
| - |
|
1060 |
$dbh->do ("delete from emt_credential_verified where date = date(now()) and RCid = ?", undef, $target) or warn $dbh->errstr;
|
| - |
|
1061 |
logit ($target, "EMT Credential Verification removed");
|
| - |
|
1062 |
logit ($ORCUSER->{RCid}, "Removed EMT Credential verification for $uservalidate->{derby_name} [$target]");
|
| - |
|
1063 |
}
|
| - |
|
1064 |
} else {
|
| - |
|
1065 |
warn "ERROR: validate_emt() called with a bad parameter! target: $target, change: $change";
|
| - |
|
1066 |
return -1;
|
| - |
|
1067 |
}
|
| Line 1027... |
Line 1068... |
| 1027 |
}
|
1068 |
}
|