Add GetBranchLoop since so many pages use exactly the same code.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com> Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
This commit is contained in:
parent
17b3535be4
commit
39188f8cd9
16
C4/Branch.pm
16
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue