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

(-)a/Koha/Item.pm (-3 / +1 lines)
Lines 267-275 sub safe_to_delete { Link Here
267
267
268
    return "not_same_branch"
268
    return "not_same_branch"
269
      if defined C4::Context->userenv
269
      if defined C4::Context->userenv
270
      and !C4::Context->IsSuperLibrarian()
270
      and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $self ) )
271
      and C4::Context->preference("IndependentBranches")
272
      and ( C4::Context->userenv->{branch} ne $self->homebranch );
273
271
274
    # check it doesn't have a waiting reserve
272
    # check it doesn't have a waiting reserve
275
    return "book_reserved"
273
    return "book_reserved"
(-)a/catalogue/detail.pl (-7 / +1 lines)
Lines 399-411 foreach my $item (@items) { Link Here
399
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
399
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
400
    }
400
    }
401
401
402
    if ( C4::Context->preference('IndependentBranches') ) {
402
    $item->{cannot_be_edited} = !$patron->can_edit_item( $item_object );
403
        my $userenv = C4::Context->userenv();
404
        if ( not C4::Context->IsSuperLibrarian()
405
            and $userenv->{branch} ne $item->{homebranch} ) {
406
            $item->{cannot_be_edited} = 1;
407
        }
408
    }
409
403
410
    if ( C4::Context->preference("LocalCoverImages") == 1 ) {
404
    if ( C4::Context->preference("LocalCoverImages") == 1 ) {
411
        $item->{cover_images} = $item_object->cover_images;
405
        $item->{cover_images} = $item_object->cover_images;
(-)a/catalogue/moredetail.pl (+3 lines)
Lines 234-239 foreach my $item (@items){ Link Here
234
                $item->{'nomod'}=1;
234
                $item->{'nomod'}=1;
235
        }
235
        }
236
    }
236
    }
237
238
    $item->{nomod} = !$patron->can_edit_item( $item );
239
237
    if ($item->{'datedue'}) {
240
    if ($item->{'datedue'}) {
238
        $item->{'issue'}= 1;
241
        $item->{'issue'}= 1;
239
    } else {
242
    } else {
(-)a/cataloguing/additem.pl (-4 / +9 lines)
Lines 443-449 my ($template, $loggedinuser, $cookie) Link Here
443
443
444
444
445
# Does the user have a restricted item editing permission?
445
# Does the user have a restricted item editing permission?
446
my $uid = Koha::Patrons->find( $loggedinuser )->userid;
446
my $patron = Koha::Patrons->find( $loggedinuser );
447
my $uid = $patron->userid;
447
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
448
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
448
# In case user is a superlibrarian, editing is not restricted
449
# In case user is a superlibrarian, editing is not restricted
449
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
450
$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 325-331 Link Here
325
                <tr>
325
                <tr>
326
                [% IF (StaffDetailItemSelection) %]
326
                [% IF (StaffDetailItemSelection) %]
327
                    <td style="text-align:center;vertical-align:middle">
327
                    <td style="text-align:center;vertical-align:middle">
328
                        <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
328
                        [% UNLESS item.cannot_be_edited %]
329
                            <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
330
                        [% END %]
329
                    </td>
331
                    </td>
330
                [% END %]
332
                [% END %]
331
                    [% IF Koha.Preference('LocalCoverImages') && ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %]
333
                    [% IF Koha.Preference('LocalCoverImages') && ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %]
(-)a/tools/batchMod.pl (-12 / +8 lines)
Lines 81-87 my ($template, $loggedinuser, $cookie) Link Here
81
$template->param( searchid => scalar $input->param('searchid'), );
81
$template->param( searchid => scalar $input->param('searchid'), );
82
82
83
# Does the user have a restricted item edition permission?
83
# Does the user have a restricted item edition permission?
84
my $uid = $loggedinuser ? Koha::Patrons->find( $loggedinuser )->userid : undef;
84
my $patron = Koha::Patrons->find( $loggedinuser );
85
my $uid = $loggedinuser ? $patron->userid : undef;
85
my $restrictededition = $uid ? haspermission($uid,  {'tools' => 'items_batchmod_restricted'}) : undef;
86
my $restrictededition = $uid ? haspermission($uid,  {'tools' => 'items_batchmod_restricted'}) : undef;
86
# In case user is a superlibrarian, edition is not restricted
87
# In case user is a superlibrarian, edition is not restricted
87
$restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian());
88
$restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian());
Lines 665-685 sub BuildItemsData{ Link Here
665
    my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField( "items.itemnumber" );
666
    my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField( "items.itemnumber" );
666
    my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField( "items.homebranch" );
667
    my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField( "items.homebranch" );
667
		foreach my $itemnumber (@itemnumbers){
668
		foreach my $itemnumber (@itemnumbers){
668
            my $itemdata = Koha::Items->find($itemnumber);
669
            my $item = Koha::Items->find($itemnumber);
669
            next unless $itemdata; # Should have been tested earlier, but just in case...
670
            next unless $item; # Should have been tested earlier, but just in case...
670
            $itemdata = $itemdata->unblessed;
671
            my $itemdata = $item->unblessed;
671
			my $itemmarc=Item2Marc($itemdata);
672
			my $itemmarc=Item2Marc($itemdata);
672
			my %this_row;
673
			my %this_row;
673
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
674
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
674
				# loop through each subfield
675
				# loop through each subfield
675
				my $itembranchcode=$field->subfield($branchtagsubfield);
676
				my $itembranchcode=$field->subfield($branchtagsubfield);
676
                if ($itembranchcode && C4::Context->preference("IndependentBranches")) {
677
                if ($itembranchcode) {
677
						#verifying rights
678
                    $this_row{'nomod'} = !$patron->can_edit_item($item);
678
						my $userenv = C4::Context->userenv();
679
                }
679
                        unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $itembranchcode))){
680
								$this_row{'nomod'}=1;
681
						}
682
				}
683
				my $tag=$field->tag();
680
				my $tag=$field->tag();
684
				foreach my $subfield ($field->subfields) {
681
				foreach my $subfield ($field->subfields) {
685
					my ($subfcode,$subfvalue)=@$subfield;
682
					my ($subfcode,$subfvalue)=@$subfield;
686
- 

Return to bug 20256