From: Bill Erickson Date: Wed, 25 Mar 2020 14:28:15 +0000 (-0400) Subject: SIP2Gateway DB configs wip X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=fd361ef0898fe16dae7a116fa6068e9de4385165;p=working%2FEvergreen.git SIP2Gateway DB configs wip Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SIP2Gateway.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SIP2Gateway.pm index 2b88721528..587d557e82 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SIP2Gateway.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SIP2Gateway.pm @@ -113,7 +113,7 @@ my $json = JSON::XS->new; $json->ascii(1); $json->allow_nonref(1); -my $SIP_DATE_FORMAT = "%Y%m%d %H%M%S"; +use constant SIP_DATE_FORMAT => "%Y%m%d %H%M%S"; # TODO: move to config / database my $config = { @@ -162,6 +162,7 @@ sub import { $osrf_config = shift; } +my $config; my $init_complete = 0; sub init { return if $init_complete; @@ -170,12 +171,48 @@ sub init { OpenSRF::System->bootstrap_client(config_file => $osrf_config); OpenILS::Utils::CStoreEditor->init; - return Apache2::Const::OK; + my $e = new_editor(); + + my $settings = $e->retrieve_all_config_sip_setting; + + $config = { + institutions => [] + }; + + # Institution specific settings. + # In addition to the options, this tells us what institutions we support. + for my $set (grep {$_->institution ne '*'} @$settings) { + my $inst = $set->institution; + my $value = $json->decode($set->value); + my $name = $set->name; + + my ($inst_conf) = + grep {$_->id eq $inst} @{$config->{institutions}} || + { id => $inst, + currency => 'USD', + supports => [], + options => {} + }; + + $inst_conf->{options}->{$name} = $value; + } + + # Global options only are only used when they do not replace + # institution-specific options. + for my $set (grep {$_->institution eq '*'} @$settings) { + my $name = $set->name; + my $value = $json->decode($set->value); + + for my $inst_conf (@{$config->{institutions}}) { + $inst_conf->{options}->{$name} = $value + unless exists $inst_conf->{options}->{$name}; + } + } } sub sipdate { my $date = shift || DateTime->now; - return $date->strftime($SIP_DATE_FORMAT); + return $date->strftime(SIP_DATE_FORMAT); } # False == 'N' diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.sip-config.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.sip-config.sql index 1d094d510f..39e9beefc7 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.sip-config.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.sip-config.sql @@ -31,14 +31,20 @@ INSERT INTO actor.passwd_type (code, name, login, crypt_algo, iter_count) VALUES ('sip2', 'SIP2 Client Password', FALSE, 'bf', 5); /* EXAMPLE SETTINGS + +-- Example linking a SIP password to the 'admin' account. +SELECT actor.set_passwd(1, 'sip2', 'sip_password'); + INSERT INTO config.sip_setting (institution, name, value) VALUES ('*', 'allow_sc_status_before_login', 'true'), + ('*', 'currency', 'USD'), ('example', 'due_date_use_sip_date_format', 'false'), ('example', 'patron_status_permit_loans', 'false'), ('example', 'patron_status_permit_all', 'false'), ('example', 'msg64_hold_items_available', 'false') -); +; + */ COMMIT;