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

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 03 Feb 2005 23:59:42 -0000


matthew		Thu Feb  3 18:59:42 2005 EDT

  Modified files:              
    /loncom/interface/spreadsheet	Spreadsheet.pm 
  Log:
  Safe space changes
  Fix &EXT routine by including all appropriate context information (symb,
  name, domain, section).
  Fixed bug in which the symb was not actually available in the safe space
  (used 'usymb' instead of 'symb' to denote the symb).
  
  
Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.37 loncom/interface/spreadsheet/Spreadsheet.pm:1.38
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.37	Wed Mar 31 00:24:00 2004
+++ loncom/interface/spreadsheet/Spreadsheet.pm	Thu Feb  3 18:59:41 2005
@@ -1,5 +1,5 @@
 #
-# $Id: Spreadsheet.pm,v 1.37 2004/03/31 05:24:00 albertel Exp $
+# $Id: Spreadsheet.pm,v 1.38 2005/02/03 23:59:41 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -313,6 +313,9 @@
 
 sub initialize_safe_space {
   my $self = shift;
+  my $usection = &Apache::lonnet::getsection($self->{'domain'},
+                                             $self->{'name'},
+                                             $ENV{'request.course.id'});
   if (! defined($safeeval)) {
       $safeeval = new Safe(shift);
       my $safehole = new Safe::Hole;
@@ -320,7 +323,7 @@
       $safeeval->permit(":base_math");
       $safeeval->permit("sort");
       $safeeval->deny(":base_io");
-      $safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
+      $safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&Apache::lonnet::EXT');
       $safehole->wrap(\&mask,$safeeval,'&mask');
       $safeeval->share('$@');
       my $code=<<'ENDDEFS';
@@ -379,6 +382,25 @@
 
 =pod
 
+=item EXT(parameter)
+
+Calls the system EXT function to determine the value of the given parameter.
+
+=cut
+
+#-------------------------------------------------------
+sub EXT {
+    my ($parameter) = @_;
+    return '' if (! defined($parameter) || $parameter eq '');
+    $parameter =~ s/^parameter\./resource\./;
+    my $value = &Apache::lonnet::EXT($parameter,$symb,$domain,$name,$usection);
+    return $value;
+}
+
+#-------------------------------------------------------
+
+=pod
+
 =item NUM(range)
 
 returns the number of items in the range.
@@ -696,10 +718,11 @@
     # Place some of the %$self  items into the safe space except the safe space
     # itself
     my $initstring = '';
-    foreach (qw/name domain type usymb cid csec coursefilename
+    foreach (qw/name domain type symb cid csec coursefilename
              cnum cdom chome uhome/) {
         $initstring.= qq{\$$_="$self->{$_}";};
     }
+    $initstring.=qq{\$usection="$usection";};
     $self->{'safe'}->reval($initstring);
     return $self;
 }