[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm loncommon.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 29 Feb 2008 19:07:11 -0000


raeburn		Fri Feb 29 14:07:11 2008 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm loncommon.pm 
  Log:
  - Move &sorted_inst_types() to loncommon.pm for broader use.
  - Change "othertitle" to be used when in course context. 
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.43 loncom/interface/domainprefs.pm:1.44
--- loncom/interface/domainprefs.pm:1.43	Sun Feb 24 18:18:40 2008
+++ loncom/interface/domainprefs.pm	Fri Feb 29 14:07:06 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.43 2008/02/24 23:18:40 raeburn Exp $
+# $Id: domainprefs.pm,v 1.44 2008/02/29 19:07:06 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1110,7 +1110,7 @@
 sub print_quotas {
     my ($dom,$settings,$rowtotal) = @_;
     my $datatable;
-    my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
+    my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
     my $typecount = 0;
     my $css_class;
     if (ref($types) eq 'ARRAY') {
@@ -1240,7 +1240,7 @@
                   '</tr>';
         $$rowtotal += 2;
     } else {
-        my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
+        my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
         my @fields = ('lastname','firstname','middlename','gen',
                       'permanentemail','id');
         my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
@@ -1300,7 +1300,7 @@
         }
     }
     my ($searchtitles,$titleorder) = &sorted_searchtitles();
-    my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
+    my ($othertitle,$usertypes,$types) = &Apache::Loncommon::sorted_inst_types($dom);
 
     my $numinrow = 4;
     my $cansrchrow = 0;
@@ -1906,25 +1906,6 @@
     return $output;
 }
 
-sub sorted_inst_types {
-    my ($dom) = @_;
-    my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
-    my $othertitle = &mt('All users');
-    my @types;
-    if (ref($order) eq 'ARRAY') {
-        @types = @{$order};
-    }
-    if (@types == 0) {
-        if (ref($usertypes) eq 'HASH') {
-            @types = sort(keys(%{$usertypes}));
-        }
-    }
-    if (keys(%{$usertypes}) > 0) {
-        $othertitle = &mt('Other users');
-    }
-    return ($othertitle,$usertypes,\@types);
-}
-
 sub sorted_searchtitles {
     my %searchtitles = &Apache::lonlocal::texthash(
                          'uname' => 'username',
@@ -2661,7 +2642,7 @@
 sub modify_quotas {
     my ($dom,%domconfig) = @_;
     my ($resulttext,%changes);
-    my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
+    my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
     my %formhash;
     foreach my $key (keys(%env)) {
         if ($key =~ /^form\.quota_(.+)$/) {
@@ -2796,7 +2777,7 @@
                    run => 'Auto-update:',
                    classlists => 'Updates to user information in classlists?'
                 );
-    my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
+    my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
     my %fieldtitles = &Apache::lonlocal::texthash (
                         id => 'Student/Employee ID',
                         permanentemail => 'E-mail address',
@@ -2925,7 +2906,7 @@
     my @cansearch = &Apache::loncommon::get_env_multiple('form.cansearch');
     my @searchby = &Apache::loncommon::get_env_multiple('form.searchby');
 
-    my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
+    my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
     if (keys(%{$usertypes}) == 0) {
         @cansearch = ('default');
     } else {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.641 loncom/interface/loncommon.pm:1.642
--- loncom/interface/loncommon.pm:1.641	Sun Feb 24 17:59:13 2008
+++ loncom/interface/loncommon.pm	Fri Feb 29 14:07:07 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.641 2008/02/24 22:59:13 raeburn Exp $
+# $Id: loncommon.pm,v 1.642 2008/02/29 19:07:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6653,6 +6653,31 @@
     return %fieldtitles;
 }
 
+sub sorted_inst_types {
+    my ($dom) = @_;
+    my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
+    my $othertitle = &mt('All users');
+    if ($env{'request.course.id'}) {
+        $othertitle  = 'any';
+    }
+    my @types;
+    if (ref($order) eq 'ARRAY') {
+        @types = @{$order};
+    }
+    if (@types == 0) {
+        if (ref($usertypes) eq 'HASH') {
+            @types = sort(keys(%{$usertypes}));
+        }
+    }
+    if (keys(%{$usertypes}) > 0) {
+        $othertitle = &mt('Other users');
+        if ($env{'request.course.id'}) {
+            $othertitle = 'other';
+        }
+    }
+    return ($othertitle,$usertypes,\@types);
+}
+
 =pod
 
 =back