use Data::Dumper;
use LWP::UserAgent;
use OpenILS::Utils::KCLSNormalize;
+use DateTime;
$Data::Dumper::Indent = 0;
my $U = 'OpenILS::Application::AppUtils';
# KCLS JBAS-1138
my $profile = $U->ou_ancestor_setting_value(
$user->home_ou, 'opac.self_register.profile');
+
+ $self->apply_net_access_level($user);
$user->profile($profile) if $profile;
return Apache2::Const::OK;
}
+
+sub apply_net_access_level {
+ my ($self, $user) = @_;
+ return unless $user->dob;
+
+ # DoB is YYYY-MM-DD
+ my @parts = split(/-/, $user->dob);
+
+ my $dob_date;
+ eval {
+ # avoid dying on funky dates
+ $dob_date = DateTime->new(
+ year => $parts[0], month => $parts[1], day => $parts[2]);
+ };
+
+ return unless $dob_date;
+
+ # DoB has no time, so compare to a date w/ no time.
+ my $comp_date = DateTime->now;
+ $comp_date->set_hour(0);
+ $comp_date->set_minute(0);
+ $comp_date->set_second(0);
+ $comp_date->subtract(years => 17);
+
+ $user->net_access_level(
+ $comp_date >= $dob_date ? # 17 or older.
+ 1 : # == 17 and Up Only
+ 102 # == Under 17 Plus
+ );
+}
+
# returns true if the addresses contain all of the same values.
sub addrs_match {
my ($self, $addr1, $addr2) = @_;