--- loncom/interface/londocs.pm 2004/12/23 20:50:35 1.162
+++ loncom/interface/londocs.pm 2006/07/20 20:42:48 1.242
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.162 2004/12/23 20:50:35 raeburn Exp $
+# $Id: londocs.pm,v 1.242 2006/07/20 20:42:48 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,6 +42,8 @@ use HTML::Entities;
use GDBM_File;
use Apache::lonlocal;
use Cwd;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
my $iconpath;
@@ -86,17 +88,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+)$/);
}
@@ -119,48 +121,58 @@ sub authorhosts {
sub dumpbutton {
my ($home,$other,%outhash)=&authorhosts();
+ my $type = &Apache::loncommon::course_type();
if ($home+$other==0) { return ''; }
my $output='
';
if ($home) {
return '
'.
''.
+ &mt('Dump '.$type.' 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');
+ &mt('Dump '.$type.
+ ' DOCS to Construction Space: available on other servers');
}
}
+sub clean {
+ my ($title)=@_;
+ $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
+ return $title;
+}
# -------------------------------------------------------- Actually dump course
sub dumpcourse {
- my $r=shift;
- $r->print('Dump DOCS'.
- &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
+ my ($r) = @_;
+ my $type = &Apache::loncommon::course_type();
+ $r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space').
'');
+ '');
}
}
# ------------------------------------------------------ Generate "export" button
sub exportbutton {
- return '';
+ my $type = &Apache::loncommon::course_type();
return '
'.
''.
- &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
+ &mt('Export '.$type.' to IMS').'" />'.
+ &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
}
sub exportcourse {
my $r=shift;
+ my $type = &Apache::loncommon::course_type();
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);
@@ -261,26 +277,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 {
@@ -297,21 +299,15 @@ 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 ';
+ $outcome .= &mt('Download the zip file from IMS '.lc($type).' archive ',$imszipfile,);
if ($copyresult) {
$outcome .= 'The following errors occurred during export - '.$copyresult;
}
@@ -319,15 +315,13 @@ 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'.
- &Apache::loncommon::bodytag('Export course to IMS content package'));
+ $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
$r->print($outcome);
- $r->print('');
+ $r->print(&Apache::loncommon::end_page());
} else {
my $display;
$display = '