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

(-)a/C4/Acquisition.pm (-4 / +7 lines)
Lines 1777-1784 sub SearchOrders { Link Here
1777
    }
1777
    }
1778
1778
1779
    my $userenv = C4::Context->userenv;
1779
    my $userenv = C4::Context->userenv;
1780
    if ( C4::Context->preference("IndependentBranches") ) {
1780
    if ( C4::Context->preference("IndependentBranches") && $userenv ) {
1781
        unless ( C4::Context->IsSuperLibrarian() ) {
1781
        my $logged_in_user = Koha::Patrons->find($userenv->{number});
1782
        unless ( $logged_in_user->is_superlibrarian ) {
1782
            $query .= q{
1783
            $query .= q{
1783
                AND (
1784
                AND (
1784
                    borrowers.branchcode = ?
1785
                    borrowers.branchcode = ?
Lines 2286-2293 sub GetHistory { Link Here
2286
        $query .= ' AND aqbasket.basketno IN ( ' . join( ',', map { $_->basketno } @baskets ) . ' )';
2287
        $query .= ' AND aqbasket.basketno IN ( ' . join( ',', map { $_->basketno } @baskets ) . ' )';
2287
    }
2288
    }
2288
2289
2289
    if ( C4::Context->preference("IndependentBranches") ) {
2290
    my $userenv = C4::Context->userenv;
2290
        unless ( C4::Context->IsSuperLibrarian() ) {
2291
    if ( C4::Context->preference("IndependentBranches") && $userenv ) {
2292
        my $logged_in_user = Koha::Patrons->find($userenv->{number});
2293
        unless ( $logged_in_user->is_superlibrarian ) {
2291
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2294
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2292
            push @query_params, C4::Context->userenv->{branch};
2295
            push @query_params, C4::Context->userenv->{branch};
2293
        }
2296
        }
(-)a/C4/Circulation.pm (-3 / +5 lines)
Lines 1070-1078 sub CanBookBeIssued { Link Here
1070
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1070
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1071
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1071
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1072
    }
1072
    }
1073
    if ( C4::Context->preference("IndependentBranches") ) {
1073
1074
        my $userenv = C4::Context->userenv;
1074
    my $userenv = C4::Context->userenv;
1075
        unless ( C4::Context->IsSuperLibrarian() ) {
1075
    if ( C4::Context->preference("IndependentBranches") && $userenv ) {
1076
        my $logged_in_user = Koha::Patrons->find($userenv->{number});
1077
        unless ( $logged_in_user->is_superlibrarian ) {
1076
            my $HomeOrHoldingBranch = C4::Context->preference("HomeOrHoldingBranch");
1078
            my $HomeOrHoldingBranch = C4::Context->preference("HomeOrHoldingBranch");
1077
            if ( $item_object->$HomeOrHoldingBranch ne $userenv->{branch} ){
1079
            if ( $item_object->$HomeOrHoldingBranch ne $userenv->{branch} ){
1078
                $issuingimpossible{ITEMNOTSAMEBRANCH} = 1;
1080
                $issuingimpossible{ITEMNOTSAMEBRANCH} = 1;
(-)a/Koha/Patron.pm (-1 / +2 lines)
Lines 1475-1481 Return true if the patron is a superlibrarian. Link Here
1475
1475
1476
sub is_superlibrarian {
1476
sub is_superlibrarian {
1477
    my ($self) = @_;
1477
    my ($self) = @_;
1478
    return $self->has_permission( { superlibrarian => 1 } ) ? 1 : 0;
1478
1479
    return ( $self->flags // 0 ) % 2;
1479
}
1480
}
1480
1481
1481
=head3 is_adult
1482
=head3 is_adult
(-)a/acqui/basket.pl (-1 / +1 lines)
Lines 252-258 if ( $op eq 'list' ) { Link Here
252
    # get librarian branch...
252
    # get librarian branch...
253
    if ( C4::Context->preference("IndependentBranches") ) {
253
    if ( C4::Context->preference("IndependentBranches") ) {
254
        my $userenv = C4::Context->userenv;
254
        my $userenv = C4::Context->userenv;
255
        unless ( C4::Context->IsSuperLibrarian() ) {
255
        unless ( $logged_in_patron->is_superlibrarian ) {
256
            my $validtest = ( $basket->{creationdate} eq '' )
256
            my $validtest = ( $basket->{creationdate} eq '' )
257
              || ( $userenv->{branch} eq $basket->{branch} )
257
              || ( $userenv->{branch} eq $basket->{branch} )
258
              || ( $userenv->{branch} eq '' )
258
              || ( $userenv->{branch} eq '' )
(-)a/catalogue/detail.pl (-3 / +3 lines)
Lines 182-190 my $dbh = C4::Context->dbh; Link Here
182
182
183
my @all_items = GetItemsInfo( $biblionumber );
183
my @all_items = GetItemsInfo( $biblionumber );
184
my @items;
184
my @items;
185
my $patron = Koha::Patrons->find( $borrowernumber );
185
my $logged_in_patron = Koha::Patrons->find( $borrowernumber );
186
for my $itm (@all_items) {
186
for my $itm (@all_items) {
187
    push @items, $itm unless ( $itm->{itemlost} && $patron->category->hidelostitems && !$showallitems);
187
    push @items, $itm unless ( $itm->{itemlost} && $logged_in_patron->category->hidelostitems && !$showallitems);
188
}
188
}
189
189
190
# flag indicating existence of at least one item linked via a host record
190
# flag indicating existence of at least one item linked via a host record
Lines 380-386 foreach my $item (@items) { Link Here
380
380
381
    if ( C4::Context->preference('IndependentBranches') ) {
381
    if ( C4::Context->preference('IndependentBranches') ) {
382
        my $userenv = C4::Context->userenv();
382
        my $userenv = C4::Context->userenv();
383
        if ( not C4::Context->IsSuperLibrarian()
383
        if ( not $logged_in_patron->is_superlibrarian
384
            and $userenv->{branch} ne $item->{homebranch} ) {
384
            and $userenv->{branch} ne $item->{homebranch} ) {
385
            $item->{cannot_be_edited} = 1;
385
            $item->{cannot_be_edited} = 1;
386
        }
386
        }
(-)a/catalogue/moredetail.pl (-4 / +6 lines)
Lines 108-117 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber); Link Here
108
my $fw = GetFrameworkCode($biblionumber);
108
my $fw = GetFrameworkCode($biblionumber);
109
my @all_items= GetItemsInfo($biblionumber);
109
my @all_items= GetItemsInfo($biblionumber);
110
my @items;
110
my @items;
111
my $patron = Koha::Patrons->find( $loggedinuser );
111
my $logged_in_patron = Koha::Patrons->find( $loggedinuser );
112
for my $itm (@all_items) {
112
for my $itm (@all_items) {
113
    push @items, $itm unless ( $itm->{itemlost} && 
113
    push @items, $itm unless ( $itm->{itemlost} && 
114
                               $patron->category->hidelostitems &&
114
                               $logged_in_patron->category->hidelostitems &&
115
                               !$showallitems && 
115
                               !$showallitems && 
116
                               ($itemnumber != $itm->{itemnumber}));
116
                               ($itemnumber != $itm->{itemnumber}));
117
}
117
}
Lines 230-237 foreach my $item (@items){ Link Here
230
    if (C4::Context->preference("IndependentBranches")) {
230
    if (C4::Context->preference("IndependentBranches")) {
231
        #verifying rights
231
        #verifying rights
232
        my $userenv = C4::Context->userenv();
232
        my $userenv = C4::Context->userenv();
233
        unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) {
233
        unless ( $logged_in_patron->is_superlibrarian()
234
                $item->{'nomod'}=1;
234
            or ( $userenv->{'branch'} eq $item->{'homebranch'} ) )
235
        {
236
            $item->{'nomod'} = 1;
235
        }
237
        }
236
    }
238
    }
237
    if ($item->{'datedue'}) {
239
    if ($item->{'datedue'}) {
(-)a/catalogue/search.pl (+1 lines)
Lines 186-191 my ($template, $borrowernumber, $cookie) = get_template_and_user({ Link Here
186
    }
186
    }
187
);
187
);
188
188
189
my $logged_in_patron = Koha::Patrons->find($borrowernumber);
189
my $lang = C4::Languages::getlanguage($cgi);
190
my $lang = C4::Languages::getlanguage($cgi);
190
191
191
if (C4::Context->preference("marcflavour") eq "UNIMARC" ) {
192
if (C4::Context->preference("marcflavour") eq "UNIMARC" ) {
(-)a/cataloguing/additem.pl (-4 / +6 lines)
Lines 425-431 if (not defined $userflags) { Link Here
425
    $userflags = ($frameworkcode eq 'FA') ? "fast_cataloging" : "edit_items";
425
    $userflags = ($frameworkcode eq 'FA') ? "fast_cataloging" : "edit_items";
426
}
426
}
427
427
428
my ($template, $loggedinuser, $cookie)
428
my ($template, $borrowernumber, $cookie)
429
    = get_template_and_user({template_name => "cataloguing/additem.tt",
429
    = get_template_and_user({template_name => "cataloguing/additem.tt",
430
                 query => $input,
430
                 query => $input,
431
                 type => "intranet",
431
                 type => "intranet",
Lines 434-443 my ($template, $loggedinuser, $cookie) Link Here
434
434
435
435
436
# Does the user have a restricted item editing permission?
436
# Does the user have a restricted item editing permission?
437
my $uid = Koha::Patrons->find( $loggedinuser )->userid;
437
my $logged_in_patron = Koha::Patrons->find( $borrowernumber );
438
my $is_superlibrarian = $logged_in_patron->is_superlibrarian;
439
my $uid = $logged_in_patron->userid;
438
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
440
my $restrictededition = $uid ? haspermission($uid,  {'editcatalogue' => 'edit_items_restricted'}) : undef;
439
# In case user is a superlibrarian, editing is not restricted
441
# In case user is a superlibrarian, editing is not restricted
440
$restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibrarian());
442
$restrictededition = 0 if ($restrictededition != 0 && $is_superlibrarian);
441
# In case user has fast cataloging permission (and we're in fast cataloging), editing is not restricted
443
# In case user has fast cataloging permission (and we're in fast cataloging), editing is not restricted
442
$restrictededition = 0 if ($restrictededition != 0 && $frameworkcode eq 'FA' && haspermission($uid, {'editcatalogue' => 'fast_cataloging'}));
444
$restrictededition = 0 if ($restrictededition != 0 && $frameworkcode eq 'FA' && haspermission($uid, {'editcatalogue' => 'fast_cataloging'}));
443
445
Lines 855-861 foreach my $field (@fields) { Link Here
855
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
857
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
856
            #verifying rights
858
            #verifying rights
857
            my $userenv = C4::Context->userenv();
859
            my $userenv = C4::Context->userenv();
858
            unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $subfieldvalue))){
860
            unless ($is_super_librarian or (($userenv->{'branch'} eq $subfieldvalue))){
859
                $this_row{'nomod'} = 1;
861
                $this_row{'nomod'} = 1;
860
            }
862
            }
861
        }
863
        }
(-)a/circ/branchtransfers.pl (-1 / +2 lines)
Lines 63-70 my ($template, $user, $cookie, $flags ) = get_template_and_user( Link Here
63
    }
63
    }
64
);
64
);
65
65
66
my $logged_in_patron = Koha::Patrons->find($user);
66
# Check transfers is allowed from system preference
67
# Check transfers is allowed from system preference
67
if ( C4::Context->preference("IndependentBranchesTransfers") && !C4::Context->IsSuperLibrarian() ) {
68
if ( C4::Context->preference("IndependentBranchesTransfers") && !$logged_in_patron->is_superlibrarian() ) {
68
    print $query->redirect("/cgi-bin/koha/errors/403.pl");
69
    print $query->redirect("/cgi-bin/koha/errors/403.pl");
69
    exit;
70
    exit;
70
}
71
}
(-)a/members/deletemem.pl (-1 / +1 lines)
Lines 78-84 if ($patron->category->category_type eq "S") { Link Here
78
78
79
if (C4::Context->preference("IndependentBranches")) {
79
if (C4::Context->preference("IndependentBranches")) {
80
    my $userenv = C4::Context->userenv;
80
    my $userenv = C4::Context->userenv;
81
    if ( !C4::Context->IsSuperLibrarian() && $patron->branchcode){
81
    if ( !$logged_in_patron->is_superlibrarian  && $patron->branchcode){
82
        unless ($userenv->{branch} eq $patron->branchcode){
82
        unless ($userenv->{branch} eq $patron->branchcode){
83
            print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
83
            print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
84
            exit 0; # Exit without error
84
            exit 0; # Exit without error
(-)a/members/discharges.pl (-2 / +2 lines)
Lines 35-49 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user({ Link Here
35
    flagsrequired   => { borrowers => 'edit_borrowers' },
35
    flagsrequired   => { borrowers => 'edit_borrowers' },
36
});
36
});
37
37
38
my $logged_in_user = Koha::Patrons->find( $loggedinuser );
38
my $branchcode =
39
my $branchcode =
39
  ( C4::Context->preference("IndependentBranches")
40
  ( C4::Context->preference("IndependentBranches")
40
      and not C4::Context->IsSuperLibrarian() )
41
      and not $logged_in_user->is_superlibrarian )
41
  ? C4::Context->userenv()->{'branch'}
42
  ? C4::Context->userenv()->{'branch'}
42
  : undef;
43
  : undef;
43
44
44
if( $op eq 'allow' ) {
45
if( $op eq 'allow' ) {
45
    my $borrowernumber = $input->param('borrowernumber');
46
    my $borrowernumber = $input->param('borrowernumber');
46
    my $logged_in_user = Koha::Patrons->find( $loggedinuser );
47
    my $patron         = Koha::Patrons->find($borrowernumber);
47
    my $patron         = Koha::Patrons->find($borrowernumber);
48
    output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
48
    output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
49
    Koha::Patron::Discharge::discharge({
49
    Koha::Patron::Discharge::discharge({
(-)a/members/member-flags.pl (-2 / +1 lines)
Lines 84-90 if ($input->param('newflags')) { Link Here
84
    my $old_flags = $patron->flags // 0;
84
    my $old_flags = $patron->flags // 0;
85
    if( ( $old_flags == 1 || $module_flags == 1 ) &&
85
    if( ( $old_flags == 1 || $module_flags == 1 ) &&
86
      $old_flags != $module_flags ) {
86
      $old_flags != $module_flags ) {
87
        die "Non-superlibrarian is changing superlibrarian privileges" if !C4::Context->IsSuperLibrarian && C4::Context->preference('ProtectSuperlibrarianPrivileges'); # Interface should not allow this, so we can just die here
87
        die "Non-superlibrarian is changing superlibrarian privileges" if !$logged_in_user->is_superlibrarian() && C4::Context->preference('ProtectSuperlibrarianPrivileges'); # Interface should not allow this, so we can just die here
88
    }
88
    }
89
    $sth->execute($module_flags, $member);
89
    $sth->execute($module_flags, $member);
90
90
91
- 

Return to bug 26383