From: Steven Callender Date: Thu, 14 Nov 2013 20:07:33 +0000 (-0500) Subject: LP#1251415: Use the juvenile setting when removing juvenile flag. X-Git-Tag: sprint4-merge-nov22~880 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0fd4ecc461258320328bb5a63aa24ca0e9488a03;p=working%2FEvergreen.git LP#1251415: Use the juvenile setting when removing juvenile flag. When calling the API open-ils.storage.actor.user.juvenile_to_adult, most notably from the juv_to_adult.srfsh support script, instead of strictly using the hardcoded passed value, first check the global.juvenile_age_threshold from the settings based on the user's home library. If the setting does not exist, then fall back on the hardcoded passed value. This will allow each library to be able to set different juvenile thresholds if needed and at the very least, give control to the settings rather than rely strictly on the hardcoded passed value. Signed-off-by: Steven Callender Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm index f55da8c998..ff9327ff11 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm @@ -32,8 +32,11 @@ sub juv_to_adult { my $sql = <<" SQL"; UPDATE actor.usr SET juvenile = FALSE - WHERE AGE(dob) > ?::INTERVAL - AND juvenile IS TRUE; + WHERE id IN ( + SELECT au.id + FROM actor.usr au + WHERE AGE(au.dob) > COALESCE( BTRIM( (SELECT value FROM actor.org_unit_ancestor_setting('global.juvenile_age_threshold', au.home_ou)),'"' ), ? )::INTERVAL + AND au.juvenile IS TRUE) SQL my $sth = actor::user->db_Main->prepare_cached($sql);