@@ -, +, @@ outside of an IP range --- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++++ .../en/modules/admin/preferences/cataloguing.pref | 4 ++++ opac/opac-search.pl | 12 +++++++++++- 4 files changed, 23 insertions(+), 1 deletions(-) --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -374,3 +374,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( INSERT INTO systempreferences (variable,value,explanation,type) VALUES('EnableBorrowerFiles','0','If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UpdateTotalIssuesOnCirc','0','Whether to update the totalissues field in the biblio on each circ.',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('IntranetSlipPrinterJS','','Use this JavaScript for printing slips. Define at least function printThenClose(). For use e.g. with Firefox PlugIn jsPrintSetup, see http://jsprintsetup.mozdev.org/','','Free'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSuppressionByIPRange','','Restrict the suppression to IP adresses outside of the IP range','','free'); --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -5635,6 +5635,13 @@ if(C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = 'XXX'; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSuppressionByIPRange','','Restrict the suppression to IP adresses outside of the IP range','','free');"); + print "Upgrade to $DBversion done (Add OpacSuppressionByIPRange syspref)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -142,4 +142,8 @@ Cataloging: yes: Hide no: "Don't hide" - items marked as suppressed from OPAC search results. Note that you must have the Suppress index set up in Zebra and at least one suppressed item, or your searches will be broken. + - Restrict the suppression to IP adresses outside of the IP range + - pref: OpacSuppressionByIPRange + class: short + - (Leave blank if not used. Define a range like 192.168..) --- a/opac/opac-search.pl +++ a/opac/opac-search.pl @@ -449,7 +449,17 @@ my @limit_inputs = $limit_cgi ? _input_cgi_parse($limit_cgi) : (); # # add OPAC suppression - requires at least one item indexed with Suppress if (C4::Context->preference('OpacSuppression')) { - $query = "($query) not Suppress=1"; + # OPAC suppression by IP address + if (C4::Context->preference('OpacSuppressionByIPRange')) { + my $IPAddress = $ENV{'REMOTE_ADDR'}; + my $IPRange = C4::Context->preference('OpacSuppressionByIPRange'); + if ($IPAddress !~ /^$IPRange/) { + $query = "($query) not Suppress=1"; + } + } + else { + $query = "($query) not Suppress=1"; + } } $template->param ( LIMIT_INPUTS => \@limit_inputs ); --