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

(-)a/C4/Items.pm (-3 / +1 lines)
Lines 1746-1754 sub ItemSafeToDelete { Link Here
1746
        $status = "book_on_loan";
1746
        $status = "book_on_loan";
1747
    }
1747
    }
1748
    elsif ( defined C4::Context->userenv
1748
    elsif ( defined C4::Context->userenv
1749
        and !C4::Context->IsSuperLibrarian()
1749
         and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $item ) )
1750
        and C4::Context->preference("IndependentBranches")
1751
        and ( C4::Context->userenv->{branch} ne $item->homebranch ) )
1752
    {
1750
    {
1753
        $status = "not_same_branch";
1751
        $status = "not_same_branch";
1754
    }
1752
    }
(-)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 802-814 foreach my $field (@fields) { Link Here
802
						|| $subfieldvalue;
803
						|| $subfieldvalue;
803
        }
804
        }
804
805
805
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
806
        if (   $subfieldvalue
807
            && ( $field->tag eq $branchtagfield )
808
            && ( $subfieldcode eq $branchtagsubfield ) )
809
        {
806
            #verifying rights
810
            #verifying rights
807
            my $userenv = C4::Context->userenv();
811
            unless ( $patron->can_edit_item($subfieldvalue) ) {
808
            unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $subfieldvalue))){
812
                warn "NOMOD";
809
                $this_row{'nomod'} = 1;
813
                $this_row{'nomod'} = 1;
810
            }
814
            }
811
        }
815
        }
816
812
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
817
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
813
818
814
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
819
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +3 lines)
Lines 222-228 Link Here
222
                <tr>
222
                <tr>
223
                [% IF (StaffDetailItemSelection) %]
223
                [% IF (StaffDetailItemSelection) %]
224
                    <td style="text-align:center;vertical-align:middle">
224
                    <td style="text-align:center;vertical-align:middle">
225
                        <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
225
                        [% UNLESS item.cannot_be_edited %]
226
                            <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
227
                        [% END %]
226
                    </td>
228
                    </td>
227
                [% END %]
229
                [% END %]
228
                    [% IF ( item_level_itypes ) %]
230
                    [% 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 539-559 sub BuildItemsData{ Link Here
539
		my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumber", "");
540
		my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumber", "");
540
		my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebranch", "");
541
		my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebranch", "");
541
		foreach my $itemnumber (@itemnumbers){
542
		foreach my $itemnumber (@itemnumbers){
542
            my $itemdata = Koha::Items->find($itemnumber);
543
            my $item = Koha::Items->find($itemnumber);
543
            next unless $itemdata; # Should have been tested earlier, but just in case...
544
            next unless $item; # Should have been tested earlier, but just in case...
544
            $itemdata = $itemdata->unblessed;
545
            my $itemdata = $item->unblessed;
545
			my $itemmarc=Item2Marc($itemdata);
546
			my $itemmarc=Item2Marc($itemdata);
546
			my %this_row;
547
			my %this_row;
547
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
548
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
548
				# loop through each subfield
549
				# loop through each subfield
549
				my $itembranchcode=$field->subfield($branchtagsubfield);
550
				my $itembranchcode=$field->subfield($branchtagsubfield);
550
                if ($itembranchcode && C4::Context->preference("IndependentBranches")) {
551
                if ($itembranchcode) {
551
						#verifying rights
552
                    $this_row{'nomod'} = !$patron->can_edit_item($item);
552
						my $userenv = C4::Context->userenv();
553
                }
553
                        unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $itembranchcode))){
554
								$this_row{'nomod'}=1;
555
						}
556
				}
557
				my $tag=$field->tag();
554
				my $tag=$field->tag();
558
				foreach my $subfield ($field->subfields) {
555
				foreach my $subfield ($field->subfields) {
559
					my ($subfcode,$subfvalue)=@$subfield;
556
					my ($subfcode,$subfvalue)=@$subfield;
560
- 

Return to bug 20256