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 170-176 System Pref options. Link Here
170
#
170
#
171
sub barcodedecode {
171
sub barcodedecode {
172
    my ($barcode, $filter) = @_;
172
    my ($barcode, $filter) = @_;
173
    my $branch = C4::Branch::mybranch();
173
    my $branch = C4::Context::mybranch();
174
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
174
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
175
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
175
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
176
	if ($filter eq 'whitespace') {
176
	if ($filter eq 'whitespace') {
Lines 3290-3296 sub GetIssuingCharges { Link Here
3290
    if ( my $item_data = $sth->fetchrow_hashref ) {
3290
    if ( my $item_data = $sth->fetchrow_hashref ) {
3291
        $item_type = $item_data->{itemtype};
3291
        $item_type = $item_data->{itemtype};
3292
        $charge    = $item_data->{rentalcharge};
3292
        $charge    = $item_data->{rentalcharge};
3293
        my $branch = C4::Branch::mybranch();
3293
        my $branch = C4::Context::mybranch();
3294
        my $discount_query = q|SELECT rentaldiscount,
3294
        my $discount_query = q|SELECT rentaldiscount,
3295
            issuingrules.itemtype, issuingrules.branchcode
3295
            issuingrules.itemtype, issuingrules.branchcode
3296
            FROM borrowers
3296
            FROM borrowers
(-)a/admin/branch_transfer_limits.pl (-2 / +2 lines)
Lines 41-49 my ($template, $loggedinuser, $cookie) Link Here
41
41
42
my $dbh = C4::Context->dbh;
42
my $dbh = C4::Context->dbh;
43
my $branchcode;
43
my $branchcode;
44
if((!defined($input->param('branchcode'))) & mybranch() ne '')
44
if((!defined($input->param('branchcode'))) & C4::Context::mybranch() ne '')
45
{
45
{
46
	$branchcode = mybranch();
46
    $branchcode = C4::Context::mybranch();
47
}
47
}
48
else
48
else
49
{
49
{
(-)a/admin/smart-rules.pl (-2 / +2 lines)
Lines 55-64 my $type=$input->param('type'); Link Here
55
my $branch = $input->param('branch');
55
my $branch = $input->param('branch');
56
unless ( $branch ) {
56
unless ( $branch ) {
57
    if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) {
57
    if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) {
58
        $branch = Koha::Libraries->search->count() == 1 ? undef : C4::Branch::mybranch();
58
        $branch = Koha::Libraries->search->count() == 1 ? undef : C4::Context::mybranch();
59
    }
59
    }
60
    else {
60
    else {
61
        $branch = C4::Branch::onlymine() ? ( C4::Branch::mybranch() || '*' ) : '*';
61
        $branch = C4::Branch::onlymine() ? ( C4::Context::mybranch() || '*' ) : '*';
62
    }
62
    }
63
}
63
}
64
$branch = '*' if $branch eq 'NO_LIBRARY_SET';
64
$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