[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /lonnet/perl lonnet.pm

raeburn raeburn at source.lon-capa.org
Sat Apr 5 08:49:32 EDT 2014


raeburn		Sat Apr  5 12:49:32 2014 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - For 2.11
    - Backport 1.1253, 1.1254
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1172.2.40 loncom/lonnet/perl/lonnet.pm:1.1172.2.41
--- loncom/lonnet/perl/lonnet.pm:1.1172.2.40	Mon Feb 24 03:09:05 2014
+++ loncom/lonnet/perl/lonnet.pm	Sat Apr  5 12:49:31 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1172.2.40 2014/02/24 03:09:05 raeburn Exp $
+# $Id: lonnet.pm,v 1.1172.2.41 2014/04/05 12:49:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -885,7 +885,17 @@
 }
 
 sub compare_server_load {
-    my ($try_server, $spare_server, $lowest_load) = @_;
+    my ($try_server, $spare_server, $lowest_load, $required) = @_;
+
+    if ($required) {
+        my ($reqdmajor,$reqdminor) = ($required =~ /^(\d+)\.(\d+)$/);
+        my $remoterev = &get_server_loncaparev(undef,$try_server);
+        my ($major,$minor) = ($remoterev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/);
+        if (($major eq '' && $minor eq '') ||
+            (($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) {
+            return ($spare_server,$lowest_load);
+        }
+    }
 
     my $loadans     = &reply('load',    $try_server);
     my $userloadans = &reply('userload',$try_server);
@@ -946,7 +956,7 @@
 # --------- determine least loaded server in a user's domain which allows login
 
 sub choose_server {
-    my ($udom,$checkloginvia) = @_;
+    my ($udom,$checkloginvia,$required)) = @_;
     my %domconfhash = &Apache::loncommon::get_domainconf($udom);
     my %servers = &get_servers($udom);
     my $lowest_load = 30000;
@@ -958,14 +968,14 @@
             if ($loginvia) {
                 my ($server,$path) = split(/:/,$loginvia);
                 ($login_host, $lowest_load) =
-                    &compare_server_load($server, $login_host, $lowest_load);
+                    &compare_server_load($server, $login_host, $lowest_load, $required);
                 if ($login_host eq $server) {
                     $portal_path = $path;
                     $isredirect = 1;
                 }
             } else {
                 ($login_host, $lowest_load) =
-                    &compare_server_load($lonhost, $login_host, $lowest_load);
+                    &compare_server_load($lonhost, $login_host, $lowest_load, $required);
                 if ($login_host eq $lonhost) {
                     $portal_path = '';
                     $isredirect = ''; 
@@ -973,7 +983,7 @@
             }
         } else {
             ($login_host, $lowest_load) =
-                &compare_server_load($lonhost, $login_host, $lowest_load);
+                &compare_server_load($lonhost, $login_host, $lowest_load, $required);
         }
     }
     if ($login_host ne '') {
@@ -1998,6 +2008,7 @@
                                   'requestcourses','inststatus',
                                   'coursedefaults','usersessions',
                                   'requestauthor'],$domain);
+    my @coursetypes = ('official','unofficial','community','textbook');
     if (ref($domconfig{'defaults'}) eq 'HASH') {
         $domdefaults{'lang_def'} = $domconfig{'defaults'}{'lang_def'}; 
         $domdefaults{'auth_def'} = $domconfig{'defaults'}{'auth_def'};
@@ -2040,16 +2051,15 @@
         }
     }
     if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
-        if (ref($domconfig{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
-            $domdefaults{'officialcredits'} = $domconfig{'coursedefaults'}{'coursecredits'}{'official'};
-            $domdefaults{'unofficialcredits'} = $domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'};
-            $domdefaults{'textbookcredits'} = $domconfig{'coursedefaults'}{'coursecredits'}{'textbook'};
-        }
-        if (ref($domconfig{'coursedefaults'}{'uploadquota'}) eq 'HASH') {
-            $domdefaults{'officialquota'} = $domconfig{'coursedefaults'}{'uploadquota'}{'official'};
-            $domdefaults{'unofficialquota'} = $domconfig{'coursedefaults'}{'uploadquota'}{'unofficial'};
-            $domdefaults{'communityquota'} = $domconfig{'coursedefaults'}{'uploadquota'}{'community'};
-            $domdefaults{'textbookquota'} = $domconfig{'coursedefaults'}{'uploadquota'}{'textbook'};
+        foreach my $type (@coursetypes) {
+            if (ref($domconfig{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
+                unless ($type eq 'community') {
+                    $domdefaults{$type.'credits'} = $domconfig{'coursedefaults'}{'coursecredits'}{$type};
+                }
+            }
+            if (ref($domconfig{'coursedefaults'}{'uploadquota'}) eq 'HASH') {
+                $domdefaults{$type.'quota'} = $domconfig{'coursedefaults'}{'uploadquota'}{$type};
+            }
         }
     }
     if (ref($domconfig{'usersessions'}) eq 'HASH') {
@@ -2060,6 +2070,34 @@
             $domdefaults{'hostedsessions'} = $domconfig{'usersessions'}{'hosted'};
         }
     }
+    if (ref($domconfig{'selfenrollment'}) eq 'HASH') {
+        if (ref($domconfig{'selfenrollment'}{'admin'}) eq 'HASH') {
+            my @settings = ('types','registered','enroll_dates','access_dates','section',
+                            'approval','limit');
+            foreach my $type (@coursetypes) {
+                if (ref($domconfig{'selfenrollment'}{'admin'}{$type}) eq 'HASH') {
+                    my @mgrdc = ();
+                    foreach my $item (@settings) {
+                        if ($domconfig{'selfenrollment'}{'admin'}{$type}{$item} eq '0') {
+                            push(@mgrdc,$item);
+                        }
+                    }
+                    if (@mgrdc) {
+                        $domdefaults{$type.'selfenrolladmdc'} = join(',', at mgrdc);
+                    }
+                }
+            }
+        }
+        if (ref($domconfig{'selfenrollment'}{'default'}) eq 'HASH') {
+            foreach my $type (@coursetypes) {
+                if (ref($domconfig{'selfenrollment'}{'default'}{$type}) eq 'HASH') {
+                    foreach my $item (keys(%{$domconfig{'selfenrollment'}{'default'}{$type}})) {
+                        $domdefaults{$type.'selfenroll'.$item} = $domconfig{'selfenrollment'}{'default'}{$type}{$item};
+                    }
+                }
+            }
+        }
+    }
     &do_cache_new('domdefaults',$domain,\%domdefaults,$cachetime);
     return %domdefaults;
 }




More information about the LON-CAPA-cvs mailing list