--- loncom/interface/londocs.pm 2005/04/07 06:56:23 1.174 +++ 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.174 2005/04/07 06:56:23 albertel Exp $ +# $Id: londocs.pm,v 1.183 2005/06/09 18:01:29 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -272,22 +272,8 @@ sub exportcourse { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['archive','discussion']); - my @exportitems = (); - if (defined($env{'form.archive'})) { - if (ref($env{'form.archive'}) eq 'ARRAY') { - @exportitems = @{$env{'form.archive'}}; - } else { - $exportitems[0] = $env{'form.archive'}; - } - } - my @discussions = (); - if (defined($env{'form.discussion'})) { - if (ref($env{'form.discussion'}) eq 'ARRAY') { - @discussions = $env{'form.discussion'}; - } else { - $discussions[0] = $env{'form.discussion'}; - } - } + my @exportitems = &Apache::loncommon::get_env_multiple('form.archive'); + my @discussions = &Apache::loncommon::get_env_multiple('form.discussion'); if (@exportitems == 0 && @discussions == 0) { $outcome = '
As you did not select any content items or discussions for export, an IMS package has not been created. Please go back to select either content items or discussions for export'; } else { @@ -866,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'; } @@ -928,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 @@ -1032,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; @@ -1048,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; @@ -1080,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]; @@ -1089,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]; @@ -1154,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; @@ -1851,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'}.'

'); } @@ -1974,7 +1979,7 @@ sub handler { # graphics settings - $iconpath = $r->dir_config('lonIconsURL') . "/"; + $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/"); my $now=time; @@ -2157,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', @@ -2263,7 +2268,7 @@ ENDCOURSEVERIFY $lt{'file'}:
-
+
$lt{'title'}:
@@ -2287,8 +2292,8 @@ $help{'Importing_LON-CAPA_Resource'}


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