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

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 23 Dec 2006 07:17:34 -0000


albertel		Sat Dec 23 02:17:34 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  - saveabilty for settings in a non course context
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.495 loncom/interface/loncommon.pm:1.496
--- loncom/interface/loncommon.pm:1.495	Mon Dec 18 18:01:35 2006
+++ loncom/interface/loncommon.pm	Sat Dec 23 02:17:34 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.495 2006/12/18 23:01:35 albertel Exp $
+# $Id: loncommon.pm,v 1.496 2006/12/23 07:17:34 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6074,16 +6074,19 @@
 #######################################################
 #######################################################
 sub store_course_settings {
+    return &store_settings($env{'request.course.id'},@_);
+}
+
+sub store_settings {
     # save to the environment
     # appenv the same items, just to be safe
-    my $courseid = $env{'request.course.id'};
     my $udom  = $env{'user.domain'};
     my $uname = $env{'user.name'};
-    my ($prefix,$Settings) = @_;
+    my ($context,$prefix,$Settings) = @_;
     my %SaveHash;
     my %AppHash;
     while (my ($setting,$type) = each(%$Settings)) {
-        my $basename = join('.','internal',$courseid,$prefix,$setting);
+        my $basename = join('.','internal',$context,$prefix,$setting);
         my $envname = 'environment.'.$basename;
         if (exists($env{'form.'.$setting})) {
             # Save this value away
@@ -6119,15 +6122,19 @@
     }
     # Make sure these settings stick around in this session, too
     &Apache::lonnet::appenv(%AppHash);
+    &Apache::lonnet::logthis(join(':',%AppHash));
     return;
 }
 
 sub restore_course_settings {
-    my $courseid = $env{'request.course.id'};
-    my ($prefix,$Settings) = @_;
+    return &return_settings($env{'request.course.id'},@_);
+}
+
+sub restore_settings {
+    my ($context,$prefix,$Settings) = @_;
     while (my ($setting,$type) = each(%$Settings)) {
         next if (exists($env{'form.'.$setting}));
-        my $envname = 'environment.internal.'.$courseid.'.'.$prefix.
+        my $envname = 'environment.internal.'.$context.'.'.$prefix.
             '.'.$setting;
         if (exists($env{$envname})) {
             if ($type eq 'scalar') {