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

(-)a/C4/Acquisition.pm (-9 / +6 lines)
Lines 1696-1702 sub SearchOrders { Link Here
1696
1696
1697
    my $userenv = C4::Context->userenv;
1697
    my $userenv = C4::Context->userenv;
1698
    if ( C4::Context->preference("IndependentBranches") ) {
1698
    if ( C4::Context->preference("IndependentBranches") ) {
1699
        if ( ( $userenv ) and ( $userenv->{flags} != 1 ) ) {
1699
        unless ( C4::Context->IsSuperLibrarian() ) {
1700
            $query .= q{
1700
            $query .= q{
1701
                AND (
1701
                AND (
1702
                    borrowers.branchcode = ?
1702
                    borrowers.branchcode = ?
Lines 1892-1902 sub GetParcel { Link Here
1892
1892
1893
    my @query_params = ( $supplierid, $code, $datereceived );
1893
    my @query_params = ( $supplierid, $code, $datereceived );
1894
    if ( C4::Context->preference("IndependentBranches") ) {
1894
    if ( C4::Context->preference("IndependentBranches") ) {
1895
        my $userenv = C4::Context->userenv;
1895
        unless ( C4::Context->IsSuperLibrarian() ) {
1896
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
1897
            $strsth .= " and (borrowers.branchcode = ?
1896
            $strsth .= " and (borrowers.branchcode = ?
1898
                        or borrowers.branchcode  = '')";
1897
                        or borrowers.branchcode  = '')";
1899
            push @query_params, $userenv->{branch};
1898
            push @query_params, C4::Context->userenv->{branch};
1900
        }
1899
        }
1901
    }
1900
    }
1902
    $strsth .= " ORDER BY aqbasket.basketno";
1901
    $strsth .= " ORDER BY aqbasket.basketno";
Lines 2111-2118 sub GetLateOrders { Link Here
2111
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= CAST(now() AS date)';
2110
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= CAST(now() AS date)';
2112
    }
2111
    }
2113
    if (C4::Context->preference("IndependentBranches")
2112
    if (C4::Context->preference("IndependentBranches")
2114
            && C4::Context->userenv
2113
            && !C4::Context->IsSuperLibrarian() ) {
2115
            && C4::Context->userenv->{flags} != 1 ) {
2116
        $from .= ' AND borrowers.branchcode LIKE ? ';
2114
        $from .= ' AND borrowers.branchcode LIKE ? ';
2117
        push @query_params, C4::Context->userenv->{branch};
2115
        push @query_params, C4::Context->userenv->{branch};
2118
    }
2116
    }
Lines 2326-2335 sub GetHistory { Link Here
2326
    }
2324
    }
2327
2325
2328
    if ( C4::Context->preference("IndependentBranches") ) {
2326
    if ( C4::Context->preference("IndependentBranches") ) {
2329
        my $userenv = C4::Context->userenv;
2327
        unless ( C4::Context->IsSuperLibrarian() ) {
2330
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
2331
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2328
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2332
            push @query_params, $userenv->{branch};
2329
            push @query_params, C4::Context->userenv->{branch};
2333
        }
2330
        }
2334
    }
2331
    }
2335
    $query .= " ORDER BY id";
2332
    $query .= " ORDER BY id";
(-)a/C4/Branch.pm (-5 / +5 lines)
Lines 146-156 sub GetBranches { Link Here
146
}
146
}
147
147
148
sub onlymine {
148
sub onlymine {
149
    return 
149
    return
150
    C4::Context->preference('IndependentBranches') &&
150
         C4::Context->preference('IndependentBranches')
151
    C4::Context->userenv                           &&
151
      && C4::Context->userenv
152
    C4::Context->userenv->{flags} %2 != 1          &&
152
      && !C4::Context->IsSuperLibrarian()
153
    C4::Context->userenv->{branch}                 ;
153
      && C4::Context->userenv->{branch};
154
}
154
}
155
155
156
# always returns a string for OK comparison via "eq" or "ne"
156
# always returns a string for OK comparison via "eq" or "ne"
(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 896-902 sub CanBookBeIssued { Link Here
896
    }
896
    }
897
    if ( C4::Context->preference("IndependentBranches") ) {
897
    if ( C4::Context->preference("IndependentBranches") ) {
898
        my $userenv = C4::Context->userenv;
898
        my $userenv = C4::Context->userenv;
899
        if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) {
899
        unless ( C4::Context->IsSuperLibrarian() ) {
900
            if ( $item->{C4::Context->preference("HomeOrHoldingBranch")} ne $userenv->{branch} ){
900
            if ( $item->{C4::Context->preference("HomeOrHoldingBranch")} ne $userenv->{branch} ){
901
                $issuingimpossible{ITEMNOTSAMEBRANCH} = 1;
901
                $issuingimpossible{ITEMNOTSAMEBRANCH} = 1;
902
                $issuingimpossible{'itemhomebranch'} = $item->{C4::Context->preference("HomeOrHoldingBranch")};
902
                $issuingimpossible{'itemhomebranch'} = $item->{C4::Context->preference("HomeOrHoldingBranch")};
(-)a/C4/Context.pm (+13 lines)
Lines 105-110 use C4::Debug; Link Here
105
use POSIX ();
105
use POSIX ();
106
use DateTime::TimeZone;
106
use DateTime::TimeZone;
107
use Module::Load::Conditional qw(can_load);
107
use Module::Load::Conditional qw(can_load);
108
use Carp;
108
109
109
=head1 NAME
110
=head1 NAME
110
111
Lines 1234-1239 sub tz { Link Here
1234
}
1235
}
1235
1236
1236
1237
1238
=head2 IsSuperLibrarian
1239
1240
    C4::Context->IsSuperlibrarian();
1241
1242
=cut
1243
1244
sub IsSuperLibrarian {
1245
    my $userenv = C4::Context->userenv
1246
      || carp("C4::Context->userenv not defined!");
1247
1248
    return $userenv->{flags} % 2 == 1;
1249
}
1237
1250
1238
1;
1251
1;
1239
__END__
1252
__END__
(-)a/C4/Items.pm (-3 / +3 lines)
Lines 1303-1309 sub GetItemsInfo { Link Here
1303
            $datedue                = $idata->{'date_due'};
1303
            $datedue                = $idata->{'date_due'};
1304
        if (C4::Context->preference("IndependentBranches")){
1304
        if (C4::Context->preference("IndependentBranches")){
1305
        my $userenv = C4::Context->userenv;
1305
        my $userenv = C4::Context->userenv;
1306
        if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) { 
1306
        unless ( C4::Context->IsSuperLibrarian() ) {
1307
            $data->{'NOTSAMEBRANCH'} = 1 if ($idata->{'bcode'} ne $userenv->{branch});
1307
            $data->{'NOTSAMEBRANCH'} = 1 if ($idata->{'bcode'} ne $userenv->{branch});
1308
        }
1308
        }
1309
        }
1309
        }
Lines 2265-2271 sub DelItemCheck { Link Here
2265
    if ($onloan){
2265
    if ($onloan){
2266
        $error = "book_on_loan" 
2266
        $error = "book_on_loan" 
2267
    }
2267
    }
2268
    elsif ( !( C4::Context->userenv->{flags} & 1 )
2268
    elsif ( !C4::Context->IsSuperLibrarian()
2269
        and C4::Context->preference("IndependentBranches")
2269
        and C4::Context->preference("IndependentBranches")
2270
        and ( C4::Context->userenv->{branch} ne $item->{'homebranch'} ) )
2270
        and ( C4::Context->userenv->{branch} ne $item->{'homebranch'} ) )
2271
    {
2271
    {
Lines 2747-2753 sub PrepareItemrecordDisplay { Link Here
2747
                    #---- branch
2747
                    #---- branch
2748
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2748
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2749
                        if (   ( C4::Context->preference("IndependentBranches") )
2749
                        if (   ( C4::Context->preference("IndependentBranches") )
2750
                            && ( C4::Context->userenv && C4::Context->userenv->{flags} % 2 != 1 ) ) {
2750
                            && !C4::Context->IsSuperLibrarian() ) {
2751
                            my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" );
2751
                            my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" );
2752
                            $sth->execute( C4::Context->userenv->{branch} );
2752
                            $sth->execute( C4::Context->userenv->{branch} );
2753
                            push @authorised_values, ""
2753
                            push @authorised_values, ""
(-)a/C4/Members.pm (-4 / +4 lines)
Lines 262-268 sub Search { Link Here
262
    if ( C4::Context->preference("IndependentBranches") ) { # && !$showallbranches){
262
    if ( C4::Context->preference("IndependentBranches") ) { # && !$showallbranches){
263
        if ( my $userenv = C4::Context->userenv ) {
263
        if ( my $userenv = C4::Context->userenv ) {
264
            my $branch =  $userenv->{'branch'};
264
            my $branch =  $userenv->{'branch'};
265
            if ( ($userenv->{flags} % 2 !=1) && $branch ){
265
            if ( !C4::Context->IsSuperLibrarian() && $branch ){
266
                if (my $fr = ref $filter) {
266
                if (my $fr = ref $filter) {
267
                    if ( $fr eq "HASH" ) {
267
                    if ( $fr eq "HASH" ) {
268
                        $filter->{branchcode} = $branch;
268
                        $filter->{branchcode} = $branch;
Lines 2046-2052 sub GetBorrowersToExpunge { Link Here
2046
    my $filterbranch   = $params->{'branchcode'} ||
2046
    my $filterbranch   = $params->{'branchcode'} ||
2047
                        ((C4::Context->preference('IndependentBranches')
2047
                        ((C4::Context->preference('IndependentBranches')
2048
                             && C4::Context->userenv 
2048
                             && C4::Context->userenv 
2049
                             && C4::Context->userenv->{flags} % 2 !=1 
2049
                             && !C4::Context->IsSuperLibrarian()
2050
                             && C4::Context->userenv->{branch})
2050
                             && C4::Context->userenv->{branch})
2051
                         ? C4::Context->userenv->{branch}
2051
                         ? C4::Context->userenv->{branch}
2052
                         : "");  
2052
                         : "");  
Lines 2112-2118 sub GetBorrowersWhoHaveNeverBorrowed { Link Here
2112
    my $filterbranch = shift || 
2112
    my $filterbranch = shift || 
2113
                        ((C4::Context->preference('IndependentBranches')
2113
                        ((C4::Context->preference('IndependentBranches')
2114
                             && C4::Context->userenv 
2114
                             && C4::Context->userenv 
2115
                             && C4::Context->userenv->{flags} % 2 !=1 
2115
                             && !C4::Context->IsSuperLibrarian()
2116
                             && C4::Context->userenv->{branch})
2116
                             && C4::Context->userenv->{branch})
2117
                         ? C4::Context->userenv->{branch}
2117
                         ? C4::Context->userenv->{branch}
2118
                         : "");  
2118
                         : "");  
Lines 2162-2168 sub GetBorrowersWithIssuesHistoryOlderThan { Link Here
2162
    my $filterbranch = shift || 
2162
    my $filterbranch = shift || 
2163
                        ((C4::Context->preference('IndependentBranches')
2163
                        ((C4::Context->preference('IndependentBranches')
2164
                             && C4::Context->userenv 
2164
                             && C4::Context->userenv 
2165
                             && C4::Context->userenv->{flags} % 2 !=1 
2165
                             && !C4::Context->IsSuperLibrarian()
2166
                             && C4::Context->userenv->{branch})
2166
                             && C4::Context->userenv->{branch})
2167
                         ? C4::Context->userenv->{branch}
2167
                         ? C4::Context->userenv->{branch}
2168
                         : "");  
2168
                         : "");  
(-)a/C4/Serials.pm (-1 / +1 lines)
Lines 2837-2843 sub can_edit_subscription { Link Here
2837
    $userid ||= C4::Context->userenv->{'id'};
2837
    $userid ||= C4::Context->userenv->{'id'};
2838
    my $independent_branches = C4::Context->preference('IndependentBranches');
2838
    my $independent_branches = C4::Context->preference('IndependentBranches');
2839
    return 1 unless $independent_branches;
2839
    return 1 unless $independent_branches;
2840
    if( $flags % 2 == 1 # superlibrarian
2840
    if( C4::Context->IsSuperLibrarian()
2841
        or C4::Auth::haspermission( $userid, {serials => 'superserials'}),
2841
        or C4::Auth::haspermission( $userid, {serials => 'superserials'}),
2842
        or C4::Auth::haspermission( $userid, {serials => 'edit_subscription'}),
2842
        or C4::Auth::haspermission( $userid, {serials => 'edit_subscription'}),
2843
        or not defined $subscription->{branchcode}
2843
        or not defined $subscription->{branchcode}
(-)a/C4/Suggestions.pm (-8 / +8 lines)
Lines 135-141 sub SearchSuggestion { Link Here
135
    if ( C4::Context->preference('IndependentBranches') ) {
135
    if ( C4::Context->preference('IndependentBranches') ) {
136
        my $userenv = C4::Context->userenv;
136
        my $userenv = C4::Context->userenv;
137
        if ($userenv) {
137
        if ($userenv) {
138
            if ( ( $userenv->{flags} % 2 ) != 1 && !$suggestion->{branchcode} )
138
            if ( !C4::Context->IsSuperLibrarian() && !$suggestion->{branchcode} )
139
            {
139
            {
140
                push @sql_params, $$userenv{branch};
140
                push @sql_params, $$userenv{branch};
141
                push @query,      q{
141
                push @query,      q{
Lines 342-348 sub GetSuggestionByStatus { Link Here
342
    if ( C4::Context->preference("IndependentBranches") || $branchcode ) {
342
    if ( C4::Context->preference("IndependentBranches") || $branchcode ) {
343
        my $userenv = C4::Context->userenv;
343
        my $userenv = C4::Context->userenv;
344
        if ($userenv) {
344
        if ($userenv) {
345
            unless ( $userenv->{flags} % 2 == 1 ) {
345
            unless ( C4::Context->IsSuperLibrarian() ) {
346
                push @sql_params, $userenv->{branch};
346
                push @sql_params, $userenv->{branch};
347
                $query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') };
347
                $query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') };
348
            }
348
            }
Lines 352-358 sub GetSuggestionByStatus { Link Here
352
            $query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') };
352
            $query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') };
353
        }
353
        }
354
    }
354
    }
355
    
355
356
    my $sth = $dbh->prepare($query);
356
    my $sth = $dbh->prepare($query);
357
    $sth->execute(@sql_params);
357
    $sth->execute(@sql_params);
358
    my $results;
358
    my $results;
Lines 390-396 sub CountSuggestion { Link Here
390
    my $sth;
390
    my $sth;
391
    my $userenv = C4::Context->userenv;
391
    my $userenv = C4::Context->userenv;
392
    if ( C4::Context->preference("IndependentBranches")
392
    if ( C4::Context->preference("IndependentBranches")
393
        && $userenv->{flags} % 2 != 1 )
393
        && !C4::Context->IsSuperLibrarian() )
394
    {
394
    {
395
        my $query = q{
395
        my $query = q{
396
            SELECT count(*)
396
            SELECT count(*)
Lines 436-445 sub NewSuggestion { Link Here
436
436
437
Modify the suggestion according to the hash passed by ref.
437
Modify the suggestion according to the hash passed by ref.
438
The hash HAS to contain suggestionid
438
The hash HAS to contain suggestionid
439
Data not defined is not updated unless it is a note or sort1 
439
Data not defined is not updated unless it is a note or sort1
440
Send a mail to notify the user that did the suggestion.
440
Send a mail to notify the user that did the suggestion.
441
441
442
Note that there is no function to modify a suggestion. 
442
Note that there is no function to modify a suggestion.
443
443
444
=cut
444
=cut
445
445
Lines 533-541 sub DelSuggestion { Link Here
533
533
534
=head2 DelSuggestionsOlderThan
534
=head2 DelSuggestionsOlderThan
535
    &DelSuggestionsOlderThan($days)
535
    &DelSuggestionsOlderThan($days)
536
    
536
537
    Delete all suggestions older than TODAY-$days , that have be accepted or rejected.
537
    Delete all suggestions older than TODAY-$days , that have be accepted or rejected.
538
    
538
539
=cut
539
=cut
540
540
541
sub DelSuggestionsOlderThan {
541
sub DelSuggestionsOlderThan {
(-)a/acqui/basket.pl (-2 / +2 lines)
Lines 154-160 if ( $op eq 'delete_confirm' ) { Link Here
154
    $template->param( delete_confirm => 1 );
154
    $template->param( delete_confirm => 1 );
155
    if ( C4::Context->preference("IndependentBranches") ) {
155
    if ( C4::Context->preference("IndependentBranches") ) {
156
        my $userenv = C4::Context->userenv;
156
        my $userenv = C4::Context->userenv;
157
        unless ( $userenv->{flags} == 1 ) {
157
        unless ( C4::Context->IsSuperLibrarian() ) {
158
            my $validtest = ( $basket->{creationdate} eq '' )
158
            my $validtest = ( $basket->{creationdate} eq '' )
159
              || ( $userenv->{branch} eq $basket->{branch} )
159
              || ( $userenv->{branch} eq $basket->{branch} )
160
              || ( $userenv->{branch} eq '' )
160
              || ( $userenv->{branch} eq '' )
Lines 257-263 if ( $op eq 'delete_confirm' ) { Link Here
257
    # get librarian branch...
257
    # get librarian branch...
258
    if ( C4::Context->preference("IndependentBranches") ) {
258
    if ( C4::Context->preference("IndependentBranches") ) {
259
        my $userenv = C4::Context->userenv;
259
        my $userenv = C4::Context->userenv;
260
        unless ( $userenv->{flags} == 1 ) {
260
        unless ( C4::Context->IsSuperLibrarian() ) {
261
            my $validtest = ( $basket->{creationdate} eq '' )
261
            my $validtest = ( $basket->{creationdate} eq '' )
262
              || ( $userenv->{branch} eq $basket->{branch} )
262
              || ( $userenv->{branch} eq $basket->{branch} )
263
              || ( $userenv->{branch} eq '' )
263
              || ( $userenv->{branch} eq '' )
(-)a/acqui/neworderempty.pl (-4 / +5 lines)
Lines 229-238 for my $curr ( @rates ) { Link Here
229
}
229
}
230
230
231
# build branches list
231
# build branches list
232
my $onlymine=C4::Context->preference('IndependentBranches') &&
232
my $onlymine =
233
            C4::Context->userenv && 
233
     C4::Context->preference('IndependentBranches')
234
            C4::Context->userenv->{flags}!=1 && 
234
  && C4::Context->userenv
235
            C4::Context->userenv->{branch};
235
  && !C4::Context->IsSuperLibrarian()
236
  && C4::Context->userenv->{branch};
236
my $branches = GetBranches($onlymine);
237
my $branches = GetBranches($onlymine);
237
my @branchloop;
238
my @branchloop;
238
foreach my $thisbranch ( sort {$branches->{$a}->{'branchname'} cmp $branches->{$b}->{'branchname'}} keys %$branches ) {
239
foreach my $thisbranch ( sort {$branches->{$a}->{'branchname'} cmp $branches->{$b}->{'branchname'}} keys %$branches ) {
(-)a/cataloguing/addbiblio.pl (-4 / +5 lines)
Lines 172-181 sub build_authorized_values_list { Link Here
172
    #---- branch
172
    #---- branch
173
    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
173
    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
174
        #Use GetBranches($onlymine)
174
        #Use GetBranches($onlymine)
175
        my $onlymine=C4::Context->preference('IndependentBranches') &&
175
        my $onlymine =
176
                C4::Context->userenv && 
176
             C4::Context->preference('IndependentBranches')
177
                C4::Context->userenv->{flags} % 2 == 0 && 
177
          && C4::Context->userenv
178
                C4::Context->userenv->{branch};
178
          && !C4::Context->IsSuperLibrarian()
179
          && C4::Context->userenv->{branch};
179
        my $branches = GetBranches($onlymine);
180
        my $branches = GetBranches($onlymine);
180
        my @branchloop;
181
        my @branchloop;
181
        foreach my $thisbranch ( sort keys %$branches ) {
182
        foreach my $thisbranch ( sort keys %$branches ) {
(-)a/cataloguing/additem.pl (-4 / +5 lines)
Lines 756-765 my $i=0; Link Here
756
756
757
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
757
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
758
758
759
my $onlymine = C4::Context->preference('IndependentBranches') &&
759
my $onlymine =
760
               C4::Context->userenv                           && 
760
     C4::Context->preference('IndependentBranches')
761
               C4::Context->userenv->{flags}!=1               && 
761
  && C4::Context->userenv
762
               C4::Context->userenv->{branch};
762
  && !C4::Context->IsSuperLibrarian()
763
  && C4::Context->userenv->{branch};
763
my $branch = $input->param('branch') || C4::Context->userenv->{branch};
764
my $branch = $input->param('branch') || C4::Context->userenv->{branch};
764
my $branches = GetBranchesLoop($branch,$onlymine);  # build once ahead of time, instead of multiple times later.
765
my $branches = GetBranchesLoop($branch,$onlymine);  # build once ahead of time, instead of multiple times later.
765
766
(-)a/circ/overdue.pl (-4 / +5 lines)
Lines 91-100 while (my ($itemtype, $description) =$req->fetchrow) { Link Here
91
        itemtypename => $description,
91
        itemtypename => $description,
92
    };
92
    };
93
}
93
}
94
my $onlymine=C4::Context->preference('IndependentBranches') &&
94
my $onlymine =
95
             C4::Context->userenv &&
95
     C4::Context->preference('IndependentBranches')
96
             C4::Context->userenv->{flags} % 2 !=1 &&
96
  && C4::Context->userenv
97
             C4::Context->userenv->{branch};
97
  && !C4::Context->IsSuperLibrarian()
98
  && C4::Context->userenv->{branch};
98
99
99
$branchfilter = C4::Context->userenv->{'branch'} if ($onlymine && !$branchfilter);
100
$branchfilter = C4::Context->userenv->{'branch'} if ($onlymine && !$branchfilter);
100
101
(-)a/circ/ysearch.pl (-7 / +7 lines)
Lines 51-63 my $sql = q( Link Here
51
        OR firstname LIKE ?
51
        OR firstname LIKE ?
52
        OR cardnumber LIKE ? )
52
        OR cardnumber LIKE ? )
53
);
53
);
54
if (C4::Context->preference("IndependentBranches")){
54
if (   C4::Context->preference("IndependentBranches")
55
  if ( C4::Context->userenv
55
    && C4::Context->userenv
56
      && (C4::Context->userenv->{flags} % 2) !=1
56
    && !C4::Context->IsSuperLibrarian()
57
      && C4::Context->userenv->{'branch'}
57
    && C4::Context->userenv->{'branch'} )
58
  ){
58
{
59
     $sql .= " AND borrowers.branchcode =" . $dbh->quote(C4::Context->userenv->{'branch'});
59
    $sql .= " AND borrowers.branchcode ="
60
  }
60
      . $dbh->quote( C4::Context->userenv->{'branch'} );
61
}
61
}
62
62
63
$sql    .= q( ORDER BY surname, firstname LIMIT 10);
63
$sql    .= q( ORDER BY surname, firstname LIMIT 10);
(-)a/members/deletemem.pl (-1 / +1 lines)
Lines 68-74 if ($bor->{category_type} eq "S") { Link Here
68
68
69
if (C4::Context->preference("IndependentBranches")) {
69
if (C4::Context->preference("IndependentBranches")) {
70
    my $userenv = C4::Context->userenv;
70
    my $userenv = C4::Context->userenv;
71
    if (($userenv->{flags} % 2 != 1) && $bor->{'branchcode'}){
71
    if ( !C4::Context->IsSuperLibrarian() && $bor->{'branchcode'}){
72
        unless ($userenv->{branch} eq $bor->{'branchcode'}){
72
        unless ($userenv->{branch} eq $bor->{'branchcode'}){
73
            print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
73
            print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
74
            exit;
74
            exit;
(-)a/members/memberentry.pl (-2 / +2 lines)
Lines 313-319 if ($op eq 'save' || $op eq 'insert'){ Link Here
313
    }
313
    }
314
314
315
  if (C4::Context->preference("IndependentBranches")) {
315
  if (C4::Context->preference("IndependentBranches")) {
316
    if ($userenv && $userenv->{flags} % 2 != 1){
316
    unless ( C4::Context->IsSuperLibrarian() ){
317
      $debug and print STDERR "  $newdata{'branchcode'} : ".$userenv->{flags}.":".$userenv->{branch};
317
      $debug and print STDERR "  $newdata{'branchcode'} : ".$userenv->{flags}.":".$userenv->{branch};
318
      unless (!$newdata{'branchcode'} || $userenv->{branch} eq $newdata{'branchcode'}){
318
      unless (!$newdata{'branchcode'} || $userenv->{branch} eq $newdata{'branchcode'}){
319
        push @errors, "ERROR_branch";
319
        push @errors, "ERROR_branch";
Lines 450-456 if ($nok or !$nodouble){ Link Here
450
} 
450
} 
451
if (C4::Context->preference("IndependentBranches")) {
451
if (C4::Context->preference("IndependentBranches")) {
452
    my $userenv = C4::Context->userenv;
452
    my $userenv = C4::Context->userenv;
453
    if ($userenv->{flags} % 2 != 1 && $data{'branchcode'}){
453
    if ( !C4::Context->IsSuperLibrarian() && $data{'branchcode'} ) {
454
        unless ($userenv->{branch} eq $data{'branchcode'}){
454
        unless ($userenv->{branch} eq $data{'branchcode'}){
455
            print $input->redirect("/cgi-bin/koha/members/members-home.pl");
455
            print $input->redirect("/cgi-bin/koha/members/members-home.pl");
456
            exit;
456
            exit;
(-)a/members/moremember.pl (-8 / +14 lines)
Lines 213-223 $bor{'borrowernumber'} = $borrowernumber; Link Here
213
my $samebranch;
213
my $samebranch;
214
if ( C4::Context->preference("IndependentBranches") ) {
214
if ( C4::Context->preference("IndependentBranches") ) {
215
    my $userenv = C4::Context->userenv;
215
    my $userenv = C4::Context->userenv;
216
    unless ( $userenv->{flags} % 2 == 1 ) {
216
    if ( C4::Context->IsSuperLibrarian() ) {
217
        $samebranch = 1;
218
    }
219
    else {
217
        $samebranch = ( $data->{'branchcode'} eq $userenv->{branch} );
220
        $samebranch = ( $data->{'branchcode'} eq $userenv->{branch} );
218
    }
221
    }
219
    $samebranch = 1 if ( $userenv->{flags} % 2 == 1 );
222
}
220
}else{
223
else {
221
    $samebranch = 1;
224
    $samebranch = 1;
222
}
225
}
223
my $branchdetail = GetBranchDetail( $data->{'branchcode'});
226
my $branchdetail = GetBranchDetail( $data->{'branchcode'});
Lines 340-353 foreach (@$alerts) { Link Here
340
343
341
my $candeleteuser;
344
my $candeleteuser;
342
my $userenv = C4::Context->userenv;
345
my $userenv = C4::Context->userenv;
343
if($userenv->{flags} % 2 == 1){
346
if ( C4::Context->IsSuperLibrarian() ) {
344
    $candeleteuser = 1;
347
    $candeleteuser = 1;
345
}elsif ( C4::Context->preference("IndependentBranches") ) {
348
}
349
elsif ( C4::Context->preference("IndependentBranches") ) {
346
    $candeleteuser = ( $data->{'branchcode'} eq $userenv->{branch} );
350
    $candeleteuser = ( $data->{'branchcode'} eq $userenv->{branch} );
347
}else{
351
}
348
    if( C4::Auth::getuserflags( $userenv->{flags},$userenv->{number})->{borrowers} ) {
352
else {
353
    if ( C4::Auth::getuserflags( $userenv->{flags}, $userenv->{number} )->{borrowers} ) {
349
        $candeleteuser = 1;
354
        $candeleteuser = 1;
350
    }else{
355
    }
356
    else {
351
        $candeleteuser = 0;
357
        $candeleteuser = 0;
352
    }
358
    }
353
}
359
}
(-)a/reserve/request.pl (-1 / +1 lines)
Lines 384-390 foreach my $biblionumber (@biblionumbers) { Link Here
384
                if (! C4::Context->preference("canreservefromotherbranches")){
384
                if (! C4::Context->preference("canreservefromotherbranches")){
385
                    # cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
385
                    # cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
386
                    my $userenv = C4::Context->userenv;
386
                    my $userenv = C4::Context->userenv;
387
                    if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) {
387
                    unless ( C4::Context->IsSuperLibrarian ) {
388
                        $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
388
                        $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
389
                    }
389
                    }
390
                }
390
                }
(-)a/serials/member-search.pl (-4 / +7 lines)
Lines 82-91 if (defined $member) { Link Here
82
82
83
my ($count,$results);
83
my ($count,$results);
84
84
85
if (C4::Context->preference("IndependentBranches")){
85
if ( C4::Context->preference("IndependentBranches") ) {
86
   if (C4::Context->userenv && C4::Context->userenv->{flags} % 2 !=1 && C4::Context->userenv->{'branch'}){
86
    if (   C4::Context->userenv
87
        $$patron{branchcode}=C4::Context->userenv->{'branch'};
87
        && !C4::Context->IsSuperLibrarian()
88
   }
88
        && C4::Context->userenv->{'branch'} )
89
    {
90
        $$patron{branchcode} = C4::Context->userenv->{'branch'};
91
    }
89
}
92
}
90
$$patron{firstname}.="\%" if ($$patron{firstname});
93
$$patron{firstname}.="\%" if ($$patron{firstname});
91
$$patron{surname}.="\%" if ($$patron{surname});
94
$$patron{surname}.="\%" if ($$patron{surname});
(-)a/serials/subscription-add.pl (-6 / +4 lines)
Lines 125-140 if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { Link Here
125
    }
125
    }
126
}
126
}
127
127
128
my $userenv = C4::Context->userenv;
129
my $onlymine =
128
my $onlymine =
130
     C4::Context->preference('IndependentBranches')
129
     C4::Context->preference('IndependentBranches')
131
  && $userenv
130
  && C4::Context->userenv
132
  && $userenv->{flags} % 2 != 1
131
  && !C4::Context->IsSuperLibrarian
133
  && (
132
  && (
134
    not C4::Auth::haspermission( $userenv->{id}, { serials => 'superserials' } )
133
    not C4::Auth::haspermission( C4::Context->userenv->{id}, { serials => 'superserials' } )
135
  )
134
  )
136
  && $userenv->{branch};
135
  && C4::Context->userenv->{branch};
137
138
my $branches = GetBranches($onlymine);
136
my $branches = GetBranches($onlymine);
139
my $branchloop;
137
my $branchloop;
140
for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
138
for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
(-)a/suggestion/suggestion.pl (-4 / +5 lines)
Lines 288-297 if(defined($returnsuggested) and $returnsuggested ne "noone") Link Here
288
288
289
#branch display management
289
#branch display management
290
my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : '';
290
my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : '';
291
my $onlymine=C4::Context->preference('IndependentBranches') &&
291
my $onlymine =
292
            C4::Context->userenv && 
292
     C4::Context->preference('IndependentBranches')
293
            C4::Context->userenv->{flags}!=1 && 
293
  && C4::Context->userenv
294
            C4::Context->userenv->{branch};
294
  && !C4::Context->IsSuperLibrarian()
295
  && C4::Context->userenv->{branch};
295
my $branches = GetBranches($onlymine);
296
my $branches = GetBranches($onlymine);
296
my @branchloop;
297
my @branchloop;
297
298
(-)a/tools/export.pl (-2 / +2 lines)
Lines 120-132 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( Link Here
120
my $limit_ind_branch =
120
my $limit_ind_branch =
121
  (      C4::Context->preference('IndependentBranches')
121
  (      C4::Context->preference('IndependentBranches')
122
      && C4::Context->userenv
122
      && C4::Context->userenv
123
      && !( C4::Context->userenv->{flags} & 1 )
123
      && !C4::Context->IsSuperLibrarian()
124
      && C4::Context->userenv->{branch} ) ? 1 : 0;
124
      && C4::Context->userenv->{branch} ) ? 1 : 0;
125
125
126
my $branch = $query->param("branch") || '';
126
my $branch = $query->param("branch") || '';
127
if (   C4::Context->preference("IndependentBranches")
127
if (   C4::Context->preference("IndependentBranches")
128
    && C4::Context->userenv
128
    && C4::Context->userenv
129
    && !( C4::Context->userenv->{flags} & 1 ) )
129
    && !C4::Context->IsSuperLibrarian() )
130
{
130
{
131
    $branch = C4::Context->userenv->{'branch'};
131
    $branch = C4::Context->userenv->{'branch'};
132
}
132
}
(-)a/tools/holidays.pl (-5 / +5 lines)
Lines 57-66 $keydate =~ s/-/\//g; Link Here
57
57
58
my $branch= $input->param('branch') || C4::Context->userenv->{'branch'};
58
my $branch= $input->param('branch') || C4::Context->userenv->{'branch'};
59
# Set all the branches.
59
# Set all the branches.
60
my $onlymine=(C4::Context->preference('IndependentBranches') &&
60
my $onlymine =
61
              C4::Context->userenv &&
61
  (      C4::Context->preference('IndependentBranches')
62
              C4::Context->userenv->{flags} % 2 !=1  &&
62
      && C4::Context->userenv
63
              C4::Context->userenv->{branch}?1:0);
63
      && !C4::Context->IsSuperLibrarian()
64
      && C4::Context->userenv->{branch} ? 1 : 0 );
64
if ( $onlymine ) { 
65
if ( $onlymine ) { 
65
    $branch = C4::Context->userenv->{'branch'};
66
    $branch = C4::Context->userenv->{'branch'};
66
}
67
}
67
- 

Return to bug 10277