Diff for /loncom/auth/migrateuser.pm between versions 1.21 and 1.23

version 1.21, 2014/10/04 02:59:32 version 1.23, 2014/10/06 00:48:44
Line 72  sub ip_changed { Line 72  sub ip_changed {
     if (ref($dataref) eq 'HASH') {      if (ref($dataref) eq 'HASH') {
         my $title = 'LON-CAPA Session redirected';          my $title = 'LON-CAPA Session redirected';
         my $message = &mt('Your internet address has changed since you logged in.');            my $message = &mt('Your internet address has changed since you logged in.');  
         my $camefrom = &Apache::lonnet::hostname($dataref->{'server'});  
         my $frombalancer = $dataref->{'balancer'};  
         my $rule_in_effect;          my $rule_in_effect;
         if ($frombalancer) {          if ($dataref->{'balancer'}) {
             my $balancerdom = &Apache::lonnet::host_domain($dataref->{'server'});              my $baldom = &Apache::lonnet::host_domain($camefrom);
             if ($dataref->{'sso.login'}) {              my $balprimaryid = &Apache::lonnet::domain($baldom,'primary');
                 if (&Apache::lonnet::domain($dataref->{'domain'})) {              my $balintdom = &Apache::lonnet::internet_dom($balprimaryid);
                     $balancerdom = $dataref->{'domain'};              my $uprimaryid = &Apache::lonnet::domain($udom,'primary'); 
                 }              my $uintdom = &Apache::lonnet::internet_dom($uprimaryid);
               my $dom_in_use;
               if (($uintdom ne '') && ($uintdom eq $balintdom)) {
                   $dom_in_use = $udom;
               } else {
                   $dom_in_use = $baldom;
             }              }
             my ($result,$cached)=&Apache::lonnet::is_cached_new('loadbalancing',$balancerdom);              my ($result,$cached)=&Apache::lonnet::is_cached_new('loadbalancing',$dom_in_use);
             unless (defined($cached)) {              unless (defined($cached)) {
                 my $cachetime = 60*60*24;                   my $cachetime = 60*60*24; 
                 my %domconfig =                  my %domconfig =
                     &Apache::lonnet::get_dom('configuration',['loadbalancing'],$balancerdom);                      &Apache::lonnet::get_dom('configuration',['loadbalancing'],$dom_in_use);
                 if (ref($domconfig{'loadbalancing'}) eq 'HASH') {                  if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
                     $result = &Apache::lonnet::do_cache_new('loadbalancing',$balancerdom,                      $result = &Apache::lonnet::do_cache_new('loadbalancing',$dom_in_use,
                                                             $domconfig{'loadbalancing'},$cachetime);                                                              $domconfig{'loadbalancing'},$cachetime);
                 }                  }
             }              }
Line 111  sub ip_changed { Line 114  sub ip_changed {
         my $url;          my $url;
         my $lonhost= $r->dir_config('lonHostID');          my $lonhost= $r->dir_config('lonHostID');
         my $switchto = $lonhost;          my $switchto = $lonhost;
         if ($rule_in_effect eq 'balancer') {          if ($rule_in_effect ne 'offloadedto') {
             my $hosthere;              my $hosthere;
             if ($dataref->{'role'}) {              my @ids=&Apache::lonnet::current_machine_ids();
                 my ($adom,$aname);              unless ($rule_in_effect eq 'balancer') {
                 if ($dataref->{'role'} =~ m{^au\./($match_domain)/$}) {                  if (grep(/^\Q$rule_in_effect\E$/,@ids)) {
                     $adom = $1;                      $hosthere = 1;
                     $aname = $dataref->{'username'};                  }
                 } elsif ($dataref->{'role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)$}) {              }
                     $adom = $1;              unless ($hosthere) {
                     $aname = $2;                  if ($dataref->{'role'}) {
                 }                      my ($adom,$aname);
                 if ($adom ne '' && $aname ne '') {                      if ($dataref->{'role'} =~ m{^au\./($match_domain)/$}) {
                     my $ahome = &Apache::lonnet::homeserver($aname,$adom);                          $adom = $1;
                     unless ($ahome eq 'no_host') {                          $aname = $dataref->{'username'};
                         my @ids=&Apache::lonnet::current_machine_ids();                      } elsif ($dataref->{'role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)$}) {
                         if ($ahome && grep(/^\Q$ahome\E$/,@ids)) {                          $adom = $1;
                             $hosthere = 1;                          $aname = $2;
                       }
                       if ($adom ne '' && $aname ne '') {
                           my $ahome = &Apache::lonnet::homeserver($aname,$adom);
                           unless ($ahome eq 'no_host') {
                               if ($ahome && grep(/^\Q$ahome\E$/,@ids)) {
                                   $hosthere = 1;
                               }
                         }                          }
                     }                      }
                 }                  }
             }              }
             unless ($hosthere) {               unless ($hosthere) {
                 my $hostname = &Apache::lonnet::hostname($dataref->{'server'});                  my $hostname;
                   if ($rule_in_effect eq 'balancer') {
                       $hostname = &Apache::lonnet::hostname($dataref->{'server'});
                       if ($hostname) {
                           $switchto = $dataref->{'server'};
                       }
                   } else {
                       $hostname = &Apache::lonnet::hostname($rule_in_effect);
                       if ($hostname) {
                           $switchto = $rule_in_effect;
                       }
                   }
                 if ($hostname) {                  if ($hostname) {
                     $switchto = $dataref->{'server'};  
                     my $protocol = $Apache::lonnet::protocol{$switchto};                      my $protocol = $Apache::lonnet::protocol{$switchto};
                     $protocol = 'http' if ($protocol ne 'https');                      $protocol = 'http' if ($protocol ne 'https');
                     $url = $protocol.'://'.$hostname;                      $url = $protocol.'://'.$hostname;
                     $message .= '<br />'.                      if ($rule_in_effect eq 'balancer') {
                                 &mt('As a result, your LON-CAPA session is being redirected to the server where you originally logged in.');                          $message .= '<br />'.
                                       &mt('As a result, your LON-CAPA session is being redirected to the server where you originally logged in.');
                       } else {
                           $message .= '<br />'.
                                       &mt('As a result, your LON-CAPA session is being redirected.');
                       }
                 }                  }
             }              }
         }          }

Removed from v.1.21  
changed lines
  Added in v.1.23


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>