[LON-CAPA-cvs] cvs: loncom /auth lonlogout.pm /interface loncommon.pm /lonnet/perl lonnet.pm

raeburn raeburn@source.lon-capa.org
Mon, 13 Jun 2011 17:41:04 -0000


raeburn		Mon Jun 13 17:41:04 2011 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
    /loncom/auth	lonlogout.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - "Log-in again" link on logout page:
    - link pointed to is determined in the following order
      (a) portal page for user's domain, if defined.
      (b) the domain's portal server, if log-in pages for user's domain's
          servers are set to redirect (e.g., to a lonBalancer server).
      (c) least busy server in user's domain.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1012 loncom/interface/loncommon.pm:1.1013
--- loncom/interface/loncommon.pm:1.1012	Tue Jun  7 19:17:56 2011
+++ loncom/interface/loncommon.pm	Mon Jun 13 17:40:58 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1012 2011/06/07 19:17:56 www Exp $
+# $Id: loncommon.pm,v 1.1013 2011/06/13 17:40:58 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4306,8 +4306,7 @@
                     if (ref($domconfig{'login'}{$key}) eq 'HASH') {
                         if ($key eq 'loginvia') {
                             if (ref($domconfig{'login'}{'loginvia'}) eq 'HASH') {
-                                my @ids = &Apache::lonnet::current_machine_ids();
-                                foreach my $hostname (@ids) {
+                                foreach my $hostname (keys(%{$domconfig{'login'}{'loginvia'}})) {
                                     if (ref($domconfig{'login'}{'loginvia'}{$hostname}) eq 'HASH') {
                                         if ($domconfig{'login'}{'loginvia'}{$hostname}{'server'}) {
                                             my $server = $domconfig{'login'}{'loginvia'}{$hostname}{'server'};
@@ -4316,7 +4315,7 @@
 
                                                 $designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'custompath'};
                                             } else {
-                                                 $designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'};
+                                                $designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'};
                                             }
                                             if ($domconfig{'login'}{'loginvia'}{$hostname}{'exempt'}) {
                                                 $designhash{$udom.'.login.loginvia_exempt_'.$hostname} = $domconfig{'login'}{'loginvia'}{$hostname}{'exempt'};
Index: loncom/auth/lonlogout.pm
diff -u loncom/auth/lonlogout.pm:1.41 loncom/auth/lonlogout.pm:1.42
--- loncom/auth/lonlogout.pm:1.41	Mon Mar 22 20:11:08 2010
+++ loncom/auth/lonlogout.pm	Mon Jun 13 17:41:01 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Logout Handler
 #
-# $Id: lonlogout.pm,v 1.41 2010/03/22 20:11:08 droeschl Exp $
+# $Id: lonlogout.pm,v 1.42 2011/06/13 17:41:01 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -106,14 +106,29 @@
         $relogmessage.='<h1>'.&mt('Goodbye').'</h1>'
                       .'<p>'.&mt('Thank you for using LON-CAPA.').'</p>';
 
+        my $domain = $env{'user.domain'};
 	if (!$env{'request.sso.norelogin'}) {
-	    my $relogin_server;
+	    my ($relogin_server,$login_url);
 	    if ($env{'request.sso.reloginserver'}) {
 		$relogin_server = $env{'request.sso.reloginserver'};
-	    }
-	    my $login_url = $relogin_server.'/adm/'.
-		($env{'request.sso.login'} ? 'roles': 'login');
-
+	    } else {
+                 my %domdefaults = &Apache::lonnet::get_domain_defaults($domain);
+                 if ($domdefaults{'portal_def'}) {
+                     $login_url = $domdefaults{'portal_def'};
+                 } else {
+                     my $checkloginvia = 1;
+                     my ($lonhost,$server,$path) = 
+                         &Apache::lonnet::choose_server($domain,$checkloginvia);
+                     if ($server && $lonhost) {
+                         $login_url = $Apache::lonnet::protocol{$lonhost}.
+                                      '://'.$server.$path;
+                     }
+                 }
+            }
+            if ($login_url eq '') {
+	        $login_url = $relogin_server.'/adm/'.
+		    ($env{'request.sso.login'} ? 'roles': 'login?domain='.$domain);
+            }
             $relogmessage.='<p>'.&mt('You have been successfully logged out.').' '
                           .&mt('You can [_1]close this window[_2] now.'
                               ,'','') # ,'<a href="javascript:self.close();">','</a>')
@@ -128,10 +143,9 @@
 
 =cut
             $relogmessage.='<p>'.&mt('[_1]Log in again[_2]'
-                              ,'<a href="'.$login_url.'?domain='.$env{'user.domain'}.'">','</a>')
+                              ,'<a href="'.$login_url.'">','</a>')
                           .'</p>';
         }
-	my $domain = $env{'user.domain'};
         if ($env{'request.sso.login'}
 	    && defined($r->dir_config("lonSSOUserLogoutMessageFile_$domain"))) {
 	    open(my $fh,$r->dir_config("lonSSOUserLogoutMessageFile_$domain"));
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1115 loncom/lonnet/perl/lonnet.pm:1.1116
--- loncom/lonnet/perl/lonnet.pm:1.1115	Sun Jun 12 14:18:12 2011
+++ loncom/lonnet/perl/lonnet.pm	Mon Jun 13 17:41:04 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1115 2011/06/12 14:18:12 raeburn Exp $
+# $Id: lonnet.pm,v 1.1116 2011/06/13 17:41:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -866,21 +866,34 @@
     my %domconfhash = &Apache::loncommon::get_domainconf($udom);
     my %servers = &get_servers($udom);
     my $lowest_load = 30000;
-    my ($login_host,$hostname);
+    my ($login_host,$hostname,$portal_path);
     foreach my $lonhost (keys(%servers)) {
         my $loginvia;
         if ($checkloginvia) {
             $loginvia = $domconfhash{$udom.'.login.loginvia_'.$lonhost};
-        }
-        if ($loginvia eq '') {
+            if ($loginvia) {
+                my ($server,$path) = split(/:/,$loginvia);
+                ($login_host, $lowest_load) =
+                    &compare_server_load($server, $login_host, $lowest_load);
+                if ($login_host eq $server) {
+                    $portal_path = $path;
+                }
+            } else {
+                ($login_host, $lowest_load) =
+                    &compare_server_load($lonhost, $login_host, $lowest_load);
+                if ($login_host eq $lonhost) {
+                    $portal_path = '';
+                }
+            }
+        } else {
             ($login_host, $lowest_load) =
-            &compare_server_load($lonhost, $login_host, $lowest_load);
+                &compare_server_load($lonhost, $login_host, $lowest_load);
         }
     }
     if ($login_host ne '') {
-        $hostname = $servers{$login_host};
+        $hostname = &hostname($login_host);
     }
-    return ($login_host,$hostname);
+    return ($login_host,$hostname,$portal_path);
 }
 
 # --------------------------------------------- Try to change a user's password