[Koha-patches] [PATCH] Bugfix: Adding error trapping for missing or invalid branch code

Chris Nighswonger cnighswonger at foundations.edu
Thu Feb 4 16:20:46 CET 2010


This patch adds code to trap, log, and return an intelligent message to the user
when a missing or invalid branch code is passed in. This condition can occur if
the user is logged in as the kohaadmin or the user has multiple instances of the staff
client open and has switched users in some instance.
---
 .../prog/en/includes/error-messages.inc            |    2 ++
 patroncards/edit-batch.pl                          |    7 ++++++-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/error-messages.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/error-messages.inc
index 0d1c43f..7eb0fe8 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/error-messages.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/error-messages.inc
@@ -79,6 +79,8 @@ window.onload=function(){
         An unsupported operation was attempted<!-- TMPL_IF NAME="element_id" --> on <!-- TMPL_VAR NAME="card_element" --> <!-- TMPL_VAR NAME="element_id" --><!-- /TMPL_IF -->. Please have your system administrator check the error log for details.
         <!-- TMPL_ELSIF NAME="202" -->
         An error has occurred. Please ask your system administrator to check the error log for more details.
+        <!-- TMPL_ELSIF NAME="203" -->
+        A non-existent or invalid branch code was supplied. Please <a href="/cgi-bin/koha/circ/selectbranchprinter.pl">verify</a> that you have a branch selected.
         <!-- TMPL_ELSIF NAME="301" -->
         An error has occurred while attempting to upload the image file. Please ask you system administrator to check the error log for more details.
         <!-- TMPL_ELSIF NAME="302" -->
diff --git a/patroncards/edit-batch.pl b/patroncards/edit-batch.pl
index 9c3a57d..47f0896 100755
--- a/patroncards/edit-batch.pl
+++ b/patroncards/edit-batch.pl
@@ -105,10 +105,15 @@ elsif ($op eq 'de_duplicate') {
         exit;
     }
 }
-elsif ($op = 'edit') {
+elsif ($op eq 'edit') {
     $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
 }
 elsif ($op eq 'new') {
+    if (!$branch_code) {
+        warn sprintf('Batch edit interface called with an invalid/non-existent branch code: %s',$branch_code ? $branch_code : 'NULL');
+        print $cgi->redirect("manage.pl?card_element=batch&error=203") if $err;
+        exit;
+    }
     $batch = C4::Patroncards::Batch->new(branch_code => $branch_code);
     $batch_id = $batch->get_attr('batch_id');
 }
-- 
1.6.0.4



More information about the Koha-patches mailing list