[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Tue, 23 Apr 2002 21:00:01 -0000
matthew Tue Apr 23 17:00:01 2002 EDT
Modified files:
/loncom/interface loncommon.pm
Log:
Added &get_domains and &select_dom_form.
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.33 loncom/interface/loncommon.pm:1.34
--- loncom/interface/loncommon.pm:1.33 Mon Apr 22 14:04:19 2002
+++ loncom/interface/loncommon.pm Tue Apr 23 17:00:01 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.33 2002/04/22 18:04:19 matthew Exp $
+# $Id: loncommon.pm,v 1.34 2002/04/23 21:00:01 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -149,6 +149,29 @@
###############################################################
## Home server <option> list generating code ##
###############################################################
+sub get_domains {
+ # The code below was stolen from "The Perl Cookbook", p 102, 1st ed.
+ my @domains;
+ my %seen;
+ foreach (sort values(%Apache::lonnet::hostdom)) {
+ push (@domains,$_) unless $seen{$_}++;
+ }
+ return @domains;
+}
+
+sub select_dom_form {
+ my ($defdom,$name) = @_;
+ my @domains = get_domains();
+ my $selectdomain = "<select name=\"$name\" size=\"1\">\n";
+ foreach (@domains) {
+ $selectdomain.="<option value=\"$_\" ".
+ ($_ eq $defdom ? 'selected' : '').
+ ">$_</option>\n";
+ }
+ $selectdomain.="</select>";
+ return $selectdomain;
+}
+
sub get_home_servers {
my $domain = shift;
my %home_servers;