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

(-)a/C4/Acquisition.pm (-5 / +5 lines)
Lines 867-873 sub GetPendingOrders { Link Here
867
        AND datecancellationprinted IS NULL";
867
        AND datecancellationprinted IS NULL";
868
    my @query_params;
868
    my @query_params;
869
    my $userenv = C4::Context->userenv;
869
    my $userenv = C4::Context->userenv;
870
    if ( C4::Context->preference("IndependantBranches") ) {
870
    if ( C4::Context->preference("IndependentBranches") ) {
871
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
871
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
872
            $strsth .= " AND (borrowers.branchcode = ?
872
            $strsth .= " AND (borrowers.branchcode = ?
873
                        or borrowers.branchcode  = '')";
873
                        or borrowers.branchcode  = '')";
Lines 1730-1736 sub GetParcel { Link Here
1730
            AND aqorders.datereceived = ? ";
1730
            AND aqorders.datereceived = ? ";
1731
1731
1732
    my @query_params = ( $supplierid, $code, $datereceived );
1732
    my @query_params = ( $supplierid, $code, $datereceived );
1733
    if ( C4::Context->preference("IndependantBranches") ) {
1733
    if ( C4::Context->preference("IndependentBranches") ) {
1734
        my $userenv = C4::Context->userenv;
1734
        my $userenv = C4::Context->userenv;
1735
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
1735
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
1736
            $strsth .= " and (borrowers.branchcode = ?
1736
            $strsth .= " and (borrowers.branchcode = ?
Lines 1949-1955 sub GetLateOrders { Link Here
1949
    if ( defined $estimateddeliverydatefrom and not defined $estimateddeliverydateto ) {
1949
    if ( defined $estimateddeliverydatefrom and not defined $estimateddeliverydateto ) {
1950
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= CAST(now() AS date)';
1950
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= CAST(now() AS date)';
1951
    }
1951
    }
1952
    if (C4::Context->preference("IndependantBranches")
1952
    if (C4::Context->preference("IndependentBranches")
1953
            && C4::Context->userenv
1953
            && C4::Context->userenv
1954
            && C4::Context->userenv->{flags} != 1 ) {
1954
            && C4::Context->userenv->{flags} != 1 ) {
1955
        $from .= ' AND borrowers.branchcode LIKE ? ';
1955
        $from .= ' AND borrowers.branchcode LIKE ? ';
Lines 2058-2064 sub GetHistory { Link Here
2058
    LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
2058
    LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
2059
2059
2060
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
2060
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
2061
    if ( C4::Context->preference("IndependantBranches") );
2061
    if ( C4::Context->preference("IndependentBranches") );
2062
2062
2063
    $query .= " WHERE (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') ";
2063
    $query .= " WHERE (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') ";
2064
2064
Lines 2118-2124 sub GetHistory { Link Here
2118
        push @query_params, "%$basketgroupname%";
2118
        push @query_params, "%$basketgroupname%";
2119
    }
2119
    }
2120
2120
2121
    if ( C4::Context->preference("IndependantBranches") ) {
2121
    if ( C4::Context->preference("IndependentBranches") ) {
2122
        my $userenv = C4::Context->userenv;
2122
        my $userenv = C4::Context->userenv;
2123
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
2123
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
2124
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2124
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
(-)a/C4/Auth.pm (-3 / +3 lines)
Lines 345-351 sub get_template_and_user { Link Here
345
            CalendarFirstDayOfWeek      => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1,
345
            CalendarFirstDayOfWeek      => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1,
346
            CircAutocompl               => C4::Context->preference("CircAutocompl"),
346
            CircAutocompl               => C4::Context->preference("CircAutocompl"),
347
            FRBRizeEditions             => C4::Context->preference("FRBRizeEditions"),
347
            FRBRizeEditions             => C4::Context->preference("FRBRizeEditions"),
348
            IndependantBranches         => C4::Context->preference("IndependantBranches"),
348
            IndependentBranches         => C4::Context->preference("IndependentBranches"),
349
            IntranetNav                 => C4::Context->preference("IntranetNav"),
349
            IntranetNav                 => C4::Context->preference("IntranetNav"),
350
            IntranetmainUserblock       => C4::Context->preference("IntranetmainUserblock"),
350
            IntranetmainUserblock       => C4::Context->preference("IntranetmainUserblock"),
351
            LibraryName                 => C4::Context->preference("LibraryName"),
351
            LibraryName                 => C4::Context->preference("LibraryName"),
Lines 880-886 sub checkauth { Link Here
880
                        $branchname = GetBranchName($branchcode);
880
                        $branchname = GetBranchName($branchcode);
881
                    }
881
                    }
882
                    my $branches = GetBranches();
882
                    my $branches = GetBranches();
883
                    if (C4::Context->boolean_preference('IndependantBranches') && C4::Context->boolean_preference('Autolocation')){
883
                    if (C4::Context->boolean_preference('IndependentBranches') && C4::Context->boolean_preference('Autolocation')){
884
                        # we have to check they are coming from the right ip range
884
                        # we have to check they are coming from the right ip range
885
                        my $domain = $branches->{$branchcode}->{'branchip'};
885
                        my $domain = $branches->{$branchcode}->{'branchip'};
886
                        if ($ip !~ /^$domain/){
886
                        if ($ip !~ /^$domain/){
Lines 1025-1031 sub checkauth { Link Here
1025
        IntranetNav        => C4::Context->preference("IntranetNav"),
1025
        IntranetNav        => C4::Context->preference("IntranetNav"),
1026
        IntranetFavicon    => C4::Context->preference("IntranetFavicon"),
1026
        IntranetFavicon    => C4::Context->preference("IntranetFavicon"),
1027
        intranetuserjs     => C4::Context->preference("intranetuserjs"),
1027
        intranetuserjs     => C4::Context->preference("intranetuserjs"),
1028
        IndependantBranches=> C4::Context->preference("IndependantBranches"),
1028
        IndependentBranches=> C4::Context->preference("IndependentBranches"),
1029
        AutoLocation       => C4::Context->preference("AutoLocation"),
1029
        AutoLocation       => C4::Context->preference("AutoLocation"),
1030
        wrongip            => $info{'wrongip'},
1030
        wrongip            => $info{'wrongip'},
1031
        PatronSelfRegistration => C4::Context->preference("PatronSelfRegistration"),
1031
        PatronSelfRegistration => C4::Context->preference("PatronSelfRegistration"),
(-)a/C4/Boolean.pm (-1 / +1 lines)
Lines 67-73 our %strings = ( Link Here
67
67
68
=item true_p
68
=item true_p
69
69
70
    if ( C4::Boolean::true_p(C4::Context->preference("IndependantBranches")) ) {
70
    if ( C4::Boolean::true_p(C4::Context->preference("IndependentBranches")) ) {
71
    ...
71
    ...
72
    }
72
    }
73
73
(-)a/C4/Branch.pm (-2 / +2 lines)
Lines 69-75 The functions in this module deal with branches. Link Here
69
69
70
  $branches = &GetBranches();
70
  $branches = &GetBranches();
71
71
72
Returns informations about ALL branches, IndependantBranches Insensitive.
72
Returns informations about ALL branches, IndependentBranches Insensitive.
73
GetBranchInfo() returns the same information without the problems of this function 
73
GetBranchInfo() returns the same information without the problems of this function 
74
(namespace collision, mainly).
74
(namespace collision, mainly).
75
75
Lines 143-149 sub GetBranches { Link Here
143
143
144
sub onlymine {
144
sub onlymine {
145
    return 
145
    return 
146
    C4::Context->preference('IndependantBranches') &&
146
    C4::Context->preference('IndependentBranches') &&
147
    C4::Context->userenv                           &&
147
    C4::Context->userenv                           &&
148
    C4::Context->userenv->{flags} %2 != 1          &&
148
    C4::Context->userenv->{flags} %2 != 1          &&
149
    C4::Context->userenv->{branch}                 ;
149
    C4::Context->userenv->{branch}                 ;
(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 887-893 sub CanBookBeIssued { Link Here
887
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
887
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
888
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
888
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
889
    }
889
    }
890
    if ( C4::Context->preference("IndependantBranches") ) {
890
    if ( C4::Context->preference("IndependentBranches") ) {
891
        my $userenv = C4::Context->userenv;
891
        my $userenv = C4::Context->userenv;
892
        if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) {
892
        if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) {
893
            $issuingimpossible{ITEMNOTSAMEBRANCH} = 1
893
            $issuingimpossible{ITEMNOTSAMEBRANCH} = 1
(-)a/C4/Items.pm (-3 / +3 lines)
Lines 1253-1259 sub GetItemsInfo { Link Here
1253
            $data->{firstname}     = $idata->{firstname};
1253
            $data->{firstname}     = $idata->{firstname};
1254
            $data->{lastreneweddate} = $idata->{lastreneweddate};
1254
            $data->{lastreneweddate} = $idata->{lastreneweddate};
1255
            $datedue                = $idata->{'date_due'};
1255
            $datedue                = $idata->{'date_due'};
1256
        if (C4::Context->preference("IndependantBranches")){
1256
        if (C4::Context->preference("IndependentBranches")){
1257
        my $userenv = C4::Context->userenv;
1257
        my $userenv = C4::Context->userenv;
1258
        if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) { 
1258
        if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) { 
1259
            $data->{'NOTSAMEBRANCH'} = 1 if ($idata->{'bcode'} ne $userenv->{branch});
1259
            $data->{'NOTSAMEBRANCH'} = 1 if ($idata->{'bcode'} ne $userenv->{branch});
Lines 2214-2220 sub DelItemCheck { Link Here
2214
        $error = "book_on_loan" 
2214
        $error = "book_on_loan" 
2215
    }
2215
    }
2216
    elsif ( !( C4::Context->userenv->{flags} & 1 )
2216
    elsif ( !( C4::Context->userenv->{flags} & 1 )
2217
        and C4::Context->preference("IndependantBranches")
2217
        and C4::Context->preference("IndependentBranches")
2218
        and ( C4::Context->userenv->{branch} ne $item->{'homebranch'} ) )
2218
        and ( C4::Context->userenv->{branch} ne $item->{'homebranch'} ) )
2219
    {
2219
    {
2220
        $error = "not_same_branch";
2220
        $error = "not_same_branch";
Lines 2689-2695 sub PrepareItemrecordDisplay { Link Here
2689
                    # builds list, depending on authorised value...
2689
                    # builds list, depending on authorised value...
2690
                    #---- branch
2690
                    #---- branch
2691
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2691
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2692
                        if (   ( C4::Context->preference("IndependantBranches") )
2692
                        if (   ( C4::Context->preference("IndependentBranches") )
2693
                            && ( C4::Context->userenv->{flags} % 2 != 1 ) ) {
2693
                            && ( C4::Context->userenv->{flags} % 2 != 1 ) ) {
2694
                            my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" );
2694
                            my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" );
2695
                            $sth->execute( C4::Context->userenv->{branch} );
2695
                            $sth->execute( C4::Context->userenv->{branch} );
(-)a/C4/Letters.pm (-1 / +1 lines)
Lines 123-129 sub getletter { Link Here
123
123
124
    $branchcode ||= '';
124
    $branchcode ||= '';
125
125
126
    if ( C4::Context->preference('IndependantBranches')
126
    if ( C4::Context->preference('IndependentBranches')
127
            and $branchcode
127
            and $branchcode
128
            and C4::Context->userenv ) {
128
            and C4::Context->userenv ) {
129
129
(-)a/C4/Members.pm (-4 / +4 lines)
Lines 256-262 sub Search { Link Here
256
    # $showallbranches was not used at the time SearchMember() was mainstreamed into Search().
256
    # $showallbranches was not used at the time SearchMember() was mainstreamed into Search().
257
    # Mentioning for the reference
257
    # Mentioning for the reference
258
258
259
    if ( C4::Context->preference("IndependantBranches") ) { # && !$showallbranches){
259
    if ( C4::Context->preference("IndependentBranches") ) { # && !$showallbranches){
260
        if ( my $userenv = C4::Context->userenv ) {
260
        if ( my $userenv = C4::Context->userenv ) {
261
            my $branch =  $userenv->{'branch'};
261
            my $branch =  $userenv->{'branch'};
262
            if ( ($userenv->{flags} % 2 !=1) && $branch ){
262
            if ( ($userenv->{flags} % 2 !=1) && $branch ){
Lines 2042-2048 sub GetBorrowersToExpunge { Link Here
2042
    my $filterexpiry   = $params->{'expired_before'};
2042
    my $filterexpiry   = $params->{'expired_before'};
2043
    my $filtercategory = $params->{'category_code'};
2043
    my $filtercategory = $params->{'category_code'};
2044
    my $filterbranch   = $params->{'branchcode'} ||
2044
    my $filterbranch   = $params->{'branchcode'} ||
2045
                        ((C4::Context->preference('IndependantBranches') 
2045
                        ((C4::Context->preference('IndependentBranches')
2046
                             && C4::Context->userenv 
2046
                             && C4::Context->userenv 
2047
                             && C4::Context->userenv->{flags} % 2 !=1 
2047
                             && C4::Context->userenv->{flags} % 2 !=1 
2048
                             && C4::Context->userenv->{branch})
2048
                             && C4::Context->userenv->{branch})
Lines 2108-2114 I<$result> is a ref to an array which all elements are a hasref. Link Here
2108
2108
2109
sub GetBorrowersWhoHaveNeverBorrowed {
2109
sub GetBorrowersWhoHaveNeverBorrowed {
2110
    my $filterbranch = shift || 
2110
    my $filterbranch = shift || 
2111
                        ((C4::Context->preference('IndependantBranches') 
2111
                        ((C4::Context->preference('IndependentBranches')
2112
                             && C4::Context->userenv 
2112
                             && C4::Context->userenv 
2113
                             && C4::Context->userenv->{flags} % 2 !=1 
2113
                             && C4::Context->userenv->{flags} % 2 !=1 
2114
                             && C4::Context->userenv->{branch})
2114
                             && C4::Context->userenv->{branch})
Lines 2158-2164 sub GetBorrowersWithIssuesHistoryOlderThan { Link Here
2158
    my $dbh  = C4::Context->dbh;
2158
    my $dbh  = C4::Context->dbh;
2159
    my $date = shift ||POSIX::strftime("%Y-%m-%d",localtime());
2159
    my $date = shift ||POSIX::strftime("%Y-%m-%d",localtime());
2160
    my $filterbranch = shift || 
2160
    my $filterbranch = shift || 
2161
                        ((C4::Context->preference('IndependantBranches') 
2161
                        ((C4::Context->preference('IndependentBranches')
2162
                             && C4::Context->userenv 
2162
                             && C4::Context->userenv 
2163
                             && C4::Context->userenv->{flags} % 2 !=1 
2163
                             && C4::Context->userenv->{flags} % 2 !=1 
2164
                             && C4::Context->userenv->{branch})
2164
                             && C4::Context->userenv->{branch})
(-)a/C4/Reserves.pm (-1 / +1 lines)
Lines 1419-1425 be the target of an item-level hold request. Link Here
1419
Note that IsAvailableForItemLevelRequest() does not
1419
Note that IsAvailableForItemLevelRequest() does not
1420
check if the staff operator is authorized to place
1420
check if the staff operator is authorized to place
1421
a request on the item - in particular,
1421
a request on the item - in particular,
1422
this routine does not check IndependantBranches
1422
this routine does not check IndependentBranches
1423
and canreservefromotherbranches.
1423
and canreservefromotherbranches.
1424
1424
1425
=cut
1425
=cut
(-)a/C4/Serials.pm (-7 / +7 lines)
Lines 216-222 sub GetSerialInformation { Link Here
216
    my $dbh        = C4::Context->dbh;
216
    my $dbh        = C4::Context->dbh;
217
    my $query      = qq|
217
    my $query      = qq|
218
        SELECT serial.*, serial.notes as sernotes, serial.status as serstatus,subscription.*,subscription.subscriptionid as subsid |;
218
        SELECT serial.*, serial.notes as sernotes, serial.status as serstatus,subscription.*,subscription.subscriptionid as subsid |;
219
    if (   C4::Context->preference('IndependantBranches')
219
    if (   C4::Context->preference('IndependentBranches')
220
        && C4::Context->userenv
220
        && C4::Context->userenv
221
        && C4::Context->userenv->{'flags'} != 1
221
        && C4::Context->userenv->{'flags'} != 1
222
        && C4::Context->userenv->{'branch'} ) {
222
        && C4::Context->userenv->{'branch'} ) {
Lines 321-327 sub GetSubscription { Link Here
321
                aqbooksellers.name AS aqbooksellername,
321
                aqbooksellers.name AS aqbooksellername,
322
                biblio.title AS bibliotitle,
322
                biblio.title AS bibliotitle,
323
                subscription.biblionumber as bibnum);
323
                subscription.biblionumber as bibnum);
324
    if (   C4::Context->preference('IndependantBranches')
324
    if (   C4::Context->preference('IndependentBranches')
325
        && C4::Context->userenv
325
        && C4::Context->userenv
326
        && C4::Context->userenv->{'flags'} != 1
326
        && C4::Context->userenv->{'flags'} != 1
327
        && C4::Context->userenv->{'branch'} ) {
327
        && C4::Context->userenv->{'branch'} ) {
Lines 336-342 sub GetSubscription { Link Here
336
       WHERE subscription.subscriptionid = ?
336
       WHERE subscription.subscriptionid = ?
337
    );
337
    );
338
338
339
    #     if (C4::Context->preference('IndependantBranches') &&
339
    #     if (C4::Context->preference('IndependentBranches') &&
340
    #         C4::Context->userenv &&
340
    #         C4::Context->userenv &&
341
    #         C4::Context->userenv->{'flags'} != 1){
341
    #         C4::Context->userenv->{'flags'} != 1){
342
    # #       $debug and warn "flags: ".C4::Context->userenv->{'flags'};
342
    # #       $debug and warn "flags: ".C4::Context->userenv->{'flags'};
Lines 370-376 sub GetFullSubscription { Link Here
370
            biblio.title as bibliotitle,
370
            biblio.title as bibliotitle,
371
            subscription.branchcode AS branchcode,
371
            subscription.branchcode AS branchcode,
372
            subscription.subscriptionid AS subscriptionid |;
372
            subscription.subscriptionid AS subscriptionid |;
373
    if (   C4::Context->preference('IndependantBranches')
373
    if (   C4::Context->preference('IndependentBranches')
374
        && C4::Context->userenv
374
        && C4::Context->userenv
375
        && C4::Context->userenv->{'flags'} != 1
375
        && C4::Context->userenv->{'flags'} != 1
376
        && C4::Context->userenv->{'branch'} ) {
376
        && C4::Context->userenv->{'branch'} ) {
Lines 490-496 sub GetSubscriptionsFromBiblionumber { Link Here
490
        $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
490
        $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
491
        $subs->{ "status" . $subs->{'status'} }             = 1;
491
        $subs->{ "status" . $subs->{'status'} }             = 1;
492
        $subs->{'cannotedit'} =
492
        $subs->{'cannotedit'} =
493
          (      C4::Context->preference('IndependantBranches')
493
          (      C4::Context->preference('IndependentBranches')
494
              && C4::Context->userenv
494
              && C4::Context->userenv
495
              && C4::Context->userenv->{flags} % 2 != 1
495
              && C4::Context->userenv->{flags} % 2 != 1
496
              && C4::Context->userenv->{branch}
496
              && C4::Context->userenv->{branch}
Lines 530-536 sub GetFullSubscriptionsFromBiblionumber { Link Here
530
            biblio.title as bibliotitle,
530
            biblio.title as bibliotitle,
531
            subscription.branchcode AS branchcode,
531
            subscription.branchcode AS branchcode,
532
            subscription.subscriptionid AS subscriptionid|;
532
            subscription.subscriptionid AS subscriptionid|;
533
    if (   C4::Context->preference('IndependantBranches')
533
    if (   C4::Context->preference('IndependentBranches')
534
        && C4::Context->userenv
534
        && C4::Context->userenv
535
        && C4::Context->userenv->{'flags'} != 1
535
        && C4::Context->userenv->{'flags'} != 1
536
        && C4::Context->userenv->{'branch'} ) {
536
        && C4::Context->userenv->{'branch'} ) {
Lines 630-636 sub GetSubscriptions { Link Here
630
630
631
    while ( my $line = $sth->fetchrow_hashref ) {
631
    while ( my $line = $sth->fetchrow_hashref ) {
632
        $line->{'cannotedit'} =
632
        $line->{'cannotedit'} =
633
          (      C4::Context->preference('IndependantBranches')
633
          (      C4::Context->preference('IndependentBranches')
634
              && C4::Context->userenv
634
              && C4::Context->userenv
635
              && C4::Context->userenv->{flags} % 2 != 1
635
              && C4::Context->userenv->{flags} % 2 != 1
636
              && C4::Context->userenv->{branch}
636
              && C4::Context->userenv->{branch}
(-)a/C4/Suggestions.pm (-3 / +3 lines)
Lines 132-138 sub SearchSuggestion { Link Here
132
    }
132
    }
133
133
134
    # filter on user branch
134
    # filter on user branch
135
    if ( C4::Context->preference('IndependantBranches') ) {
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 ( ( $userenv->{flags} % 2 ) != 1 && !$suggestion->{branchcode} )
Lines 339-345 sub GetSuggestionByStatus { Link Here
339
    };
339
    };
340
340
341
    # filter on branch
341
    # filter on branch
342
    if ( C4::Context->preference("IndependantBranches") || $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 ( $userenv->{flags} % 2 == 1 ) {
Lines 389-395 sub CountSuggestion { Link Here
389
    my $dbh = C4::Context->dbh;
389
    my $dbh = C4::Context->dbh;
390
    my $sth;
390
    my $sth;
391
    my $userenv = C4::Context->userenv;
391
    my $userenv = C4::Context->userenv;
392
    if ( C4::Context->preference("IndependantBranches")
392
    if ( C4::Context->preference("IndependentBranches")
393
        && $userenv->{flags} % 2 != 1 )
393
        && $userenv->{flags} % 2 != 1 )
394
    {
394
    {
395
        my $query = q{
395
        my $query = q{
(-)a/acqui/basket.pl (-2 / +2 lines)
Lines 103-109 if ( $op eq 'delete_confirm' ) { Link Here
103
    $template->param( NO_BOOKSELLER => 1 );
103
    $template->param( NO_BOOKSELLER => 1 );
104
} elsif ( $op eq 'del_basket') {
104
} elsif ( $op eq 'del_basket') {
105
    $template->param( delete_confirm => 1 );
105
    $template->param( delete_confirm => 1 );
106
    if ( C4::Context->preference("IndependantBranches") ) {
106
    if ( C4::Context->preference("IndependentBranches") ) {
107
        my $userenv = C4::Context->userenv;
107
        my $userenv = C4::Context->userenv;
108
        unless ( $userenv->{flags} == 1 ) {
108
        unless ( $userenv->{flags} == 1 ) {
109
            my $validtest = ( $basket->{creationdate} eq '' )
109
            my $validtest = ( $basket->{creationdate} eq '' )
Lines 192-198 if ( $op eq 'delete_confirm' ) { Link Here
192
    print $query->redirect('/cgi-bin/koha/acqui/basket.pl?basketno='.$basket->{'basketno'})
192
    print $query->redirect('/cgi-bin/koha/acqui/basket.pl?basketno='.$basket->{'basketno'})
193
} else {
193
} else {
194
    # get librarian branch...
194
    # get librarian branch...
195
    if ( C4::Context->preference("IndependantBranches") ) {
195
    if ( C4::Context->preference("IndependentBranches") ) {
196
        my $userenv = C4::Context->userenv;
196
        my $userenv = C4::Context->userenv;
197
        unless ( $userenv->{flags} == 1 ) {
197
        unless ( $userenv->{flags} == 1 ) {
198
            my $validtest = ( $basket->{creationdate} eq '' )
198
            my $validtest = ( $basket->{creationdate} eq '' )
(-)a/acqui/neworderempty.pl (-1 / +1 lines)
Lines 229-235 for my $curr ( @rates ) { Link Here
229
}
229
}
230
230
231
# build branches list
231
# build branches list
232
my $onlymine=C4::Context->preference('IndependantBranches') && 
232
my $onlymine=C4::Context->preference('IndependentBranches') &&
233
            C4::Context->userenv && 
233
            C4::Context->userenv && 
234
            C4::Context->userenv->{flags}!=1 && 
234
            C4::Context->userenv->{flags}!=1 && 
235
            C4::Context->userenv->{branch};
235
            C4::Context->userenv->{branch};
(-)a/catalogue/moredetail.pl (-1 / +1 lines)
Lines 172-178 foreach my $item (@items){ Link Here
172
        $item->{status_advisory} = 1;
172
        $item->{status_advisory} = 1;
173
    }
173
    }
174
174
175
    if (C4::Context->preference("IndependantBranches")) {
175
    if (C4::Context->preference("IndependentBranches")) {
176
        #verifying rights
176
        #verifying rights
177
        my $userenv = C4::Context->userenv();
177
        my $userenv = C4::Context->userenv();
178
        unless (($userenv->{'flags'} == 1) or ($userenv->{'branch'} eq $item->{'homebranch'})) {
178
        unless (($userenv->{'flags'} == 1) or ($userenv->{'branch'} eq $item->{'homebranch'})) {
(-)a/cataloguing/addbiblio.pl (-1 / +1 lines)
Lines 172-178 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('IndependantBranches') && 
175
        my $onlymine=C4::Context->preference('IndependentBranches') &&
176
                C4::Context->userenv && 
176
                C4::Context->userenv && 
177
                C4::Context->userenv->{flags} % 2 == 0 && 
177
                C4::Context->userenv->{flags} % 2 == 0 && 
178
                C4::Context->userenv->{branch};
178
                C4::Context->userenv->{branch};
(-)a/cataloguing/additem.pl (-2 / +2 lines)
Lines 689-695 foreach my $field (@fields) { Link Here
689
						|| $subfieldvalue;
689
						|| $subfieldvalue;
690
        }
690
        }
691
691
692
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependantBranches")) {
692
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
693
            #verifying rights
693
            #verifying rights
694
            my $userenv = C4::Context->userenv();
694
            my $userenv = C4::Context->userenv();
695
            unless (($userenv->{'flags'} == 1) or (($userenv->{'branch'} eq $subfieldvalue))){
695
            unless (($userenv->{'flags'} == 1) or (($userenv->{'branch'} eq $subfieldvalue))){
Lines 750-756 my $i=0; Link Here
750
750
751
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
751
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
752
752
753
my $onlymine = C4::Context->preference('IndependantBranches') && 
753
my $onlymine = C4::Context->preference('IndependentBranches') &&
754
               C4::Context->userenv                           && 
754
               C4::Context->userenv                           && 
755
               C4::Context->userenv->{flags}!=1               && 
755
               C4::Context->userenv->{flags}!=1               && 
756
               C4::Context->userenv->{branch};
756
               C4::Context->userenv->{branch};
(-)a/circ/circulation-home.pl (-1 / +1 lines)
Lines 38-44 my $fa = getframeworkinfo('FA'); Link Here
38
$template->param( fast_cataloging => 1 ) if (defined $fa);
38
$template->param( fast_cataloging => 1 ) if (defined $fa);
39
39
40
# Checking if the transfer page needs to be displayed
40
# Checking if the transfer page needs to be displayed
41
$template->param( display_transfer => 1 ) if ( ($flags->{'superlibrarian'} == 1) || (C4::Context->preference("IndependantBranches") == 0) );
41
$template->param( display_transfer => 1 ) if ( ($flags->{'superlibrarian'} == 1) || (C4::Context->preference("IndependentBranches") == 0) );
42
42
43
43
44
output_html_with_http_headers $query, $cookie, $template->output;
44
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/circ/overdue.pl (-1 / +1 lines)
Lines 91-97 while (my ($itemtype, $description) =$req->fetchrow) { Link Here
91
        itemtypename => $description,
91
        itemtypename => $description,
92
    };
92
    };
93
}
93
}
94
my $onlymine=C4::Context->preference('IndependantBranches') && 
94
my $onlymine=C4::Context->preference('IndependentBranches') &&
95
             C4::Context->userenv &&
95
             C4::Context->userenv &&
96
             C4::Context->userenv->{flags} % 2 !=1 &&
96
             C4::Context->userenv->{flags} % 2 !=1 &&
97
             C4::Context->userenv->{branch};
97
             C4::Context->userenv->{branch};
(-)a/circ/pendingreserves.pl (-1 / +1 lines)
Lines 151-157 if ( $run_report ) { Link Here
151
    #    multiple patrons have a hold on an item
151
    #    multiple patrons have a hold on an item
152
152
153
153
154
    if (C4::Context->preference('IndependantBranches')){
154
    if (C4::Context->preference('IndependentBranches')){
155
        $strsth .= " AND items.holdingbranch=? ";
155
        $strsth .= " AND items.holdingbranch=? ";
156
        push @query_params, C4::Context->userenv->{'branch'};
156
        push @query_params, C4::Context->userenv->{'branch'};
157
    }
157
    }
(-)a/circ/reserveratios.pl (-1 / +1 lines)
Lines 113-119 my $strsth = Link Here
113
 $sqldatewhere
113
 $sqldatewhere
114
";
114
";
115
115
116
if (C4::Context->preference('IndependantBranches')){
116
if (C4::Context->preference('IndependentBranches')){
117
    $strsth .= " AND items.holdingbranch=? ";
117
    $strsth .= " AND items.holdingbranch=? ";
118
    push @query_params, C4::Context->userenv->{'branch'};
118
    push @query_params, C4::Context->userenv->{'branch'};
119
}
119
}
(-)a/circ/waitingreserves.pl (-1 / +1 lines)
Lines 73-79 if ($item) { Link Here
73
    push @cancel_result, $res if $res;
73
    push @cancel_result, $res if $res;
74
}
74
}
75
75
76
if ( C4::Context->preference('IndependantBranches') ) {
76
if ( C4::Context->preference('IndependentBranches') ) {
77
    undef $all_branches;
77
    undef $all_branches;
78
} else {
78
} else {
79
    $template->param( all_branches_link => $input->url . '?allbranches=1' )
79
    $template->param( all_branches_link => $input->url . '?allbranches=1' )
(-)a/installer/data/mysql/sysprefs.sql (-1 / +1 lines)
Lines 31-37 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES Link Here
31
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('hidelostitems',0,'If ON, disables display of\"lost\" items in OPAC.','','YesNo');
31
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('hidelostitems',0,'If ON, disables display of\"lost\" items in OPAC.','','YesNo');
32
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('hide_marc',0,'If ON, disables display of MARC fields, subfield codes & indicators (still shows data)',NULL,'YesNo');
32
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('hide_marc',0,'If ON, disables display of MARC fields, subfield codes & indicators (still shows data)',NULL,'YesNo');
33
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WaitingNotifyAtCheckin',0,'If ON, notify librarians of waiting holds for the patron whose items they are checking in.',NULL,'YesNo');
33
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WaitingNotifyAtCheckin',0,'If ON, notify librarians of waiting holds for the patron whose items they are checking in.',NULL,'YesNo');
34
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IndependantBranches',0,'If ON, increases security between libraries',NULL,'YesNo');
34
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IndependentBranches',0,'If ON, increases security between libraries',NULL,'YesNo');
35
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetBiblioDefaultView','normal','Choose the default detail view in the staff interface; choose between normal, labeled_marc, marc or isbd','normal|marc|isbd|labeled_marc','Choice');
35
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetBiblioDefaultView','normal','Choose the default detail view in the staff interface; choose between normal, labeled_marc, marc or isbd','normal|marc|isbd|labeled_marc','Choice');
36
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('intranetcolorstylesheet','','Define the color stylesheet to use in the Staff Client','50','free');
36
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('intranetcolorstylesheet','','Define the color stylesheet to use in the Staff Client','50','free');
37
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetmainUserblock','','Add a block of HTML that will display on the intranet home page','70|10','Textarea');
37
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetmainUserblock','','Add a block of HTML that will display on the intranet home page','70|10','Textarea');
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 6834-6839 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
6834
    SetVersion($DBversion);
6834
    SetVersion($DBversion);
6835
}
6835
}
6836
6836
6837
$DBversion = "3.11.00.XXX";
6838
if ( CheckVersion($DBversion) ) {
6839
   $dbh->do("UPDATE systempreferences SET variable = 'IndependentBranches' WHERE variable = 'IndependantBranches'");
6840
   print "Upgrade to $DBversion done (Bug 10080 - Change system pref IndependantBranches to IndependentBranches)\n";
6841
   SetVersion ($DBversion);
6842
}
6843
6837
=head1 FUNCTIONS
6844
=head1 FUNCTIONS
6838
6845
6839
=head2 TableExists($table)
6846
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (-1 / +1 lines)
Lines 61-67 Link Here
61
              <b class="caret"></b>
61
              <b class="caret"></b>
62
          </a>
62
          </a>
63
          <ul class="dropdown-menu" role="menu" aria-labelledby="drop3">
63
          <ul class="dropdown-menu" role="menu" aria-labelledby="drop3">
64
           [% IF ( IndependantBranches ) %]
64
           [% IF ( IndependentBranches ) %]
65
              [% IF ( CAN_user_management || CAN_user_editcatalogue_edit_catalogue ) %]
65
              [% IF ( CAN_user_management || CAN_user_editcatalogue_edit_catalogue ) %]
66
                  <li>
66
                  <li>
67
                     <a class="toplinks" href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a>
67
                     <a class="toplinks" href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (-1 / +1 lines)
Lines 64-70 Administration: Link Here
64
                  tmp: as temporary files.
64
                  tmp: as temporary files.
65
                  memcached: in a memcached server.
65
                  memcached: in a memcached server.
66
        -
66
        -
67
            - pref: IndependantBranches
67
            - pref: IndependentBranches
68
              default: 0
68
              default: 0
69
              choices:
69
              choices:
70
                  yes: Prevent
70
                  yes: Prevent
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt (-1 / +1 lines)
Lines 49-55 Link Here
49
</p>
49
</p>
50
50
51
[% IF ( AutoLocation ) %][% ELSE %]
51
[% IF ( AutoLocation ) %][% ELSE %]
52
[% IF ( IndependantBranches ) %][% ELSE %]
52
[% IF ( IndependentBranches ) %][% ELSE %]
53
<p><label for="branch">Library:</label>
53
<p><label for="branch">Library:</label>
54
    <select name="branch" id="branch" class="input" tabindex="3">
54
    <select name="branch" id="branch" class="input" tabindex="3">
55
    <option value="">My library</option>
55
    <option value="">My library</option>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt (-1 / +1 lines)
Lines 22-28 Link Here
22
    [% IF ( display_transfer ) %]
22
    [% IF ( display_transfer ) %]
23
		<li><a href="/cgi-bin/koha/circ/branchtransfers.pl">Transfer</a></li>
23
		<li><a href="/cgi-bin/koha/circ/branchtransfers.pl">Transfer</a></li>
24
    [% END %]
24
    [% END %]
25
	[% IF ( AutoLocation ) %][% ELSE %][% IF ( IndependantBranches ) %][% ELSE %]<li><a href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a></li>[% END %][% END %]
25
    [% IF ( AutoLocation ) %][% ELSE %][% IF ( IndependentBranches ) %][% ELSE %]<li><a href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a></li>[% END %][% END %]
26
	[% IF ( fast_cataloging ) %]
26
	[% IF ( fast_cataloging ) %]
27
	    [% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
27
	    [% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
28
		<li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=FA">Fast cataloging</a></li>
28
		<li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=FA">Fast cataloging</a></li>
(-)a/mainpage.pl (-1 / +1 lines)
Lines 51-57 $template->param( Link Here
51
);
51
);
52
52
53
my $branch =
53
my $branch =
54
  C4::Context->preference("IndependantBranches")
54
  C4::Context->preference("IndependentBranches")
55
  && !$flags->{'superlibrarian'}
55
  && !$flags->{'superlibrarian'}
56
  ? C4::Context->userenv()->{'branch'}
56
  ? C4::Context->userenv()->{'branch'}
57
  : undef;
57
  : undef;
(-)a/members/deletemem.pl (-1 / +1 lines)
Lines 66-72 if ($bor->{category_type} eq "S") { Link Here
66
    }
66
    }
67
}
67
}
68
68
69
if (C4::Context->preference("IndependantBranches")) {
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 (($userenv->{flags} % 2 != 1) && $bor->{'branchcode'}){
72
        unless ($userenv->{branch} eq $bor->{'branchcode'}){
72
        unless ($userenv->{branch} eq $bor->{'branchcode'}){
(-)a/members/memberentry.pl (-2 / +2 lines)
Lines 292-298 if ($op eq 'save' || $op eq 'insert'){ Link Here
292
        $newdata{'surname'} = uc($newdata{'surname'});
292
        $newdata{'surname'} = uc($newdata{'surname'});
293
    }
293
    }
294
294
295
  if (C4::Context->preference("IndependantBranches")) {
295
  if (C4::Context->preference("IndependentBranches")) {
296
    if ($userenv && $userenv->{flags} % 2 != 1){
296
    if ($userenv && $userenv->{flags} % 2 != 1){
297
      $debug and print STDERR "  $newdata{'branchcode'} : ".$userenv->{flags}.":".$userenv->{branch};
297
      $debug and print STDERR "  $newdata{'branchcode'} : ".$userenv->{flags}.":".$userenv->{branch};
298
      unless (!$newdata{'branchcode'} || $userenv->{branch} eq $newdata{'branchcode'}){
298
      unless (!$newdata{'branchcode'} || $userenv->{branch} eq $newdata{'branchcode'}){
Lines 422-428 if ($nok or !$nodouble){ Link Here
422
        $template->param( step_1 => 1,step_2 => 1,step_3 => 1, step_4 => 1, step_5 => 1, step_6 => 1);
422
        $template->param( step_1 => 1,step_2 => 1,step_3 => 1, step_4 => 1, step_5 => 1, step_6 => 1);
423
    }  
423
    }  
424
} 
424
} 
425
if (C4::Context->preference("IndependantBranches")) {
425
if (C4::Context->preference("IndependentBranches")) {
426
    my $userenv = C4::Context->userenv;
426
    my $userenv = C4::Context->userenv;
427
    if ($userenv->{flags} % 2 != 1 && $data{'branchcode'}){
427
    if ($userenv->{flags} % 2 != 1 && $data{'branchcode'}){
428
        unless ($userenv->{branch} eq $data{'branchcode'}){
428
        unless ($userenv->{branch} eq $data{'branchcode'}){
(-)a/members/members-update.pl (-1 / +1 lines)
Lines 42-48 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( Link Here
42
);
42
);
43
43
44
my $branch =
44
my $branch =
45
  C4::Context->preference("IndependantBranches")
45
  C4::Context->preference("IndependentBranches")
46
  && !$flags->{'superlibrarian'}
46
  && !$flags->{'superlibrarian'}
47
  ? C4::Context->userenv()->{'branch'}
47
  ? C4::Context->userenv()->{'branch'}
48
  : undef;
48
  : undef;
(-)a/members/moremember.pl (-2 / +2 lines)
Lines 212-218 $bor{'borrowernumber'} = $borrowernumber; Link Here
212
212
213
# Converts the branchcode to the branch name
213
# Converts the branchcode to the branch name
214
my $samebranch;
214
my $samebranch;
215
if ( C4::Context->preference("IndependantBranches") ) {
215
if ( C4::Context->preference("IndependentBranches") ) {
216
    my $userenv = C4::Context->userenv;
216
    my $userenv = C4::Context->userenv;
217
    unless ( $userenv->{flags} % 2 == 1 ) {
217
    unless ( $userenv->{flags} % 2 == 1 ) {
218
        $samebranch = ( $data->{'branchcode'} eq $userenv->{branch} );
218
        $samebranch = ( $data->{'branchcode'} eq $userenv->{branch} );
Lines 338-344 my $candeleteuser; Link Here
338
my $userenv = C4::Context->userenv;
338
my $userenv = C4::Context->userenv;
339
if($userenv->{flags} % 2 == 1){
339
if($userenv->{flags} % 2 == 1){
340
    $candeleteuser = 1;
340
    $candeleteuser = 1;
341
}elsif ( C4::Context->preference("IndependantBranches") ) {
341
}elsif ( C4::Context->preference("IndependentBranches") ) {
342
    $candeleteuser = ( $data->{'branchcode'} eq $userenv->{branch} );
342
    $candeleteuser = ( $data->{'branchcode'} eq $userenv->{branch} );
343
}else{
343
}else{
344
    if( C4::Auth::getuserflags( $userenv->{flags},$userenv->{number})->{borrowers} ) {
344
    if( C4::Auth::getuserflags( $userenv->{flags},$userenv->{number})->{borrowers} ) {
(-)a/reserve/request.pl (-1 / +1 lines)
Lines 426-432 foreach my $biblionumber (@biblionumbers) { Link Here
426
426
427
            # if independent branches is on we need to check if the person can reserve
427
            # if independent branches is on we need to check if the person can reserve
428
            # for branches they arent logged in to
428
            # for branches they arent logged in to
429
            if ( C4::Context->preference("IndependantBranches") ) {
429
            if ( C4::Context->preference("IndependentBranches") ) {
430
                if (! C4::Context->preference("canreservefromotherbranches")){
430
                if (! C4::Context->preference("canreservefromotherbranches")){
431
                    # cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
431
                    # cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
432
                    my $userenv = C4::Context->userenv;
432
                    my $userenv = C4::Context->userenv;
(-)a/serials/member-search.pl (-1 / +1 lines)
Lines 82-88 if (defined $member) { Link Here
82
82
83
my ($count,$results);
83
my ($count,$results);
84
84
85
if (C4::Context->preference("IndependantBranches")){
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 && C4::Context->userenv->{flags} % 2 !=1 && C4::Context->userenv->{'branch'}){
87
        $$patron{branchcode}=C4::Context->userenv->{'branch'};
87
        $$patron{branchcode}=C4::Context->userenv->{'branch'};
88
   }
88
   }
(-)a/serials/subscription-add.pl (-1 / +1 lines)
Lines 120-126 if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { Link Here
120
    }
120
    }
121
}
121
}
122
122
123
my $onlymine=C4::Context->preference('IndependantBranches') &&
123
my $onlymine=C4::Context->preference('IndependentBranches') &&
124
             C4::Context->userenv &&
124
             C4::Context->userenv &&
125
             C4::Context->userenv->{flags} % 2 !=1 &&
125
             C4::Context->userenv->{flags} % 2 !=1 &&
126
             C4::Context->userenv->{branch};
126
             C4::Context->userenv->{branch};
(-)a/serials/subscription-detail.pl (-1 / +1 lines)
Lines 162-168 $template->param( Link Here
162
    routing => C4::Context->preference("RoutingSerials"),
162
    routing => C4::Context->preference("RoutingSerials"),
163
    totalissues => $totalissues,
163
    totalissues => $totalissues,
164
    hemisphere => $hemisphere,
164
    hemisphere => $hemisphere,
165
    cannotedit =>(C4::Context->preference('IndependantBranches') &&
165
    cannotedit =>(C4::Context->preference('IndependentBranches') &&
166
                C4::Context->userenv &&
166
                C4::Context->userenv &&
167
                C4::Context->userenv->{flags} % 2 !=1  &&
167
                C4::Context->userenv->{flags} % 2 !=1  &&
168
                C4::Context->userenv->{branch} && $subs->{branchcode} &&
168
                C4::Context->userenv->{branch} && $subs->{branchcode} &&
(-)a/suggestion/suggestion.pl (-1 / +1 lines)
Lines 276-282 if(defined($returnsuggested) and $returnsuggested ne "noone") Link Here
276
276
277
#branch display management
277
#branch display management
278
my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : '';
278
my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : '';
279
my $onlymine=C4::Context->preference('IndependantBranches') && 
279
my $onlymine=C4::Context->preference('IndependentBranches') &&
280
            C4::Context->userenv && 
280
            C4::Context->userenv && 
281
            C4::Context->userenv->{flags}!=1 && 
281
            C4::Context->userenv->{flags}!=1 && 
282
            C4::Context->userenv->{branch};
282
            C4::Context->userenv->{branch};
(-)a/t/db_dependent/Members.t (-1 / +1 lines)
Lines 29-35 my $PHONE = "555-12123"; Link Here
29
# XXX should be randomised and checked against the database
29
# XXX should be randomised and checked against the database
30
my $IMPOSSIBLE_CARDNUMBER = "XYZZZ999";
30
my $IMPOSSIBLE_CARDNUMBER = "XYZZZ999";
31
31
32
my $INDEPENDENT_BRANCHES_PREF = 'IndependantBranches';
32
my $INDEPENDENT_BRANCHES_PREF = 'IndependentBranches';
33
33
34
# XXX make a non-commit transaction and rollback rather than insert/delete
34
# XXX make a non-commit transaction and rollback rather than insert/delete
35
35
(-)a/t/db_dependent/lib/KohaTest/Acquisition.pm (-2 / +2 lines)
Lines 119-125 sub enable_independant_branches { Link Here
119
                         );
119
                         );
120
120
121
    # set a preference. There's surely a method for this, but I can't find it.
121
    # set a preference. There's surely a method for this, but I can't find it.
122
    my $retval = C4::Context->dbh->do( q(update systempreferences set value = '1' where variable = 'IndependantBranches') );
122
    my $retval = C4::Context->dbh->do( q(update systempreferences set value = '1' where variable = 'IndependentBranches') );
123
    ok( $retval, 'set the preference' );
123
    ok( $retval, 'set the preference' );
124
    
124
    
125
    ok( C4::Context->userenv, 'usernev' );
125
    ok( C4::Context->userenv, 'usernev' );
Lines 133-139 sub enable_independant_branches { Link Here
133
sub disable_independant_branches {
133
sub disable_independant_branches {
134
    my $self = shift;
134
    my $self = shift;
135
135
136
    my $retval = C4::Context->dbh->do( q(update systempreferences set value = '0' where variable = 'IndependantBranches') );
136
    my $retval = C4::Context->dbh->do( q(update systempreferences set value = '0' where variable = 'IndependentBranches') );
137
    ok( $retval, 'set the preference back' );
137
    ok( $retval, 'set the preference back' );
138
138
139
    
139
    
(-)a/t/db_dependent/lib/KohaTest/Acquisition/GetHistory.pm (-1 / +1 lines)
Lines 180-186 sub one_order : Test( 55 ) { Link Here
180
        is( $total_qtyreceived,  0, 'total_qtyreceived searched by from_date' );
180
        is( $total_qtyreceived,  0, 'total_qtyreceived searched by from_date' );
181
    }
181
    }
182
182
183
    # set up some things necessary to make GetHistory use the IndependantBranches
183
    # set up some things necessary to make GetHistory use the IndependentBranches
184
    $self->enable_independant_branches();    
184
    $self->enable_independant_branches();    
185
185
186
    # just search by title here, we need to search by something.
186
    # just search by title here, we need to search by something.
(-)a/t/db_dependent/lib/KohaTest/Acquisition/GetLateOrders.pm (-1 / +1 lines)
Lines 80-86 sub one_order : Test( 29 ) { Link Here
80
          or diag( Data::Dumper->Dump( [ \@orders ], [ 'orders' ] ) );
80
          or diag( Data::Dumper->Dump( [ \@orders ], [ 'orders' ] ) );
81
    }
81
    }
82
82
83
    # set up some things necessary to make GetLateOrders use the IndependantBranches
83
    # set up some things necessary to make GetLateOrders use the IndependentBranches
84
    $self->enable_independant_branches();    
84
    $self->enable_independant_branches();    
85
85
86
    {
86
    {
(-)a/tools/batchMod.pl (-2 / +2 lines)
Lines 318-324 foreach my $tag (sort keys %{$tagslib}) { Link Here
318
	    $value =~ s/DD/$day/g;
318
	    $value =~ s/DD/$day/g;
319
	}
319
	}
320
	$subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} > 4) || ($tagslib->{$tag}->{$subfield}->{hidden} < -4));
320
	$subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} > 4) || ($tagslib->{$tag}->{$subfield}->{hidden} < -4));
321
	# testing branch value if IndependantBranches.
321
    # testing branch value if IndependentBranches.
322
322
323
	my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="255" );
323
	my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="255" );
324
	my $attributes          = qq($attributes_no_value value="$value" );
324
	my $attributes          = qq($attributes_no_value value="$value" );
Lines 492-498 sub BuildItemsData{ Link Here
492
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
492
			foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
493
				# loop through each subfield
493
				# loop through each subfield
494
				my $itembranchcode=$field->subfield($branchtagsubfield);
494
				my $itembranchcode=$field->subfield($branchtagsubfield);
495
				if ($itembranchcode && C4::Context->preference("IndependantBranches")) {
495
                if ($itembranchcode && C4::Context->preference("IndependentBranches")) {
496
						#verifying rights
496
						#verifying rights
497
						my $userenv = C4::Context->userenv();
497
						my $userenv = C4::Context->userenv();
498
						unless (($userenv->{'flags'} == 1) or (($userenv->{'branch'} eq $itembranchcode))){
498
						unless (($userenv->{'flags'} == 1) or (($userenv->{'branch'} eq $itembranchcode))){
(-)a/tools/export.pl (-2 / +2 lines)
Lines 118-130 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( Link Here
118
);
118
);
119
119
120
my $limit_ind_branch =
120
my $limit_ind_branch =
121
  (      C4::Context->preference('IndependantBranches')
121
  (      C4::Context->preference('IndependentBranches')
122
      && C4::Context->userenv
122
      && C4::Context->userenv
123
      && !( C4::Context->userenv->{flags} & 1 )
123
      && !( C4::Context->userenv->{flags} & 1 )
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("IndependantBranches")
127
if (   C4::Context->preference("IndependentBranches")
128
    && C4::Context->userenv
128
    && C4::Context->userenv
129
    && !( C4::Context->userenv->{flags} & 1 ) )
129
    && !( C4::Context->userenv->{flags} & 1 ) )
130
{
130
{
(-)a/tools/holidays.pl (-1 / +1 lines)
Lines 57-63 $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('IndependantBranches') &&
60
my $onlymine=(C4::Context->preference('IndependentBranches') &&
61
              C4::Context->userenv &&
61
              C4::Context->userenv &&
62
              C4::Context->userenv->{flags} % 2 !=1  &&
62
              C4::Context->userenv->{flags} % 2 !=1  &&
63
              C4::Context->userenv->{branch}?1:0);
63
              C4::Context->userenv->{branch}?1:0);
(-)a/tools/letter.pl (-2 / +1 lines)
Lines 106-112 our ( $template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user Link Here
106
    }
106
    }
107
);
107
);
108
108
109
our $my_branch = C4::Context->preference("IndependantBranches") && !$staffflags->{'superlibrarian'}
109
our $my_branch = C4::Context->preference("IndependentBranches") && !$staffflags->{'superlibrarian'}
110
  ?  C4::Context->userenv()->{'branch'}
110
  ?  C4::Context->userenv()->{'branch'}
111
  : undef;
111
  : undef;
112
# we show only the TMPL_VAR names $op
112
# we show only the TMPL_VAR names $op
113
- 

Return to bug 10080