--- loncom/interface/londocs.pm 2005/06/08 17:42:01 1.178 +++ loncom/interface/londocs.pm 2005/06/09 18:01:29 1.183 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.178 2005/06/08 17:42:01 www Exp $ +# $Id: londocs.pm,v 1.183 2005/06/09 18:01:29 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1020,7 +1020,7 @@ sub editor { if ($url=~/^http\:\/\//) { $ext='true'; } $url=~s/\:/\:/g; # Now insert the URL at the bottom - my $newidx=1+$#Apache::lonratedt::resources; + my $newidx=&Apache::lonratedt::getresidx($url); $Apache::lonratedt::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res'; $Apache::lonratedt::order[1+$#Apache::lonratedt::order]=$newidx; @@ -1036,10 +1036,19 @@ sub editor { if (($env{'form.uploaddoc.filename'}) && ($env{'form.cmd'}=~/^upload_(\w+)/)) { if ( ($folder=~/^$1/) || ($1 eq 'default') ) { + my $destination = 'docs/'; + if ($folder eq 'default') { + $destination .= 'default/'; + } elsif ($folder =~ /^default_(\d+)$/) { + $destination .= $1.'/'; + } # this is for a course, not a user, so set coursedoc flag # probably the only place in the system where this should be "1" - my $newidx=$#Apache::lonratedt::resources+1; - my $url=&Apache::lonnet::userfileupload('uploaddoc',1,'docs/'.$newidx); + + my $newidx=&Apache::lonratedt::getresidx(); + $destination .= $newidx; + my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination); + my $ext='false'; if ($url=~/^http\:\/\//) { $ext='true'; } $url=~s/\:/\:/g; @@ -1068,8 +1077,11 @@ sub editor { if ($cmd eq 'del') { my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]); if ($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) { - &Apache::lonnet::removeuploadedurl($url); + unless ($url=~/\.(page|sequence)$/) { + &Apache::lonnet::removeuploadedurl($url); + } } + &Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]); for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) { $Apache::lonratedt::order[$i]= $Apache::lonratedt::order[$i+1]; @@ -1077,6 +1089,7 @@ sub editor { $#Apache::lonratedt::order--; } elsif ($cmd eq 'cut') { my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]); + &Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]); for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) { $Apache::lonratedt::order[$i]= $Apache::lonratedt::order[$i+1]; @@ -1142,8 +1155,8 @@ sub editor { # Loading a complete map if (($env{'form.importmap'}) && ($env{'form.loadmap'})) { foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { - my $idx=$#Apache::lonratedt::resources; - $idx++; + my ($title,$url,$ext,$type)=split(/\:/,$_); + my $idx=&Apache::lonratedt::getresidx($url); $Apache::lonratedt::resources[$idx]=$_; $Apache::lonratedt::order [$#Apache::lonratedt::order+1]=$idx; @@ -1856,7 +1869,7 @@ sub changewarning { } $r->print( ''. -'
'. +''. '

'. &mt($message,' $lt{'file'}:
- +
$lt{'title'}:
@@ -2279,8 +2292,8 @@ $help{'Importing_LON-CAPA_Resource'}


-$lt{'copm'} -
+$lt{'copm'}
+
@@ -2395,6 +2408,7 @@ $uploadtag + ENDFORM } if ($env{'form.pagepath'}) { @@ -2415,8 +2429,8 @@ $uploadtag onClick="javascript:makeexamupload();" /> $help{'Score_Upload_Form'} + ENDBLOCK - $r->print(''); } $r->print(''."\n". ''); @@ -2505,7 +2519,7 @@ ENDSUPFORM } } if ($allowed) { - $r->print('
'); + $r->print('
'); } $r->print(''); } else {