--- loncom/interface/londocs.pm 2005/06/08 17:42:01 1.178 +++ loncom/interface/londocs.pm 2005/06/10 17:51:29 1.187 @@ -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.187 2005/06/10 17:51: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; @@ -1067,8 +1076,11 @@ sub editor { my ($cmd,$idx)=split(/\_/,$env{'form.cmd'}); 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/|) { + if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && + ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library)$/)) { &Apache::lonnet::removeuploadedurl($url); + } else { + &Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]); } for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) { $Apache::lonratedt::order[$i]= @@ -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; @@ -1854,15 +1867,15 @@ sub changewarning { if (!defined($message)) { $message='Changes will become active for your current session after [_1], or the next time you log in.'; } - $r->print( -'<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'. -'<form method="post" action="/adm/roles" target="loncapaclient">'. + $r->print("\n\n". +'<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'."\n". +'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'. '<input type="hidden" name="orgurl" value="'.$url. '" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'. &mt($message,' <input type="hidden" name="'. $env{'request.role'}.'" value="1" /><input type="button" value="'. &mt('re-initializing course').'" onClick="reinit(this.form)" />'). -$help{'Caching'}.'</font></h3></form>'); +$help{'Caching'}.'</font></h3></form>'."\n\n"); } # ================================================================ Main Handler @@ -2107,7 +2120,7 @@ function removeres(folderpath,index,oldt } function cutres(folderpath,index,oldtitle,container,pagesymb) { - if (confirm('WARNING: Cutting a resource makes associated grades and scores inaccessible,\\neven if it is pasted in again elsewhere!\\nCut "'+oldtitle+'"?')) { + if (confirm('WARNING: Cutting a resource makes associated grades and scores inaccessible!\\nGrades remain inaccessible if resource is pasted into another folder.\\nCut "'+oldtitle+'"?')) { this.document.forms.renameform.cmd.value='cut_'+index; this.document.forms.renameform.markcopy.value=index; if (container == 'sequence') { @@ -2149,13 +2162,14 @@ 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', 'impo' => 'Import', 'selm' => 'Select Map', 'load' => 'Load Map', + 'reco' => 'Recover Deleted Resources', 'newf' => 'New Folder', 'newp' => 'New Composite Page', 'extr' => 'External Resource', @@ -2246,7 +2260,11 @@ ENDCOURSEVERIFY '.sequence'; my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. '.page'; - + my $container='sequence'; + if ($env{'form.pagepath'}) { + $container='page'; + } + my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; $r->print(<<ENDFORM); <table cellspacing=4 cellpadding=4><tr> <th bgcolor="#DDDDDD">$lt{'uplm'}</th> @@ -2255,7 +2273,7 @@ ENDCOURSEVERIFY </tr> <tr><td bgcolor="#DDDDDD"> $lt{'file'}:<br /> -<form action="/adm/coursedocs" method="post" enctype="multipart/form-data"> +<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data"> <input type="file" name="uploaddoc" size="40"> <br /> $lt{'title'}:<br /> @@ -2279,14 +2297,18 @@ $help{'Importing_LON-CAPA_Resource'} </nobr> <p> <hr /> -$lt{'copm'} -<input type="text" size="20" name="importmap"><br /> +$lt{'copm'}<br /> +<input type="text" size="40" name="importmap"><br /> <nobr><input type=button onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')" value="$lt{'selm'}"> <input type="submit" name="loadmap" value="$lt{'load'}"> $help{'Load_Map'}</nobr> </p> </form> +<hr /> +<form action="/adm/groupsort" method="post" name="recover"> +<input type="button" name="recovermap" onClick="javascript:groupopen('$readfile',1)" value="$lt{'reco'}" /> +</form> ENDFORM unless ($env{'form.pagepath'}) { $r->print(<<ENDFORM); @@ -2395,6 +2417,7 @@ $uploadtag <input name="newaboutsomeone" type="button" value="$lt{'abou'}" onClick="javascript:makeabout();" /> </nobr> +</form> ENDFORM } if ($env{'form.pagepath'}) { @@ -2415,8 +2438,8 @@ $uploadtag onClick="javascript:makeexamupload();" /> $help{'Score_Upload_Form'} </nobr> +</form> ENDBLOCK - $r->print('</form>'); } $r->print('</td></tr>'."\n". '</table>'); @@ -2505,7 +2528,7 @@ ENDSUPFORM } } if ($allowed) { - $r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>'); + $r->print('<form method="POST" name="extimport" action="/adm/coursedocs"><input type="hidden" name="title" /><input type="hidden" name="url" /><input type="hidden" name="useform" /></form>'); } $r->print('</table>'); } else {