--- loncom/interface/londocs.pm 2013/05/25 21:56:23 1.551
+++ loncom/interface/londocs.pm 2013/09/01 03:01:13 1.563
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.551 2013/05/25 21:56:23 raeburn Exp $
+# $Id: londocs.pm,v 1.563 2013/09/01 03:01:13 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -56,6 +56,7 @@ my $hashtied;
my %alreadyseen=();
my $hadchanges;
+my $suppchanges;
my %help=();
@@ -79,7 +80,11 @@ sub storemap {
$map,1,$report);
if ($errtext) { return ($errtext,2); }
- $hadchanges=1;
+ if ($map =~ /^default/) {
+ $hadchanges=1;
+ } else {
+ $suppchanges=1;
+ }
return ($errtext,0);
}
@@ -402,6 +407,13 @@ END
}
my ($errtext,$fatal) =
&storemap($coursenum, $coursedom, $folder.'.'.$container,1);
+ unless ($fatal) {
+ if ($folder =~ /^supplemental/) {
+ &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
+ my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
+ $folder.'.'.$container);
+ }
+ }
return ($errtext,$fatal,$fixuperrors);
}
@@ -1610,16 +1622,18 @@ sub dbcopy {
}
}
if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
- $lockerrorsref->{$prefix} =
+ $lockerrorsref->{$prefix} =
'
'.
&mt('There was a problem removing a lockfile.');
if ($prefix eq 'smppg') {
- $lockerrorsref->{$prefix} .=
- &mt('This will prevent creation of additional simple pages in this course.');
+ $lockerrorsref->{$prefix} .=
+ ' '.&mt('This will prevent creation of additional simple pages in this course.');
} else {
- $lockerrorsref->{$prefix} .= &mt('This will prevent creation of additional bulletin boards in this course.');
+ $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional bulletin boards in this course.');
}
- $lockerrorsref->{$prefix} .= &mt('Please contact the domain coordinator for your LON-CAPA domain.').'
';
+ $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
+ '','').
+ '';
}
}
} elsif ($url =~ m{/syllabus$}) {
@@ -2802,8 +2816,30 @@ sub multiple_check_form {
}
sub process_file_upload {
- my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
+ my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
# upload a file, if present
+ my $filesize = length($env{'form.uploaddoc'});
+ if (!$filesize) {
+ $$upload_output = '
'.
+ &mt('Unable to upload [_1]. (size = [_2] bytes)',
+ ''.$env{'form.uploaddoc.filename'}.'',
+ $filesize).' '.
+ &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').' '.
+ '
';
+ return;
+ }
+ my $quotatype = 'unofficial';
+ if ($crstype eq 'Community') {
+ $quotatype = 'community';
+ } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) {
+ $quotatype = 'official';
+ }
+ if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
+ $filesize = int($filesize/1000); #expressed in kb
+ $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
+ $env{'form.uploaddoc.filename'},$filesize,'upload');
+ return if ($$upload_output);
+ }
my ($parseaction,$showupload,$nextphase,$mimetype);
if ($env{'form.parserflag'}) {
$parseaction = 'parse';
@@ -3484,7 +3520,8 @@ sub new_timebased_suffix {
}
unless ($type eq 'paste') {
$locknotfreed .=
- ' '.&mt('Please contact the domain coordinator for your LON-CAPA domain.');
+ ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
+ '','');
}
$locknotfreed .= '';
}
@@ -4076,7 +4113,8 @@ sub handler {
'Supplemental','Score_Upload_Form','Adding_Pages',
'Importing_LON-CAPA_Resource','Importing_IMS_Course',
'Uploading_From_Harddrive',
- 'Check_Resource_Versions','Verify_Content') {
+ 'Check_Resource_Versions','Verify_Content',
+ 'Course_Roster','Web_Page','Dropbox') {
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
}
# Composite help files
@@ -4092,8 +4130,6 @@ sub handler {
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
$help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
- $help{'Course Roster'} = &Apache::loncommon::help_open_topic('Docs_Course_Roster');
- $help{'Web Page'} = &Apache::loncommon::help_open_topic('Docs_Web_Page');
my $allowed;
# URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
@@ -4150,9 +4186,9 @@ sub handler {
# supplementalflag=0: show standard documents
# toolsflag=1: show utilities
- $env{'form.folderpath'} = &unescape($env{'form.folderpath'});
- my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
- if (($env{'form.folderpath'}=~/^default/) || ($env{'form.folderpath'} eq "")) {
+ my $unesc_folderpath = &unescape($env{'form.folderpath'});
+ my $supplementalflag=($unesc_folderpath=~/^supplemental/);
+ if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
$supplementalflag=0;
}
if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
@@ -4358,7 +4394,7 @@ sub handler {
# Process file upload - phase one - upload and parse primary file.
undef($hadchanges);
$uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
- \%allfiles,\%codebase,$context);
+ \%allfiles,\%codebase,$context,$crstype);
if ($hadchanges) {
&mark_hash_old();
}
@@ -4410,7 +4446,7 @@ sub handler {
my %lt=&Apache::lonlocal::texthash(
'copm' => 'All documents out of a published map into this folder',
'upfi' => 'Upload File',
- 'upld' => 'Import Content',
+ 'upld' => 'Upload Content',
'srch' => 'Search',
'impo' => 'Import',
'lnks' => 'Import from Stored Links',
@@ -4431,8 +4467,8 @@ sub handler {
'grpo' => 'Group Portfolio',
'rost' => 'Course Roster',
'abou' => 'Personal Information Page for a User',
- 'imsf' => 'IMS Import',
- 'imsl' => 'Import IMS package',
+ 'imsf' => 'IMS Upload',
+ 'imsl' => 'Upload IMS package',
'cms' => 'Origin of IMS package',
'se' => 'Select',
'file' => 'File',
@@ -4636,6 +4672,7 @@ NSPROBFORM
$pathitem
$lt{'drbx'}
+ $help{'Dropbox'}
NDBFORM
@@ -4686,7 +4723,7 @@ NASOFORM
$lt{'rost'}
- $help{'Course Roster'}
+ $help{'Course_Roster'}
NROSTFORM
@@ -4706,7 +4743,7 @@ NROSTFORM
$pathitem
$lt{'webp'}
- $help{'Web Page'}
+ $help{'Web_Page'}
NWEBFORM
@@ -4783,7 +4820,7 @@ NGFFORM
);
}
push(@importdoc,
- {''=>$fileuploadform}
+ {''=>$fileuploadform}
);
$fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
@@ -4805,14 +4842,14 @@ NGFFORM
$communityform = &create_form_ul(&create_list_elements(@communityforma));
my %orderhash = (
- 'aa' => ['Import Content',$fileuploadform],
- 'bb' => ['Published Content',$importpubform],
- 'cc' => ['Grading Resources',$gradingform],
+ 'aa' => ['Upload',$fileuploadform],
+ 'bb' => ['Import',$importpubform],
+ 'cc' => ['Grading',$gradingform],
);
unless ($container eq 'page') {
$orderhash{'00'} = ['Newfolder',$newfolderform];
$orderhash{'dd'} = ['Collaboration',$communityform];
- $orderhash{'ee'} = ['Special Pages',$specialdocumentsform];
+ $orderhash{'ee'} = ['Other',$specialdocumentsform];
}
$hadchanges=0;
@@ -4923,7 +4960,7 @@ SNAMFORM
$pathitem
$lt{'webp'}
- $help{'Web Page'}
+ $help{'Web_Page'}
SWEBFORM
@@ -4946,15 +4983,27 @@ my @supimportdoc = (
$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
my %suporderhash = (
'00' => ['Supnewfolder', $supnewfolderform],
- 'ee' => ['Import Content',$supupdocform],
- 'ff' => ['Special Pages',&create_form_ul(&create_list_elements(@specialdocs))]
+ 'ee' => ['Upload',$supupdocform],
+ 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
);
if ($supplementalflag) {
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
$supplementalflag,\%suporderhash,$iconpath,$pathitem);
if ($error) {
$r->print('
'.$error.'
');
- }
+ } else {
+ if ($suppchanges) {
+ my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
+ my @ids=&Apache::lonnet::current_machine_ids();
+ foreach my $server (keys(%servers)) {
+ next if (grep(/^\Q$server\E$/,@ids));
+ my $hashid=$coursenum.':'.$coursedom;
+ &Apache::lonnet::remote_devalidate_cache($server,'suppcount',$hashid);
+ }
+ &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
+ undef($suppchanges);
+ }
+ }
}
} elsif ($supplementalflag) {
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
@@ -5101,8 +5150,8 @@ sub remove_archive {
} else {
my $currcmd = $env{'form.cmd'};
my $position = $env{'form.position'};
- if ($position > 0) {
- $env{'form.cmd'} = 'del_'.$position;
+ if ($position > 0) {
+ $env{'form.cmd'} = 'remove_'.$position;
my ($title,$url,@rrest) =
split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
if (&handle_edit_cmd($docuname,$docudom)) {
@@ -5137,13 +5186,13 @@ sub generate_admin_menu {
my ($crstype) = @_;
my $lc_crstype = lc($crstype);
my ($home,$other,%outhash)=&authorhosts();
- my %lt=&Apache::lonlocal::texthash (
+ my %lt= ( # do not translate here
'vc' => 'Verify Content',
'cv' => 'Check/Set Resource Versions',
'ls' => 'List Resource Identifiers',
'imse' => 'Export contents to IMS Archive',
'dcd' => "Dump $crstype Content to Authoring Space",
- );
+ );
my ($candump,$dumpurl);
if ($home + $other > 0) {
$candump = 'F';