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

(-)a/C4/Branch.pm (-8 / +1 lines)
Lines 31-39 BEGIN { Link Here
31
	@EXPORT = qw(
31
	@EXPORT = qw(
32
		&GetBranch
32
		&GetBranch
33
		&GetBranches
33
		&GetBranches
34
		&mybranch
35
	);
34
	);
36
    @EXPORT_OK = qw( &onlymine &mybranch );
35
    @EXPORT_OK = qw( &onlymine );
37
}
36
}
38
37
39
=head1 NAME
38
=head1 NAME
Lines 128-139 sub onlymine { Link Here
128
      && C4::Context->userenv->{branch};
127
      && C4::Context->userenv->{branch};
129
}
128
}
130
129
131
# always returns a string for OK comparison via "eq" or "ne"
132
sub mybranch {
133
    C4::Context->userenv           or return '';
134
    return C4::Context->userenv->{branch} || '';
135
}
136
137
=head2 GetBranch
130
=head2 GetBranch
138
131
139
$branch = GetBranch( $query, $branches );
132
$branch = GetBranch( $query, $branches );
(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 167-173 System Pref options. Link Here
167
#
167
#
168
sub barcodedecode {
168
sub barcodedecode {
169
    my ($barcode, $filter) = @_;
169
    my ($barcode, $filter) = @_;
170
    my $branch = C4::Branch::mybranch();
170
    my $branch = C4::Context::mybranch();
171
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
171
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
172
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
172
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
173
	if ($filter eq 'whitespace') {
173
	if ($filter eq 'whitespace') {
Lines 3120-3126 sub GetIssuingCharges { Link Here
3120
    if ( my $item_data = $sth->fetchrow_hashref ) {
3120
    if ( my $item_data = $sth->fetchrow_hashref ) {
3121
        $item_type = $item_data->{itemtype};
3121
        $item_type = $item_data->{itemtype};
3122
        $charge    = $item_data->{rentalcharge};
3122
        $charge    = $item_data->{rentalcharge};
3123
        my $branch = C4::Branch::mybranch();
3123
        my $branch = C4::Context::mybranch();
3124
        my $discount_query = q|SELECT rentaldiscount,
3124
        my $discount_query = q|SELECT rentaldiscount,
3125
            issuingrules.itemtype, issuingrules.branchcode
3125
            issuingrules.itemtype, issuingrules.branchcode
3126
            FROM borrowers
3126
            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