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

(-)a/C4/Items.pm (-3 / +1 lines)
Lines 1731-1739 sub ItemSafeToDelete { Link Here
1731
        $status = "book_on_loan";
1731
        $status = "book_on_loan";
1732
    }
1732
    }
1733
    elsif ( defined C4::Context->userenv
1733
    elsif ( defined C4::Context->userenv
1734
        and !C4::Context->IsSuperLibrarian()
1734
         and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $item ) )
1735
        and C4::Context->preference("IndependentBranches")
1736
        and ( C4::Context->userenv->{branch} ne $item->homebranch ) )
1737
    {
1735
    {
1738
        $status = "not_same_branch";
1736
        $status = "not_same_branch";
1739
    }
1737
    }
(-)a/catalogue/detail.pl (-7 / +1 lines)
Lines 372-384 foreach my $item (@items) { Link Here
372
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
372
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
373
    }
373
    }
374
374
375
    if ( C4::Context->preference('IndependentBranches') ) {
375
    $item->{cannot_be_edited} = !$patron->can_edit_item( $item_object );
376
        my $userenv = C4::Context->userenv();
377
        if ( not C4::Context->IsSuperLibrarian()
378
            and $userenv->{branch} ne $item->{homebranch} ) {
379
            $item->{cannot_be_edited} = 1;
380
        }
381
    }
382
376
383
    if ($currentbranch and $currentbranch ne "NO_LIBRARY_SET"
377
    if ($currentbranch and $currentbranch ne "NO_LIBRARY_SET"
384
    and C4::Context->preference('SeparateHoldings')) {
378
    and C4::Context->preference('SeparateHoldings')) {
(-)a/catalogue/moredetail.pl (+3 lines)
Lines 219-224 foreach my $item (@items){ Link Here
219
                $item->{'nomod'}=1;
219
                $item->{'nomod'}=1;
220
        }
220
        }
221
    }
221
    }
222
223
    $item->{nomod} = !$patron->can_edit_item( $item );
224
222
    if ($item->{'datedue'}) {
225
    if ($item->{'datedue'}) {
223
        $item->{'issue'}= 1;
226
        $item->{'issue'}= 1;
224
    } else {
227
    } else {
(-)a/cataloguing/additem.pl (-4 / +9 lines)
Lines 418-424 my ($template, $loggedinuser, $cookie) Link Here
418
418
419
419
420
# Does the user have a restricted item editing permission?
420
# Does the user have a restricted item editing permission?
421
my $uid = Koha::Patrons->find( $loggedinuser )->userid;
421
my $patron = Koha::Patrons->find( $loggedinuser );
422
my $uid = $patron->userid;
422
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
423
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
423
# In case user is a superlibrarian, editing is not restricted
424
# In case user is a superlibrarian, editing is not restricted
424
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
425
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
Lines 822-834 foreach my $field (@fields) { Link Here
822
						|| $subfieldvalue;
823
						|| $subfieldvalue;
823
        }
824
        }
824
825
825
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
826
        if (   $subfieldvalue
827
            && ( $field->tag eq $branchtagfield )
828
            && ( $subfieldcode eq $branchtagsubfield ) )
829
        {
826
            #verifying rights
830
            #verifying rights
827
            my $userenv = C4::Context->userenv();
831
            unless ( $patron->can_edit_item($subfieldvalue) ) {
828
            unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $subfieldvalue))){
832
                warn "NOMOD";
829
                $this_row{'nomod'} = 1;
833
                $this_row{'nomod'} = 1;
830
            }
834
            }
831
        }
835
        }
836
832
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
837
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
833
838
834
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
839
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +3 lines)
Lines 252-258 Link Here
252
                <tr>
252
                <tr>
253
                [% IF (StaffDetailItemSelection) %]
253
                [% IF (StaffDetailItemSelection) %]
254
                    <td style="text-align:center;vertical-align:middle">
254
                    <td style="text-align:center;vertical-align:middle">
255
                        <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
255
                        [% UNLESS item.cannot_be_edited %]
256
                            <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
257
                        [% END %]
256
                    </td>
258
                    </td>
257
                [% END %]
259
                [% END %]
258
                    [% IF ( item_level_itypes ) %]
260
                    [% IF ( item_level_itypes ) %]
(-)a/tools/batchMod.pl (-12 / +8 lines)
Lines 75-81 my ($template, $loggedinuser, $cookie) Link Here
75
                 });
75
                 });
76
76
77
# Does the user have a restricted item edition permission?
77
# Does the user have a restricted item edition permission?
78
my $uid = $loggedinuser ? Koha::Patrons->find( $loggedinuser )->userid : undef;
78
my $patron = Koha::Patrons->find( $loggedinuser );
79
my $uid = $loggedinuser ? $patron->userid : undef;
79
my $restrictededition = $uid ? haspermission($uid,  {'tools' => 'items_batchmod_restricted'}) : undef;
80
my $restrictededition = $uid ? haspermission($uid,  {'tools' => 'items_batchmod_restricted'}) : undef;
80
# In case user is a superlibrarian, edition is not restricted
81
# In case user is a superlibrarian, edition is not restricted
81
$restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian());
82
$restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian());
Lines 551-571 sub BuildItemsData{ Link Here
551
    my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField( "items.itemnumber" );
552
    my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField( "items.itemnumber" );
552
    my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField( "items.homebranch" );
553
    my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField( "items.homebranch" );
553
		foreach my $itemnumber (@itemnumbers){
554
		foreach my $itemnumber (@itemnumbers){
554
            my $itemdata = Koha::Items->find($itemnumber);
555
            my $item = Koha::Items->find($itemnumber);
555
            next unless $itemdata; # Should have been tested earlier, but just in case...
556
            next unless $item; # Should have been tested earlier, but just in case...
556
            $itemdata = $itemdata->unblessed;
557
            my $itemdata = $item->unblessed;
557
			my $itemmarc=Item2Marc($itemdata);
558
			my $itemmarc=Item2Marc($itemdata);
558
			my %this_row;
559
			my %this_row;
559
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
560
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
560
				# loop through each subfield
561
				# loop through each subfield
561
				my $itembranchcode=$field->subfield($branchtagsubfield);
562
				my $itembranchcode=$field->subfield($branchtagsubfield);
562
                if ($itembranchcode && C4::Context->preference("IndependentBranches")) {
563
                if ($itembranchcode) {
563
						#verifying rights
564
                    $this_row{'nomod'} = !$patron->can_edit_item($item);
564
						my $userenv = C4::Context->userenv();
565
                }
565
                        unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $itembranchcode))){
566
								$this_row{'nomod'}=1;
567
						}
568
				}
569
				my $tag=$field->tag();
566
				my $tag=$field->tag();
570
				foreach my $subfield ($field->subfields) {
567
				foreach my $subfield ($field->subfields) {
571
					my ($subfcode,$subfvalue)=@$subfield;
568
					my ($subfcode,$subfvalue)=@$subfield;
572
- 

Return to bug 20256