--- loncom/interface/londocs.pm 2022/10/19 00:03:10 1.682
+++ loncom/interface/londocs.pm 2024/12/27 02:32:55 1.714
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.682 2022/10/19 00:03:10 raeburn Exp $
+# $Id: londocs.pm,v 1.714 2024/12/27 02:32:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -45,10 +45,10 @@ use Apache::lontemplate();
use Apache::lonsimplepage();
use Apache::lonhomework();
use Apache::lonpublisher();
-use Apache::lonparmset();
use Apache::loncourserespicker();
use HTML::Entities;
use HTML::TokeParser;
+use HTML::LCParser;
use GDBM_File;
use File::MMagic;
use File::Copy;
@@ -103,6 +103,7 @@ sub authorhosts {
my %outhash=();
my $home=0;
my $other=0;
+ my @ids=&Apache::lonnet::current_machine_ids();
foreach my $key (keys(%env)) {
if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
my $role=$1;
@@ -119,7 +120,6 @@ sub authorhosts {
}
my $allowed=0;
my $myhome=&Apache::lonnet::homeserver($ca,$cd);
- my @ids=&Apache::lonnet::current_machine_ids();
foreach my $id (@ids) {
if ($id eq $myhome) {
$allowed=1;
@@ -183,43 +183,62 @@ sub default_folderpath {
}
}
-sub validate_folderpath {
- my ($supplementalflag) = @_;
- if ($env{'form.folderpath'} ne '') {
- my @items = split(/\&/,$env{'form.folderpath'});
- my $badpath;
- for (my $i=0; $i<@items; $i++) {
- my $odd = $i%2;
- if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) {
- $badpath = 1;
- } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) {
- $badpath = 1;
- }
- last if ($badpath);
- }
- if ($badpath) {
- delete($env{'form.folderpath'});
- }
- }
- return;
-}
-
-sub validate_suppath {
+sub validate_supppath {
+ my ($coursenum,$coursedom) = @_;
+ my $backto;
if ($env{'form.supppath'} ne '') {
my @items = split(/\&/,$env{'form.supppath'});
- my $badpath;
+ my ($badpath,$got_supp,$supppath,%supphidden,%suppids);
for (my $i=0; $i<@items; $i++) {
my $odd = $i%2;
if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
$badpath = 1;
+ last;
+ } elsif ($odd) {
+ my $suffix;
+ my $idx = $i-1;
+ if ($items[$i] =~ /^([^:]*)::(|1):::$/) {
+ $backto .= '&'.$1;
+ } elsif ($items[$idx] eq 'supplemental') {
+ $backto .= '&'.$items[$i];
+ } else {
+ $backto .= '&'.$items[$i];
+ my $is_hidden;
+ unless ($got_supp) {
+ my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
+ if (ref($supplemental) eq 'HASH') {
+ if (ref($supplemental->{'hidden'}) eq 'HASH') {
+ %supphidden = %{$supplemental->{'hidden'}};
+ }
+ if (ref($supplemental->{'ids'}) eq 'HASH') {
+ %suppids = %{$supplemental->{'ids'}};
+ }
+ }
+ $got_supp = 1;
+ }
+ if (ref($suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}) eq 'ARRAY') {
+ my $mapid = $suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}->[0];
+ if ($supphidden{$mapid}) {
+ $is_hidden = 1;
+ }
+ }
+ $suffix = '::'.$is_hidden.':::';
+ }
+ $supppath .= '&'.$items[$i].$suffix;
+ } else {
+ $supppath .= '&'.$items[$i];
+ $backto .= '&'.$items[$i];
}
- last if ($badpath);
}
if ($badpath) {
delete($env{'form.supppath'});
+ } else {
+ $supppath =~ s/^\&//;
+ $backto =~ s/^\&//;
+ $env{'form.supppath'} = $supppath;
}
}
- return;
+ return $backto;
}
sub dumpcourse {
@@ -245,11 +264,12 @@ ENDJS
add_entries => {'onload' => "hide_searching();"},
};
}
- $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
- &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
+ $r->print(&Apache::loncommon::start_page('Copy uploaded content to Authoring Space',$js,$starthash)."\n".
+ &Apache::lonhtmlcommon::breadcrumbs('Copy uploaded content to Authoring Space')."\n");
$r->print(&startContentScreen('tools'));
my ($home,$other,%outhash)=&authorhosts();
unless ($home) {
+ $r->print('
'.&mt('No author or co-author roles on this server.').'
');
$r->print(&endContentScreen());
return '';
}
@@ -258,7 +278,8 @@ ENDJS
if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
# Do the dumping
unless ($outhash{'home_'.$env{'form.authorspace'}}) {
- $r->print(&endContentScreen());
+ $r->print(''.&mt('Selected Authoring Space is not on this server.').'
'.
+ &endContentScreen());
return '';
}
my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
@@ -554,49 +575,12 @@ $contents{webreferences}.'
if (!ref($navmap)) {
$r->print($errormsg);
} else {
- $r->print(''.&mt('Searching ...').'
');
- $r->rflush();
- my ($preamble,$formname);
- $formname = 'dumpdoc';
- unless ($home==1) {
- $preamble = ''.
- '
'."\n";
- }
my $title=$origcrsdata{'description'};
$title=~s/[\/\s]+/\_/gs;
$title=&clean($title);
- $preamble .= ''.
- '
'."\n";
- my %uploadedfiles;
+ my $formname = 'dumpdoc';
+ my $preamble = &authorspace_selector($r,$formname,$home,$title,%outhash);
+ my %uploadedfiles;
&tiehash();
foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
my ($ext)=($file=~/\.(\w+)$/);
@@ -622,6 +606,48 @@ $contents{webreferences}.'
$r->print(&endContentScreen());
}
+sub authorspace_selector {
+ my ($r,$formname,$home,$title,%outhash) = @_;
+ $r->print(''.&mt('Searching ...').'
'."\n");
+ $r->rflush();
+ my $preamble;
+ unless ($home==1) {
+ $preamble = ''.
+ '
'."\n";
+ }
+ $preamble .= ''.
+ '
'."\n";
+ return $preamble;
+}
+
sub recurse_html {
my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
@@ -666,6 +692,640 @@ sub recurse_html {
return;
}
+sub copycrsauthored {
+ my ($r,$coursenum,$coursedom,$coursehome,$readonly) = @_;
+ my ($starthash,$js);
+ unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
+ $js = <<"ENDJS";
+
+ENDJS
+ $starthash = {
+ add_entries => {'onload' => "hide_searching();"},
+ };
+ }
+ $r->print(&Apache::loncommon::start_page('Copy from Course Authoring to User Authoring',$js,$starthash)."\n".
+ &Apache::lonhtmlcommon::breadcrumbs('Copy from Course Authoring Space')."\n");
+ $r->print(&startContentScreen('tools'));
+ my ($home,$other,%outhash)=&authorhosts();
+ unless ($home) {
+ $r->print(''.&mt('No author or co-author roles on this server.').'
');
+ $r->print(&endContentScreen());
+ return '';
+ }
+ my $is_course_home;
+ my @ids=&Apache::lonnet::current_machine_ids();
+ if (($coursehome ne '') && (grep(/^\Q$coursehome\E$/,@ids))) {
+ $is_course_home = 1;
+ }
+ my %origcrsdata=&Apache::lonnet::coursedescription($env{'request.course.id'});
+ my $exclude = &Apache::lonnet::priv_exclude();
+ my $srcurl = "/priv/$coursedom/$coursenum";
+ my $srctop = $r->dir_config('lonDocRoot').$srcurl;
+ if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
+ $r->print(''.&mt('Copying Files and/or Sub-directories').'
');
+ if ($readonly) {
+ $r->print(''.
+ &mt('You do not have permission to copy files and/or directories from Course Authoring Space.').
+ '
'.
+ &endContentScreen());
+ return '';
+ }
+ unless ($outhash{'home_'.$env{'form.authorspace'}}) {
+ $r->print(''.&mt('Selected Authoring Space is not on this server.').'
'.
+ &endContentScreen());
+ return '';
+ }
+ my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
+ my $desturl = "/priv/$cd/$ca";
+ my $desttop = $r->dir_config('lonDocRoot').$desturl;
+ my $subdir = &clean($env{'form.authorfolder'});
+ $subdir = &cleandir($subdir);
+ if ($subdir eq '') {
+ $r->print(''.&mt('After removal of disallowed characters target sub-directory name was blank.').'
'.
+ &endContentScreen());
+ return '';
+ } elsif ($subdir =~/^_+$/) {
+ $r->print(''.&mt('After replacement of non-alphanumeric characters with _ in target sub-directory name, nothing but underscores was left.').'
'.
+ &endContentScreen());
+ return '';
+ }
+ my (%tocopy,%dirs_to_make,%files_to_copy);
+ map { $tocopy{&unescape($_)} = 1; } &Apache::loncommon::get_env_multiple('form.copytouser');
+ if (keys(%tocopy)) {
+ my (%subdirs,%files);
+ &Apache::lonnet::recursedirs($is_course_home,1,undef,$exclude,0,0,$srcurl,'',\%subdirs,\%files);
+ foreach my $possible (sort(keys(%tocopy))) {
+ if ($possible =~ m{/$}) {
+ my $possdir = $possible;
+ $possdir =~ s{^/+|/+$}{}g;
+ if (exists($subdirs{$possdir})) {
+ $dirs_to_make{$possdir} = 1;
+ } else {
+ delete($tocopy{$possible});
+ }
+ } else {
+ my ($path,$fname) = ($possible =~ m{(.*/)([^/]+)$});
+ my $found = 0;
+ if ($path eq '/') {
+ if (ref($files{$path}) eq 'HASH') {
+ if (exists($files{$path}{$fname})) {
+ $found = 1;
+ $files_to_copy{$fname} = 1;
+ }
+ }
+ } else {
+ $path =~ s{^/+|/+$}{}g;
+ if (ref($files{$path}) eq 'HASH') {
+ if (exists($files{$path}{$fname})) {
+ $dirs_to_make{$path} = 1;
+ $files_to_copy{"$path/$fname"} = 1;
+ $found = 1;
+ }
+ }
+ }
+ unless ($found) {
+ delete($tocopy{$possible});
+ }
+ }
+ }
+ } else {
+ $r->print(''.&mt('No files or directories selected for copying').'
');
+ $r->print(&endContentScreen());
+ return '';
+ }
+ if (keys(%tocopy)) {
+ my (%resdirs,%resfiles);
+ my $resurl = "/res/$coursedom/$coursenum";
+ my $res_exclude = &Apache::lonnet::res_exclude();
+ &Apache::lonnet::recursedirs($is_course_home,1,undef,$res_exclude,0,0,$resurl,'',\%resdirs,\%resfiles);
+ my ($notopdir,%newdir,%newfile,%checkdeps);
+ $r->print(''.&mt('Copy to: [_1]',
+ ''.$desturl.'/'.$subdir.'').
+ '
'."\n");
+ if (keys(%dirs_to_make)) {
+ unless (-e $desttop.'/'.$subdir) {
+ mkdir($desttop.'/'.$subdir,0755);
+ }
+ if (-e $desttop.'/'.$subdir) {
+ foreach my $dir (sort(keys(%dirs_to_make))) {
+ my @dirs=split(/\//,$dir);
+ my $path="$desttop/$subdir";
+ my $makepath=$path;
+ my $fail;
+ for (my $i=0;$i<@dirs;$i++) {
+ $makepath.='/'.$dirs[$i];
+ unless (-e $makepath) {
+ unless (mkdir($makepath,0755)) {
+ $fail = 1;
+ last;
+ }
+ if (($i == scalar(@dirs)-1) && (!$fail)) {
+ $newdir{$dir} = 1;
+ }
+ }
+ }
+ if ($fail) {
+ $r->print(''.&mt('Target directory: [_1] does not exist, and could not be created.',
+ ''.$desturl.'/'.$subdir.'/'.$dir.'').
+ '
'."\n");
+ }
+ }
+ } else {
+ $notopdir = 1;
+ }
+ }
+ if (keys(%files_to_copy)) {
+ unless (-e $desttop.'/'.$subdir) {
+ mkdir($desttop.'/'.$subdir,0755);
+ }
+ if (-e $desttop.'/'.$subdir) {
+ my $num = 0;
+ foreach my $file (keys(%files_to_copy)) {
+ my ($fail,$dup,$dir_is_file,$src,$dest,$path,$fname);
+ if ($file =~ m{/}) {
+ ($path,$fname) = ($file =~ m{^(.+)/([^/]+)$});
+ if (-d "$desttop/$subdir/$path") {
+ if (-e "$desttop/$subdir/$path/$fname") {
+ $dup = 1;
+ } else {
+ $src = "$srctop/$path/$fname";
+ $dest = "$desttop/$subdir/$path/$fname";
+ }
+ } elsif (-f "$desttop/$subdir/$path") {
+ $dir_is_file = 1;
+ } else {
+ $fail = 1;
+ }
+ } elsif (-e "$desttop/$subdir/$file") {
+ $dup = 1;
+ } else {
+ $src = "$srctop/$file";
+ $dest = "$desttop/$subdir/$file";
+ $fname = $file;
+ }
+ if ($fail) {
+ $r->print(''.&mt('Target directory: [_1] does not exist, and could not be created.',
+ ''.$desturl.'/'.$subdir.'/'.$path.'').
+ '
'."\n");
+ } elsif ($dup) {
+ $r->print(''.&mt('Target file: [_1] already exists -- not overwriting.',
+ ''.$desturl.'/'.$subdir.'/'.$file.'').
+ '
'."\n");
+ } elsif ($dir_is_file) {
+ $r->print(''.&mt('Target directory: [_1] name is already in a use for a file -- not overwriting.',
+ ''.$desturl.'/'.$subdir.'/'.$file.'').
+ '
'."\n");
+ } elsif (($src ne '') && ($dest ne '')) {
+ if ($is_course_home) {
+ if (&File::Copy::copy($src,$dest)) {
+ $newfile{$file} = 1;
+ }
+ } else {
+ if (&Apache::lonnet::repcopy_crsprivfile($srcurl.'/'.$file,$dest) eq 'ok') {
+ $newfile{$file} = 1;
+ }
+ }
+ if ($newfile{$file}) {
+ my $gotmeta;
+ if ($is_course_home) {
+ if ((-e $src.'.meta') && (!-e $dest.'.meta')) {
+ if (&File::Copy::copy($src.'.meta',$dest.'.meta')) {
+ $gotmeta = 1;
+ }
+ }
+ } else {
+ if (&Apache::lonnet::repcopy_crsprivfile($srcurl.'/'.$file.'.meta',$dest.'.meta') eq 'ok') {
+ $gotmeta = 1;
+ }
+ }
+ if ($gotmeta) {
+ if (open(my $fh,'<',$dest.'.meta')) {
+ my ($output,$now);
+ $now = time;
+ while (my $line=<$fh>) {
+ chomp($line);
+ if ($line eq "$coursenum:$coursedom") {
+ $output .= "$ca:$cd\n";
+ } elsif ($line eq 'custom') {
+ $output .= "default\n";
+ } elsif ($line =~ m{^\d+$}) {
+ $output .= "$now\n";
+ } elsif ($line eq "/res/$coursedom/$coursenum/default.rights") {
+ $output .= "\n";
+ } elsif ($line eq "$coursedom") {
+ $output .= "$cd\n";
+ } elsif ($line =~ m{^\d+$}) {
+ $output .= "$now\n";
+ } elsif ($line =~ m{^$match_username:$match_domain$}) {
+ $output .= "$env{'user.name'}:$env{'user.domain'}\n";
+ } elsif ($line eq "$coursenum:$coursedom") {
+ $output .= "$ca:$cd\n";
+ } elsif ($line =~ m{^(.+)$}) {
+ my @deps = split(/\s*,\s*/,$1);
+ my @newdeps;
+ my $changed = 0;
+ foreach my $dep (@deps) {
+ if ($dep =~ m{^/res/$coursedom/$coursenum/(.+)$}) {
+ my $rest = $1;
+ push(@newdeps,"/res/$cd/$ca/$rest");
+ $checkdeps{$rest} = 1;
+ $changed ++;
+ } else {
+ push(@newdeps,$dep);
+ }
+ }
+ if ($changed) {
+ $output .= ''.join(',',@newdeps).''."\n";
+ }
+ } else {
+ $output .= "$line\n";
+ }
+ }
+ close($fh);
+ if (open(my $fh,'>',$dest.'.meta')) {
+ print $fh $output;
+ close($fh);
+ }
+ }
+ }
+ my ($ext) = ($file =~ /\.(\w+)$/);
+ my $embstyle=&Apache::loncommon::fileembstyle($ext);
+ if ($embstyle eq 'ssi') {
+ my $outstring='';
+ my $changes = 0;
+ my @parser;
+ $parser[0]=HTML::LCParser->new($dest);
+ $parser[-1]->xml_mode(1);
+ my $token;
+ while (@parser) {
+ while ($token=$parser[-1]->get_token) {
+ if ($token->[0] eq 'S') {
+ my $tag=$token->[1];
+ my $lctag=lc($tag);
+ my %parms=%{$token->[2]};
+ foreach my $type ('src','href','background','bgimg') {
+ foreach my $key (keys(%parms)) {
+ if ($key =~ /^$type$/i) {
+ next if (($lctag eq 'img') && ($type eq 'src') &&
+ ($parms{$key} =~ m{^data\:image/gif;base64,}));
+ if ($parms{$key} =~ m{^\Q/res/$coursedom/$coursenum/\E}si) {
+ $parms{$key} =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/}si;
+ $changes ++;
+ }
+ }
+ }
+ }
+ # probably a image type '."\n".
''.
''.
- ' | '.
''."\n";
}
@@ -3972,13 +4996,14 @@ sub is_supplemental_title {
sub entryline {
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
$crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
- $ltitoolsref,$canedit,$isencrypted,$navmapref,$hostname,
- $supphidden,$suppids,$suppmapid)=@_;
- my ($foldertitle,$renametitle,$oldtitle);
+ $ltitoolsref,$canedit,$isencrypted,$ishidden,$navmapref,$hostname)=@_;
+ my ($foldertitle,$renametitle,$oldtitle,$encodedtitle);
if (&is_supplemental_title($title)) {
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
+ $encodedtitle=$title;
} else {
$title=&HTML::Entities::encode($title,'"<>&\'');
+ $encodedtitle=$title;
$renametitle=$title;
$foldertitle=$title;
}
@@ -4205,6 +5230,7 @@ END
my $ispage;
my $containerarg;
my $folderurl;
+ my $plainurl;
if ($uploaded) {
if (($extension eq 'sequence') || ($extension eq 'page')) {
$url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
@@ -4223,7 +5249,7 @@ END
$url='/adm/supplemental?';
}
} else {
- &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
+ $plainurl = $url;
}
}
@@ -4273,7 +5299,7 @@ END
$nomodal = 1;
}
}
- my ($checkencrypt,$shownurl);
+ my $checkencrypt;
if (!$env{'request.role.adv'}) {
if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
($isencrypted) || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
@@ -4293,7 +5319,7 @@ END
my $currenc = $env{'request.enc'};
$env{'request.enc'} = 1;
$shownsymb = &Apache::lonenc::encrypted($symb);
- $shownurl = &Apache::lonenc::encrypted($url);
+ my $shownurl = &Apache::lonenc::encrypted($url);
if (&Apache::lonnet::symbverify($symb,$url)) {
$url = $shownurl;
} else {
@@ -4308,7 +5334,8 @@ END
$url = &Apache::lonnet::clutter($url);
}
}
- $shownurl = $url;
+ } else {
+ $url = '';
}
unless ($env{'request.role.adv'}) {
if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
@@ -4319,8 +5346,8 @@ END
$hiddenres = 1;
}
}
- if ($url ne '') {
- $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
+ if (($url ne '') && ($shownsymb ne '')) {
+ $url .= (($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
}
}
} elsif ($supplementalflag) {
@@ -4349,6 +5376,22 @@ END
}
$nomodal = 1;
}
+ } elsif (($uploaded) && ($url ne '/adm/supplemental?') && ($url ne '/adm/coursedocs?')) {
+ my $embstyle=&Apache::loncommon::fileembstyle($extension);
+ unless ($embstyle eq 'ssi') {
+ if (($embstyle eq 'img')
+ || ($embstyle eq 'emb')
+ || ($embstyle eq 'wrp')) {
+ $url='/adm/wrapper'.$url;
+ } elsif ($url !~ /\.(sequence|page)$/) {
+ $url='/adm/coursedocs/showdoc'.$url;
+ }
+ }
+ }
+ unless ($allowed && $env{'request.role.adv'}) {
+ if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
+ $hiddenres = 1;
+ }
}
}
my ($rand_pick_text,$rand_order_text,$hiddenfolder);
@@ -4360,10 +5403,8 @@ END
if (!$allowed && $supplementalflag) {
$folderpath.=$containerarg.'&'.$foldername;
$url.='folderpath='.&escape($folderpath);
- if (ref($supphidden) eq 'HASH') {
- if ($supphidden->{$suppmapid.':'.$residx}) {
- $hiddenfolder = 1;
- }
+ if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
+ $hiddenfolder = 1;
}
} else {
my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
@@ -4441,7 +5482,7 @@ $form_common."\n".
' '.&mt('Random Order').' '.
$form_end;
}
- } elsif ($supplementalflag && !$allowed) {
+ } elsif ($supplementalflag) {
my $isexttool;
if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
$url='/adm/wrapper'.$url;
@@ -4450,7 +5491,7 @@ $form_end;
$url .= ($url =~ /\?/) ? '&':'?';
$url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
if ($title) {
- $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
+ $url .= '&title='.$encodedtitle;
}
if ((($isexternal) || ($isexttool)) && $orderidx) {
$url .= '&idx='.$orderidx;
@@ -4458,11 +5499,6 @@ $form_end;
if ($anchor ne '') {
$url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
}
- if (ref($supphidden) eq 'HASH') {
- if ($supphidden->{$suppmapid.':'.$residx}) {
- $hiddenres = 1;
- }
- }
}
my ($tdalign,$tdwidth);
if ($allowed) {
@@ -4509,7 +5545,7 @@ $form_end;
} else {
$reinit = &mt('(re-initialize course to access)');
}
- $line.=''.$editlink.$renamelink;
+ $line.=' | '.$editlink.$renamelink.'';
if ($orig_url =~ /$LONCAPA::assess_re/) {
$line.= ' ';
if ($curralias ne '') {
@@ -4520,10 +5556,19 @@ $form_end;
$lt{'sa'}.'';
}
}
- $line.=' | ';
- my $link;
+ $line.=' | ';
+ my ($link,$nolink);
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
- $line.='';
+ if ($allowed && !$env{'request.role.adv'} && !$isfolder && !$ispage) {
+ if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
+ $nolink = 1;
+ }
+ }
+ if ($nolink) {
+ $line .= '';
+ } else {
+ $line.='';
+ }
} elsif ($url) {
if ($anchor ne '') {
if ($supplementalflag) {
@@ -4532,13 +5577,28 @@ $form_end;
$anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
}
}
- if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) {
+ if (($nomodal) && ($hostname ne '')) {
$link = 'http://'.$hostname.$url;
} else {
$link = $url;
}
- $link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.$anchor);
- if ($nomodal) {
+ my $inhibitmenu;
+ if ((($supplementalflag) && ($allowed) && ($url =~ m{^/adm/wrapper/})) ||
+ (($allowed) && (($url =~ m{^/adm/(viewclasslist|$match_domain/$match_username/aboutme)(\?|$)}) ||
+ ($url =~ m{^/public/$match_domain/$match_courseid/syllabus(\?|$)})))) {
+ $inhibitmenu = 'only_body=1';
+ } else {
+ $inhibitmenu = 'inhibitmenu=yes';
+ }
+ $link = &js_escape($link.(($url=~/\?/)?'&':'?').$inhibitmenu.$anchor);
+ if ($allowed && !$env{'request.role.adv'} && !$isfolder && !$ispage && !$uploaded) {
+ if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
+ $nolink = 1;
+ }
+ }
+ if ($nolink) {
+ $line.='';
+ } elsif ($nomodal) {
$line.=''.
'';
} else {
@@ -4550,7 +5610,11 @@ $form_end;
}
$line.=' | ';
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
- $line.=''.$title.'';
+ if ($nolink) {
+ $line.=$title;
+ } else {
+ $line.=''.$title.'';
+ }
if (!$allowed && $supplementalflag && $canedit && $isfolder) {
my $editicon = &Apache::loncommon::lonhttpdurl('/res/adm/pages').'/editmap.png';
my $editurl = $url;
@@ -4563,7 +5627,9 @@ $form_end;
$line.= ' ('.&mt('hidden').') ';
}
} elsif ($url) {
- if ($nomodal) {
+ if ($nolink) {
+ $line.=$title;
+ } elsif ($nomodal) {
$line.=''.
$title.'';
} else {
@@ -4582,6 +5648,11 @@ $form_end;
$line .= ' | ';
$rand_pick_text = ' ' if ($rand_pick_text eq '');
$rand_order_text = ' ' if ($rand_order_text eq '');
+ if ($uploaded && $url && !$isfolder && !$ispage) {
+ if (($plainurl ne '') && ($env{'request.role.adv'} || $allowed || !$hiddenres)) {
+ &Apache::lonnet::allowuploaded('/adm/coursedoc',$plainurl);
+ }
+ }
if ($allowed) {
my %lt=&Apache::lonlocal::texthash(
'hd' => 'Hidden',
@@ -4589,7 +5660,7 @@ $form_end;
my ($enctext,$hidtext,$formhidden,$formurlhidden);
if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
$hidtext = ' checked="checked"';
- if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
+ if (($ishash) && (ref($filtersref->{'hiddenresource'}) eq 'ARRAY')) {
push(@{$filtersref->{'hiddenresource'}},$orderidx);
}
}
@@ -4973,7 +6044,7 @@ sub short_urls {
}
my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum);
$r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef,
- undef,undef,undef,undef,undef,\%currtiny,$readonly));
+ undef,undef,undef,undef,undef,\%currtiny,undef,$readonly));
}
$r->print(&endContentScreen());
}
@@ -5448,6 +6519,7 @@ sub handler {
my $crstype = &Apache::loncommon::course_type();
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $coursehome=$env{'course.'.$env{'request.course.id'}.'.home'};
# get docroot
my $londocroot = $r->dir_config('lonDocRoot');
@@ -5463,7 +6535,9 @@ sub handler {
'Load_Map','Supplemental','Score_Upload_Form',
'Adding_Pages','Importing_LON-CAPA_Resource',
'Importing_IMS_Course','Uploading_From_Harddrive',
- 'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
+ 'Course_Roster','Web_Page','Dropbox','Simple_Problem',
+ 'Standard_Problem','Course_Resources',
+ 'Search_LON-CAPA_Resource','Import_Stored_Links') {
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
}
# Composite help files
@@ -5534,8 +6608,15 @@ sub handler {
&init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
&checkversions($r,$canedit);
} elsif ($canedit && $env{'form.dumpcourse'}) {
- &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
+ &init_breadcrumbs('dumpcourse','Copy uploaded content to Authoring Space');
&dumpcourse($r);
+ } elsif (($canedit || $canview) && ($env{'form.copyauthored'})) {
+ &init_breadcrumbs('copyauthored','Copy from Course Authoring to User Authoring');
+ my $readonly;
+ if (!$canedit) {
+ $readonly = 1;
+ }
+ ©crsauthored($r,$coursenum,$coursedom,$coursehome,$readonly);
} elsif ($canedit && $env{'form.exportcourse'}) {
&init_breadcrumbs('exportcourse','IMS Export');
&Apache::imsexport::exportcourse($r);
@@ -5638,17 +6719,23 @@ sub handler {
}
if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
if ($env{'form.forcestandard'}) { $supplementalflag=0; }
- unless ($allowed) { $supplementalflag=1; }
- unless ($standard) { $supplementalflag=1; }
+ unless (($supplementalflag) ||
+ ($r->uri =~ m{^/adm/coursedocs/showdoc/uploaded/\Q$coursedom\E/\Q$coursenum\E/docs/})) {
+ unless ($allowed) { $supplementalflag=1; }
+ unless ($standard) { $supplementalflag=1; }
+ }
my $toolsflag=0;
if ($env{'form.tools'}) { $toolsflag=1; }
if ($env{'form.folderpath'} ne '') {
- &validate_folderpath($supplementalflag);
+ &Apache::loncommon::validate_folderpath($supplementalflag,$allowed,$coursenum,$coursedom);
}
+ my $backto_supppath;
if ($env{'form.supppath'} ne '') {
- &validate_suppath();
+ if ($supplementalflag && $allowed) {
+ $backto_supppath = &validate_supppath($coursenum,$coursedom);
+ }
}
my $script='';
@@ -5658,6 +6745,7 @@ sub handler {
my $containertag;
my $pathitem;
my %ltitools;
+ my $posslti;
my $hiddentop;
my $navmap;
my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
@@ -5669,10 +6757,10 @@ sub handler {
&Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
&Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
$env{'form.command'}.'_'.$env{'form.symb'}});
- } elsif ($env{'form.supppath'} ne '') {
+ } elsif (($env{'form.supppath'} ne '') && $supplementalflag && $allowed) {
$env{'form.folderpath'}=$env{'form.supppath'};
&Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
- $env{'form.command'}.'_'.$env{'form.supppath'}});
+ $env{'form.command'}.'_'.$backto_supppath});
}
} elsif ($env{'form.command'} eq 'editdocs') {
$env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
@@ -5708,12 +6796,12 @@ sub handler {
undef($env{'form.folderpath'});
}
if ($env{'form.folderpath'} ne '') {
- &validate_folderpath($supplementalflag);
+ &Apache::loncommon::validate_folderpath($supplementalflag,$allowed,$coursenum,$coursedom);
}
}
-
-# If we are not allowed to make changes, all we can see are supplemental docs
- if (!$allowed) {
+
+# Set folderpath if we are not allowed to make changes and this is supplemental content
+ if ((!$allowed) && ($supplementalflag)) {
unless ($env{'form.folderpath'} =~ /^supplemental/) {
$env{'form.folderpath'} = &supplemental_base();
}
@@ -5724,10 +6812,10 @@ sub handler {
.'&'.
$env{'form.folderpath'};
}
-# If allowed and user's role is not advanced check folderpath is not hidden
- if (($allowed) && (!$env{'request.role.adv'}) &&
- ($env{'form.folderpath'} ne '') && (!$supplementalflag)) {
- my $folderurl;
+# If allowed and user's role is not advanced check folderpath is not hidden
+ my $hidden_and_empty;
+ if (($allowed) && (!$env{'request.role.adv'}) && ($env{'form.folderpath'} ne '')) {
+ my ($folderurl,$foldername,$hiddenfolder);
my @pathitems = split(/\&/,$env{'form.folderpath'});
my $folder = $pathitems[-2];
if ($folder eq '') {
@@ -5739,21 +6827,74 @@ sub handler {
} else {
$folderurl .= '.sequence';
}
- unless (ref($navmap)) {
- $navmap = Apache::lonnavmaps::navmap->new();
- }
- if (ref($navmap)) {
- if (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
- my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
- unless (@resources) {
- undef($env{'form.folderpath'});
+ if ($supplementalflag) {
+ ($foldername,$hiddenfolder) = ($pathitems[-1] =~ /^([^:]*)::(|1):::$/);
+ $foldername = &HTML::Entities::decode(&unescape($foldername));
+ my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
+ if (ref($supplemental) eq 'HASH') {
+ my ($suppmap,$suppmapnum);
+ if ($folder eq 'supplemental') {
+ $suppmap = 'default';
+ $suppmapnum = 0;
+ } elsif ($folder =~ /^supplemental_(\d+)$/) {
+ $suppmap = $1;
+ $suppmapnum = $suppmap;
+ }
+ if ($hiddenfolder) {
+ my $hascontent;
+ foreach my $key (reverse(sort(keys(%{$supplemental->{'ids'}})))) {
+ if ($key =~ m{^\Q/uploaded/$coursedom/$coursenum/supplemental/$suppmap/\E}) {
+ $hascontent = 1;
+ } elsif (ref($supplemental->{'ids'}->{$key}) eq 'ARRAY') {
+ foreach my $id (@{$supplemental->{'ids'}->{$key}}) {
+ if ($id =~ /^$suppmapnum\:/) {
+ $hascontent = 1;
+ last;
+ }
+ }
+ }
+ last if ($hascontent);
+ }
+ unless ($hascontent) {
+ if ($foldername ne '') {
+ $hidden_and_empty = $foldername;
+ } else {
+ $hidden_and_empty = $folder;
+ }
+ }
}
}
+ } else {
+ unless (ref($navmap)) {
+ $navmap = Apache::lonnavmaps::navmap->new();
+ }
+ ($foldername,$hiddenfolder) = ($pathitems[-1] =~ /^([^:]*):|\d+:|1:(|1):|1:|1$/);
+ $foldername = &HTML::Entities::decode(&unescape($foldername));
+ if (ref($navmap)) {
+ if ($hiddenfolder ||
+ (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes')) {
+ my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
+ unless (@resources) {
+ if ($foldername ne '') {
+ $hidden_and_empty = $foldername;
+ } else {
+ $hidden_and_empty = $folder;
+ }
+ }
+ }
+ }
+ }
+ if ($hidden_and_empty ne '') {
+ splice(@pathitems,-2);
+ if (@pathitems) {
+ $env{'form.folderpath'} = join('&',@pathitems);
+ } else {
+ undef($env{'form.folderpath'});
+ }
}
}
}
-
# If after all of this, we still don't have any paths, make them
unless ($env{'form.folderpath'}) {
if ($supplementalflag) {
@@ -5838,8 +6979,19 @@ sub handler {
}
}
my $tabidstr = join("','",@tabids);
- %ltitools = &Apache::lonnet::get_domain_lti($coursedom,'consumer');
- my $posslti = keys(%ltitools);
+ my (%domtools,%crstools);
+ my %tooltypes = &Apache::loncommon::usable_exttools();
+ if ($tooltypes{'dom'}) {
+ %domtools = &Apache::lonnet::get_domain_lti($coursedom,'consumer');
+ }
+ if ($tooltypes{'crs'}) {
+ %crstools = &Apache::lonnet::get_course_lti($coursenum,$coursedom,'consumer');
+ }
+ %ltitools = (
+ dom => \%domtools,
+ crs => \%crstools,
+ );
+ $posslti = scalar(keys(%domtools)) + scalar(keys(%crstools));
my $hostname = $r->hostname();
$script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
$londocroot,$canedit,$hostname,\$navmap).
@@ -5847,8 +6999,14 @@ sub handler {
&inject_data_js().
&Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
&Apache::lonextresedit::extedit_javascript(\%ltitools);
+ my $onload = "javascript:resize_scrollbox('contentscroll','1','1');";
+ if ($hidden_and_empty ne '') {
+ my $alert = &mt("Additional privileges required to edit empty and hidden folder: '[_1]'",
+ $hidden_and_empty);
+ $onload .= "javascript:alert('".&js_escape($alert)."');";
+ }
$addentries = {
- onload => "javascript:resize_scrollbox('contentscroll','1','1');",
+ onload => $onload,
};
}
$script .= &paste_popup_js();
@@ -5872,8 +7030,10 @@ sub handler {
if ($showdoc) {
my $args;
if ($supplementalflag) {
- my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$env{'form.title'},1);
- $args = {'bread_crumbs' => $brcrum};
+ my $title = &HTML::Entities::encode($env{'form.title'},'\'"<>&');
+ my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+ $args = {'bread_crumbs' => $brcrum,
+ 'bread_crumbs_nomenu' => 1};
} else {
$args = {'force_register' => $showdoc};
}
@@ -5902,8 +7062,13 @@ sub handler {
}
}
my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
+ my $args = {'bread_crumbs' => $brcrum};
+ unless (($env{'form.folderpath'} eq '') ||
+ ($env{'form.folder'} eq 'supplemental')) {
+ $args->{'bread_crumbs_nomenu'} = 1;
+ }
$r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
- {'bread_crumbs' => $brcrum,}));
+ $args));
} else {
my ($breadtext,$breadtitle,$helpitem);
$breadtext = "$crstype Editor";
@@ -5931,6 +7096,7 @@ sub handler {
my %codebase = ();
my ($upload_result,$upload_output,$uploadphase);
if ($canedit) {
+ undef($suppchanges);
if (($env{'form.uploaddoc.filename'}) &&
($env{'form.cmd'}=~/^upload_(\w+)/)) {
my $context = $1;
@@ -5942,6 +7108,10 @@ sub handler {
if ($hadchanges) {
&mark_hash_old();
}
+ if ($suppchanges) {
+ &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
+ undef($suppchanges);
+ }
$r->print($upload_output);
} elsif ($env{'form.phase'} eq 'upload_embedded') {
# Process file upload - phase two - upload embedded objects
@@ -5983,7 +7153,7 @@ sub handler {
if ($allowed && $toolsflag) {
$r->print(&startContentScreen('tools'));
- $r->print(&generate_admin_menu($crstype,$canedit));
+ $r->print(&generate_admin_menu($crstype,$canedit,$coursenum,$coursedom));
$r->print(&endContentScreen());
} elsif ((!$showdoc) && (!$uploadphase)) {
# -----------------------------------------------------------------------------
@@ -5991,8 +7161,8 @@ sub handler {
'copm' => 'All documents out of a published map into this folder',
'upfi' => 'Upload File',
'upld' => 'Upload Content',
- 'srch' => 'Search',
- 'impo' => 'Import',
+ 'srch' => 'Search Repository',
+ 'impo' => 'Import from Repository',
'lnks' => 'Import from Stored Links',
'impm' => 'Import from Assembled Map',
'imcr' => 'Import from Course Resources',
@@ -6010,6 +7180,7 @@ sub handler {
'stpr' => 'Standard Problem',
'news' => 'New sub-directory',
'crpr' => 'Create Problem',
+ 'swit' => 'Switch Server',
'drbx' => 'Drop Box',
'scuf' => 'External Scores (handgrade, upload, clicker)',
'bull' => 'Discussion Board',
@@ -6030,6 +7201,7 @@ sub handler {
'dire' => 'Directory:',
'cate' => 'Category:',
'tmpl' => 'Template:',
+ 'empd' => 'No resources found',
'comment' => 'Comment',
'parse' => 'Upload embedded images/multimedia files if HTML file',
'bb5' => 'Blackboard 5',
@@ -6079,10 +7251,7 @@ sub handler {
my $fileupload=(<
-
-
FIUP
-
my $checkbox=(<$lt{'parse'}?
@@ -6102,6 +7271,8 @@ CHBO
RESFORM
+ }
my $specialdocumentsform;
my @specialdocumentsforma;
@@ -6694,7 +7836,7 @@ NGFFORM
my @external = (
{''=>$extresourcesform}
);
- if (keys(%ltitools)) {
+ if ($posslti) {
push(@external,
{''=>$exttoolform},
);
@@ -6715,9 +7857,13 @@ NGFFORM
@gradingforma=(
{''=>$newsmpproblemform},
{''=>$newdropboxform},
- {''=>$newexuploadform},
- {''=>$crsresform},
+ {''=>$newexuploadform}
);
+ if ($crsresform) {
+ push(@gradingforma,
+ {''=>$crsresform}
+ );
+ }
$gradingform = &create_form_ul(&create_list_elements(@gradingforma));
@communityforma=(
@@ -6731,9 +7877,9 @@ NGFFORM
my %orderhash = (
'aa' => ['Upload',$fileuploadform],
- 'bb' => ['Import',$importpubform],
- 'cc' => ['External',$externalform],
- 'dd' => ['Grading',$gradingform],
+ 'bb' => ['External',$externalform],
+ 'cc' => ['Import',$importpubform],
+ 'dd' => ['Assessment',$gradingform],
'ff' => ['Other',$specialdocumentsform],
);
unless ($container eq 'page') {
@@ -6766,7 +7912,7 @@ unless ($container eq 'page') {
unless ($supplementalflag) {
$folder='supplemental';
}
- if ($folder =~ /^supplemental$/ &&
+ if (($folder eq 'supplemental') &&
(($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
$env{'form.folderpath'} = &supplemental_base();
} elsif ($allowed) {
@@ -6786,6 +7932,8 @@ unless ($container eq 'page') {
$fileupload
+
+
@@ -6798,6 +7946,7 @@ unless ($container eq 'page') {
$pathitem
+
SUPDOCFORM
@@ -6877,7 +8026,7 @@ my @specialdocs = (
my @supexternal = (
{''
=>$supextform});
- if (keys(%ltitools)) {
+ if ($posslti) {
push(@supexternal,
{''
=>$supexttoolform});
@@ -6903,26 +8052,7 @@ my %suporderhash = (
$r->print(''.$error.'
');
}
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;
- my $cachekey = &escape('showsupp').':'.&escape($hashid);
- &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
- }
- &Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom,1);
- &Apache::lonnet::count_supptools($coursenum,$coursedom,1);
- my $now = time;
- if ($env{'request.course.id'} eq $coursedom.'_'.$coursenum) {
- &Apache::lonnet::appenv({'request.course.suppupdated' => $now});
- }
- &Apache::lonnet::put('environment',{'internal.supplementalchange' => $now},
- $coursedom,$coursenum);
- &Apache::lonnet::appenv(
- {'course.'.$coursedom.'_'.$coursenum.'.internal.supplementalchange' => $now});
- &Apache::lonnet::do_cache_new('suppchange',$coursedom.'_'.$coursenum,$now,600);
- &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
+ &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
undef($suppchanges);
}
}
@@ -7093,6 +8223,10 @@ sub remove_archive {
if ($url eq $env{'form.archiveurl'}) {
if (&handle_edit_cmd($docuname,$docudom)) {
($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
+ if ($suppchanges) {
+ &Apache::lonnet::update_supp_caches($docudom,$docuname);
+ undef($suppchanges);
+ }
if ($fatal) {
if ($container eq 'page') {
$delwarning = &mt('An error occurred updating the contents of the current page.');
@@ -7124,7 +8258,7 @@ sub remove_archive {
}
sub generate_admin_menu {
- my ($crstype,$canedit) = @_;
+ my ($crstype,$canedit,$coursenum,$coursedom) = @_;
my $lc_crstype = lc($crstype);
my ($home,$other,%outhash)=&authorhosts();
my %lt= ( # do not translate here
@@ -7132,14 +8266,17 @@ sub generate_admin_menu {
'cv' => 'Check/Set Resource Versions',
'ls' => 'List Resource Identifiers',
'ct' => 'Display/Set Shortened URLs for Deep-linking',
+ 'ca' => "Enter $crstype Authoring Space",
'imse' => 'Export contents to IMS Archive',
- 'dcd' => "Copy $crstype Content to Authoring Space",
+ 'dcd' => 'Copy uploaded content to Authoring Space',
+ 'cpc' => 'Copy from Course Authoring to User Authoring',
);
- my ($candump,$dumpurl);
+ my ($candump,$dumpurl,$exportcrsurl);
if ($home + $other > 0) {
$candump = 'F';
if ($home) {
$dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
+ $exportcrsurl = "javascript:injectData(document.courseverify,'dummy','copyauthored','$lt{'cpc'}')";
} else {
my @hosts;
foreach my $aurole (keys(%outhash)) {
@@ -7153,8 +8290,10 @@ sub generate_admin_menu {
&HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
&HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
$dumpurl = "javascript:dump_needs_switchserver('$switchto')";
+ $exportcrsurl = $dumpurl;
} else {
$dumpurl = "javascript:choose_switchserver_window()";
+ $exportcrsurl = $dumpurl;
}
}
}
@@ -7192,6 +8331,31 @@ sub generate_admin_menu {
]
});
if ($canedit) {
+ my ($crsauname,$crsaudom,$crshome);
+ if (($coursenum ne '') && ($coursedom ne '')) {
+ my $crsauthorurl = "/priv/$coursedom/$coursenum/";
+ ($crsauname,$crsaudom,$crshome) = &Apache::lonnet::constructaccess($crsauthorurl);
+ if (($crsauname eq $coursenum) && ($crsaudom eq $coursedom)) {
+ my @ids=&Apache::lonnet::current_machine_ids();
+ my $linkurl;
+ if (grep(/^\Q$crshome\E$/,@ids)) {
+ $linkurl = $crsauthorurl;
+ } else {
+ $linkurl =
+ &Apache::lonhtmlcommon::jump_to_editres($crsauthorurl,$crshome,1);
+ }
+ if ((ref($menu[0]) eq 'HASH') && (ref($menu[0]->{'items'}) eq 'ARRAY')) {
+ push(@{$menu[0]->{items}},
+ { linktext => $lt{'ca'},
+ url => $linkurl,
+ permission => 'F',
+ help => 'Docs_Course_Authorspace',
+ icon => 'impcrsau.png',
+ linktitle => $lt{'ca'},
+ });
+ }
+ }
+ }
push(@menu,
{ categorytitle=>'Export',
items =>[
@@ -7211,6 +8375,18 @@ sub generate_admin_menu {
},
]
});
+ if (($crsauname eq $coursenum) && ($crsaudom eq $coursedom)) {
+ if ((ref($menu[1]) eq 'HASH') && (ref($menu[1]->{'items'}) eq 'ARRAY')) {
+ push(@{$menu[1]->{items}},
+ { linktext => $lt{'cpc'},
+ url => $exportcrsurl,
+ permission => 'F',
+ help => 'Docs_Export_Course_Author',
+ icon => 'res.png',
+ linktitle => $lt{'cpc'},
+ });
+ }
+ }
}
return '