--- loncom/interface/londocs.pm	2004/12/23 16:31:27	1.159
+++ loncom/interface/londocs.pm	2005/01/08 06:34:30	1.163
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.159 2004/12/23 16:31:27 raeburn Exp $
+# $Id: londocs.pm,v 1.163 2005/01/08 06:34:30 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -214,7 +214,7 @@ sub dumpcourse {
 	}
 	my $title=$origcrsdata{'description'};
 	$title=~s/\s+/\_/gs;
-	$title=~s/\W//gs;
+	$title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
 	$r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
 	&tiehash();
 	$r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>');
@@ -223,12 +223,13 @@ sub dumpcourse {
 	    my ($ext)=($_=~/\.(\w+)$/);
 	    my $title=$hash{'title_'.$hash{
 		'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
+	    $title=~s/&colon;/:/g;
 	    $r->print('<td>'.($title?$title:'&nbsp;').'</td>');
 	    unless ($title) {
 		$title=$_;
 	    }
 	    $title=~s/\.(\w+)$//;
-	    $title=~s/[^\w\/]+/\_/gs;
+	    $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
 	    $title.='.'.$ext;
 	    $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
 	}
@@ -242,6 +243,7 @@ sub dumpcourse {
 # ------------------------------------------------------ Generate "export" button
 
 sub exportbutton {
+    return '';
     return '</td><td bgcolor="#DDDDCC">'.
             '<input type="submit" name="exportcourse" value="'.
             &mt('Export Course to IMS').'" />'.
@@ -658,7 +660,6 @@ sub process_content {
     my $content_type;
     my $message;
 # find where user is author or co-author
-    my %roleshash = &Apache::lonnet::get_my_roles();
     my @uploads = ();
     if ($curRes->is_sequence()) {
         $content_type = 'sequence';
@@ -705,29 +706,20 @@ sub process_content {
         if ($contents) {
             $$content_file = &store_template($contents,$tempexport,$count,$content_type);
         }
-    } elsif ($symb =~ m-uploaded/$cdom/$cnum-) {
-        $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
     } elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) {
         $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
-    } elsif ($symb =~ m-\.(sequence|page)___\d+___([^/])/([^/])-) {
-        my $coauth = $3.':'.$2.':ca';
+    } elsif ($symb =~ m-\.(sequence|page)___\d+___([^/]+)/([^/]+)-) {
         my $canedit = 0;
         if ($2 eq $ENV{'user.domain'} && $3 eq $ENV{'user.name'})  {
             $canedit= 1;
-        } elsif (defined($roleshash{$coauth})) {
-            if ($roleshash{$coauth} =~ /(\d+):(\d+)/) {
-                if (($1 < time || $1 == 0) && ($2 == 0 || $2 >= time)) {
-                    $canedit = 1;
-                }
-            } elsif ($roleshash{$coauth} eq ':') {
-                $canedit = 1;
-            }
         }
         if ($canedit) {
             $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');
         } else {
             $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit');
         }
+    } elsif ($symb =~ m-uploaded/$cdom/$cnum-) {
+        $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
     }
     if (@uploads > 0) {
         foreach my $item (@uploads) {
@@ -769,14 +761,14 @@ sub replicate_content {
         if ($copiedfile = Apache::File->new('>'.$destination)) {
             my $content;
             if ($caller eq 'resource') {
-                $content = &Apache::lonnet::getfile($url);
+                $content = &Apache::lonnet::getfile('/home/httpd/html/res/'.$url);
                 if ($content eq -1) {
                     $$message = 'Could not copy file '.$filename;
                 } else {
                     &extract_media($content,$count,$tempexport,$href,'resource');
                     $repstatus = 'ok';
                 }
-            } elsif ($caller eq 'noedit' || $caller eq 'uploaded' || $caller eq 'templateupload') {
+            } elsif ($caller eq 'uploaded' || $caller eq 'templateupload') {
                 my $rtncode;
                 $repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode);
                 if ($repstatus eq 'ok') {
@@ -786,6 +778,10 @@ sub replicate_content {
                 } else {
                     $$message = 'Could not render '.$url.' server message - '.$rtncode;
                 }
+            } elsif ($caller eq 'noedit') {
+# Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this. 
+                $repstatus = 'ok';
+                $content = 'Not the owner of this resource'; 
             }
             if ($repstatus eq 'ok') {
                 print $copiedfile $content;