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

(-)a/Koha/Item.pm (-3 / +1 lines)
Lines 227-235 sub safe_to_delete { Link Here
227
227
228
    return "not_same_branch"
228
    return "not_same_branch"
229
      if defined C4::Context->userenv
229
      if defined C4::Context->userenv
230
      and !C4::Context->IsSuperLibrarian()
230
      and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $self ) )
231
      and C4::Context->preference("IndependentBranches")
232
      and ( C4::Context->userenv->{branch} ne $self->homebranch );
233
231
234
    # check it doesn't have a waiting reserve
232
    # check it doesn't have a waiting reserve
235
    return "book_reserved"
233
    return "book_reserved"
(-)a/catalogue/detail.pl (-7 / +1 lines)
Lines 373-385 foreach my $item (@items) { Link Here
373
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
373
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
374
    }
374
    }
375
375
376
    if ( C4::Context->preference('IndependentBranches') ) {
376
    $item->{cannot_be_edited} = !$patron->can_edit_item( $item_object );
377
        my $userenv = C4::Context->userenv();
378
        if ( not C4::Context->IsSuperLibrarian()
379
            and $userenv->{branch} ne $item->{homebranch} ) {
380
            $item->{cannot_be_edited} = 1;
381
        }
382
    }
383
377
384
    if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
378
    if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
385
        if ($itembranchcode and $itembranchcode eq $currentbranch) {
379
        if ($itembranchcode and $itembranchcode eq $currentbranch) {
(-)a/catalogue/moredetail.pl (+3 lines)
Lines 227-232 foreach my $item (@items){ Link Here
227
                $item->{'nomod'}=1;
227
                $item->{'nomod'}=1;
228
        }
228
        }
229
    }
229
    }
230
231
    $item->{nomod} = !$patron->can_edit_item( $item );
232
230
    if ($item->{'datedue'}) {
233
    if ($item->{'datedue'}) {
231
        $item->{'issue'}= 1;
234
        $item->{'issue'}= 1;
232
    } else {
235
    } else {
(-)a/cataloguing/additem.pl (-4 / +9 lines)
Lines 414-420 my ($template, $loggedinuser, $cookie) Link Here
414
414
415
415
416
# Does the user have a restricted item editing permission?
416
# Does the user have a restricted item editing permission?
417
my $uid = Koha::Patrons->find( $loggedinuser )->userid;
417
my $patron = Koha::Patrons->find( $loggedinuser );
418
my $uid = $patron->userid;
418
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
419
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
419
# In case user is a superlibrarian, editing is not restricted
420
# In case user is a superlibrarian, editing is not restricted
420
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
421
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
Lines 818-830 foreach my $field (@fields) { Link Here
818
						|| $subfieldvalue;
819
						|| $subfieldvalue;
819
        }
820
        }
820
821
821
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
822
        if (   $subfieldvalue
823
            && ( $field->tag eq $branchtagfield )
824
            && ( $subfieldcode eq $branchtagsubfield ) )
825
        {
822
            #verifying rights
826
            #verifying rights
823
            my $userenv = C4::Context->userenv();
827
            unless ( $patron->can_edit_item($subfieldvalue) ) {
824
            unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $subfieldvalue))){
828
                warn "NOMOD";
825
                $this_row{'nomod'} = 1;
829
                $this_row{'nomod'} = 1;
826
            }
830
            }
827
        }
831
        }
832
828
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
833
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
829
834
830
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
835
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +3 lines)
Lines 258-264 Link Here
258
                <tr>
258
                <tr>
259
                [% IF (StaffDetailItemSelection) %]
259
                [% IF (StaffDetailItemSelection) %]
260
                    <td style="text-align:center;vertical-align:middle">
260
                    <td style="text-align:center;vertical-align:middle">
261
                        <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
261
                        [% UNLESS item.cannot_be_edited %]
262
                            <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
263
                        [% END %]
262
                    </td>
264
                    </td>
263
                [% END %]
265
                [% END %]
264
                    [% IF ( item_level_itypes ) %]
266
                    [% 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 591-611 sub BuildItemsData{ Link Here
591
    my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField( "items.itemnumber" );
592
    my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField( "items.itemnumber" );
592
    my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField( "items.homebranch" );
593
    my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField( "items.homebranch" );
593
		foreach my $itemnumber (@itemnumbers){
594
		foreach my $itemnumber (@itemnumbers){
594
            my $itemdata = Koha::Items->find($itemnumber);
595
            my $item = Koha::Items->find($itemnumber);
595
            next unless $itemdata; # Should have been tested earlier, but just in case...
596
            next unless $item; # Should have been tested earlier, but just in case...
596
            $itemdata = $itemdata->unblessed;
597
            my $itemdata = $item->unblessed;
597
			my $itemmarc=Item2Marc($itemdata);
598
			my $itemmarc=Item2Marc($itemdata);
598
			my %this_row;
599
			my %this_row;
599
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
600
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
600
				# loop through each subfield
601
				# loop through each subfield
601
				my $itembranchcode=$field->subfield($branchtagsubfield);
602
				my $itembranchcode=$field->subfield($branchtagsubfield);
602
                if ($itembranchcode && C4::Context->preference("IndependentBranches")) {
603
                if ($itembranchcode) {
603
						#verifying rights
604
                    $this_row{'nomod'} = !$patron->can_edit_item($item);
604
						my $userenv = C4::Context->userenv();
605
                }
605
                        unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $itembranchcode))){
606
								$this_row{'nomod'}=1;
607
						}
608
				}
609
				my $tag=$field->tag();
606
				my $tag=$field->tag();
610
				foreach my $subfield ($field->subfields) {
607
				foreach my $subfield ($field->subfields) {
611
					my ($subfcode,$subfvalue)=@$subfield;
608
					my ($subfcode,$subfvalue)=@$subfield;
612
- 

Return to bug 20256