From 507cc5c24dfede0607dd8151cbe1a0bd2a48e080 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 16 Jul 2009 20:22:17 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@13616 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Actor.pm | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index 68503d188a..7d1c5b19fb 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -2679,23 +2679,24 @@ __PACKAGE__->register_method( 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; } -- 2.11.0