renew now accepts either a circ object or a circ id
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 15 Jul 2005 17:55:26 +0000 (17:55 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 15 Jul 2005 17:55:26 +0000 (17:55 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1211 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm

index aaa35f0..df2d00c 100644 (file)
@@ -711,8 +711,19 @@ __PACKAGE__->register_method(
 
 sub renew {
        my($self, $client, $login_session, $circ) = @_;
+
+       throw OpenSRF::EX::InvalidArg 
+               ("open-ils.circ.renew no circ") unless defined($circ);
+
        my $user = $apputils->check_user_session($login_session);
 
+       my $session = OpenSRF::AppSession->create("open-ils.storage");
+
+       if(!ref($circ)) {
+               $circ = $session->request(
+                       "open-ils.storage.direct.action.circulation.retrieve", $circ )->gather(1);
+       }
+
        if($user->id ne $circ->usr) {
                if($apputils->check_user_perms($user->id, $user->home_ou, "RENEW_CIRC")) {
                        return OpenILS::Perm->new("RENEW_CIRC");
@@ -726,7 +737,6 @@ sub renew {
        # XXX XXX See if the copy this circ points to is needed to fulfill a hold!
        # XXX check overdue..?
 
-       my $session = OpenSRF::AppSession->create("open-ils.storage");
        my $copy = _grab_copy_by_id($session, $circ->target_copy);
        my $checkin = $self->method_lookup("open-ils.circ.checkin.barcode");
        my ($status) = $checkin->run($login_session, $copy->barcode, 1);