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 442-448 my ($template, $loggedinuser, $cookie) Link Here
442
442
443
443
444
# Does the user have a restricted item editing permission?
444
# Does the user have a restricted item editing permission?
445
my $uid = Koha::Patrons->find( $loggedinuser )->userid;
445
my $patron = Koha::Patrons->find( $loggedinuser );
446
my $uid = $patron->userid;
446
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
447
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
447
# In case user is a superlibrarian, editing is not restricted
448
# In case user is a superlibrarian, editing is not restricted
448
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
449
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
Lines 862-874 foreach my $field (@fields) { Link Here
862
						|| $subfieldvalue;
863
						|| $subfieldvalue;
863
        }
864
        }
864
865
865
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
866
        if (   $subfieldvalue
867
            && ( $field->tag eq $branchtagfield )
868
            && ( $subfieldcode eq $branchtagsubfield ) )
869
        {
866
            #verifying rights
870
            #verifying rights
867
            my $userenv = C4::Context->userenv();
871
            unless ( $patron->can_edit_item($subfieldvalue) ) {
868
            unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $subfieldvalue))){
872
                warn "NOMOD";
869
                $this_row{'nomod'} = 1;
873
                $this_row{'nomod'} = 1;
870
            }
874
            }
871
        }
875
        }
876
872
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
877
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
873
878
874
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
879
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +3 lines)
Lines 322-328 Link Here
322
                <tr>
322
                <tr>
323
                [% IF (StaffDetailItemSelection) %]
323
                [% IF (StaffDetailItemSelection) %]
324
                    <td style="text-align:center;vertical-align:middle">
324
                    <td style="text-align:center;vertical-align:middle">
325
                        <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
325
                        [% UNLESS item.cannot_be_edited %]
326
                            <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
327
                        [% END %]
326
                    </td>
328
                    </td>
327
                [% END %]
329
                [% END %]
328
                    [% IF Koha.Preference('LocalCoverImages') && ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %]
330
                    [% 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