Lines 25-50
use base qw( Template::Plugin );
Link Here
|
25 |
|
25 |
|
26 |
use C4::Koha; |
26 |
use C4::Koha; |
27 |
use C4::Context; |
27 |
use C4::Context; |
|
|
28 |
use Koha::Cache::Memory::Lite; |
28 |
use Koha::Libraries; |
29 |
use Koha::Libraries; |
29 |
|
30 |
|
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 |
|
40 |
sub GetName { |
31 |
sub GetName { |
41 |
my ( $self, $branchcode ) = @_; |
32 |
my ( $self, $branchcode ) = @_; |
42 |
|
33 |
|
43 |
unless (exists $self->{libraries}->{$branchcode} ){ |
34 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance; |
44 |
my $l = Koha::Libraries->find($branchcode); |
35 |
my $cache_key = "Library_branchname:" . $branchcode; |
45 |
$self->{libraries}->{$branchcode} = $l if $l; |
36 |
my $cached = $memory_cache->get_from_cache($cache_key); |
46 |
} |
37 |
return $cached if $cached; |
47 |
return $self->{libraries}->{$branchcode} ? $self->{libraries}->{$branchcode}->branchname : q{}; |
38 |
|
|
|
39 |
my $l = Koha::Libraries->find($branchcode); |
40 |
|
41 |
my $branchname = $l ? $l->branchname : q{}; |
42 |
$memory_cache->set_in_cache( $cache_key, $branchname ); |
43 |
return $branchname; |
48 |
} |
44 |
} |
49 |
|
45 |
|
50 |
sub GetLoggedInBranchcode { |
46 |
sub GetLoggedInBranchcode { |
51 |
- |
|
|