From 2d0ec0151e3138f64733919c4ca8ba75f802f783 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc=20V=C3=A9ron?= <veron@veron.ch>
Date: Thu, 5 May 2016 08:13:53 +0200
Subject: [PATCH] [FOLLOW-UP] Bug 15823: Redirect opac-discharge.pl to 404
 page

See comment #17: Redirect to 404 in opac-discharge.pl and remove
message in template because with the redirect it will never be
reached.
---
 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt |    4 ----
 opac/opac-discharge.pl                                     |    5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt
index 23f088d..d8f5648 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt
@@ -23,9 +23,6 @@
             <div class="span10">
                 <div id="discharge" class="maincontainer">
                     <h1>Discharge</h1>
-                    [% IF not(Koha.Preference("useDischarge")) %]
-                        Discharges have not been enabled. Please contact the library.
-                    [% ELSE %]
                     [% FOR message IN messages %]
                         <div class="dialog [% message.type %]">
                         [% IF message.code == "unable_to_generate_pdf" %]
@@ -49,7 +46,6 @@
                         <p><strong>Warning</strong>: This request is only valid if you are in good standing with the library. Once the application is made, you can not borrow library materials.</p>
                         <a href="/cgi-bin/koha/opac-discharge.pl?op=request">Ask for a discharge</a>
                     [% END %]
-                    [% END %]
                 </div> <!-- / #discharge -->
             </div> <!-- / .span10 -->
         </div> <!-- / .row-fluid -->
diff --git a/opac/opac-discharge.pl b/opac/opac-discharge.pl
index c9dea91..605efb7 100755
--- a/opac/opac-discharge.pl
+++ b/opac/opac-discharge.pl
@@ -33,6 +33,11 @@ use Koha::DateUtils;
 
 my $input = new CGI;
 
+unless ( C4::Context->preference('useDischarge') ) {
+    print $input->redirect("/cgi-bin/koha/errors/404.pl");
+    exit;
+}
+
 my $op = $input->param("op");
 
 # Getting the template and auth
-- 
1.7.10.4