--- loncom/interface/londocs.pm 2005/04/07 07:34:52 1.175 +++ loncom/interface/londocs.pm 2005/06/09 20:41:38 1.184 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.175 2005/04/07 07:34:52 albertel Exp $ +# $Id: londocs.pm,v 1.184 2005/06/09 20:41:38 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -852,7 +852,7 @@ sub group_import { } } if ($url) { - my $idx = $#Apache::lonratedt::resources + 1; + my $idx = &Apache::lonratedt::getresidx($url); $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx; my $ext = 'false'; if ($url=~/^http:\/\//) { $ext = 'true'; } @@ -914,8 +914,10 @@ sub editor { ($errtext,$fatal)= &mapread($coursenum,$coursedom,$folder.'.'.$container); if ($#Apache::lonratedt::order<1) { - $Apache::lonratedt::order[0]=1; - $Apache::lonratedt::resources[1]=''; + my $idx=&Apache::lonratedt::getresidx(); + if ($idx<=0) { $idx=1; } + $Apache::lonratedt::order[0]=$idx; + $Apache::lonratedt::resources[$idx]=''; } if (defined($env{'form.markcopy'})) { # Mark for copying @@ -1018,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; @@ -1034,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; @@ -1066,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|problem|exam|quiz|assess|survey|form|library)$/) { + &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]; @@ -1075,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]; @@ -1140,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; @@ -1837,25 +1852,29 @@ sub is_hash_old { } sub changewarning { - my ($r,$postexec)=@_; + my ($r,$postexec,$message,$url)=@_; if (!&is_hash_old()) { return; } my $pathvar='folderpath'; my $path=&Apache::lonnet::escape($env{'form.folderpath'}); - if (defined($env{'form.pagepath'})) { - $pathvar='pagepath'; - $path=&Apache::lonnet::escape($env{'form.pagepath'}); - $path.='&symb='.&Apache::lonnet::escape($env{'form.pagesymb'}); + if (!defined($url)) { + if (defined($env{'form.pagepath'})) { + $pathvar='pagepath'; + $path=&Apache::lonnet::escape($env{'form.pagepath'}); + $path.='&symb='.&Apache::lonnet::escape($env{'form.pagesymb'}); + } + $url='/adm/coursedocs?'.$pathvar.'='.$path; + } + if (!defined($message)) { + $message='Changes will become active for your current session after [_1], or the next time you log in.'; } $r->print( ''. -'
'. -''. +'

'. -&mt('Changes will become active for your current session after'). -' '.&mt(', or the next time you log in.'). +&mt($message,' '). $help{'Caching'}.'

'); } @@ -1960,7 +1979,7 @@ sub handler { # graphics settings - $iconpath = $r->dir_config('lonIconsURL') . "/"; + $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/"); my $now=time; @@ -2143,7 +2162,7 @@ ENDNEWSCRIPT 'upls' => 'Upload a new supplemental course document', 'impp' => 'Import a document', 'pubd' => 'Published documents', - 'copm' => 'All documents out of a published map', + 'copm' => 'All documents out of a published map into this folder', 'spec' => 'Special documents', 'upld' => 'Upload Document', 'srch' => 'Search', @@ -2249,7 +2268,7 @@ ENDCOURSEVERIFY $lt{'file'}:
-
+
$lt{'title'}:
@@ -2273,8 +2292,8 @@ $help{'Importing_LON-CAPA_Resource'}


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