'."\n";
+ my %uploadedfiles;
+ &tiehash();
+ foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
+ my ($ext)=($file=~/\.(\w+)$/);
+# FIXME Check supplemental here
+ my $title=$hash{'title_'.$hash{
+ 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
+ if (!$title) {
+ $title=$file;
+ } else {
+ $title=~s|/|_|g;
+ }
+ $title=~s/\.(\w+)$//;
+ $title=&clean($title);
+ $title.='.'.$ext;
+# $r->print("\n
"
+ $uploadedfiles{$file} = $title;
+ }
+ &untiehash();
+ $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
+ undef,undef,$preamble,$home,\%uploadedfiles));
+ }
}
$r->print(&endContentScreen());
}
+sub recurse_html {
+ my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
+ return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
+ my (%allfiles,%codebase);
+ if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
+ if (keys(%allfiles)) {
+ foreach my $dependency (keys(%allfiles)) {
+ next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
+ my ($depurl,$relfile,$newcontainer);
+ if ($dependency =~ m{^/}) {
+ if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
+ $relfile = $1;
+ if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
+ $newcontainer = $1;
+ next if ($replacehash->{$newcontainer});
+ }
+ $depurl = $dependency;
+ } else {
+ next;
+ }
+ } else {
+ $relfile = $dependency;
+ $depurl = $currurlpath;
+ $depurl =~ s{[^/]+$}{};
+ $depurl .= $dependency;
+ ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
+ }
+ next if ($relfile eq '');
+ my $newname = $replacehash->{$container};
+ $newname =~ s{[^/]+$}{};
+ $replacehash->{$newcontainer} = $newname.$relfile;
+ $deps->{$item}{$newcontainer} = 1;
+ my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
+ my $depfile = &Apache::lonnet::filelocation('',$depurl);
+ my $type = $mm->checktype_filename($depfile);
+ if ($type eq 'text/html') {
+ &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
+ }
+ }
+ }
+ }
+ return;
+}
+
sub group_import {
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
@@ -402,6 +719,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);
}
@@ -653,7 +977,7 @@ sub docs_change_log {
sub update_paste_buffer {
my ($coursenum,$coursedom,$folder) = @_;
- my (@possibles,%removals,%cuts);
+ my (@possibles,%removals,%cuts,$output);
if ($env{'form.multiremove'}) {
$env{'form.multiremove'} =~ s/,$//;
map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
@@ -700,7 +1024,7 @@ sub update_paste_buffer {
my $url = $env{'docs.markedcopy_url_'.$suffix};
if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
($url ne '')) {
- $pasteurls{$cid.'_'.$url};
+ $pasteurls{$cid.'_'.$url} = 1;
}
}
}
@@ -721,10 +1045,12 @@ sub update_paste_buffer {
next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));
my ($suffix,$errortxt,$locknotfreed) =
&new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
- push(@newpaste,$suffix);
- if ($locknotfreed) {
- return $locknotfreed;
- last;
+ if ($suffix ne '') {
+ push(@newpaste,$suffix);
+ } else {
+ if ($locknotfreed) {
+ return $locknotfreed;
+ }
}
if (&is_supplemental_title($title)) {
&Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
@@ -758,12 +1084,17 @@ sub update_paste_buffer {
}
}
}
+ if ($locknotfreed) {
+ $output = $locknotfreed;
+ last;
+ }
}
if (@newpaste) {
$addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
}
&Apache::lonnet::appenv(\%addtoenv);
delete($env{'form.markcopy'});
+ return $output;
}
sub recurse_uploaded_maps {
@@ -801,6 +1132,7 @@ sub print_paste_buffer {
my @currpaste = split(/,/,$env{'docs.markedcopies'});
my ($pasteitems,@pasteable);
+ my $clipboardcount = 0;
# Construct identifiers for current contents of user's paste buffer
foreach my $suffix (@currpaste) {
@@ -809,6 +1141,7 @@ sub print_paste_buffer {
my $url = $env{'docs.markedcopy_url_'.$suffix};
if (($cid =~ /^$match_domain\_$match_courseid$/) &&
($url ne '')) {
+ $clipboardcount ++;
my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
$canpaste,$nopaste,$othercrs,$areachange);
my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
@@ -864,10 +1197,14 @@ sub print_paste_buffer {
$icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
$icon .= '/navmap.folder.closed.gif';
}
+ my $title = $env{'docs.markedcopy_title_'.$suffix};
+ if ($title eq '') {
+ ($title) = ($url =~ m{/([^/]+)$});
+ }
$buffer = ''.
': '.
&Apache::loncommon::parse_supplemental_title(
- &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}));
+ &LONCAPA::map::qtescape($title));
}
$pasteitems .= '
';
my ($options,$onclick);
@@ -902,11 +1239,23 @@ sub print_paste_buffer {
$pasteitems .= '';
$form_start = '';
+ $buttons .= ''.(' 'x2);
+ if ($clipboardcount > 1) {
+ $buttons .=
+ ''.(' 'x20).''.(' 'x2).
+ ''.
+ (' 'x2).
+ ''.
+ (' 'x2);
+ }
+ $form_end = ''.
+ '';
} else {
$pasteitems = &mt('Clipboard is empty');
}
@@ -1004,29 +1353,34 @@ sub supp_pasteable {
}
sub paste_popup_js {
- my %lt = &Apache::lonlocal::texthash(
+ my %html_js_lt = &Apache::lonlocal::texthash(
show => 'Show Options',
hide => 'Hide Options',
+ );
+ my %js_lt = &Apache::lonlocal::texthash(
none => 'No items selected from clipboard.',
);
+ &html_escape(\%html_js_lt);
+ &js_escape(\%html_js_lt);
+ &js_escape(\%js_lt);
return <<"END";
function showPasteOptions(suffix) {
document.getElementById('pasteoptions_'+suffix).style.display='block';
- document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' $lt{'hide'}';
+ document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' $html_js_lt{'hide'}';
return;
}
function hidePasteOptions(suffix) {
document.getElementById('pasteoptions_'+suffix).style.display='none';
- document.getElementById('pasteoptionstext_'+suffix).innerHTML =' $lt{'show'}';
+ document.getElementById('pasteoptionstext_'+suffix).innerHTML =' $html_js_lt{'show'}';
return;
}
function showOptions(caller,suffix) {
if (document.getElementById('pasteoptionstext_'+suffix)) {
if (caller.checked) {
- document.getElementById('pasteoptionstext_'+suffix).innerHTML =' $lt{'show'}';
+ document.getElementById('pasteoptionstext_'+suffix).innerHTML =' $html_js_lt{'show'}';
} else {
document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
}
@@ -1055,11 +1409,29 @@ function validateClipboard() {
if (numchk > 0) {
return true;
} else {
- alert("$lt{'none'}");
+ alert("$js_lt{'none'}");
return false;
}
}
+function checkClipboard() {
+ if (document.pasteform.pasting.length > 1) {
+ for (var i=0; i1) {
+ for (var i=0; i{'src'};
+ $url = $dbref->{'src'};
if (ref($dbref) eq 'HASH') {
if ($url =~ m{/(smppg|bulletinboard)$}) {
my $prefix = $1;
@@ -1574,7 +1945,7 @@ sub dbcopy {
if ($prefix eq 'smppg') {
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
} else {
- $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a bulletin board [_1].',$url);
+ $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
}
if ($error) {
$errtext .= ' '.$error;
@@ -1610,16 +1981,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 discussion 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$}) {
@@ -2245,26 +2618,44 @@ sub update_parameter {
}
return $haschanges;
} else {
- return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
+ my $haschanges = 0;
+ return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
my $which = $env{'form.changeparms'};
my $idx = $env{'form.setparms'};
+ my $oldvalue = 0;
+ my $newvalue = 0;
+ my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
+ if ($which eq 'randompick') {
+ if ($current =~ /^(\d+)$/) {
+ $oldvalue = $1;
+ }
+ } elsif ($current =~ /^yes$/i) {
+ $oldvalue = 1;
+ }
if ($env{'form.'.$which.'_'.$idx}) {
- my $value = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
- : 'yes';
- &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
- $parameter_type{$which});
- &remember_parms($idx,$which,'set',$value);
- } else {
- &LONCAPA::map::delparameter($idx,'parameter_'.$which);
-
- &remember_parms($idx,$which,'del');
+ $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
+ : 1;
}
- return 1;
+ if ($oldvalue ne $newvalue) {
+ $haschanges = 1;
+ if ($newvalue) {
+ my $storeval = 'yes';
+ if ($which eq 'randompick') {
+ $storeval = $newvalue;
+ }
+ &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
+ $parameter_type{$which});
+ &remember_parms($idx,$which,'set',$storeval);
+ } else {
+ &LONCAPA::map::delparameter($idx,'parameter_'.$which);
+ &remember_parms($idx,$which,'del');
+ }
+ }
+ return $haschanges;
}
}
-
sub handle_edit_cmd {
my ($coursenum,$coursedom) =@_;
if ($env{'form.cmd'} eq '') {
@@ -2356,7 +2747,7 @@ sub editor {
&snapshotbefore();
if (&update_parameter()) {
- ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
+ ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
return $errtext if ($fatal);
}
@@ -2420,7 +2811,7 @@ sub editor {
# Rename, cut, copy or remove a single resource
if (&handle_edit_cmd()) {
my $contentchg;
- if ($env{'form.cmd'} =~ m{^(del|cut)_}) {
+ if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {
$contentchg = 1;
}
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
@@ -2452,7 +2843,7 @@ sub editor {
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
$name=&LONCAPA::map::qtescape($name);
$url=&LONCAPA::map::qtescape($url);
- next unless ($name && $url);
+ next unless $url;
my %denied =
&action_restrictions($coursenum,$coursedom,$url,
$env{'form.folderpath'},\%curr_groups);
@@ -2817,13 +3208,16 @@ sub process_file_upload {
my $quotatype = 'unofficial';
if ($crstype eq 'Community') {
$quotatype = 'community';
- } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) {
+ } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
$quotatype = 'official';
+ } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
+ $quotatype = 'textbook';
}
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');
+ $env{'form.uploaddoc.filename'},$filesize,
+ 'upload',$quotatype);
return if ($$upload_output);
}
my ($parseaction,$showupload,$nextphase,$mimetype);
@@ -2921,7 +3315,8 @@ sub process_file_upload {
$$upload_output .= &mt('No embedded items identified').' ';
}
$$upload_output = '
'.$$upload_output.'
';
- } elsif (&Apache::loncommon::is_archive_file($mimetype)) {
+ } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
+ ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
$nextphase = 'decompress_uploaded';
my $position = scalar(@LONCAPA::map::order)-1;
my $noextract = &return_to_editor();
@@ -2983,7 +3378,7 @@ sub is_supplemental_title {
sub entryline {
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
$crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups)=@_;
- my ($foldertitle,$renametitle);
+ my ($foldertitle,$renametitle,$oldtitle);
if (&is_supplemental_title($title)) {
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
} else {
@@ -2996,7 +3391,10 @@ sub entryline {
$renametitle=~s/\\/\\\\/g;
$renametitle=~s/\"\;/\\\"/g;
+ $renametitle=~s/"/%22/g;
$renametitle=~s/ /%20/g;
+ $oldtitle = $renametitle;
+ $renametitle=~s/\'/\\\'/g;
my $line=&Apache::loncommon::start_data_table_row();
my ($form_start,$form_end,$form_common,$form_param);
# Edit commands
@@ -3146,7 +3544,7 @@ ENDREM
}
}
$renamelink=(<$lt{'rn'}
+$lt{'rn'}
ENDREN
$line.=(<
@@ -3280,7 +3678,7 @@ $form_common."\n".
push(@{$filtersref->{'randomorder'}},$orderidx);
}
}
- my $formname = 'edit_rorder_'.$orderidx;
+ $formname = 'edit_rorder_'.$orderidx;
$rand_order_text =
'