--- loncom/lonnet/perl/lonnet.pm	2007/04/03 18:47:29	1.860
+++ loncom/lonnet/perl/lonnet.pm	2007/04/04 18:01:11	1.865
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.860 2007/04/03 18:47:29 raeburn Exp $
+# $Id: lonnet.pm,v 1.865 2007/04/04 18:01:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -671,61 +671,6 @@ sub homeserver {
     return 'no_host';
 }
 
-# ---------------------- Get domain configuration for a domain
-sub get_domainconf {
-    my ($udom) = @_;
-    my $cachetime=1800;
-    my ($result,$cached)=&is_cached_new('domainconfig',$udom);
-    if (defined($cached)) { return %{$result}; }
-
-    if ($udom eq '') {
-        $udom = &Apache::loncommon::determinedomain();
-    }
-    my %domconfig = &get_dom('configuration',['login','rolecolors'],$udom);
-    my %designhash;
-    if (keys(%domconfig) > 0) {
-        if (ref($domconfig{'login'}) eq 'HASH') {
-            foreach my $key (keys(%{$domconfig{'login'}})) {
-                $designhash{$udom.'.login.'.$key}=$domconfig{'login'}{$key};
-            }
-        }
-        if (ref($domconfig{'rolecolors'}) eq 'HASH') {
-            foreach my $role (keys(%{$domconfig{'rolecolors'}})) {
-                if (ref($domconfig{'rolecolors'}{$role}) eq 'HASH') {
-                    foreach my $item (keys(%{$domconfig{'rolecolors'}{$role}})) {
-                        $designhash{$udom.'.'.$role.'.'.$item}=$domconfig{'rolecolors'}{$role}{$item};
-                    }
-                }
-            }
-        }
-    } else {
-        my $designdir=$perlvar{'lonTabDir'}.'/lonDomColors';
-        my $designfile =  $designdir.'/'.$udom.'.tab';
-        if (-e $designfile) {
-            if ( open (my $fh,"<$designfile") ) {
-                while (my $line = <$fh>) {
-                    next if ($line =~ /^\#/);
-                    chomp($line);
-                    my ($key,$val)=(split(/\=/,$line));
-                    if ($val) { $designhash{$udom.'.'.$key}=$val; }
-                }
-                close($fh);
-            }
-        }
-        if (-e '/home/httpd/html/adm/lonDomLogos/'.$udom.'.gif') {
-            $designhash{$udom.'.login.domlogo'} = 
-                &lonhttpdurl("/adm/lonDomLogos/$udom.gif"); 
-        }
-    }
-    &do_cache_new('domainconfig',$udom,\%designhash,$cachetime);
-    return %designhash;
-}
-
-sub devalidate_domconfig_cache {
-    my ($udom)=@_;
-    &devalidate_cache_new('domainconfig',$udom);
-}
-
 # ------------------------------------- Find the usernames behind a list of IDs
 
 sub idget {
@@ -3641,9 +3586,16 @@ sub get_portfolio_access {
             }
             if (@users > 0) {
                 foreach my $userkey (@users) {
-                    if (exists($access_hash->{$userkey}{'users'}{$env{'user.name'}.':'.$env{'user.domain'}})) {
-                        return 'ok';
-                    }
+                    if (ref($access_hash->{$userkey}{'users'}) eq 'ARRAY') {
+                        foreach my $item (@{$access_hash->{$userkey}{'users'}}) {
+                            if (ref($item) eq 'HASH') {
+                                if (($item->{'uname'} eq $env{'user.name'}) &&
+                                    ($item->{'udom'} eq $env{'user.domain'})) {
+                                    return 'ok';
+                                }
+                            }
+                        }
+                    } 
                 }
             }
             my %roleshash;
@@ -7704,15 +7656,6 @@ sub goodbye {
    &logthis("Shutting down");
 }
 
-BEGIN {
-
-# ----------------------------------- Read loncapa.conf and loncapa_apache.conf
-    unless ($readit) {
-{
-    my $configvars = LONCAPA::Configuration::read_conf('loncapa.conf');
-    %perlvar = (%perlvar,%{$configvars});
-}
-
 sub get_dns {
     my ($url,$func) = @_;
     open(my $config,"<$perlvar{'lonTabDir'}/hosts.tab");
@@ -7747,10 +7690,14 @@ sub get_dns {
 		$this_domain{$field} = shift(@elements);
 	    }
 	    $domain{$name} = \%this_domain;
-	    &logthis("Domain.tab: $name ".$domain{$name}{'description'} );
 	}
     }
-    
+
+    sub reset_domain_info {
+	undef($loaded);
+	undef(%domain);
+    }
+
     sub load_domain_tab {
 	&get_dns('/adm/dns/domain',\&parse_domain_tab);
 	my $fh;
@@ -7796,9 +7743,17 @@ sub get_dns {
 		$hostdom{$id}=$domain;
 		if ($role eq 'library') { $libserv{$id}=$name; }
 	    }
-	    &logthis("Hosts.tab: $name ".$id );
 	}
     }
+    
+    sub reset_hosts_info {
+	&reset_domain_info();
+	&reset_hosts_ip_info();
+	undef(%hostname);
+	undef(%hostdom);
+	undef(%libserv);
+	undef($loaded);
+    }
 
     sub load_hosts_tab {
 	&get_dns('/adm/dns/hosts',\&parse_hosts_tab);
@@ -7809,9 +7764,6 @@ sub get_dns {
 	$loaded=1;
     }
 
-    # FIXME: dev server don't want this, production servers _do_ want this
-    #&get_iphost();
-
     sub hostname {
 	&load_hosts_tab() if (!$loaded);
 
@@ -7888,6 +7840,12 @@ sub get_dns {
 	}
 	return;
     }
+    
+    sub reset_hosts_ip_info {
+	undef(%iphost);
+	undef(%name_to_ip);
+	undef(%lonid_to_ip);
+    }
 
     sub get_host_ip {
 	my ($lonid) = @_;
@@ -7907,7 +7865,7 @@ sub get_dns {
 	if (%iphost) { return %iphost; }
 	my %hostname = &all_hostnames();
 	foreach my $id (keys(%hostname)) {
-	    my $name=$hostname{$id};
+	    my $name=&hostname($id);
 	    my $ip;
 	    if (!exists($name_to_ip{$name})) {
 		$ip = gethostbyname($name);
@@ -7927,6 +7885,16 @@ sub get_dns {
     }
 }
 
+BEGIN {
+
+# ----------------------------------- Read loncapa.conf and loncapa_apache.conf
+    unless ($readit) {
+{
+    my $configvars = LONCAPA::Configuration::read_conf('loncapa.conf');
+    %perlvar = (%perlvar,%{$configvars});
+}
+
+
 # ------------------------------------------------------ Read spare server file
 {
     open(my $config,"<$perlvar{'lonTabDir'}/spare.tab");