--- loncom/interface/londocs.pm 2005/03/10 02:34:58 1.170
+++ loncom/interface/londocs.pm 2006/07/20 01:18:26 1.238
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.170 2005/03/10 02:34:58 www Exp $
+# $Id: londocs.pm,v 1.238 2006/07/20 01:18:26 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,16 +121,18 @@ 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');
}
}
@@ -140,33 +144,35 @@ sub clean {
# -------------------------------------------------------- Actually dump course
sub dumpcourse {
- my $r=shift;
- my $html=&Apache::lonxml::xmlbegin();
- $r->print($html.'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);
@@ -268,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 {
@@ -304,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;
}
@@ -326,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. ';
}
}
- my $html=&Apache::lonxml::xmlbegin();
- $r->print($html.'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('