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

(-)a/Koha/Template/Plugin/Branches.pm (-8 / +20 lines)
Lines 27-37 use C4::Koha; Link Here
27
use C4::Context;
27
use C4::Context;
28
use Koha::Libraries;
28
use Koha::Libraries;
29
29
30
sub new {
31
    my ($self) = shift;
32
    my (@params) = @_;
33
    $self = $self->SUPER::new(@params);
34
    #Initialize a cache of libraries for lookups of names,urls etc.
35
    $self->{libraries} = {};
36
37
    return $self;
38
}
39
30
sub GetName {
40
sub GetName {
31
    my ( $self, $branchcode ) = @_;
41
    my ( $self, $branchcode ) = @_;
32
42
33
    my $l = Koha::Libraries->find($branchcode);
43
    unless (exists $self->{libraries}->{$branchcode} ){
34
    return $l ? $l->branchname : q{};
44
        my $l = Koha::Libraries->find($branchcode);
45
        $self->{libraries}->{$branchcode} = $l if $l;
46
    }
47
    return $self->{libraries}->{$branchcode} ? $self->{libraries}->{$branchcode}->branchname : q{};
35
}
48
}
36
49
37
sub GetLoggedInBranchcode {
50
sub GetLoggedInBranchcode {
Lines 49-59 sub GetLoggedInBranchname { Link Here
49
sub GetURL {
62
sub GetURL {
50
    my ( $self, $branchcode ) = @_;
63
    my ( $self, $branchcode ) = @_;
51
64
52
    my $query = "SELECT branchurl FROM branches WHERE branchcode = ?";
65
    unless (exists $self->{libraries}->{$branchcode} ){
53
    my $sth   = C4::Context->dbh->prepare($query);
66
        my $l = Koha::Libraries->find($branchcode);
54
    $sth->execute($branchcode);
67
        $self->{libraries}->{$branchcode} = $l if $l;
55
    my $b = $sth->fetchrow_hashref();
68
    }
56
    return $b->{branchurl};
69
    return $self->{libraries}->{$branchcode} ? $self->{libraries}->{$branchcode}->branchurl : q{};
57
}
70
}
58
71
59
sub all {
72
sub all {
60
- 

Return to bug 26587