--- loncom/interface/londocs.pm 2006/11/29 22:02:47 1.261 +++ loncom/interface/londocs.pm 2007/01/05 19:40:43 1.268 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.261 2006/11/29 22:02:47 www Exp $ +# $Id: londocs.pm,v 1.268 2007/01/05 19:40:43 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,7 @@ use HTML::Entities; use GDBM_File; use Apache::lonlocal; use Cwd; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); my $iconpath; @@ -99,7 +99,7 @@ sub authorhosts { $ca=$env{'user.name'}; $cd=$env{'user.domain'}; } else { - ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/); + ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/); } my $allowed=0; my $myhome=&Apache::lonnet::homeserver($ca,$cd); @@ -366,7 +366,7 @@ sub exportcourse { if (ref($curRes)) { my $symb = $curRes->symb(); my $ressymb = $symb; - if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) { + if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) { unless ($ressymb =~ m|adm/wrapper/adm|) { $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; } @@ -613,7 +613,7 @@ sub build_package { if (grep/^$count$/,@$discussions) { my $ressymb = $symb; my $mode; - if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) { + if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) { unless ($ressymb =~ m|adm/wrapper/adm|) { $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; } @@ -698,7 +698,7 @@ sub process_content { } } elsif ($symb =~ m-lib/templates/examupload\.problem$-) { $content_type = 'examupload'; - } elsif ($symb =~ m-adm/(\w+)/(\w+)/(\d+)/bulletinboard$-) { + } elsif ($symb =~ m-adm/($match_domain)/($match_username)/(\d+)/bulletinboard$-) { $content_type = 'bulletinboard'; my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2); if ($contents) { @@ -913,7 +913,7 @@ sub group_import { while (@_) { my $name = shift; my $url = shift; - if (($url =~ m#^/uploaded/$coursedom/$coursenum/(default_\d+\.)(page|sequence)$#) && ($caller eq 'londocs')) { + if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) && ($caller eq 'londocs')) { my $errtext = ''; my $fatal = 0; my $newmapstr = ''."\n". @@ -936,7 +936,7 @@ sub group_import { my $idx = &LONCAPA::map::getresidx($url); $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; my $ext = 'false'; - if ($url=~/^http:\/\//) { $ext = 'true'; } + if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; } $url =~ s/:/\:/g; $name =~ s/:/\:/g; $LONCAPA::map::resources[$idx] = @@ -988,7 +988,8 @@ sub breadcrumbs { {'href'=>$url.$cpinfo, 'title'=>$name, 'text'=>''. - $name.'' + $name.'', + 'no_mt'=>1, }); $plain.=$name.' > '; } @@ -1309,7 +1310,7 @@ sub editor { $url=~/^(.+)\.(\w+)$/; my $newurl=$1.$newid.'.'.$2; my $storefn=$newurl; - $storefn=~s/^\/\w+\/\w+\/\w+\///; + $storefn=~s{^/\w+/$match_domain/$match_username/}{}; &Apache::lonclonecourse::writefile ($env{'request.course.id'},$storefn, &Apache::lonnet::getfile($url)); @@ -1617,7 +1618,7 @@ sub process_secondary_uploads { $destination .= $newidx; my ($url,$filename); $url=&Apache::lonnet::userfileupload($formname.$num,1,$destination); - ($filename) = ($url =~ m-^/uploaded/$coursedom/$coursenum/$destination/(.+)$-); + ($filename) = ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/\Q$destination\E/(.+)$}); return $filename; } @@ -1632,7 +1633,7 @@ sub entryline { my $foldertitle=$title; my $pagetitle=$title; my $orderidx=$LONCAPA::map::order[$index]; - if ($title=~ /^(\d+)___&&&___(\w+)___&&&___(\w+)___&&&___(.*)$/ ) { + if ($title=~ /^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/ ) { $foldertitle=&Apache::lontexconvert::msgtexconverted($4); $renametitle=$4; $title=''.&Apache::lonlocal::locallocaltime($1).' '. @@ -1694,6 +1695,7 @@ sub entryline { 'rn' => 'Rename', 'cp' => 'Copy'); my $nocopy=0; + my $nocut=0; if ($url=~/\.(page|sequence)$/) { foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) { my ($title,$url,$ext,$type)=split(/\:/,$_); @@ -1703,13 +1705,24 @@ sub entryline { } } } + if ($url=~/^\/res\/lib\/templates\//) { + $nocopy=1; + $nocut=1; + } my $copylink=' '; + my $cutlink=' '; if ($env{'form.pagepath'}) { - unless ($nocopy) { + if (!$nocopy) { $copylink=(< $lt{'cp'} ENDCOPY + } + if (!$nocut) { + $cutlink=(< +$lt{'ct'} +ENDCUT } $line.=(< @@ -1731,19 +1744,24 @@ ENDCOPY $lt{'rm'} - -$lt{'ct'} +$cutlink $lt{'rn'} $copylink END } else { - unless ($nocopy) { + if (!$nocopy) { $copylink=(< $lt{'cp'} ENDCOPY } + if (!$nocut) { + $cutlink=(< +$lt{'ct'} +ENDCUT + } $line.=(< @@ -1763,8 +1781,7 @@ ENDCOPY $lt{'rm'} - -$lt{'ct'} +$cutlink $lt{'rn'} $copylink @@ -1783,13 +1800,13 @@ END if ($uploaded) { if ($extension eq 'sequence') { $icon=$iconpath.'/folder_closed.gif'; - $url=~/$coursenum\/([\/\w]+)\.sequence$/; + $url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/; $url='/adm/coursedocs?'; $folderarg=$1; $isfolder=1; } elsif ($extension eq 'page') { $icon=$iconpath.'/page.gif'; - $url=~/$coursenum\/([\/\w]+)\.page$/; + $url=~/\Q$coursenum\E\/([\/\w]+)\.page$/; $pagearg=$1; $url='/adm/coursedocs?'; $ispage=1; @@ -2490,7 +2507,8 @@ sub handler { my %codebase = (); my ($upload_result,$upload_output); if ($allowed) { - if (($env{'form.uploaddoc.filename'}) && ($env{'form.cmd'}=~/^upload_(\w+)/)) { + if (($env{'form.uploaddoc.filename'}) && + ($env{'form.cmd'}=~/^upload_(\w+)/)) { # Process file upload - phase one - upload and parse primary file. $upload_result = &process_file_upload(\$upload_output,$coursenum, $coursedom,\%allfiles,