[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /interface loncommon.pm

raeburn raeburn@source.lon-capa.org
Tue, 19 Jan 2010 16:20:39 -0000


raeburn		Tue Jan 19 16:20:39 2010 EDT

  Modified files:              (Branch: version_2_9_X)
    /loncom/interface	loncommon.pm 
  Log:
  - Backport 1.910.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.692.4.22 loncom/interface/loncommon.pm:1.692.4.23
--- loncom/interface/loncommon.pm:1.692.4.22	Tue Jan 19 16:10:11 2010
+++ loncom/interface/loncommon.pm	Tue Jan 19 16:20:38 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.692.4.22 2010/01/19 16:10:11 raeburn Exp $
+# $Id: loncommon.pm,v 1.692.4.23 2010/01/19 16:20:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1943,7 +1943,7 @@
 
 =pod
 
-=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange)
+=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms)
 
 Returns a string containing a <select name='$name' size='1'> form to 
 allow a user to select the domain to preform an operation in.  
@@ -1956,15 +1956,22 @@
 
 The optional $onchange argument specifies what should occur if the domain selector is changed, e.g., 'this.form.submit()' if the form is to be automatically submitted.
 
+The optional $incdoms is a reference to an array of domains which will be the only available options.
+
 =cut
 
 #-------------------------------------------
 sub select_dom_form {
-    my ($defdom,$name,$includeempty,$showdomdesc,$onchange) = @_;
+    my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms) = @_;
     if ($onchange) {
         $onchange = ' onchange="'.$onchange.'"';
     }
-    my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());
+    my @domains;
+    if (ref($incdoms) eq 'ARRAY') {
+        @domains = sort {lc($a) cmp lc($b)} (@{$incdoms});
+    } else {
+        @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());
+    }
     if ($includeempty) { @domains=('',@domains); }
     my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange>\n";
     foreach my $dom (@domains) {