--- loncom/interface/londocs.pm 2006/11/29 22:02:47 1.261
+++ loncom/interface/londocs.pm 2007/07/03 00:17:42 1.283
@@ -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.283 2007/07/03 00:17:42 albertel 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);
@@ -122,16 +122,17 @@ sub dumpbutton {
my ($home,$other,%outhash)=&authorhosts();
my $type = &Apache::loncommon::course_type();
if ($home+$other==0) { return ''; }
- my $output='
';
if ($home) {
- return ' | '.
+ return ' '.
''.
- &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs');
+ &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs').
+ ' ';
} else {
- return' | '.
+ return ' '.
&mt('Dump '.$type.
- ' DOCS to Construction Space: available on other servers');
+ ' DOCS to Construction Space: available on other servers').
+ ' ';
}
}
@@ -199,9 +200,9 @@ sub dumpcourse {
$fail=1;
}
if ($fail) {
- $r->print('fail');
+ $r->print(''.&mt('fail').'');
} else {
- $r->print('ok');
+ $r->print(''.&mt('ok').'');
}
}
} else {
@@ -235,7 +236,6 @@ sub dumpcourse {
my ($ext)=($_=~/\.(\w+)$/);
my $title=$hash{'title_'.$hash{
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
- $title=~s/:/:/g;
$r->print(' | '.($title?$title:' ').' | ');
if (!$title) {
$title=$_;
@@ -258,10 +258,10 @@ sub dumpcourse {
sub exportbutton {
my $type = &Apache::loncommon::course_type();
- return ''.
+ return ' '.
''.
- &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
+ &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').' ';
}
sub exportcourse {
@@ -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';
}
@@ -380,7 +380,7 @@ sub exportcourse {
}
$display .= ' />'."\n";
for (my $i=0; $i<$depth; $i++) {
- $display .= ''."\n";
+ $display .= ''."\n";
}
if ($curRes->is_sequence()) {
$display .= ' '."\n";
@@ -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) {
@@ -905,15 +905,16 @@ sub store_template {
# Imports the given (name, url) resources into the course
# coursenum, coursedom, and folder must precede the list
sub group_import {
- my $coursenum = shift;
- my $coursedom = shift;
- my $folder = shift;
- my $container = shift;
- my $caller = shift;
- while (@_) {
- my $name = shift;
- my $url = shift;
- if (($url =~ m#^/uploaded/$coursedom/$coursenum/(default_\d+\.)(page|sequence)$#) && ($caller eq 'londocs')) {
+ my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
+
+ while (@files) {
+ my $name = shift(@files);
+ my $url = shift(@files);
+ #FIXME check if file exists before overwriting, might be restoring it
+ if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
+ && ($caller eq 'londocs')
+ && (!&Apache::lonnet::stat_file($url))) {
+
my $errtext = '';
my $fatal = 0;
my $newmapstr = ' |