[open-ils-commits] r10360 - branches/rel_1_2/Open-ILS/src/offline
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Aug 14 12:42:29 EDT 2008
Author: erickson
Date: 2008-08-14 12:42:26 -0400 (Thu, 14 Aug 2008)
New Revision: 10360
Modified:
branches/rel_1_2/Open-ILS/src/offline/offline.pl
Log:
backporting expire-date calculation for offline patron registration
Modified: branches/rel_1_2/Open-ILS/src/offline/offline.pl
===================================================================
--- branches/rel_1_2/Open-ILS/src/offline/offline.pl 2008-08-14 16:09:25 UTC (rev 10359)
+++ branches/rel_1_2/Open-ILS/src/offline/offline.pl 2008-08-14 16:42:26 UTC (rev 10360)
@@ -13,6 +13,8 @@
use OpenSRF::Utils qw/:daemon/;
use OpenILS::Utils::OfflineStore;
use OpenSRF::Utils::SettingsClient;
+use OpenSRF::Utils;
+use DateTime;
use DBI;
$DBI::trace = 1;
@@ -21,6 +23,7 @@
my $DB = "OpenILS::Utils::OfflineStore";
my $SES = "${DB}::Session";
my $SCRIPT = "OpenILS::Utils::OfflineStore::Script";
+my $user_groups;
# --------------------------------------------------------------------
# Load the config
@@ -92,6 +95,9 @@
$org = $requestor->ws_ou unless $org;
ol_handle_result(OpenILS::Event->new('OFFLINE_NO_ORG')) unless $org;
}
+
+ $user_groups = $U->simplereq(
+ 'open-ils.actor', 'open-ils.actor.groups.retrieve');
}
@@ -770,6 +776,15 @@
# pull all of the rest of the data from the command blob
$actor->$_( $command->{user}->{$_} ) for keys %{$command->{user}};
+ # calculate the expire date for the patron based on the profile group
+ my ($grp) = grep {$_->id == $actor->profile} @$user_groups;
+ if($grp) {
+ my $seconds = OpenSRF::Utils->interval_to_seconds($grp->perm_interval);
+ my $expire_date = DateTime->from_epoch(epoch => DateTime->now->epoch + $seconds);
+ $logger->debug("offline: setting expire date to $expire_date");
+ $actor->expire_date($U->epoch2ISO8601($expire_date));
+ }
+
$logger->debug("offline: creating user object...");
$actor = $U->simplereq(
'open-ils.actor',
More information about the open-ils-commits
mailing list