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

raeburn raeburn@source.lon-capa.org
Thu, 18 Dec 2008 16:58:32 -0000


raeburn		Thu Dec 18 16:58:32 2008 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm loncreateuser.pm loncommon.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Storage of availability of user tools (portfolio,blog,aboutme) moved from memcache to %env.
    - When DC modifies defaults or custom settings for a specific user.
      - values for $env{environment.availabletools.$tool} in DC's own %env are updated, as needed.
      - values for other users will change when %env is next set.
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.79 loncom/interface/domainprefs.pm:1.80
--- loncom/interface/domainprefs.pm:1.79	Wed Dec 17 22:12:53 2008
+++ loncom/interface/domainprefs.pm	Thu Dec 18 16:58:26 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.79 2008/12/17 22:12:53 raeburn Exp $
+# $Id: domainprefs.pm,v 1.80 2008/12/18 16:58:26 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3612,10 +3612,18 @@
                 }
                 $resulttext .= '</ul></li>';
             }
+            my %newenv;
             foreach my $item (@usertools) {
                 if (ref($changes{$item}) eq 'HASH') {
-                    my $hashid = $env{'user.name'}.':'.$env{'user.domain'};
-                    &Apache::lonnet::devalidate_cache_new('usertools.'.$item,$hashid);
+                    my $newacc = 
+                        &Apache::lonnet::usertools_access($env{'user.name'},
+                                                          $env{'user.domain'},
+                                                          $item,'reload');
+                    if ($env{'environment.tools.'.$item} ne '') {
+                        if ($env{'environment.availabletools.'.$item} ne $newacc) { 
+                            $newenv{'environment.availabletools.'.$item} = $newacc;
+                        }
+                    }
                     $resulttext .= '<li>'.$titles{$item}.'<ul>';
                     foreach my $type (@{$types},'default','_LC_adv') {
                         if ($changes{$item}{$type}) {
@@ -3636,6 +3644,9 @@
                 }
             }
             $resulttext .= '</ul>';
+            if (keys(%newenv)) {
+                &Apache::lonnet::appenv(\%newenv);
+            }
         } else {
             $resulttext = &mt('No changes made to availability of home pages, blogs, portfolios or default quotas');
         }
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.269 loncom/interface/loncreateuser.pm:1.270
--- loncom/interface/loncreateuser.pm:1.269	Mon Dec 15 00:12:38 2008
+++ loncom/interface/loncreateuser.pm	Thu Dec 18 16:58:26 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.269 2008/12/15 00:12:38 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.270 2008/12/18 16:58:26 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2125,17 +2125,17 @@
                     &Apache::lonnet::put('environment',\%changeHash,
                                   $env{'form.ccdomain'},$env{'form.ccuname'});
                 if ($chgresult eq 'ok') {
-                    my %newenvhash;
-                    my $hashid="$env{'form.ccuname'}:$env{'form.ccdomain'}";
-                    foreach my $key (keys(%changed)) {
-                        if ($key ne 'quota') {
-                            &Apache::lonnet::devalidate_cache_new('usertools.'.$key,$hashid);
-                            $newenvhash{'environment.tools.'.$key} = 
-                                $changeHash{'tools.'.$key};
-                        }
-                    }
                     if (($env{'user.name'} eq $env{'form.ccuname'}) &&
                         ($env{'user.domain'} eq $env{'form.ccdomain'})) {
+                        my %newenvhash;
+                        foreach my $key (keys(%changed)) {
+                            if ($key ne 'quota') {
+                                $newenvhash{'environment.tools.'.$key} = 
+                                    $changeHash{'tools.'.$key};
+                                $newenvhash{'environment.availabletools.'.$key} =
+                                    $changeHash{'tools.'.$key};
+                            }
+                        }
                         &Apache::lonnet::appenv(\%newenvhash);
                     }
                 }
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.723 loncom/interface/loncommon.pm:1.724
--- loncom/interface/loncommon.pm:1.723	Thu Dec 18 08:33:11 2008
+++ loncom/interface/loncommon.pm	Thu Dec 18 16:58:26 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.723 2008/12/18 08:33:11 riegler Exp $
+# $Id: loncommon.pm,v 1.724 2008/12/18 16:58:26 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -9825,6 +9825,11 @@
 	    }
 	}
 
+        foreach my $tool ('aboutme','blog','portfolio') {
+            $userenv{'availabletools.'.$tool} = 
+                &Apache::lonnet::usertools_access($username,$domain,$tool,'reload');
+        }
+
 	$env{'user.environment'} = "$lonids/$cookie.id";
 	
 	if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id",
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.977 loncom/lonnet/perl/lonnet.pm:1.978
--- loncom/lonnet/perl/lonnet.pm:1.977	Tue Dec  9 11:32:03 2008
+++ loncom/lonnet/perl/lonnet.pm	Thu Dec 18 16:58:31 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.977 2008/12/09 11:32:03 amueller Exp $
+# $Id: lonnet.pm,v 1.978 2008/12/18 16:58:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4406,7 +4406,7 @@
 }
 
 sub usertools_access {
-    my ($uname,$udom,$tool) = @_;
+    my ($uname,$udom,$tool,$action) = @_;
     my $access;
     my %tools = (
                   aboutme   => 1,
@@ -4420,10 +4420,10 @@
         $uname = $env{'user.name'};
     }
 
-    my $hashid=$uname.':'.$udom;
-    my ($result,$cached) = &is_cached_new('usertools.'.$tool,$hashid);
-    if (defined($cached)) {
-        return $result;
+    if (($udom eq $env{'user.domain'}) && ($uname eq $env{'user.name'})) {
+        if ($action ne 'reload') {
+            return $env{'environment.availabletools.'.$tool};
+        } 
     }
 
     my ($toolstatus,$inststatus);
@@ -4443,7 +4443,6 @@
         } else {
             $access = 0;
         }
-        &do_cache_new('usertools.'.$tool,$hashid,$access,600);
         return $access;
     }
 
@@ -4457,7 +4456,6 @@
                 } else {
                     $access = 0;
                 }
-                &do_cache_new('usertools.'.$tool,$hashid,$access,600);
                 return $access;
             }
         }
@@ -4478,7 +4476,6 @@
                 } elsif ($hasnoaccess) {
                     $access = 0; 
                 }
-                &do_cache_new('usertools.'.$tool,$hashid,$access,600);
                 return $access;
             }
         } else {
@@ -4488,13 +4485,11 @@
                 } elsif ($domdef{$tool}{'default'} == 0) {
                     $access = 0;
                 }
-                &do_cache_new('usertools.'.$tool,$hashid,$access,600);
                 return $access;
             }
         }
     } else {
         $access = 1;
-        &do_cache_new('usertools.'.$tool,$hashid,$access,600);
         return $access;
     }
 }