--- loncom/interface/londocs.pm 2004/12/23 16:31:27 1.159 +++ loncom/interface/londocs.pm 2005/04/22 18:21:05 1.176 @@ -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.176 2005/04/22 18:21:05 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -86,17 +86,17 @@ sub authorhosts { my %outhash=(); my $home=0; my $other=0; - foreach (keys %ENV) { + foreach (keys %env) { if ($_=~/^user\.role\.(au|ca)\.(.+)$/) { my $role=$1; my $realm=$2; - my ($start,$end)=split(/\./,$ENV{$_}); + my ($start,$end)=split(/\./,$env{$_}); if (($start) && ($start>time)) { next; } if (($end) && (time>$end)) { next; } my $ca; my $cd; if ($1 eq 'au') { - $ca=$ENV{'user.name'}; - $cd=$ENV{'user.domain'}; + $ca=$env{'user.name'}; + $cd=$env{'user.domain'}; } else { ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/); } @@ -132,35 +132,41 @@ sub dumpbutton { } } +sub clean { + my ($title)=@_; + $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs; + return $title; +} # -------------------------------------------------------- Actually dump course sub dumpcourse { my $r=shift; - $r->print('Dump DOCS'. + my $html=&Apache::lonxml::xmlbegin(); + $r->print($html.'Dump DOCS'. &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space'). '
'); my ($home,$other,%outhash)=&authorhosts(); unless ($home) { return ''; } - my $origcrsid=$ENV{'request.course.id'}; + my $origcrsid=$env{'request.course.id'}; my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid); - if (($ENV{'form.authorspace'}) && ($ENV{'form.authorfolder'}=~/\w/)) { + if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) { # Do the dumping - unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; } - my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'}); + unless ($outhash{'home_'.$env{'form.authorspace'}}) { return ''; } + my ($ca,$cd)=split(/\@/,$env{'form.authorspace'}); $r->print('

'.&mt('Copying Files').'

'); - my $title=$ENV{'form.authorfolder'}; - $title=~s/[^\w\/]+/\_/g; + my $title=$env{'form.authorfolder'}; + $title=&clean($title); my %replacehash=(); - foreach (keys %ENV) { + foreach (keys %env) { if ($_=~/^form\.namefor\_(.+)/) { - $replacehash{$1}=$ENV{$_}; + $replacehash{$1}=$env{$_}; } } - my $crs='/uploaded/'.$ENV{'request.course.id'}.'/'; + my $crs='/uploaded/'.$env{'request.course.id'}.'/'; $crs=~s/\_/\//g; foreach (keys %replacehash) { my $newfilename=$title.'/'.$replacehash{$_}; - $newfilename=~s/[^\w\/\.\/]+/\_/g; + $newfilename=&clean($newfilename); my @dirs=split(/\//,$newfilename); my $path='/home/'.$ca.'/public_html'; my $makepath=$path; @@ -175,12 +181,12 @@ sub dumpcourse { if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) { print $fh &Apache::loncreatecourse::rewritefile( - &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_), + &Apache::loncreatecourse::readfile($env{'request.course.id'},$_), (%replacehash,$crs => '') ); } else { print $fh - &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_); + &Apache::loncreatecourse::readfile($env{'request.course.id'},$_); } $fh->close(); } else { @@ -214,7 +220,7 @@ sub dumpcourse { } my $title=$origcrsdata{'description'}; $title=~s/\s+/\_/gs; - $title=~s/\W//gs; + $title=&clean($title); $r->print('

'.&mt('Folder in Construction Space').'


'); &tiehash(); $r->print('

'.&mt('Filenames in Construction Space').'

'); @@ -223,12 +229,13 @@ sub dumpcourse { my ($ext)=($_=~/\.(\w+)$/); my $title=$hash{'title_'.$hash{ 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}}; + $title=~s/:/:/g; $r->print(''); unless ($title) { $title=$_; } $title=~s/\.(\w+)$//; - $title=~s/[^\w\/]+/\_/gs; + $title=&clean($title); $title.='.'.$ext; $r->print("\n\n"); } @@ -242,6 +249,7 @@ sub dumpcourse { # ------------------------------------------------------ Generate "export" button sub exportbutton { + return ''; return ''); } - $r->print('
'.&mt('Internal Filename').''.&mt('Title').''.&mt('Save as ...').'
'.($title?$title:' ').'
'. ''. @@ -251,7 +259,7 @@ sub exportbutton { sub exportcourse { my $r=shift; my %discussiontime = &Apache::lonnet::dump('discussiontimes', - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); my $numdisc = keys %discussiontime; my $navmap = Apache::lonnavmaps::navmap->new(); my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); @@ -260,26 +268,12 @@ sub exportcourse { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['finishexport']); - if ($ENV{'form.finishexport'}) { + if ($env{'form.finishexport'}) { &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 { @@ -296,20 +290,14 @@ sub exportcourse { #Create zip file in prtspool my $imszipfile = '/prtspool/'. - $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. + $env{'user.name'}.'_'.$env{'user.domain'}.'_'. time.'_'.rand(1000000000).'.zip'; -# zip can cause an sh launch which can pass along all of %ENV -# which can be too large for /bin/sh to handle - my %oldENV=%ENV; - undef(%ENV); my $cwd = &Cwd::getcwd(); my $imszip = '/home/httpd/'.$imszipfile; chdir $tempexport; open(OUTPUT, "zip -r $imszip * 2> /dev/null |"); close(OUTPUT); chdir $cwd; - %ENV=%oldENV; - undef(%oldENV); $outcome .= 'Download the zip file from IMS course archive
'; if ($copyresult) { $outcome .= 'The following errors occurred during export - '.$copyresult; @@ -318,8 +306,8 @@ sub exportcourse { $outcome = '
Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.
'; } } - - $r->print('Export Course'. + my $html=&Apache::lonxml::xmlbegin(); + $r->print($html.'Export Course'. &Apache::loncommon::bodytag('Export course to IMS content package')); $r->print($outcome); $r->print(''); @@ -460,7 +448,8 @@ function containerCheck(item) { |; - $r->print('Export Course'.$scripttag.''. + my $html=&Apache::lonxml::xmlbegin(); + $r->print($html.'Export Course'.$scripttag.''. &Apache::loncommon::bodytag('Export course to IMS content package' )); @@ -482,7 +471,7 @@ sub create_ims_store { if (!-e $$tempexport) { mkdir($$tempexport,0700); } - $$tempexport .= '/'.$ENV{'user.domain'}.'_'.$ENV{'user.name'}; + $$tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'}; if (!-e $$tempexport) { mkdir($$tempexport,0700); } @@ -499,13 +488,13 @@ sub create_ims_store { ''."\n". -' '."\n". -' '."\n". +' '."\n". -' '.$ENV{'request.'.$ENV{'request.course.id'}.'.description'}.'' +' '.$env{'request.'.$env{'request.course.id'}.'.description'}.'' } else { $$outcome .= 'An error occurred opening the IMS manifest file.
' ; @@ -523,8 +512,8 @@ sub build_package { my $lastcontainer = 0; my %parent = (); my @dependencies = (); - my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; - my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; while ($curRes = $it->next()) { if (ref($curRes)) { $count ++; @@ -574,7 +563,7 @@ sub build_package { $isvisible = 'false'; } unless ($curRes->is_sequence()) { - $resourceref = 'identifierref="RES-'.$ENV{'request.course.id'}.'-'.$count.'"'; + $resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"'; } if (($depth <= $prevdepth) && ($count > 1) && ($included)) { print $ims_manifest "\n".' '."\n"; @@ -583,7 +572,7 @@ sub build_package { $prevdepth = $depth; my $itementry = - ''. ''.$curRes->title().''; print $ims_manifest "\n".$itementry; @@ -594,7 +583,7 @@ sub build_package { &process_content($count,$curRes,$cdom,$cnum,$symb,\$content_file,\@hrefs,$copyresult,$tempexport); if ($content_file) { $imsresources .= "\n". - ' '."\n". ' '."\n"; foreach (@hrefs) { @@ -658,7 +647,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 +693,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'}) { + 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 +748,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 +765,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; @@ -856,7 +839,7 @@ sub group_import { ''."\n". ''."\n". ''; - $ENV{'form.output'}=$newmapstr; + $env{'form.output'}=$newmapstr; my $home=&Apache::lonnet::homeserver($coursenum,$coursedom); my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$home, 'output',$1.$2); @@ -886,12 +869,20 @@ sub breadcrumbs { my ($where)=@_; &Apache::lonhtmlcommon::clear_breadcrumbs(); my (@folders); - if ($ENV{'form.pagepath'}) { - @folders = split('&',$ENV{'form.pagepath'}); + if ($env{'form.pagepath'}) { + @folders = split('&',$env{'form.pagepath'}); } else { - @folders=split('&',$ENV{'form.folderpath'}); + @folders=split('&',$env{'form.folderpath'}); } my $folderpath; + my $cpinfo=''; + if ($env{'form.markedcopy_url'}) { + &Apache::lonnet::logthis('Found '.$env{'form.markedcopy_url'}); + $cpinfo='&markedcopy_url='. + &Apache::lonnet::escape($env{'form.markedcopy_url'}). + '&markedcopy_title='. + &Apache::lonnet::escape($env{'form.markedcopy_title'}); + } while (@folders) { my $folder=shift(@folders); my $foldername=shift(@folders); @@ -900,7 +891,7 @@ sub breadcrumbs { my $url='/adm/coursedocs?folderpath='. &Apache::lonnet::escape($folderpath); &Apache::lonhtmlcommon::add_breadcrumb( - {'href'=>$url, + {'href'=>$url.$cpinfo, 'title'=>&Apache::lonnet::unescape($foldername), 'text'=>''. &Apache::lonnet::unescape($foldername).'' @@ -914,12 +905,10 @@ sub breadcrumbs { sub editor { my ($r,$coursenum,$coursedom,$folder,$allowed)=@_; - - $r->print(&breadcrumbs($folder)); my $errtext=''; my $fatal=0; my $container='sequence'; - if ($ENV{'form.pagepath'}) { + if ($env{'form.pagepath'}) { $container='page'; } ($errtext,$fatal)= @@ -928,38 +917,45 @@ sub editor { $Apache::lonratedt::order[0]=1; $Apache::lonratedt::resources[1]=''; } + if (defined($env{'form.markcopy'})) { +# Mark for copying + my ($title,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$env{'form.markcopy'}]]); + $env{'form.markedcopy_title'}=$title; + $env{'form.markedcopy_url'}=$url; + } + $r->print(&breadcrumbs($folder)); if ($fatal) { $r->print('

'.$errtext.'

'); } else { # ------------------------------------------------------------ Process commands # ---------------- if they are for this folder and user allowed to make changes - if (($allowed) && ($ENV{'form.folder'} eq $folder)) { + if (($allowed) && ($env{'form.folder'} eq $folder)) { # set parameters and change order - if (defined($ENV{'form.setparms'})) { - my $idx=$ENV{'form.setparms'}; + if (defined($env{'form.setparms'})) { + my $idx=$env{'form.setparms'}; # set parameters - if ($ENV{'form.randpick_'.$idx}) { - &Apache::lonratedt::storeparameter($idx,'parameter_randompick',$ENV{'form.randpick_'.$idx},'int_pos'); + if ($env{'form.randpick_'.$idx}) { + &Apache::lonratedt::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos'); } else { &Apache::lonratedt::delparameter($idx,'parameter_randompick'); } - if ($ENV{'form.hidprs_'.$idx}) { + if ($env{'form.hidprs_'.$idx}) { &Apache::lonratedt::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno'); } else { &Apache::lonratedt::delparameter($idx,'parameter_hiddenresource'); } - if ($ENV{'form.encprs_'.$idx}) { + if ($env{'form.encprs_'.$idx}) { &Apache::lonratedt::storeparameter($idx,'parameter_encrypturl','yes','string_yesno'); } else { &Apache::lonratedt::delparameter($idx,'parameter_encrypturl'); } - if ($ENV{'form.newpos'}) { + if ($env{'form.newpos'}) { # change order - my $newpos=$ENV{'form.newpos'}-1; - my $currentpos=$ENV{'form.currentpos'}-1; + my $newpos=$env{'form.newpos'}-1; + my $currentpos=$env{'form.currentpos'}-1; my $i; my @neworder=(); if ($newpos>$currentpos) { @@ -998,26 +994,61 @@ sub editor { } } + if ($env{'form.pastemarked'}) { +# paste resource to end of list + my $url=$env{'form.markedcopy_url'}; + my $title=$env{'form.markedcopy_title'}; +# Maps need to be copied first + if (($url=~/\.(page|sequence)$/) || ($url=~/^\/uploaded\//)) { + $title=&mt('Copy of').' '.$title; + my $newid=$$.time; + $url=~/^(.+)\.(\w+)$/; + my $newurl=$1.$newid.'.'.$2; + my $storefn=$newurl; + $storefn=~s/^\/\w+\/\w+\/\w+\///; + &Apache::loncreatecourse::writefile + ($env{'request.course.id'},$storefn, + &Apache::lonnet::getfile($url)); + $url=$newurl; + } + $title=~s/\/\>\;/g; + $title=~s/\:/\:/g; + my $ext='false'; + if ($url=~/^http\:\/\//) { $ext='true'; } + $url=~s/\:/\:/g; +# Now insert the URL at the bottom + my $newidx=1+$#Apache::lonratedt::resources; + $Apache::lonratedt::resources[$newidx]= + $title.':'.$url.':'.$ext.':normal:res'; + $Apache::lonratedt::order[1+$#Apache::lonratedt::order]=$newidx; +# Store the result + ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); + if ($fatal) { + $r->print('

'.$errtext.'

'); + return; + } + } # upload a file, if present - if (($ENV{'form.uploaddoc.filename'}) && - ($ENV{'form.cmd'}=~/^upload_(\w+)/)) { + if (($env{'form.uploaddoc.filename'}) && + ($env{'form.cmd'}=~/^upload_(\w+)/)) { if ( ($folder=~/^$1/) || ($1 eq 'default') ) { # 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 $url=&Apache::lonnet::userfileupload('uploaddoc',1,'docs'); + my $newidx=$#Apache::lonratedt::resources+1; + my $url=&Apache::lonnet::userfileupload('uploaddoc',1,'docs/'.$newidx); my $ext='false'; if ($url=~/^http\:\/\//) { $ext='true'; } $url=~s/\:/\:/g; - my $comment=$ENV{'form.comment'}; + my $comment=$env{'form.comment'}; $comment=~s/\/\>\;/g; $comment=~s/\:/\:/g; if ($folder=~/^supplemental/) { - $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'. - $ENV{'user.domain'}.'___&&&___'.$comment; + $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'. + $env{'user.domain'}.'___&&&___'.$comment; } - my $newidx=$#Apache::lonratedt::resources+1; $Apache::lonratedt::resources[$newidx]= $comment.':'.$url.':'.$ext.':normal:res'; $Apache::lonratedt::order[$#Apache::lonratedt::order+1]= @@ -1030,8 +1061,8 @@ sub editor { } } } - if ($ENV{'form.cmd'}) { - my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'}); + if ($env{'form.cmd'}) { + 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/|) { @@ -1042,6 +1073,13 @@ sub editor { $Apache::lonratedt::order[$i+1]; } $#Apache::lonratedt::order--; + } elsif ($cmd eq 'cut') { + my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]); + for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) { + $Apache::lonratedt::order[$i]= + $Apache::lonratedt::order[$i+1]; + } + $#Apache::lonratedt::order--; } elsif ($cmd eq 'up') { if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) { my $i=$Apache::lonratedt::order[$idx-1]; @@ -1062,7 +1100,7 @@ sub editor { $Apache::lonratedt::resources[ $Apache::lonratedt::order[$idx]]); my $comment= - &HTML::Entities::decode($ENV{'form.title'}); + &HTML::Entities::decode($env{'form.title'}); $comment=~s/\/\>\;/g; $comment=~s/\:/\:/g; @@ -1081,9 +1119,9 @@ sub editor { } } # Group import/search - if ($ENV{'form.importdetail'}) { + if ($env{'form.importdetail'}) { my @imports; - foreach (split(/\&/,$ENV{'form.importdetail'})) { + foreach (split(/\&/,$env{'form.importdetail'})) { if (defined($_)) { my ($name,$url)=split(/\=/,$_); $name=&Apache::lonnet::unescape($name); @@ -1100,8 +1138,8 @@ sub editor { } } # Loading a complete map - if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) { - foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) { + if (($env{'form.importmap'}) && ($env{'form.loadmap'})) { + foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { my $idx=$#Apache::lonratedt::resources; $idx++; $Apache::lonratedt::resources[$idx]=$_; @@ -1134,7 +1172,30 @@ sub editor { unless ($shown) { $r->print('
'.&mt('Currently no documents.').'
'); + $r->print("\n\n"); + if ($env{'form.markedcopy_url'}) { + $r->print(< + + +ENDPASTE + $r->print( + ' '.&Apache::loncommon::filedescription( + (split(/\./,$env{'form.markedcopy_url'}))[-1]).': '. + $env{'form.markedcopy_title'}); + if ($container eq 'page') { + $r->print(< + +PAGEINFO + } else { + $r->print(< +FOLDERINFO + } + $r->print('

'); + } } } @@ -1161,21 +1222,35 @@ sub entryline { # Edit commands my $container; my $folderpath; - if ($ENV{'form.folderpath'}) { + if ($env{'form.folderpath'}) { $container = 'sequence'; - $folderpath=&Apache::lonnet::escape($ENV{'form.folderpath'}); - # $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"'); + $folderpath=&Apache::lonnet::escape($env{'form.folderpath'}); + # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"'); } my ($pagepath,$pagesymb); - if ($ENV{'form.pagepath'}) { + if ($env{'form.pagepath'}) { $container = 'page'; - $pagepath=&Apache::lonnet::escape($ENV{'form.pagepath'}); - $pagesymb=&Apache::lonnet::escape($ENV{'form.pagesymb'}); + $pagepath=&Apache::lonnet::escape($env{'form.pagepath'}); + $pagesymb=&Apache::lonnet::escape($env{'form.pagesymb'}); + } + my $cpinfo=''; + if ($env{'form.markedcopy_url'}) { + $cpinfo='&markedcopy_url='. + &Apache::lonnet::escape($env{'form.markedcopy_url'}). + '&markedcopy_title='. + &Apache::lonnet::escape($env{'form.markedcopy_title'}); } if ($allowed) { my $incindex=$index+1; my $selectbox=''; - if ($folder!~/^supplemental/) { + if (($folder!~/^supplemental/) && + ($#Apache::lonratedt::order>0) && + ((split(/\:/, + $Apache::lonratedt::resources[$Apache::lonratedt::order[0]]))[1] + ne '') && + ((split(/\:/, + $Apache::lonratedt::resources[$Apache::lonratedt::order[1]]))[1] + ne '')) { $selectbox= ''. ' - + + + +
- + $lt{
- + $lt{
$selectbox $lt{'rm'} + +$lt{'ct'} -$lt{'rn'} +$lt{'rn'} + +$lt{'cp'} END } else { $line.=(< - + + +
- + $lt{
- + $lt{
$selectbox $lt{'rm'} + +$lt{'ct'} -$lt{'rn'} +$lt{'rn'} + +$lt{'cp'} END } } @@ -1266,8 +1355,8 @@ END if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) { my $symb=&Apache::lonnet::symbclean( &Apache::lonnet::declutter('uploaded/'. - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'. - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'.$folder. + $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. + $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder. '.sequence'). '___'.$residx.'___'. &Apache::lonnet::declutter($url)); @@ -1288,7 +1377,7 @@ END } $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb); if ($container eq 'page') { - my $symb=$ENV{'form.pagesymb'}; + my $symb=$env{'form.pagesymb'}; $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]); $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb); @@ -1297,34 +1386,35 @@ END my $parameterset=' '; if ($isfolder) { my $foldername=&Apache::lonnet::escape($foldertitle); - my $folderpath=$ENV{'form.folderpath'}; + my $folderpath=$env{'form.folderpath'}; if ($folderpath) { $folderpath.='&' }; $folderpath.=$folderarg.'&'.$foldername; - $url.='folderpath='.&Apache::lonnet::escape($folderpath); + $url.='folderpath='.&Apache::lonnet::escape($folderpath).$cpinfo; $parameterset=''; + '" />'. +''.&mt('Store').''; } if ($ispage) { my $pagename=&Apache::lonnet::escape($pagetitle); my $pagepath; - my $folderpath=$ENV{'form.folderpath'}; + my $folderpath=$env{'form.folderpath'}; if ($folderpath) { $pagepath = $folderpath.'&' }; $pagepath.=$pagearg.'&'.$pagename; - my $symb=$ENV{'form.pagesymb'}; + my $symb=$env{'form.pagesymb'}; if (!$symb) { my $path='uploaded/'. - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'. - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'; + $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. + $env{'course.'.$env{'request.course.id'}.'.num'}.'/'; $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence', $residx, $path.$pagearg.'.page'); } $url.='pagepath='.&Apache::lonnet::escape($pagepath). - '&pagesymb='.&Apache::lonnet::escape($symb); + '&pagesymb='.&Apache::lonnet::escape($symb).$cpinfo; } $line.=''. @@ -1332,21 +1422,17 @@ END if (($allowed) && ($folder!~/^supplemental/)) { my %lt=&Apache::lonlocal::texthash( 'hd' => 'Hidden', - 'ec' => 'URL hidden', - 'sp' => 'Store Parameters'); + 'ec' => 'URL hidden'); my $enctext= ((&Apache::lonratedt::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':''); my $hidtext= ((&Apache::lonratedt::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':''); $line.=(< - + - + $parameterset - - - ENDPARMS } $line.=""; @@ -1358,14 +1444,14 @@ ENDPARMS sub tiehash { my ($mode)=@_; $hashtied=0; - if ($ENV{'request.course.fn'}) { + if ($env{'request.course.fn'}) { if ($mode eq 'write') { - if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db", + if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", &GDBM_WRCREAT(),0640)) { $hashtied=2; } } else { - if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db", + if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", &GDBM_READER(),0640)) { $hashtied=1; } @@ -1395,7 +1481,7 @@ sub checkonthis { if ($url=~/^\/res\//) { my $result=&Apache::lonnet::repcopy( &Apache::lonnet::filelocation('',$url)); - if ($result==OK) { + if ($result eq 'ok') { $r->print(''.&mt('ok').''); $r->rflush(); &Apache::lonnet::countacc($url); @@ -1407,23 +1493,20 @@ sub checkonthis { $r->print(' '); } $r->print('- '.&mt('Rendering').': '); - my $oldpath=$ENV{'request.filename'}; - $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url); - &Apache::lonxml::xmlparse($r,'web', - &Apache::lonnet::getfile( - &Apache::lonnet::filelocation('',$url))); - undef($Apache::lonhomework::parsing_a_problem); - $ENV{'request.filename'}=$oldpath; - if (($Apache::lonxml::errorcount) || - ($Apache::lonxml::warningcount)) { - if ($Apache::lonxml::errorcount) { + my ($errorcount,$warningcount)=split(/:/, + &Apache::lonnet::ssi_body($url, + ('grade_target'=>'web', + 'return_only_error_and_warning_counts' => 1))); + if (($errorcount) || + ($warningcount)) { + if ($errorcount) { $r->print(''. - $Apache::lonxml::errorcount.' '. + $errorcount.' '. &mt('error(s)').' '); } - if ($Apache::lonxml::warningcount) { + if ($warningcount) { $r->print(''. - $Apache::lonxml::warningcount.' '. + $warningcount.' '. &mt('warning(s)').''); } } else { @@ -1438,9 +1521,9 @@ sub checkonthis { &checkonthis($r,$_,$level+1); } } - } elsif ($result==HTTP_SERVICE_UNAVAILABLE) { + } elsif ($result eq 'unavailable') { $r->print(''.&mt('connection down').''); - } elsif ($result==HTTP_NOT_FOUND) { + } elsif ($result eq 'not_found') { unless ($url=~/\$/) { $r->print(''.&mt('not found').''); } else { @@ -1461,8 +1544,8 @@ sub verifycontent { my $r=shift; my $loaderror=&Apache::lonnet::overloaderror($r); if ($loaderror) { return $loaderror; } - - $r->print('Verify Content'. + my $html=&Apache::lonxml::xmlbegin(); + $r->print($html.'Verify Content'. &Apache::loncommon::bodytag('Verify Course Documents')); $hashtied=0; undef %alreadyseen; @@ -1490,7 +1573,8 @@ sub verifycontent { sub checkversions { my $r=shift; - $r->print('Check Versions'. + my $html=&Apache::lonxml::xmlbegin(); + $r->print($html.'Check Versions'. &Apache::loncommon::bodytag('Check Course Document Versions')); my $header=''; my $startsel=''; @@ -1502,20 +1586,20 @@ sub checkversions { my $starttime=0; my $haschanged=0; my %setversions=&Apache::lonnet::dump('resourceversions', - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + $env{'course.'.$env{'request.course.id'}.'.domain'}, + $env{'course.'.$env{'request.course.id'}.'.num'}); $hashtied=0; &tiehash(); my %newsetversions=(); - if ($ENV{'form.setmostrecent'}) { + if ($env{'form.setmostrecent'}) { $haschanged=1; foreach (keys %hash) { if ($_=~/^ids\_(\/res\/.+)$/) { $newsetversions{$1}='mostrecent'; } } - } elsif ($ENV{'form.setcurrent'}) { + } elsif ($env{'form.setcurrent'}) { $haschanged=1; foreach (keys %hash) { if ($_=~/^ids\_(\/res\/.+)$/) { @@ -1525,21 +1609,21 @@ sub checkversions { } } } - } elsif ($ENV{'form.setversions'}) { + } elsif ($env{'form.setversions'}) { $haschanged=1; - foreach (keys %ENV) { + foreach (keys %env) { if ($_=~/^form\.set_version_(.+)$/) { my $src=$1; - if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) { - $newsetversions{$src}=$ENV{$_}; + if (($env{$_}) && ($env{$_} ne $setversions{$src})) { + $newsetversions{$src}=$env{$_}; } } } } if ($haschanged) { if (&Apache::lonnet::put('resourceversions',\%newsetversions, - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}) eq 'ok') { + $env{'course.'.$env{'request.course.id'}.'.domain'}, + $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { $r->print('

'.&mt('Your Version Settings have been Stored').'

'); } else { $r->print('

'.&mt('An Error Occured while Attempting to Store your Version Settings').'

'); @@ -1547,7 +1631,7 @@ sub checkversions { &mark_hash_old(); } &changewarning($r,''); - if ($ENV{'form.timerange'} eq 'all') { + if ($env{'form.timerange'} eq 'all') { # show all documents $header=&mt('All Documents in Course'); $allsel=1; @@ -1560,28 +1644,28 @@ sub checkversions { } else { # show documents which changed %changes=&Apache::lonnet::dump - ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'}, + $env{'course.'.$env{'request.course.id'}.'.num'}); my $firstkey=(keys %changes)[0]; unless ($firstkey=~/^error\:/) { - unless ($ENV{'form.timerange'}) { - $ENV{'form.timerange'}=604800; + unless ($env{'form.timerange'}) { + $env{'form.timerange'}=604800; } - my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' ' + my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' ' .&mt('seconds'); - if ($ENV{'form.timerange'}==-1) { + if ($env{'form.timerange'}==-1) { $seltext='since start of course'; $startsel='selected'; - $ENV{'form.timerange'}=time; + $env{'form.timerange'}=time; } - $starttime=time-$ENV{'form.timerange'}; - if ($ENV{'form.timerange'}==2592000) { + $starttime=time-$env{'form.timerange'}; + if ($env{'form.timerange'}==2592000) { $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; $monthsel='selected'; - } elsif ($ENV{'form.timerange'}==604800) { + } elsif ($env{'form.timerange'}==604800) { $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; $weeksel='selected'; - } elsif ($ENV{'form.timerange'}==86400) { + } elsif ($env{'form.timerange'}==86400) { $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; $daysel='selected'; } @@ -1591,8 +1675,8 @@ sub checkversions { } } %setversions=&Apache::lonnet::dump('resourceversions', - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + $env{'course.'.$env{'request.course.id'}.'.domain'}, + $env{'course.'.$env{'request.course.id'}.'.num'}); my %lt=&Apache::lonlocal::texthash ('st' => 'Version changes since start of Course', 'lm' => 'Version changes since last Month', @@ -1756,11 +1840,11 @@ sub changewarning { my ($r,$postexec)=@_; if (!&is_hash_old()) { return; } my $pathvar='folderpath'; - my $path=&Apache::lonnet::escape($ENV{'form.folderpath'}); - if (defined($ENV{'form.pagepath'})) { + 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'}); + $path=&Apache::lonnet::escape($env{'form.pagepath'}); + $path.='&symb='.&Apache::lonnet::escape($env{'form.pagesymb'}); } $r->print( ''. @@ -1770,7 +1854,7 @@ $pathvar.'='.$path. '" />

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

'); } @@ -1804,18 +1888,18 @@ sub handler { 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages'); $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); - if ($ENV{'form.verify'}) { + if ($env{'form.verify'}) { &verifycontent($r); - } elsif ($ENV{'form.versions'}) { + } elsif ($env{'form.versions'}) { &checkversions($r); - } elsif ($ENV{'form.dumpcourse'}) { + } elsif ($env{'form.dumpcourse'}) { &dumpcourse($r); - } elsif ($ENV{'form.exportcourse'}) { + } elsif ($env{'form.exportcourse'}) { &exportcourse($r); } else { # is this a standard course? - my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//); + my $standard=($env{'request.course.uri'}=~/^\/uploaded\//); my $forcestandard = 0; my $forcesupplement; my $script=''; @@ -1825,33 +1909,33 @@ sub handler { my $containertag; my $uploadtag; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['folderpath','pagepath','pagesymb']); - if ($ENV{'form.folderpath'}) { - my (@folderpath)=split('&',$ENV{'form.folderpath'}); - $ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath)); - $ENV{'form.folder'}=pop(@folderpath); - } - if ($ENV{'form.pagepath'}) { - my (@pagepath)=split('&',$ENV{'form.pagepath'}); - $ENV{'form.pagename'}=&Apache::lonnet::unescape(pop(@pagepath)); - $ENV{'form.folder'}=pop(@pagepath); + ['folderpath','pagepath','pagesymb','markedcopy_url','markedcopy_title']); + if ($env{'form.folderpath'}) { + my (@folderpath)=split('&',$env{'form.folderpath'}); + $env{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath)); + $env{'form.folder'}=pop(@folderpath); + } + if ($env{'form.pagepath'}) { + my (@pagepath)=split('&',$env{'form.pagepath'}); + $env{'form.pagename'}=&Apache::lonnet::unescape(pop(@pagepath)); + $env{'form.folder'}=pop(@pagepath); $containertag = ''. ''; - $uploadtag = ''. - ''; + $uploadtag = ''. + ''; } if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) { $showdoc='/'.$1; } unless ($showdoc) { # got called from remote - if (($ENV{'form.folder'}=~/^default_/) || - ($ENV{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) { + if (($env{'form.folder'}=~/^default_/) || + ($env{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) { $forcestandard = 1; } - $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/); + $forcesupplement=($env{'form.folder'}=~/^supplemental_/); # does this user have privileges to post, etc? - $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'}); + $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); if ($allowed) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']); $script=&Apache::lonratedt::editscript('simple'); @@ -1864,25 +1948,26 @@ sub handler { } # get course data - my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; - my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; + my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; + my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; # get personal data - my $uname=$ENV{'user.name'}; - my $udom=$ENV{'user.domain'}; + my $uname=$env{'user.name'}; + my $udom=$env{'user.domain'}; my $plainname=&Apache::lonnet::escape( &Apache::loncommon::plainname($uname,$udom)); # graphics settings - $iconpath = $r->dir_config('lonIconsURL') . "/"; + $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/"); my $now=time; # print screen + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html The LearningOnline Network with CAPA ENDNEWSCRIPT @@ -2025,7 +2141,9 @@ ENDNEWSCRIPT my %lt=&Apache::lonlocal::texthash( 'uplm' => 'Upload a new main course document', 'upls' => 'Upload a new supplemental course document', - 'impp' => 'Import a published document', + 'impp' => 'Import a document', + 'pubd' => 'Published documents', + 'copm' => 'All documents out of a published map', 'spec' => 'Special documents', 'upld' => 'Upload Document', 'srch' => 'Search', @@ -2057,15 +2175,15 @@ ENDNEWSCRIPT 'cv' => 'Check/Set Resource Versions', ); - my $folderpath=$ENV{'form.folderpath'}; + my $folderpath=$env{'form.folderpath'}; if (!$folderpath) { - if ($ENV{'form.folder'} eq '' || - $ENV{'form.folder'} eq 'supplemental') { + if ($env{'form.folder'} eq '' || + $env{'form.folder'} eq 'supplemental') { $folderpath='default&'. &Apache::lonnet::escape(&mt('Main Course Documents')); } } - unless ($ENV{'form.pagepath'}) { + unless ($env{'form.pagepath'}) { $containertag = ''; $uploadtag = ''; } @@ -2074,6 +2192,7 @@ ENDNEWSCRIPT
+ $containertag
@@ -2100,10 +2219,10 @@ ENDCOURSEVERIFY $r->print(''); # '

'.&mt('Main Course Documents'). # ($allowed?' '.$help{'Main_Course_Documents'}:'').'

'); - my $folder=$ENV{'form.folder'}; + my $folder=$env{'form.folder'}; if ($folder eq '' || $folder eq 'supplemental') { $folder='default'; - $ENV{'form.folderpath'}='default&'.&Apache::lonnet::escape(&mt('Main Course Documents')); + $env{'form.folderpath'}='default&'.&Apache::lonnet::escape(&mt('Main Course Documents')); } my $postexec=''; if ($folder eq 'default') { @@ -2145,6 +2264,7 @@ $uploadtag +$lt{'pubd'}
$uploadtag @@ -2153,6 +2273,7 @@ $help{'Importing_LON-CAPA_Resource'}


+$lt{'copm'}
ENDFORM - unless ($ENV{'form.pagepath'}) { + unless ($env{'form.pagepath'}) { + $r->print(< + +$uploadtag + + + $help{'Adding_External_Resource'} + +
+
+ + + +
+ENDFORM + } + $r->print(''); + unless ($env{'form.pagepath'}) { $r->print(< - + $help{'Adding_Fold
- + $help{'Adding_Pages'}
-
-$uploadtag - - - $help{'Adding_External_Resource'} - -
$uploadtag ENDFORM } - if ($ENV{'form.pagepath'}) { + if ($env{'form.pagepath'}) { $r->print(< $uploadtag @@ -2279,17 +2409,8 @@ $uploadtag onClick="javascript:makeexamupload();" /> $help{'Score_Upload_Form'} - ENDBLOCK - } else { - $r->print(< -
- - - -
-ENDFORM + $r->print(''); } $r->print(''."\n". ''); @@ -2300,13 +2421,13 @@ ENDFORM $r->print(''); # '

'.&mt('Supplemental Course Documents'). # ($allowed?' '.$help{'Supplemental'}:'').'

'); - my $folder=$ENV{'form.folder'}; + my $folder=$env{'form.folder'}; unless ($folder=~/^supplemental/) { $folder='supplemental'; } if ($folder =~ /^supplemental$/ && - $ENV{'form.folderpath'} =~ /^default\&/) { - $ENV{'form.folderpath'}='supplemental&'. + $env{'form.folderpath'} =~ /^default\&/) { + $env{'form.folderpath'}='supplemental&'. &Apache::lonnet::escape(&mt('Supplemental Course Documents')); } &editor($r,$coursenum,$coursedom,$folder,$allowed); @@ -2327,7 +2448,7 @@ ENDFORM
- + @@ -2337,7 +2458,7 @@ ENDFORM
- + $help{'Adding_Fol
- + $help{'Adding_Ext
- + @@ -2364,7 +2485,7 @@ $help{'Syllabus'}
- +