[open-ils-commits] r13616 - trunk/Open-ILS/src/perlmods/OpenILS/Application (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Jul 16 16:22:21 EDT 2009
Author: erickson
Date: 2009-07-16 16:22:17 -0400 (Thu, 16 Jul 2009)
New Revision: 13616
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Log:
1. OK to have duplicate usr_standing_penalty's. 2. find the best context org using the configured penalty org depth. 3. set the staff field.
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2009-07-16 20:07:02 UTC (rev 13615)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2009-07-16 20:22:17 UTC (rev 13616)
@@ -2679,23 +2679,24 @@
sub apply_penalty {
my($self, $conn, $auth, $penalty) = @_;
+
my $e = new_editor(authtoken=>$auth, xact => 1);
return $e->die_event unless $e->checkauth;
+
my $user = $e->retrieve_actor_user($penalty->usr) or return $e->die_event;
return $e->die_event unless $e->allowed('UPDATE_USER', $user->home_ou);
- # is it already applied?
- return 1 if $e->search_actor_user_standing_penalty(
- { usr => $penalty->usr,
- '-or' => [
- {stop_date => undef},
- {stop_date => {'>' => 'now'}}
- ],
- standing_penalty => $penalty->standing_penalty,
- org_unit => $penalty->org_unit
- })->[0];
+ my $ptype = $e->retrieve_config_standing_penalty($penalty->standing_penalty) or return $e->die_event;
+
+ my $ctx_org =
+ (defined $ptype->org_depth) ?
+ $U->org_unit_ancestor_at_depth($penalty->org_unit, $ptype->org_depth) :
+ $penalty->org_unit;
+ $penalty->org_unit($ctx_org);
+ $penalty->staff($e->requestor->id);
$e->create_actor_user_standing_penalty($penalty) or return $e->die_event;
+
$e->commit;
return $penalty->id;
}
More information about the open-ils-commits
mailing list