'.
'';
+ &mt('Dump Course DOCS to Construction Space').'" />'.
+ &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs');
} else {
return'
'.
&mt('Dump Course DOCS to Construction Space: available on other servers');
@@ -156,7 +157,7 @@ sub dumpcourse {
$crs=~s/\_/\//g;
foreach (keys %replacehash) {
my $newfilename=$title.'/'.$replacehash{$_};
- $newfilename=~s/[^\w\/\.]+/\_/g;
+ $newfilename=~s/[^\w\/\.\/]+/\_/g;
my @dirs=split(/\//,$newfilename);
my $path='/home/'.$ca.'/public_html';
my $makepath=$path;
@@ -200,7 +201,8 @@ sub dumpcourse {
$r->print(
'');
} else {
- $r->print('');
+ $r->print('');
}
}
}
@@ -223,7 +225,7 @@ sub dumpcourse {
$title=$_;
}
$title=~s/\.(\w+)$//;
- $title=~s/\W+/\_/gs;
+ $title=~s/[^\w\/]+/\_/gs;
$title.='.'.$ext;
$r->print("\n
\n");
}
@@ -371,7 +373,7 @@ sub editor {
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);
+ my $url=&Apache::lonnet::userfileupload('uploaddoc',1,'docs');
my $ext='false';
if ($url=~/^http\:\/\//) { $ext='true'; }
$url=~s/\:/\:/g;
@@ -399,6 +401,10 @@ sub editor {
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/|) {
+ &Apache::lonnet::removeuploadedurl($url);
+ }
for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
$Apache::lonratedt::order[$i]=
$Apache::lonratedt::order[$i+1];
@@ -489,6 +495,9 @@ sub editor {
$r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
$idx++;
}
+ unless ($idx) {
+ $r->print('
'.&mt('Currently no documents.').'
');
+ }
$r->print('');
}
}
@@ -566,13 +575,15 @@ END
my $isfolder=0;
my $folderarg;
if ($uploaded) {
- if ($extension eq 'sequence') {
- $icon=$iconpath.'/folder_closed.gif';
- $url=~/$coursenum\/([\/\w]+)\.sequence$/;
- $url='/adm/coursedocs?';
- $folderarg=$1;
- $isfolder=1;
- }
+ if ($extension eq 'sequence') {
+ $icon=$iconpath.'/folder_closed.gif';
+ $url=~/$coursenum\/([\/\w]+)\.sequence$/;
+ $url='/adm/coursedocs?';
+ $folderarg=$1;
+ $isfolder=1;
+ } else {
+ &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
+ }
}
$url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/)) {
@@ -585,6 +596,17 @@ END
&Apache::lonnet::declutter($url));
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
$url=&Apache::lonnet::clutter($url);
+ if ($url=~/^\/*uploaded\//) {
+ $url=~/\.(\w+)$/;
+ my $embstyle=&Apache::loncommon::fileembstyle($1);
+ if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
+ $url='/adm/wrapper'.$url;
+ } elsif ($embstyle eq 'ssi') {
+ #do nothing with these
+ } elsif ($url!~/\.(sequence|page)$/) {
+ $url='/adm/coursedocs/showdoc'.$url;
+ }
+ }
$url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
}
my $parameterset=' ';
@@ -628,12 +650,20 @@ ENDPARMS
# ---------------------------------------------------------------- tie the hash
sub tiehash {
+ my ($mode)=@_;
$hashtied=0;
if ($ENV{'request.course.fn'}) {
- if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
- &GDBM_READER(),0640)) {
+ if ($mode eq 'write') {
+ 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",
+ &GDBM_READER(),0640)) {
$hashtied=1;
- }
+ }
+ }
}
}
@@ -799,8 +829,9 @@ sub checkversions {
} else {
$r->print('
'.&mt('An Error Occured while Attempting to Store your Version Settings').'
');
}
- &changewarning($r,'');
+ &mark_hash_old();
}
+ &changewarning($r,'');
if ($ENV{'form.timerange'} eq 'all') {
# show all documents
$header=&mt('All Documents in Course');
@@ -920,7 +951,9 @@ ENDHEADERS
# Set version
$r->print(&Apache::loncommon::select_form($setversions{$linkurl},
'set_version_'.$linkurl,
- ('' => '',
+ ('select_form_order' =>
+ ['',1..$currentversion,'mostrecent'],
+ '' => '',
'mostrecent' => 'most recent',
map {$_,$_} (1..$currentversion))));
$r->print('
');
@@ -981,8 +1014,32 @@ ENDHEADERS
&untiehash();
}
+sub mark_hash_old {
+ my $retie_hash=0;
+ if ($hashtied) {
+ $retie_hash=1;
+ &untiehash();
+ }
+ &tiehash('write');
+ $hash{'old'}=1;
+ &untiehash();
+ if ($retie_hash) { &tiehash(); }
+}
+
+sub is_hash_old {
+ my $untie_hash=0;
+ if (!$hashtied) {
+ $untie_hash=1;
+ &tiehash();
+ }
+ my $return=$hash{'old'};
+ if ($untie_hash) { &untiehash(); }
+ return $return;
+}
+
sub changewarning {
my ($r,$postexec)=@_;
+ if (!&is_hash_old()) { return; }
$r->print(
''.
'
@@ -1291,8 +1348,9 @@ ENDCOURSEVERIFY
$hadchanges=0;
&editor($r,$coursenum,$coursedom,$folder,$allowed);
if ($hadchanges) {
- &changewarning($r,$postexec);
+ &mark_hash_old()
}
+ &changewarning($r,$postexec);
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
'.sequence';
$r->print(<
-
+
$help{'Uploading_From_Harddrive'}