View | Details | Raw Unified | Return to bug 20256
Collapse All | Expand All

(-)a/Koha/Item.pm (-3 / +1 lines)
Lines 276-284 sub safe_to_delete { Link Here
276
276
277
    return "not_same_branch"
277
    return "not_same_branch"
278
      if defined C4::Context->userenv
278
      if defined C4::Context->userenv
279
      and !C4::Context->IsSuperLibrarian()
279
      and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $self ) )
280
      and C4::Context->preference("IndependentBranches")
281
      and ( C4::Context->userenv->{branch} ne $self->homebranch );
282
280
283
    # check it doesn't have a waiting reserve
281
    # check it doesn't have a waiting reserve
284
    return "book_reserved"
282
    return "book_reserved"
(-)a/catalogue/detail.pl (-7 / +1 lines)
Lines 383-395 foreach my $item (@items) { Link Here
383
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
383
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
384
    }
384
    }
385
385
386
    if ( C4::Context->preference('IndependentBranches') ) {
386
    $item->{cannot_be_edited} = !$patron->can_edit_item( $item_object );
387
        my $userenv = C4::Context->userenv();
388
        if ( not C4::Context->IsSuperLibrarian()
389
            and $userenv->{branch} ne $item->{homebranch} ) {
390
            $item->{cannot_be_edited} = 1;
391
        }
392
    }
393
387
394
    if ( C4::Context->preference("LocalCoverImages") == 1 ) {
388
    if ( C4::Context->preference("LocalCoverImages") == 1 ) {
395
        $item->{cover_images} = $item_object->cover_images;
389
        $item->{cover_images} = $item_object->cover_images;
(-)a/catalogue/moredetail.pl (+3 lines)
Lines 232-237 foreach my $item (@items){ Link Here
232
                $item->{'nomod'}=1;
232
                $item->{'nomod'}=1;
233
        }
233
        }
234
    }
234
    }
235
236
    $item->{nomod} = !$patron->can_edit_item( $item );
237
235
    if ($item->{'datedue'}) {
238
    if ($item->{'datedue'}) {
236
        $item->{'issue'}= 1;
239
        $item->{'issue'}= 1;
237
    } else {
240
    } else {
(-)a/cataloguing/additem.pl (-4 / +9 lines)
Lines 445-451 my ($template, $loggedinuser, $cookie) Link Here
445
445
446
446
447
# Does the user have a restricted item editing permission?
447
# Does the user have a restricted item editing permission?
448
my $uid = Koha::Patrons->find( $loggedinuser )->userid;
448
my $patron = Koha::Patrons->find( $loggedinuser );
449
my $uid = $patron->userid;
449
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
450
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
450
# In case user is a superlibrarian, editing is not restricted
451
# In case user is a superlibrarian, editing is not restricted
451
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
452
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
Lines 863-875 foreach my $field (@fields) { Link Here
863
						|| $subfieldvalue;
864
						|| $subfieldvalue;
864
        }
865
        }
865
866
866
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
867
        if (   $subfieldvalue
868
            && ( $field->tag eq $branchtagfield )
869
            && ( $subfieldcode eq $branchtagsubfield ) )
870
        {
867
            #verifying rights
871
            #verifying rights
868
            my $userenv = C4::Context->userenv();
872
            unless ( $patron->can_edit_item($subfieldvalue) ) {
869
            unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $subfieldvalue))){
873
                warn "NOMOD";
870
                $this_row{'nomod'} = 1;
874
                $this_row{'nomod'} = 1;
871
            }
875
            }
872
        }
876
        }
877
873
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
878
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
874
879
875
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
880
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +3 lines)
Lines 350-356 Link Here
350
                <tr>
350
                <tr>
351
                [% IF (StaffDetailItemSelection) %]
351
                [% IF (StaffDetailItemSelection) %]
352
                    <td style="text-align:center;vertical-align:middle">
352
                    <td style="text-align:center;vertical-align:middle">
353
                        <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
353
                        [% UNLESS item.cannot_be_edited %]
354
                            <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
355
                        [% END %]
354
                    </td>
356
                    </td>
355
                [% END %]
357
                [% END %]
356
                    [% IF Koha.Preference('LocalCoverImages') && ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %]
358
                    [% IF Koha.Preference('LocalCoverImages') && ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %]
(-)a/tools/batchMod.pl (-12 / +8 lines)
Lines 84-90 my ($template, $loggedinuser, $cookie) Link Here
84
$template->param( searchid => scalar $input->param('searchid'), );
84
$template->param( searchid => scalar $input->param('searchid'), );
85
85
86
# Does the user have a restricted item edition permission?
86
# Does the user have a restricted item edition permission?
87
my $uid = $loggedinuser ? Koha::Patrons->find( $loggedinuser )->userid : undef;
87
my $patron = Koha::Patrons->find( $loggedinuser );
88
my $uid = $loggedinuser ? $patron->userid : undef;
88
my $restrictededition = $uid ? haspermission($uid,  {'tools' => 'items_batchmod_restricted'}) : undef;
89
my $restrictededition = $uid ? haspermission($uid,  {'tools' => 'items_batchmod_restricted'}) : undef;
89
# In case user is a superlibrarian, edition is not restricted
90
# In case user is a superlibrarian, edition is not restricted
90
$restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian());
91
$restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian());
Lines 641-661 sub BuildItemsData{ Link Here
641
    my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField( "items.itemnumber" );
642
    my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField( "items.itemnumber" );
642
    my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField( "items.homebranch" );
643
    my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField( "items.homebranch" );
643
		foreach my $itemnumber (@itemnumbers){
644
		foreach my $itemnumber (@itemnumbers){
644
            my $itemdata = Koha::Items->find($itemnumber);
645
            my $item = Koha::Items->find($itemnumber);
645
            next unless $itemdata; # Should have been tested earlier, but just in case...
646
            next unless $item; # Should have been tested earlier, but just in case...
646
            $itemdata = $itemdata->unblessed;
647
            my $itemdata = $item->unblessed;
647
			my $itemmarc=Item2Marc($itemdata);
648
			my $itemmarc=Item2Marc($itemdata);
648
			my %this_row;
649
			my %this_row;
649
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
650
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
650
				# loop through each subfield
651
				# loop through each subfield
651
				my $itembranchcode=$field->subfield($branchtagsubfield);
652
				my $itembranchcode=$field->subfield($branchtagsubfield);
652
                if ($itembranchcode && C4::Context->preference("IndependentBranches")) {
653
                if ($itembranchcode) {
653
						#verifying rights
654
                    $this_row{'nomod'} = !$patron->can_edit_item($item);
654
						my $userenv = C4::Context->userenv();
655
                }
655
                        unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $itembranchcode))){
656
								$this_row{'nomod'}=1;
657
						}
658
				}
659
				my $tag=$field->tag();
656
				my $tag=$field->tag();
660
				foreach my $subfield ($field->subfields) {
657
				foreach my $subfield ($field->subfields) {
661
					my ($subfcode,$subfvalue)=@$subfield;
658
					my ($subfcode,$subfvalue)=@$subfield;
662
- 

Return to bug 20256