Bug 20639: Add ILLOpacbackends syspref
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 24 Apr 2018 13:15:22 +0000 (14:15 +0100)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 7 Mar 2019 20:51:11 +0000 (20:51 +0000)
This adds the ILLOpacbackends syspref, allowing users to refine the ill
backends available to opac users for initiating ill requests

Remove default assignment for backends

We don't need a default assignment for the ILLOpacbackends assignment,
if the pref isn't set, it returns undef anyway. Also, having this
default assignment actually breaks the fetching of the preference

Signed-off-by: Niamh.Walker-Headon@it-tallaght.ie
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Koha/Illrequest/Config.pm
installer/data/mysql/atomicupdate/bug_20639-add_ILLOpacbackends_syspref.perl [new file with mode: 0644]
installer/data/mysql/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
opac/opac-illrequests.pl

index 7db926e..a64b29b 100644 (file)
@@ -104,16 +104,21 @@ sub backend_dir {
 
 =head3 available_backends
 
-Return a list of available backends.
+  $backends = $config->available_backends;
+  $backends = $config->abailable_backends($reduced);
+
+Return a list of available backends, if passed a | delimited list it
+will filter those backends down to only those present in the list.
 
 =cut
 
 sub available_backends {
-    my ( $self ) = @_;
+    my ( $self, $reduce ) = @_;
     my $backend_dir = $self->backend_dir;
     my @backends = ();
     @backends = glob "$backend_dir/*" if ( $backend_dir );
     @backends = map { basename($_) } @backends;
+    @backends = grep { $_ =~ /$reduce/ } @backends if $reduce;
     return \@backends;
 }
 
diff --git a/installer/data/mysql/atomicupdate/bug_20639-add_ILLOpacbackends_syspref.perl b/installer/data/mysql/atomicupdate/bug_20639-add_ILLOpacbackends_syspref.perl
new file mode 100644 (file)
index 0000000..d74b368
--- /dev/null
@@ -0,0 +1,11 @@
+$DBversion = 'XXX';  # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(q|
+      INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+      VALUES ('ILLOpacbackends',NULL,NULL,'ILL backends to enabled for OPAC initiated requests','multiple');
+    |);
+
+    # Always end with this (adjust the bug info)
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 20639 - Add ILLOpacbackends syspref)\n";
+}
index d142b14..be111b6 100644 (file)
@@ -218,6 +218,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('IdRef','0','','Disable/enable the IdRef webservice from the OPAC detail page.','YesNo'),
 ('ILLModule','0','If ON, enables the interlibrary loans module.','','YesNo'),
 ('ILLModuleCopyrightClearance','','70|10','Enter text to enable the copyright clearance stage of request creation. Text will be displayed','Textarea'),
+('ILLOpacbackends',NULL,NULL,'ILL backends to enabled for OPAC initiated requests','multiple'),
 ('ILS-DI','0','','Enables ILS-DI services at OPAC.','YesNo'),
 ('ILS-DI:AuthorizedIPs','','Restricts usage of ILS-DI to some IPs','.','Free'),
 ('ImageLimit','5','','Limit images stored in the database by the Patron Card image manager to this number.','Integer'),
index 2d80bdd..d1c7072 100644 (file)
@@ -796,6 +796,11 @@ Circulation:
             - pref: ILLModuleCopyrightClearance
               type: textarea
               class: long
+        -
+            - "ILL backends to enabled for OPAC initiated requests:"
+            - pref: ILLOpacbackends
+              class: multi
+            - (separated with |).
     Fines Policy:
         -
             - Calculate fines based on days overdue
index 1b7807c..0ba9e0b 100755 (executable)
@@ -50,7 +50,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
 });
 
 # Are we able to actually work?
-my $backends = Koha::Illrequest::Config->new->available_backends;
+my $reduced  = C4::Context->preference('ILLOpacbackends');
+my $backends = Koha::Illrequest::Config->new->available_backends($reduced);
 my $backends_available = ( scalar @{$backends} > 0 );
 $template->param( backends_available => $backends_available );