--- loncom/interface/lonhelper.pm	2010/09/02 00:19:17	1.180.2.2
+++ loncom/interface/lonhelper.pm	2011/12/18 17:15:03	1.188
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.180.2.2 2010/09/02 00:19:17 raeburn Exp $
+# $Id: lonhelper.pm,v 1.188 2011/12/18 17:15:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -261,7 +261,7 @@ sub real_handler {
     my $uri = shift;
     if (!defined($uri)) { $uri = $r->uri(); }
     $env{'request.uri'} = $uri;
-    my $filename = '/home/httpd/html' . $uri;
+    my $filename = $r->dir_config('lonDocRoot').$uri;
     my $fh = Apache::File->new($filename);
     my $file;
     read $fh, $file, 100000000;
@@ -1476,9 +1476,9 @@ BUTTONS
             HTML::Entities::encode($choice->[1],"<>&\"'") 
             . "'";
         if ($checkedChoices{$choice->[1]}) {
-            $result .= " checked='checked' ";
+            $result .= " checked='checked'";
         }
-        $result .= qq{id="id$id"};
+        $result .= qq{ id="id$id"};
         my $choiceLabel = $choice->[0];
         if ($choice->[3]) {  # if we need to evaluate this choice
             $choiceLabel = "sub { my $helper = shift; my $state = shift;" .
@@ -1486,7 +1486,7 @@ BUTTONS
             $choiceLabel = eval($choiceLabel);
             $choiceLabel = &$choiceLabel($helper, $self);
         }
-        $result .= "/></td><td> ".qq{<label for="id$id">}.
+        $result .= " /></td><td> ".qq{<label for="id$id">}.
 	    $choiceLabel. "</label></td>";
 	if ($choice->[4]) {
 	    $result .='<td><input type="text" size="5" name="'
@@ -1913,7 +1913,13 @@ CHECK
 	if ($anytime) {
 	    $result.=' checked="checked" '
 	}
-	$result.="name='${var}anytime'/>".&mt('Any time').'</label>'
+        my $anytimetext = &mt('Any time');
+        if (($var eq 'startreserve') || ($var eq 'endreserve')) {
+            $anytimetext = &mt('Any time before slot starts');
+        } elsif (($var eq 'startunique') || ($var eq 'endunique')) {
+            $anytimetext = &mt('No restriction on uniqueness');     
+        }
+	$result.="name='${var}anytime'/>".$anytimetext.'</label>'
     }
     return $result;
 
@@ -2971,30 +2977,31 @@ BUTTONS
     }
 
     # Get the list of files in this directory.
-    my @fileList;
+    my (@fileList,$listref,$listerror);
 
     # If the subdirectory is in local CSTR space
     my $metadir;
-    if ($subdir =~ m|/home/([^/]+)/public_html/(.*)|) {
-	my ($user,$domain)= 
-	    &Apache::loncacc::constructaccess($subdir,
-				     $Apache::lonnet::perlvar{'lonDefDomain'});
-	$metadir='/res/'.$domain.'/'.$user.'/'.$2;
-        @fileList = &Apache::lonnet::dirlist($subdir,$domain,$user,undef,undef,'/');
-    } elsif ($subdir =~ m|^~([^/]+)/(.*)$|) {
-	$subdir='/home/'.$1.'/public_html/'.$2;
+    my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
+    if ($subdir =~ m{^(?:\Q$londocroot\E)*/priv/[^/]+/[^/]+/(.*)$}) {
+        my $innerpath=$1;
+        unless ($subdir=~m{^\Q$londocroot\E}) {
+           $subdir=$londocroot.$subdir;
+        }
 	my ($user,$domain)= 
-	    &Apache::loncacc::constructaccess($subdir,
-				     $Apache::lonnet::perlvar{'lonDefDomain'});
-	$metadir='/res/'.$domain.'/'.$user.'/'.$2;
-        @fileList = &Apache::lonnet::dirlist($subdir,$domain,$user,undef,undef,'/');
+	    &Apache::loncacc::constructaccess($subdir);
+	$metadir='/res/'.$domain.'/'.$user.'/'.$innerpath;
+        ($listref,$listerror) =
+            &Apache::lonnet::dirlist($subdir,$domain,$user,undef,undef,'/');
     } else {
         # local library server resource space
-        @fileList = &Apache::lonnet::dirlist($subdir,$env{'user.domain'},$env{'user.name'},undef,undef,'/');
+        ($listref,$listerror) = 
+            &Apache::lonnet::dirlist($subdir,$env{'user.domain'},$env{'user.name'},undef,undef,'/');
     }
 
     # Sort the fileList into order
-    @fileList = sort {lc($a) cmp lc($b)} @fileList;
+    if (ref($listref) eq 'ARRAY') {
+        @fileList = sort {lc($a) cmp lc($b)} @{$listref};
+    }
 
     $result .= $buttons;
 
@@ -3089,7 +3096,7 @@ sub fileState {
     }
     my $docroot = $Apache::lonnet::perlvar{'lonDocRoot'};
     my $subdirpart = $constructionSpaceDir;
-    $subdirpart =~ s/^\/home\/$uname\/public_html//;
+    $subdirpart =~ s{^\Q$docroot/priv/$udom/$uname\E}{};
     my $resdir = $docroot . '/res/' . $udom . '/' . $uname .
         $subdirpart;
 
@@ -3364,7 +3371,7 @@ sub render {
         $result .= '<p><font color="#FF0000">' . $self->{ERROR_MSG} . '</font></p>';
     }
 
-    $result .= '<input type="string" name="' . $self->{'variable'} . '_forminput"';
+    $result .= '<input type="text" name="' . $self->{'variable'} . '_forminput"';
 
     if (defined($self->{'size'})) {
         $result .= ' size="' . $self->{'size'} . '"';
@@ -3679,10 +3686,8 @@ sub render {
     }
     my $previous = HTML::Entities::encode(&mt("Back"), '<>&"');
     my $next = HTML::Entities::encode(&mt("Next"), '<>&"');
-    my $target = " target='loncapaclient'";
-    if ($env{'environment.remote'} eq 'off') {  $target='';  }
     $result .= "<p>\n" .
-	"<form action='".$actionURL."' method='post' $target>\n" .
+	"<form action='".$actionURL."' method='post' >\n" .
 	"<input type='button' onclick='history.go(-1)' value='$previous' />" .
 	"<input type='hidden' name='orgurl' value='$targetURL' />" .
 	"<input type='hidden' name='selectrole' value='1' />\n" .