[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface domainprefs.pm

raeburn raeburn at source.lon-capa.org
Sat Sep 15 11:15:34 EDT 2018


raeburn		Sat Sep 15 15:15:34 2018 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	domainprefs.pm 
  Log:
  - For 2.11
    Backport 1.302 (with same modification as 1.160.6.84.2.8).
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.88 loncom/interface/domainprefs.pm:1.160.6.89
--- loncom/interface/domainprefs.pm:1.160.6.88	Fri Sep 14 22:43:14 2018
+++ loncom/interface/domainprefs.pm	Sat Sep 15 15:15:32 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.160.6.88 2018/09/14 22:43:14 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.89 2018/09/15 15:15:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4631,9 +4631,14 @@
            '_LC_ipchange'    => &mt('Non-SSO users with IP mismatch'),
                      );
     my @alltypes = ('_LC_adv','_LC_author','_LC_internetdom','_LC_external','_LC_ipchangesso','_LC_ipchange');
+    my @available;
     if (ref($types) eq 'ARRAY') {
-        unshift(@alltypes,@{$types},'default');
+        @available = @{$types};
     }
+    unless (grep(/^default$/, at available)) {
+        push(@available,'default');
+    }
+    unshift(@alltypes, at available);
     my %titles;
     foreach my $type (@alltypes) {
         if ($type =~ /^_LC_/) {
@@ -5009,6 +5014,7 @@
     my %radiohash;
     my $numinrow = 4;
     map { $radiohash{'cancreate_'.$_} = 1; } @selfcreate;
+    my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
     if ($position eq 'top') {
         my %choices = &Apache::lonlocal::texthash (
                                                       cancreate_login      => 'Institutional Login',
@@ -5023,14 +5029,12 @@
         ($datatable,$itemcount) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked,
                                                      \%choices,$itemcount,$onclick);
         $$rowtotal += $itemcount;
-        
-        my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
 
         if (ref($usertypes) eq 'HASH') {
             if (keys(%{$usertypes}) > 0) {
                 $datatable .= &insttypes_row($createsettings,$types,$usertypes,
                                              $dom,$numinrow,$othertitle,
-                                             'statustocreate',$$rowtotal);
+                                             'statustocreate',$rowtotal);
                 $$rowtotal ++;
             }
         }
@@ -5075,16 +5079,22 @@
         $$rowtotal ++;
     } elsif ($position eq 'middle') {
         my %domconf = &Apache::lonnet::get_dom('configuration',['usermodification'],$dom);
-        my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
-        $usertypes->{'default'} = $othertitle;
+        my @posstypes;
         if (ref($types) eq 'ARRAY') {
-            push(@{$types},'default');
-            $usertypes->{'default'} = $othertitle;
-            foreach my $status (@{$types}) {
-                $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'},
-                                                       $numinrow,$$rowtotal,$usertypes);
-                $$rowtotal ++;
-            }
+            @posstypes = @{$types};
+        }
+        unless (grep(/^default$/, at posstypes)) {
+            push(@posstypes,'default');
+        }
+        my %usertypeshash;
+        if (ref($usertypes) eq 'HASH') {
+            %usertypeshash = %{$usertypes};
+        }
+        $usertypeshash{'default'} = $othertitle;
+        foreach my $status (@posstypes) {
+            $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'},
+                                                   $numinrow,$$rowtotal,\%usertypeshash);
+            $$rowtotal ++;
         }
     } else {
         my %choices = &Apache::lonlocal::texthash (
@@ -5102,29 +5112,30 @@
         my $onclick = "toggleDisplay(this.form,'emailoptions');";
         my $additional = '<div id="emailoptions" style="display: '.$display.'">';
         my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
-        my $usertypes = {};
-        my $order = [];
-        if ((ref($domdefaults{'inststatustypes'}) eq 'HASH') && (ref($domdefaults{'inststatusguest'}) eq 'ARRAY')) {
-            $usertypes = $domdefaults{'inststatustypes'};
-            $order = $domdefaults{'inststatusguest'};
-        }
-        if (ref($order) eq 'ARRAY') {
-            push(@{$order},'default');
-            if (@{$order} > 1) {
-                $usertypes->{'default'} = &mt('Other users');
-                $additional .= '<table><tr>';
-                foreach my $status (@{$order}) {
-                    $additional .= '<th>'.$usertypes->{$status}.'</th>';
-                }
-                $additional .= '</tr><tr>';
-                foreach my $status (@{$order}) {
-                    $additional .= '<td>'.&email_as_username($rowtotal,$processing,$status).'</td>';
-                }
-                $additional .= '</tr></table>';
-            } else {
-                $usertypes->{'default'} = &mt('All users');
-                $additional .= &email_as_username($rowtotal,$processing);
+        my (@ordered,%usertypeshash);
+        if (ref($domdefaults{'inststatusguest'}) eq 'ARRAY') {
+            @ordered = @{$domdefaults{'inststatusguest'}};
+        }
+        if (@ordered) {
+            unless (grep(/^default$/, at ordered)) {
+                push(@ordered,'default');
+            }
+            if (ref($usertypes) eq 'HASH') {
+                %usertypeshash = %{$usertypes};
+            }
+            $usertypeshash{'default'} = $othertitle;
+            $additional .= '<table><tr>';
+            foreach my $status (@ordered) {
+                $additional .= '<th>'.$usertypeshash{$status}.'</th>';
             }
+            $additional .= '</tr><tr>';
+            foreach my $status (@ordered) {
+                $additional .= '<td>'.&email_as_username($rowtotal,$processing,$status).'</td>';
+            }
+            $additional .= '</tr></table>';
+        } else {
+            $usertypeshash{'default'} = $othertitle;
+            $additional .= &email_as_username($rowtotal,$processing);
         }
         $additional .= '</div>'."\n";
 
@@ -5135,12 +5146,10 @@
         $$rowtotal ++;
         my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
         $numinrow = 1;
-        if (ref($order) eq 'ARRAY') {
-            foreach my $status (@{$order}) {
-                $datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings,
-                                                       $numinrow,$$rowtotal,$usertypes,$infofields,$infotitles);
-                $$rowtotal ++;
-            }
+        foreach my $status (@ordered) {
+            $datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings,
+                                                   $numinrow,$$rowtotal,\%usertypeshash,$infofields,$infotitles);
+            $$rowtotal ++;
         }
         my ($emailrules,$emailruleorder) =
             &Apache::lonnet::inst_userrules($dom,'email');




More information about the LON-CAPA-cvs mailing list