Bug 32437: Add Objects for ImportAuths
[koha-ffzg.git] / cataloguing / additem.pl
index d4fca01..bbf801b 100755 (executable)
@@ -50,7 +50,6 @@ use MARC::File::XML;
 use MIME::Base64 qw( decode_base64url encode_base64url );
 use Storable qw( freeze thaw );
 use URI::Escape qw( uri_escape_utf8 );
-use URI::Escape qw( uri_escape_utf8 );
 
 our $dbh = C4::Context->dbh;
 
@@ -159,7 +158,15 @@ my ($template, $loggedinuser, $cookie)
 
 
 # Does the user have a restricted item editing permission?
-my $uid = Koha::Patrons->find( $loggedinuser )->userid;
+my $patron = Koha::Patrons->find( $loggedinuser );
+
+my $item = $itemnumber ? Koha::Items->find( $itemnumber ) : undef;
+if ( $item && !$patron->can_edit_items_from( $item->homebranch ) ) {
+    print $input->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber");
+    exit;
+}
+
+my $uid = $patron->userid;
 my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
 # In case user is a superlibrarian, editing is not restricted
 $restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
@@ -627,7 +634,9 @@ if ($op) {
 
 my @items;
 for my $item ( $biblio->items->as_list, $biblio->host_items->as_list ) {
-    push @items, $item->columns_to_str;
+    my $i = $item->columns_to_str;
+    $i->{nomod} = 1 unless $patron->can_edit_items_from($item->homebranch);
+    push @items, $i;
 }
 
 my @witness_attributes = uniq map {