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

(-)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 (-2 / +2 lines)
Lines 1281-1287 sub GetItemsInfo { Link Here
1281
            $datedue                = $idata->{'date_due'};
1281
            $datedue                = $idata->{'date_due'};
1282
        if (C4::Context->preference("IndependentBranches")){
1282
        if (C4::Context->preference("IndependentBranches")){
1283
        my $userenv = C4::Context->userenv;
1283
        my $userenv = C4::Context->userenv;
1284
        if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) { 
1284
        unless ( C4::Context->IsSuperLibrarian() ) {
1285
            $data->{'NOTSAMEBRANCH'} = 1 if ($idata->{'bcode'} ne $userenv->{branch});
1285
            $data->{'NOTSAMEBRANCH'} = 1 if ($idata->{'bcode'} ne $userenv->{branch});
1286
        }
1286
        }
1287
        }
1287
        }
Lines 2717-2723 sub PrepareItemrecordDisplay { Link Here
2717
                    #---- branch
2717
                    #---- branch
2718
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2718
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2719
                        if (   ( C4::Context->preference("IndependentBranches") )
2719
                        if (   ( C4::Context->preference("IndependentBranches") )
2720
                            && ( C4::Context->userenv && C4::Context->userenv->{flags} % 2 != 1 ) ) {
2720
                            && !C4::Context->IsSuperLibrarian() ) {
2721
                            my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" );
2721
                            my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" );
2722
                            $sth->execute( C4::Context->userenv->{branch} );
2722
                            $sth->execute( C4::Context->userenv->{branch} );
2723
                            push @authorised_values, ""
2723
                            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 2811-2817 sub can_edit_subscription { Link Here
2811
    $userid ||= C4::Context->userenv->{'id'};
2811
    $userid ||= C4::Context->userenv->{'id'};
2812
    my $independent_branches = C4::Context->preference('IndependentBranches');
2812
    my $independent_branches = C4::Context->preference('IndependentBranches');
2813
    return 1 unless $independent_branches;
2813
    return 1 unless $independent_branches;
2814
    if( $flags % 2 == 1 # superlibrarian
2814
    if( C4::Context->IsSuperLibrarian()
2815
        or C4::Auth::haspermission( $userid, {serials => 'superserials'}),
2815
        or C4::Auth::haspermission( $userid, {serials => 'superserials'}),
2816
        or C4::Auth::haspermission( $userid, {serials => 'edit_subscription'}),
2816
        or C4::Auth::haspermission( $userid, {serials => 'edit_subscription'}),
2817
        or not defined $subscription->{branchcode}
2817
        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/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/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/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/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