(bug #3284) fix borrower deletion in independantbranches mode
authorNahuel ANGELINETTI <nahuel.angelinetti@biblibre.com>
Thu, 25 Jun 2009 10:57:35 +0000 (12:57 +0200)
committerGalen Charlton <galen.charlton@liblime.com>
Mon, 29 Jun 2009 19:27:15 +0000 (14:27 -0500)
This patch fix the checks deleting a borrower in independantbranches mode.
Now, we check the user and the librarian are from the same branch, else we deny the deletion(and disable the link to delete).

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
members/deletemem.pl
members/moremember.pl

index 6942f73..8da6db2 100644 (file)
@@ -57,7 +57,7 @@ function update_child() {
                var moremenu = [
                        { text: _("Renew Patron"),  onclick: { fn: confirm_reregistration } },
                        { text: _("Set Permissions"), url: "/cgi-bin/koha/members/member-flags.pl?member=<!-- TMPL_VAR NAME="borrowernumber" -->"<!-- TMPL_UNLESS NAME="CAN_user_permissions" -->, disabled: true<!-- /TMPL_UNLESS -->},
-                       { text: _("Delete"), onclick: { fn: confirm_deletion } },
+                       { text: _("Delete"), onclick: { fn: confirm_deletion}<!-- TMPL_UNLESS NAME="samebranch" -->, disabled: true<!-- /TMPL_IF --> },
                        { text: _("Update Child to Adult Patron") , onclick: { fn: update_child }<!-- TMPL_UNLESS NAME="is_child" -->, disabled: true<!-- /TMPL_UNLESS -->}
                ];
 
index 99b779d..a1694f6 100755 (executable)
@@ -57,14 +57,15 @@ if ($bor->{category_type} eq "S") {
 }
 
 if (C4::Context->preference("IndependantBranches")) {
-    unless ($userenv->{flags} % 2 == 1){
-        unless ($userenv->{'branch'} eq $bor->{'branchcode'}){
-#           warn "user ".$userenv->{'branch'} ."borrower :". $bor->{'branchcode'};
+    my $userenv = C4::Context->userenv;
+    if ($userenv->{flags} != 1 && $bor->{'branchcode'}){
+        unless ($userenv->{branch} eq $bor->{'branchcode'}){
             print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
-            exit 1;
+            exit;
         }
     }
 }
+
 my $dbh = C4::Context->dbh;
 my $sth=$dbh->prepare("Select * from borrowers where guarantorid=?");
 $sth->execute($member);
index e7b718a..494121f 100755 (executable)
@@ -198,6 +198,8 @@ if ( C4::Context->preference("IndependantBranches") ) {
         $samebranch = ( $data->{'branchcode'} eq $userenv->{branch} );
     }
     $samebranch = 1 if ( $userenv->{flags} % 2 == 1 );
+}else{
+    $samebranch = 1;
 }
 my $branchdetail = GetBranchDetail( $data->{'branchcode'});
 $data->{'branchname'} = $branchdetail->{branchname};
@@ -371,6 +373,7 @@ $template->param(
 #   reserveloop     => \@reservedata,
     dateformat      => C4::Context->preference("dateformat"),
     "dateformat_" . (C4::Context->preference("dateformat") || '') => 1,
+    samebranch     => $samebranch,
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;