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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Wed, 04 Apr 2007 00:10:16 -0000


albertel		Tue Apr  3 20:10:16 2007 EDT

  Modified files:              
    /loncom/interface	loncommon.pm domainprefs.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - move get_domainconf/devailadate_domconfig_cache to loncommon to reduce 
    lonnet dependencies on loncommon
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.517 loncom/interface/loncommon.pm:1.518
--- loncom/interface/loncommon.pm:1.517	Tue Apr  3 14:47:23 2007
+++ loncom/interface/loncommon.pm	Tue Apr  3 20:10:01 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.517 2007/04/03 18:47:23 raeburn Exp $
+# $Id: loncommon.pm,v 1.518 2007/04/04 00:10:01 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3173,6 +3173,60 @@
 }
 ###############################################
 
+sub devalidate_domconfig_cache {
+    my ($udom)=@_;
+    &Apache::lonnet::devalidate_cache_new('domainconfig',$udom);
+}
+
+# ---------------------- Get domain configuration for a domain
+sub get_domainconf {
+    my ($udom) = @_;
+    my $cachetime=1800;
+    my ($result,$cached)=&Apache::lonnet::is_cached_new('domainconfig',$udom);
+    if (defined($cached)) { return %{$result}; }
+
+    my %domconfig = &Apache::lonnet::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=$Apache::lonnet::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"); 
+        }
+    }
+    &Apache::lonnet::do_cache_new('domainconfig',$udom,\%designhash,
+				  $cachetime);
+    return %designhash;
+}
+
 =pod
 
 =item * &domainlogo()
@@ -3187,7 +3241,7 @@
 ###############################################
 sub domainlogo {
     my $domain = &determinedomain(shift);
-    my %designhash = &Apache::lonnet::get_domainconf($domain);    
+    my %designhash = &get_domainconf($domain);    
     # See if there is a logo
     if ($designhash{$domain.'.login.domlogo'} ne '') {
         return '<img src="'.$designhash{$domain.'.login.domlogo'}.
@@ -3229,7 +3283,7 @@
 	return $env{'environment.color.'.$which};
     }
     $domain=&determinedomain($domain);
-    my %domdesign = &Apache::lonnet::get_domainconf($domain);
+    my %domdesign = &get_domainconf($domain);
     if ($domdesign{$domain.'.'.$which} ne '') {
 	return $domdesign{$domain.'.'.$which};
     } else {
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.6 loncom/interface/domainprefs.pm:1.7
--- loncom/interface/domainprefs.pm:1.6	Tue Apr  3 14:47:23 2007
+++ loncom/interface/domainprefs.pm	Tue Apr  3 20:10:01 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.6 2007/04/03 18:47:23 raeburn Exp $
+# $Id: domainprefs.pm,v 1.7 2007/04/04 00:10:01 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -313,7 +313,7 @@
     my @images = ('img','logo','domlogo');
     my @bgs = ('pgbg','mainbg','sidebg');
     my @links = ('link','alink','vlink');
-    my %designhash = &Apache::lonnet::get_domainconf($dom);
+    my %designhash = &Apache::loncommon::get_domainconf($dom);
     my %defaultdesign = %Apache::loncommon::defaultdesign;
     my (%is_custom,%designs);
     my %defaults = (
@@ -446,7 +446,7 @@
     my @links = ('link','alink','vlink');
     my @images = ('img');
     my %alt_text = &Apache::lonlocal::texthash(img => "Banner for $role role");
-    my %designhash = &Apache::lonnet::get_domainconf($dom);
+    my %designhash = &Apache::loncommon::get_domainconf($dom);
     my %defaultdesign = %Apache::loncommon::defaultdesign;
     my (%is_custom,%designs);
     my %defaults = (
@@ -1134,7 +1134,7 @@
 sub display_colorchgs {
     my ($dom,$changes,$roles,$confhash) = @_;
     my (%choices,$resulttext);
-    &Apache::lonnet::devalidate_domconfig_cache($dom);
+    &Apache::loncommon::devalidate_domconfig_cache($dom);
     if (!grep(/^login$/,@{$roles})) {
         $resulttext = &mt('Changes made:').'<br />';
     }
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.862 loncom/lonnet/perl/lonnet.pm:1.863
--- loncom/lonnet/perl/lonnet.pm:1.862	Tue Apr  3 20:07:07 2007
+++ loncom/lonnet/perl/lonnet.pm	Tue Apr  3 20:10:15 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.862 2007/04/04 00:07:07 albertel Exp $
+# $Id: lonnet.pm,v 1.863 2007/04/04 00:10:15 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -671,61 +671,6 @@
     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 {