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

(-)a/C4/Branch.pm (-8 / +1 lines)
Lines 29-37 BEGIN { Link Here
29
	@EXPORT = qw(
29
	@EXPORT = qw(
30
		&GetBranch
30
		&GetBranch
31
		&GetBranches
31
		&GetBranches
32
		&mybranch
33
	);
32
	);
34
    @EXPORT_OK = qw( &onlymine &mybranch );
33
    @EXPORT_OK = qw( &onlymine );
35
}
34
}
36
35
37
=head1 NAME
36
=head1 NAME
Lines 126-137 sub onlymine { Link Here
126
      && C4::Context->userenv->{branch};
125
      && C4::Context->userenv->{branch};
127
}
126
}
128
127
129
# always returns a string for OK comparison via "eq" or "ne"
130
sub mybranch {
131
    C4::Context->userenv           or return '';
132
    return C4::Context->userenv->{branch} || '';
133
}
134
135
=head2 GetBranch
128
=head2 GetBranch
136
129
137
$branch = GetBranch( $query, $branches );
130
$branch = GetBranch( $query, $branches );
(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 168-174 System Pref options. Link Here
168
#
168
#
169
sub barcodedecode {
169
sub barcodedecode {
170
    my ($barcode, $filter) = @_;
170
    my ($barcode, $filter) = @_;
171
    my $branch = C4::Branch::mybranch();
171
    my $branch = C4::Context::mybranch();
172
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
172
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
173
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
173
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
174
	if ($filter eq 'whitespace') {
174
	if ($filter eq 'whitespace') {
Lines 3236-3242 sub GetIssuingCharges { Link Here
3236
    if ( my $item_data = $sth->fetchrow_hashref ) {
3236
    if ( my $item_data = $sth->fetchrow_hashref ) {
3237
        $item_type = $item_data->{itemtype};
3237
        $item_type = $item_data->{itemtype};
3238
        $charge    = $item_data->{rentalcharge};
3238
        $charge    = $item_data->{rentalcharge};
3239
        my $branch = C4::Branch::mybranch();
3239
        my $branch = C4::Context::mybranch();
3240
        my $discount_query = q|SELECT rentaldiscount,
3240
        my $discount_query = q|SELECT rentaldiscount,
3241
            issuingrules.itemtype, issuingrules.branchcode
3241
            issuingrules.itemtype, issuingrules.branchcode
3242
            FROM borrowers
3242
            FROM borrowers
(-)a/admin/smart-rules.pl (-2 / +2 lines)
Lines 52-61 my $type=$input->param('type'); Link Here
52
my $branch = $input->param('branch');
52
my $branch = $input->param('branch');
53
unless ( $branch ) {
53
unless ( $branch ) {
54
    if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) {
54
    if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) {
55
        $branch = Koha::Libraries->search->count() == 1 ? undef : C4::Branch::mybranch();
55
        $branch = Koha::Libraries->search->count() == 1 ? undef : C4::Context::mybranch();
56
    }
56
    }
57
    else {
57
    else {
58
        $branch = C4::Branch::onlymine() ? ( C4::Branch::mybranch() || '*' ) : '*';
58
        $branch = C4::Branch::onlymine() ? ( C4::Context::mybranch() || '*' ) : '*';
59
    }
59
    }
60
}
60
}
61
$branch = '*' if $branch eq 'NO_LIBRARY_SET';
61
$branch = '*' if $branch eq 'NO_LIBRARY_SET';
(-)a/t/db_dependent/Branch.t (-4 lines)
Lines 38-44 can_ok( Link Here
38
    'C4::Branch', qw(
38
    'C4::Branch', qw(
39
      GetBranch
39
      GetBranch
40
      GetBranches
40
      GetBranches
41
      mybranch
42
      )
41
      )
43
);
42
);
44
43
Lines 194-200 is_deeply( $b2info->get_categories->count, 1, 'BRB has the category CAT1' ); Link Here
194
Koha::LibraryCategory->new($cat2)->store;
193
Koha::LibraryCategory->new($cat2)->store;
195
is( Koha::LibraryCategories->search->count, $count_cat + 3, "Two categories added" );
194
is( Koha::LibraryCategories->search->count, $count_cat + 3, "Two categories added" );
196
195
197
#TODO later: test mybranchine and onlymine
198
# Actually we cannot mock C4::Context->userenv in unit tests
199
200
$schema->storage->txn_rollback;
196
$schema->storage->txn_rollback;
(-)a/tools/letter.pl (-1 / +1 lines)
Lines 358-364 sub default_display { Link Here
358
358
359
    unless ( defined $branchcode ) {
359
    unless ( defined $branchcode ) {
360
        if ( C4::Context->preference('DefaultToLoggedInLibraryNoticesSlips') ) {
360
        if ( C4::Context->preference('DefaultToLoggedInLibraryNoticesSlips') ) {
361
            $branchcode = C4::Branch::mybranch();
361
            $branchcode = C4::Context::mybranch();
362
        }
362
        }
363
    }
363
    }
364
364
(-)a/tools/overduerules.pl (-2 / +1 lines)
Lines 74-80 my $type = $input->param('type'); Link Here
74
my $branch = $input->param('branch');
74
my $branch = $input->param('branch');
75
$branch =
75
$branch =
76
    defined $branch                                                    ? $branch
76
    defined $branch                                                    ? $branch
77
  : C4::Context->preference('DefaultToLoggedInLibraryOverdueTriggers') ? C4::Branch::mybranch()
77
  : C4::Context->preference('DefaultToLoggedInLibraryOverdueTriggers') ? C4::Context::mybranch()
78
  : Koha::Libraries->search->count() == 1                              ? undef
78
  : Koha::Libraries->search->count() == 1                              ? undef
79
  :                                                                      undef;
79
  :                                                                      undef;
80
$branch ||= q{};
80
$branch ||= q{};
81
- 

Return to bug 15758