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

(-)a/Koha/Item.pm (-3 / +1 lines)
Lines 264-272 sub safe_to_delete { Link Here
264
264
265
    return "not_same_branch"
265
    return "not_same_branch"
266
      if defined C4::Context->userenv
266
      if defined C4::Context->userenv
267
      and !C4::Context->IsSuperLibrarian()
267
      and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $self ) )
268
      and C4::Context->preference("IndependentBranches")
269
      and ( C4::Context->userenv->{branch} ne $self->homebranch );
270
268
271
    # check it doesn't have a waiting reserve
269
    # check it doesn't have a waiting reserve
272
    return "book_reserved"
270
    return "book_reserved"
(-)a/catalogue/detail.pl (-7 / +1 lines)
Lines 382-394 foreach my $item (@items) { Link Here
382
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
382
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
383
    }
383
    }
384
384
385
    if ( C4::Context->preference('IndependentBranches') ) {
385
    $item->{cannot_be_edited} = !$patron->can_edit_item( $item_object );
386
        my $userenv = C4::Context->userenv();
387
        if ( not C4::Context->IsSuperLibrarian()
388
            and $userenv->{branch} ne $item->{homebranch} ) {
389
            $item->{cannot_be_edited} = 1;
390
        }
391
    }
392
386
393
    if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
387
    if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
394
        if ($itembranchcode and $itembranchcode eq $currentbranch) {
388
        if ($itembranchcode and $itembranchcode eq $currentbranch) {
(-)a/catalogue/moredetail.pl (+3 lines)
Lines 223-228 foreach my $item (@items){ Link Here
223
                $item->{'nomod'}=1;
223
                $item->{'nomod'}=1;
224
        }
224
        }
225
    }
225
    }
226
227
    $item->{nomod} = !$patron->can_edit_item( $item );
228
226
    if ($item->{'datedue'}) {
229
    if ($item->{'datedue'}) {
227
        $item->{'issue'}= 1;
230
        $item->{'issue'}= 1;
228
    } else {
231
    } else {
(-)a/cataloguing/additem.pl (-4 / +9 lines)
Lines 430-436 my ($template, $loggedinuser, $cookie) Link Here
430
430
431
431
432
# Does the user have a restricted item editing permission?
432
# Does the user have a restricted item editing permission?
433
my $uid = Koha::Patrons->find( $loggedinuser )->userid;
433
my $patron = Koha::Patrons->find( $loggedinuser );
434
my $uid = $patron->userid;
434
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
435
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
435
# In case user is a superlibrarian, editing is not restricted
436
# In case user is a superlibrarian, editing is not restricted
436
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
437
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
Lines 840-852 foreach my $field (@fields) { Link Here
840
						|| $subfieldvalue;
841
						|| $subfieldvalue;
841
        }
842
        }
842
843
843
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
844
        if (   $subfieldvalue
845
            && ( $field->tag eq $branchtagfield )
846
            && ( $subfieldcode eq $branchtagsubfield ) )
847
        {
844
            #verifying rights
848
            #verifying rights
845
            my $userenv = C4::Context->userenv();
849
            unless ( $patron->can_edit_item($subfieldvalue) ) {
846
            unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $subfieldvalue))){
850
                warn "NOMOD";
847
                $this_row{'nomod'} = 1;
851
                $this_row{'nomod'} = 1;
848
            }
852
            }
849
        }
853
        }
854
850
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
855
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
851
856
852
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
857
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +3 lines)
Lines 308-314 Link Here
308
                <tr>
308
                <tr>
309
                [% IF (StaffDetailItemSelection) %]
309
                [% IF (StaffDetailItemSelection) %]
310
                    <td style="text-align:center;vertical-align:middle">
310
                    <td style="text-align:center;vertical-align:middle">
311
                        <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
311
                        [% UNLESS item.cannot_be_edited %]
312
                            <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
313
                        [% END %]
312
                    </td>
314
                    </td>
313
                [% END %]
315
                [% END %]
314
                    [% IF ( item_level_itypes ) %]
316
                    [% IF ( item_level_itypes ) %]
(-)a/tools/batchMod.pl (-12 / +8 lines)
Lines 80-86 my ($template, $loggedinuser, $cookie) Link Here
80
$template->param( searchid => scalar $input->param('searchid'), );
80
$template->param( searchid => scalar $input->param('searchid'), );
81
81
82
# Does the user have a restricted item edition permission?
82
# Does the user have a restricted item edition permission?
83
my $uid = $loggedinuser ? Koha::Patrons->find( $loggedinuser )->userid : undef;
83
my $patron = Koha::Patrons->find( $loggedinuser );
84
my $uid = $loggedinuser ? $patron->userid : undef;
84
my $restrictededition = $uid ? haspermission($uid,  {'tools' => 'items_batchmod_restricted'}) : undef;
85
my $restrictededition = $uid ? haspermission($uid,  {'tools' => 'items_batchmod_restricted'}) : undef;
85
# In case user is a superlibrarian, edition is not restricted
86
# In case user is a superlibrarian, edition is not restricted
86
$restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian());
87
$restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian());
Lines 628-648 sub BuildItemsData{ Link Here
628
    my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField( "items.itemnumber" );
629
    my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField( "items.itemnumber" );
629
    my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField( "items.homebranch" );
630
    my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField( "items.homebranch" );
630
		foreach my $itemnumber (@itemnumbers){
631
		foreach my $itemnumber (@itemnumbers){
631
            my $itemdata = Koha::Items->find($itemnumber);
632
            my $item = Koha::Items->find($itemnumber);
632
            next unless $itemdata; # Should have been tested earlier, but just in case...
633
            next unless $item; # Should have been tested earlier, but just in case...
633
            $itemdata = $itemdata->unblessed;
634
            my $itemdata = $item->unblessed;
634
			my $itemmarc=Item2Marc($itemdata);
635
			my $itemmarc=Item2Marc($itemdata);
635
			my %this_row;
636
			my %this_row;
636
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
637
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
637
				# loop through each subfield
638
				# loop through each subfield
638
				my $itembranchcode=$field->subfield($branchtagsubfield);
639
				my $itembranchcode=$field->subfield($branchtagsubfield);
639
                if ($itembranchcode && C4::Context->preference("IndependentBranches")) {
640
                if ($itembranchcode) {
640
						#verifying rights
641
                    $this_row{'nomod'} = !$patron->can_edit_item($item);
641
						my $userenv = C4::Context->userenv();
642
                }
642
                        unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $itembranchcode))){
643
								$this_row{'nomod'}=1;
644
						}
645
				}
646
				my $tag=$field->tag();
643
				my $tag=$field->tag();
647
				foreach my $subfield ($field->subfields) {
644
				foreach my $subfield ($field->subfields) {
648
					my ($subfcode,$subfvalue)=@$subfield;
645
					my ($subfcode,$subfvalue)=@$subfield;
649
- 

Return to bug 20256