From a97aab0212f2d41221df3b387d57e1dd03f539e9 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Thu, 4 Feb 2010 10:20:46 -0500 Subject: [PATCH] Bugfix: Adding error trapping for missing or invalid branch code 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. Signed-off-by: Galen Charlton --- .../intranet-tmpl/prog/en/includes/error-messages.inc | 2 ++ patroncards/edit-batch.pl | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) 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 0d1c43f0f8..7eb0fe85a5 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 on . Please have your system administrator check the error log for details. An error has occurred. Please ask your system administrator to check the error log for more details. + + A non-existent or invalid branch code was supplied. Please verify that you have a branch selected. An error has occurred while attempting to upload the image file. Please ask you system administrator to check the error log for more details. diff --git a/patroncards/edit-batch.pl b/patroncards/edit-batch.pl index 9c3a57d406..47f0896966 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'); } -- 2.39.5