[open-ils-commits] r10594 - trunk/Open-ILS/src/perlmods/OpenILS/Application

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Sep 15 12:41:50 EDT 2008


Author: erickson
Date: 2008-09-15 12:41:47 -0400 (Mon, 15 Sep 2008)
New Revision: 10594

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
Log:
copy checkout history now limited by org setting and better permission checking.  more cleanup

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm	2008-09-15 16:40:57 UTC (rev 10593)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm	2008-09-15 16:41:47 UTC (rev 10594)
@@ -514,74 +514,7 @@
 	api_name		=> 'open-ils.circ.non_cat_in_house_use.create',
 );
 
-=head OLD CODE
-sub ___create_in_house_use {
-	my( $self, $client, $authtoken, $params ) = @_;
 
-	my( $staff, $evt, $copy );
-	my $org			= $params->{location};
-	my $copyid		= $params->{copyid};
-	my $count		= $params->{count} || 1;
-	my $nc_type		= $params->{non_cat_type};
-	my $use_time	= $params->{use_time} || 'now';
-
-	my $non_cat = 1 if $self->api_name =~ /non_cat/;
-
-	unless( $non_cat ) {
-		unless( $copyid ) {
-			my $barcode = $params->{barcode};
-			($copy, $evt) = $U->fetch_copy_by_barcode($barcode);
-			return $evt if $evt;
-			$copyid = $copy->id;
-		}
-		($copy, $evt) = $U->fetch_copy($copyid) unless $copy;
-		return $evt if $evt;
-	}
-
-	($staff, $evt) = $U->checkses($authtoken);
-	return $evt if $evt;
-
-	$evt = $U->check_perms($staff->id, $org, 'CREATE_IN_HOUSE_USE');
-	return $evt if $evt;
-
-	if( $use_time ne 'now' ) {
-		$use_time = clense_ISO8601($use_time);
-		$logger->debug("in_house_use setting use time to $use_time");
-	}
-
-	my @ids;
-	for(1..$count) {
-
-		my $ihu;
-		my $method;
-
-		if($non_cat) {
-			$ihu = Fieldmapper::action::non_cat_in_house_use->new;
-			$ihu->noncat_type($nc_type);
-			$method = 'open-ils.storage.direct.action.non_cat_in_house_use.create';
-		} else {
-			$ihu = Fieldmapper::action::in_house_use->new;
-			$ihu->item($copyid);
-			$method = 'open-ils.storage.direct.action.in_house_use.create';
-		}
-
-		$ihu->staff($staff->id);
-		$ihu->org_unit($org);
-		$ihu->use_time($use_time);
-
-		my $id = $U->simplereq('open-ils.storage', $method, $ihu );
-
-		return $U->DB_UPDATE_FAILED($ihu) unless $id;
-		push @ids, $id;
-	}
-
-	return \@ids;
-}
-=cut
-
-
-
-
 sub create_in_house_use {
 	my( $self, $client, $auth, $params ) = @_;
 
@@ -660,29 +593,38 @@
 		@return An array of circ ids
 	/);
 
-
-
+# ----------------------------------------------------------------------
+# Returns $count most recent circs.  If count exceeds the configured 
+# max, use the configured max instead
+# ----------------------------------------------------------------------
 sub view_circs {
 	my( $self, $client, $authtoken, $copyid, $count ) = @_; 
 
-	my( $requestor, $evt ) = $U->checksesperm(
-			$authtoken, 'VIEW_COPY_CHECKOUT_HISTORY' );
-	return $evt if $evt;
+    my $e = new_editor(authtoken => $authtoken);
+    return $e->event unless $e->checkauth;
+    
+    my $copy = $e->retrieve_asset_copy([
+        $copyid,
+        {   flesh => 1,
+            flesh_fields => {acp => ['call_number']}
+        }
+    ]) or return $e->event;
 
+    return $e->event unless $e->allowed(
+        'VIEW_COPY_CHECKOUT_HISTORY', 
+        ($copy->call_number == OILS_PRECAT_CALL_NUMBER) ? 
+            $copy->circ_lib : $copy->call_number->owning_lib);
+        
+    my $max_history = $U->ou_ancestor_setting_value(
+        $user->home_ou, 'circ.item_checkout_history.max', $e);
+    $count = ($max_history and $max_history < $count) ? $max_history : $count;
+
 	return [] unless $count;
 
-	my $circs = $U->cstorereq(
-		'open-ils.cstore.direct.action.circulation.search.atomic',
-			{ 
-				target_copy => $copyid, 
-			}, 
-			{ 
-				limit => $count, 
-				order_by => { circ => "xact_start DESC" }
-			} 
-	);
-
-	return $circs;
+    return $e->search_action_circulation([
+        {target_copy => $copyid}, 
+        {limit => $count, order_by => { circ => "xact_start DESC" }} 
+    ]);
 }
 
 



More information about the open-ils-commits mailing list