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

(-)a/C4/Items.pm (-3 / +1 lines)
Lines 1743-1751 sub ItemSafeToDelete { Link Here
1743
        $status = "book_on_loan";
1743
        $status = "book_on_loan";
1744
    }
1744
    }
1745
    elsif ( defined C4::Context->userenv
1745
    elsif ( defined C4::Context->userenv
1746
        and !C4::Context->IsSuperLibrarian()
1746
         and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $item ) )
1747
        and C4::Context->preference("IndependentBranches")
1748
        and ( C4::Context->userenv->{branch} ne $item->homebranch ) )
1749
    {
1747
    {
1750
        $status = "not_same_branch";
1748
        $status = "not_same_branch";
1751
    }
1749
    }
(-)a/catalogue/detail.pl (-7 / +1 lines)
Lines 340-352 foreach my $item (@items) { Link Here
340
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
340
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
341
    }
341
    }
342
342
343
    if ( C4::Context->preference('IndependentBranches') ) {
343
    $item->{cannot_be_edited} = !$patron->can_edit_item( $item_object );
344
        my $userenv = C4::Context->userenv();
345
        if ( not C4::Context->IsSuperLibrarian()
346
            and $userenv->{branch} ne $item->{homebranch} ) {
347
            $item->{cannot_be_edited} = 1;
348
        }
349
    }
350
344
351
    if ($currentbranch and $currentbranch ne "NO_LIBRARY_SET"
345
    if ($currentbranch and $currentbranch ne "NO_LIBRARY_SET"
352
    and C4::Context->preference('SeparateHoldings')) {
346
    and C4::Context->preference('SeparateHoldings')) {
(-)a/catalogue/moredetail.pl (-7 / +2 lines)
Lines 174-186 foreach my $item (@items){ Link Here
174
        $item->{status_advisory} = 1;
174
        $item->{status_advisory} = 1;
175
    }
175
    }
176
176
177
    if (C4::Context->preference("IndependentBranches")) {
177
    $item->{nomod} = !$patron->can_edit_item( $item );
178
        #verifying rights
178
179
        my $userenv = C4::Context->userenv();
180
        unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) {
181
                $item->{'nomod'}=1;
182
        }
183
    }
184
    if ($item->{'datedue'}) {
179
    if ($item->{'datedue'}) {
185
        $item->{'issue'}= 1;
180
        $item->{'issue'}= 1;
186
    } else {
181
    } else {
(-)a/cataloguing/additem.pl (-4 / +9 lines)
Lines 412-418 my ($template, $loggedinuser, $cookie) Link Here
412
412
413
413
414
# Does the user have a restricted item editing permission?
414
# Does the user have a restricted item editing permission?
415
my $uid = Koha::Patrons->find( $loggedinuser )->userid;
415
my $patron = Koha::Patrons->find( $loggedinuser );
416
my $uid = $patron->userid;
416
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
417
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
417
# In case user is a superlibrarian, editing is not restricted
418
# In case user is a superlibrarian, editing is not restricted
418
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
419
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
Lines 794-806 foreach my $field (@fields) { Link Here
794
						|| $subfieldvalue;
795
						|| $subfieldvalue;
795
        }
796
        }
796
797
797
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
798
        if (   $subfieldvalue
799
            && ( $field->tag eq $branchtagfield )
800
            && ( $subfieldcode eq $branchtagsubfield ) )
801
        {
798
            #verifying rights
802
            #verifying rights
799
            my $userenv = C4::Context->userenv();
803
            unless ( $patron->can_edit_item($subfieldvalue) ) {
800
            unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $subfieldvalue))){
804
                warn "NOMOD";
801
                $this_row{'nomod'} = 1;
805
                $this_row{'nomod'} = 1;
802
            }
806
            }
803
        }
807
        }
808
804
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
809
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
805
810
806
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
811
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +3 lines)
Lines 380-386 Link Here
380
                <tr>
380
                <tr>
381
                [% IF (StaffDetailItemSelection) %]
381
                [% IF (StaffDetailItemSelection) %]
382
                    <td style="text-align:center;vertical-align:middle">
382
                    <td style="text-align:center;vertical-align:middle">
383
                        <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
383
                        [% UNLESS item.cannot_be_edited %]
384
                            <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
385
                        [% END %]
384
                    </td>
386
                    </td>
385
                [% END %]
387
                [% END %]
386
                    [% IF ( item_level_itypes ) %]
388
                    [% 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 532-552 sub BuildItemsData{ Link Here
532
		my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumber", "");
533
		my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumber", "");
533
		my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebranch", "");
534
		my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebranch", "");
534
		foreach my $itemnumber (@itemnumbers){
535
		foreach my $itemnumber (@itemnumbers){
535
            my $itemdata = Koha::Items->find($itemnumber);
536
            my $item = Koha::Items->find($itemnumber);
536
            next unless $itemdata; # Should have been tested earlier, but just in case...
537
            next unless $item; # Should have been tested earlier, but just in case...
537
            $itemdata = $itemdata->unblessed;
538
            my $itemdata = $item->unblessed;
538
			my $itemmarc=Item2Marc($itemdata);
539
			my $itemmarc=Item2Marc($itemdata);
539
			my %this_row;
540
			my %this_row;
540
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
541
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
541
				# loop through each subfield
542
				# loop through each subfield
542
				my $itembranchcode=$field->subfield($branchtagsubfield);
543
				my $itembranchcode=$field->subfield($branchtagsubfield);
543
                if ($itembranchcode && C4::Context->preference("IndependentBranches")) {
544
                if ($itembranchcode) {
544
						#verifying rights
545
                    $this_row{'nomod'} = !$patron->can_edit_item($item);
545
						my $userenv = C4::Context->userenv();
546
                }
546
                        unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $itembranchcode))){
547
								$this_row{'nomod'}=1;
548
						}
549
				}
550
				my $tag=$field->tag();
547
				my $tag=$field->tag();
551
				foreach my $subfield ($field->subfields) {
548
				foreach my $subfield ($field->subfields) {
552
					my ($subfcode,$subfvalue)=@$subfield;
549
					my ($subfcode,$subfvalue)=@$subfield;
553
- 

Return to bug 20256