Diff for /loncom/lonnet/perl/lonnet.pm between versions 1.976 and 1.976.2.2

version 1.976, 2008/12/08 23:00:47 version 1.976.2.2, 2008/12/21 15:20:54
Line 4375  sub is_portfolio_file { Line 4375  sub is_portfolio_file {
 }  }
   
 sub usertools_access {  sub usertools_access {
     my ($uname,$udom,$tool) = @_;      my ($uname,$udom,$tool,$action) = @_;
     my $access;      my $access;
     my %tools = (      my %tools = (
                   aboutme   => 1,                    aboutme   => 1,
Line 4389  sub usertools_access { Line 4389  sub usertools_access {
         $uname = $env{'user.name'};          $uname = $env{'user.name'};
     }      }
   
     my $hashid=$uname.':'.$udom;      if (($udom eq $env{'user.domain'}) && ($uname eq $env{'user.name'})) {
     my ($result,$cached) = &is_cached_new('usertools.'.$tool,$hashid);          if ($action ne 'reload') {
     if (defined($cached)) {              return $env{'environment.availabletools.'.$tool};
         return $result;          }
     }      }
   
     my ($toolstatus,$inststatus);      my ($toolstatus,$inststatus);
Line 4412  sub usertools_access { Line 4412  sub usertools_access {
         } else {          } else {
             $access = 0;              $access = 0;
         }          }
         &do_cache_new('usertools.'.$tool,$hashid,$access,600);  
         return $access;          return $access;
     }      }
   
Line 4426  sub usertools_access { Line 4425  sub usertools_access {
                 } else {                  } else {
                     $access = 0;                      $access = 0;
                 }                  }
                 &do_cache_new('usertools.'.$tool,$hashid,$access,600);  
                 return $access;                  return $access;
             }              }
         }          }
Line 4447  sub usertools_access { Line 4445  sub usertools_access {
                 } elsif ($hasnoaccess) {                  } elsif ($hasnoaccess) {
                     $access = 0;                       $access = 0; 
                 }                  }
                 &do_cache_new('usertools.'.$tool,$hashid,$access,600);  
                 return $access;                  return $access;
             }              }
         } else {          } else {
Line 4457  sub usertools_access { Line 4454  sub usertools_access {
                 } elsif ($domdef{$tool}{'default'} == 0) {                  } elsif ($domdef{$tool}{'default'} == 0) {
                     $access = 0;                      $access = 0;
                 }                  }
                 &do_cache_new('usertools.'.$tool,$hashid,$access,600);  
                 return $access;                  return $access;
             }              }
         }          }
     } else {      } else {
         $access = 1;          $access = 1;
         &do_cache_new('usertools.'.$tool,$hashid,$access,600);  
         return $access;          return $access;
     }      }
 }  }
Line 8622  sub get_dns { Line 8617  sub get_dns {
     open(my $config,"<$perlvar{'lonTabDir'}/hosts.tab");      open(my $config,"<$perlvar{'lonTabDir'}/hosts.tab");
     foreach my $dns (<$config>) {      foreach my $dns (<$config>) {
  next if ($dns !~ /^\^(\S*)/x);   next if ($dns !~ /^\^(\S*)/x);
  $alldns{$1} = 1;          my $line = $1;
           my ($host,$protocol) = split(/:/,$line);
           if ($protocol ne 'https') {
               $protocol = 'http';
           }
    $alldns{$host} = $protocol;
     }      }
     while (%alldns) {      while (%alldns) {
  my ($dns) = keys(%alldns);   my ($dns) = keys(%alldns);
  delete($alldns{$dns});  
  my $ua=new LWP::UserAgent;   my $ua=new LWP::UserAgent;
  my $request=new HTTP::Request('GET',"http://$dns$url");   my $request=new HTTP::Request('GET',"$alldns{$dns}://$dns$url");
  my $response=$ua->request($request);   my $response=$ua->request($request);
           delete($alldns{$dns});
  next if ($response->is_error());   next if ($response->is_error());
  my @content = split("\n",$response->content);   my @content = split("\n",$response->content);
  &Apache::lonnet::do_cache_new('dns',$url,\@content,30*24*60*60);   &Apache::lonnet::do_cache_new('dns',$url,\@content,30*24*60*60);

Removed from v.1.976  
changed lines
  Added in v.1.976.2.2


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