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

(-)a/Koha/Item.pm (-3 / +1 lines)
Lines 245-253 sub safe_to_delete { Link Here
245
245
246
    return "not_same_branch"
246
    return "not_same_branch"
247
      if defined C4::Context->userenv
247
      if defined C4::Context->userenv
248
      and !C4::Context->IsSuperLibrarian()
248
      and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $self ) )
249
      and C4::Context->preference("IndependentBranches")
250
      and ( C4::Context->userenv->{branch} ne $self->homebranch );
251
249
252
    # check it doesn't have a waiting reserve
250
    # check it doesn't have a waiting reserve
253
    return "book_reserved"
251
    return "book_reserved"
(-)a/catalogue/detail.pl (-7 / +1 lines)
Lines 387-399 foreach my $item (@items) { Link Here
387
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
387
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
388
    }
388
    }
389
389
390
    if ( C4::Context->preference('IndependentBranches') ) {
390
    $item->{cannot_be_edited} = !$patron->can_edit_item( $item_object );
391
        my $userenv = C4::Context->userenv();
392
        if ( not C4::Context->IsSuperLibrarian()
393
            and $userenv->{branch} ne $item->{homebranch} ) {
394
            $item->{cannot_be_edited} = 1;
395
        }
396
    }
397
391
398
    if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
392
    if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
399
        if ($itembranchcode and $itembranchcode eq $currentbranch) {
393
        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 823-835 foreach my $field (@fields) { Link Here
823
						|| $subfieldvalue;
824
						|| $subfieldvalue;
824
        }
825
        }
825
826
826
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
827
        if (   $subfieldvalue
828
            && ( $field->tag eq $branchtagfield )
829
            && ( $subfieldcode eq $branchtagsubfield ) )
830
        {
827
            #verifying rights
831
            #verifying rights
828
            my $userenv = C4::Context->userenv();
832
            unless ( $patron->can_edit_item($subfieldvalue) ) {
829
            unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $subfieldvalue))){
833
                warn "NOMOD";
830
                $this_row{'nomod'} = 1;
834
                $this_row{'nomod'} = 1;
831
            }
835
            }
832
        }
836
        }
837
833
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
838
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
834
839
835
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
840
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +3 lines)
Lines 261-267 Link Here
261
                <tr>
261
                <tr>
262
                [% IF (StaffDetailItemSelection) %]
262
                [% IF (StaffDetailItemSelection) %]
263
                    <td style="text-align:center;vertical-align:middle">
263
                    <td style="text-align:center;vertical-align:middle">
264
                        <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
264
                        [% UNLESS item.cannot_be_edited %]
265
                            <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
266
                        [% END %]
265
                    </td>
267
                    </td>
266
                [% END %]
268
                [% END %]
267
                    [% IF ( item_level_itypes ) %]
269
                    [% IF ( item_level_itypes ) %]
(-)a/tools/batchMod.pl (-12 / +8 lines)
Lines 79-85 my ($template, $loggedinuser, $cookie) Link Here
79
                 });
79
                 });
80
80
81
# Does the user have a restricted item edition permission?
81
# Does the user have a restricted item edition permission?
82
my $uid = $loggedinuser ? Koha::Patrons->find( $loggedinuser )->userid : undef;
82
my $patron = Koha::Patrons->find( $loggedinuser );
83
my $uid = $loggedinuser ? $patron->userid : undef;
83
my $restrictededition = $uid ? haspermission($uid,  {'tools' => 'items_batchmod_restricted'}) : undef;
84
my $restrictededition = $uid ? haspermission($uid,  {'tools' => 'items_batchmod_restricted'}) : undef;
84
# In case user is a superlibrarian, edition is not restricted
85
# In case user is a superlibrarian, edition is not restricted
85
$restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian());
86
$restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian());
Lines 627-647 sub BuildItemsData{ Link Here
627
    my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField( "items.itemnumber" );
628
    my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField( "items.itemnumber" );
628
    my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField( "items.homebranch" );
629
    my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField( "items.homebranch" );
629
		foreach my $itemnumber (@itemnumbers){
630
		foreach my $itemnumber (@itemnumbers){
630
            my $itemdata = Koha::Items->find($itemnumber);
631
            my $item = Koha::Items->find($itemnumber);
631
            next unless $itemdata; # Should have been tested earlier, but just in case...
632
            next unless $item; # Should have been tested earlier, but just in case...
632
            $itemdata = $itemdata->unblessed;
633
            my $itemdata = $item->unblessed;
633
			my $itemmarc=Item2Marc($itemdata);
634
			my $itemmarc=Item2Marc($itemdata);
634
			my %this_row;
635
			my %this_row;
635
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
636
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
636
				# loop through each subfield
637
				# loop through each subfield
637
				my $itembranchcode=$field->subfield($branchtagsubfield);
638
				my $itembranchcode=$field->subfield($branchtagsubfield);
638
                if ($itembranchcode && C4::Context->preference("IndependentBranches")) {
639
                if ($itembranchcode) {
639
						#verifying rights
640
                    $this_row{'nomod'} = !$patron->can_edit_item($item);
640
						my $userenv = C4::Context->userenv();
641
                }
641
                        unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $itembranchcode))){
642
								$this_row{'nomod'}=1;
643
						}
644
				}
645
				my $tag=$field->tag();
642
				my $tag=$field->tag();
646
				foreach my $subfield ($field->subfields) {
643
				foreach my $subfield ($field->subfields) {
647
					my ($subfcode,$subfvalue)=@$subfield;
644
					my ($subfcode,$subfvalue)=@$subfield;
648
- 

Return to bug 20256