Bug 11826: (follow-up) enable printing warnings
[koha.git] / Koha / Template / Plugin / Branches.pm
index 343158c..ff43a38 100644 (file)
@@ -24,6 +24,7 @@ use base qw( Template::Plugin );
 use Encode qw{encode decode};
 
 use C4::Koha;
+use C4::Context;
 
 sub GetName {
     my ( $self, $branchcode ) = @_;
@@ -35,4 +36,22 @@ sub GetName {
     return $b ? encode( 'UTF-8', $b->{'branchname'} ) : q{};
 }
 
+sub GetLoggedInBranchcode {
+    my ($self) = @_;
+
+    return C4::Context->userenv ?
+        C4::Context->userenv->{'branch'} :
+        '';
+}
+
+sub GetURL {
+    my ( $self, $branchcode ) = @_;
+
+    my $query = "SELECT branchurl FROM branches WHERE branchcode = ?";
+    my $sth   = C4::Context->dbh->prepare($query);
+    $sth->execute($branchcode);
+    my $b = $sth->fetchrow_hashref();
+    return encode( 'UTF-8', $b->{'branchurl'} );
+}
+
 1;