[Koha-patches] [PATCH] Add GetBranchLoop since so many pages use exactly the same code.
Galen Charlton
galen.charlton at liblime.com
Fri Mar 6 20:01:31 CET 2009
From: Joe Atzberger <joe.atzberger at liblime.com>
Signed-off-by: Galen Charlton <galen.charlton at liblime.com>
---
C4/Branch.pm | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/C4/Branch.pm b/C4/Branch.pm
index c09b129..cd81368 100644
--- a/C4/Branch.pm
+++ b/C4/Branch.pm
@@ -32,6 +32,7 @@ BEGIN {
&GetBranchName
&GetBranch
&GetBranches
+ &GetBranchesLoop
&GetBranchDetail
&get_branchinfos_of
&ModBranch
@@ -132,6 +133,21 @@ sub GetBranches {
return ( \%branches );
}
+sub GetBranchesLoop ($$) { # since this is what most pages want anyway
+ my $branch = shift or return undef;
+ my $onlymine = shift || 0;
+ my $branches = GetBranches($onlymine);
+ my @loop;
+ foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
+ push @loop, {
+ value => $_,
+ selected => ($_ eq $branch) ? 1 : 0,
+ branchname => $branches->{$_}->{branchname},
+ };
+ }
+ return \@loop;
+}
+
=head2 GetBranchName
=cut
--
1.5.6.5
More information about the Koha-patches
mailing list