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

(-)a/C4/Acquisition.pm (-7 / +4 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-1899 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, $userenv->{branch};
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 2308-2315 sub GetHistory { Link Here
2308
    }
2306
    }
2309
2307
2310
    if ( C4::Context->preference("IndependentBranches") ) {
2308
    if ( C4::Context->preference("IndependentBranches") ) {
2311
        my $userenv = C4::Context->userenv;
2309
        unless ( C4::Context->IsSuperLibrarian() ) {
2312
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
2313
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2310
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2314
            push @query_params, $userenv->{branch};
2311
            push @query_params, $userenv->{branch};
2315
        }
2312
        }
(-)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/Items.pm (-1 / +1 lines)
Lines 2240-2246 sub DelItemCheck { Link Here
2240
    if ($onloan){
2240
    if ($onloan){
2241
        $error = "book_on_loan" 
2241
        $error = "book_on_loan" 
2242
    }
2242
    }
2243
    elsif ( !( C4::Context->userenv->{flags} & 1 )
2243
    elsif ( !C4::Context->IsSuperLibrarian() 
2244
        and C4::Context->preference("IndependentBranches")
2244
        and C4::Context->preference("IndependentBranches")
2245
        and ( C4::Context->userenv->{branch} ne $item->{'homebranch'} ) )
2245
        and ( C4::Context->userenv->{branch} ne $item->{'homebranch'} ) )
2246
    {
2246
    {
(-)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/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/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/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 (-3 / +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
}
133
- 

Return to bug 10277