Bug 6885 Allow superlib to delete items from any library
authorFrédéric Demians <f.demians@tamil.fr>
Mon, 19 Sep 2011 17:53:38 +0000 (19:53 +0200)
committerChris Cormack <chrisc@catalyst.net.nz>
Thu, 13 Oct 2011 02:52:20 +0000 (15:52 +1300)
When IndependantBranches syspref is enabled, a 'regular' user can only
delete items belonging to his/her library. But a superlibrarian should
have the permission to delete items from all libraries. He can't for the
time being. This is fix by this patch.

How to test?

- On a multi-libraries Koha, activate IndependantBranches
- Log in with a superlibrarian user
- Find a biblio with one item from another library than the user home
  library
- Click on Edit > Edit Items
- On the list of items, all lines have Delete link
- If you try to delete an item from another library than the user home
  library, deletion will fail.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
C4/Items.pm

index 6092fec..328c627 100644 (file)
@@ -2198,7 +2198,11 @@ sub DelItemCheck {
     if ($onloan){
         $error = "book_on_loan" 
     }
-    elsif (C4::Context->preference("IndependantBranches") and (C4::Context->userenv->{branch} ne $item->{C4::Context->preference("HomeOrHoldingBranch")||'homebranch'})){
+    elsif ( C4::Context->userenv->{flags} % 2 != 1 and
+            C4::Context->preference("IndependantBranches") and
+           (C4::Context->userenv->{branch} ne
+             $item->{C4::Context->preference("HomeOrHoldingBranch")||'homebranch'}) )
+    {
         $error = "not_same_branch";
     }
        else{