From: Joe Atzberger Date: Thu, 30 Oct 2008 05:07:40 +0000 (-0500) Subject: Add GetBranchLoop since so many pages use exactly the same code. X-Git-Tag: v3.00.02-stable~272 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=39188f8cd968dbbad7a366b868e29bcb76518a8c;p=koha.git Add GetBranchLoop since so many pages use exactly the same code. Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- diff --git a/C4/Branch.pm b/C4/Branch.pm index c09b129576..cd81368ad9 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