--- loncom/interface/londocs.pm 2025/01/04 01:34:57 1.717 +++ loncom/interface/londocs.pm 2025/01/07 21:01:37 1.722 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.717 2025/01/04 01:34:57 raeburn Exp $ +# $Id: londocs.pm,v 1.722 2025/01/07 21:01:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -884,7 +884,7 @@ ENDJS if (keys(%tocopy)) { my (%resdirs,%resfiles); &Apache::lonnet::recursedirs($is_course_home,1,undef,$res_exclude,0,0,$resurl,'',\%resdirs,\%resfiles); - my ($notopdir,%newdir,%newfile,%checkdeps); + my ($notopdir,%newdir,%newfile,%checkdeps,%newresfile); $r->print('

'.&mt('Copy to: [_1]', ''.$desturl.'/'.$subdir.''). '

'."\n"); @@ -1026,7 +1026,7 @@ ENDJS } } else { if (&File::Copy::copy($src,$dest)) { - $newfile{$file} = 1; + $newfile{$file} = $desturl.'/'.$subdir.'/'.$file; if ($embstyle eq 'ssi') { &crsres_fixup($dest,$coursenum,$coursedom,$ca,$cd,$subdir); } @@ -1055,6 +1055,9 @@ ENDJS my $destresfile = $docroot.$destresurl.'/'.$subdir.'/'.$file; if (-e $dest) { my $output = &Apache::lonpublisher::batchpublish($r,$dest,$destresfile,$nokeyref,1); + if (-e $destresfile) { + $newresfile{$file} = $destresurl.'/'.$subdir.'/'.$file; + } } } } else { @@ -1065,7 +1068,7 @@ ENDJS } if ($needpriv) { if (&File::Copy::copy($src,$dest)) { - $newfile{$file} = 1; + $newfile{$file} = $desturl.'/'.$subdir.'/'.$file; if ($embstyle eq 'ssi') { &crsres_fixup($dest,$coursenum,$coursedom,$ca,$cd,$subdir); } @@ -1099,7 +1102,7 @@ ENDJS if ($embstyle eq 'ssi') { &crsres_fixup($dest,$coursenum,$coursedom,$ca,$cd,$subdir); } - $newfile{$file} = 1; + $newfile{$file} = $desturl.'/'.$subdir.'/'.$file; } } } else { @@ -1127,7 +1130,9 @@ ENDJS my $destresfile = $docroot.$destresurl.'/'.$subdir.'/'.$file; if (-e $dest) { my $output = &Apache::lonpublisher::batchpublish($r,$dest,$destresfile,$nokeyref,1); -#FIXME publish meta file also? + if (-e $destresfile) { + $newresfile{$file} = $destresurl.'/'.$subdir.'/'.$file; + } } } } else { @@ -1141,7 +1146,7 @@ ENDJS if ($embstyle eq 'ssi') { &crsres_fixup($dest,$coursenum,$coursedom,$ca,$cd,$subdir); } - $newfile{$file} = 1; + $newfile{$file} = $desturl.'/'.$subdir.'/'.$file; } } if ($needprivmeta) { @@ -1172,6 +1177,16 @@ ENDJS $r->print('

'.&mt('Copied the following files to [_1]:',''.$desturl.'/'.$subdir.''). '

'."\n". '

'."\n"); + foreach my $file (keys(%newfile)) { + my %storehash = ( + 'priv' => $newfile{$file}, + 'who' => $env{'user.name'}.':'.$env{'user.domain'}, + ); + if (exists($newresfile{$file})) { + $storehash{'res'} = 1; + } + &Apache::lonnet::store_userdata(\%storehash,$file,'copycourseauthor',$coursedom,$coursenum); + } } if (keys(%checkdeps)) { my %missingdep; @@ -1262,7 +1277,32 @@ ENDJS &mt('Choose the files and/or folders to copy from Course Authoring to User Authoring'). '

'."\n"; my $count = 0; - my $startcount = 4 + $home; +# +# Warning to developers: +# +# If you add or remove form elements which precede the table of items to copy +# you will need to modify the value for startcount. Form elements include both: +# and
tags. +# $startcount (set to 9) contains the following: +# fieldsets with following legends: (a) Folder in Authoring Space, (b) Distribution to set in metadata +# (c) Content to copy +# inputs: textbox for destination folder; dropdown lists: (a) Copyright, (b) Source +# hidden: customrights file; buttons: (a) check all, (b) uncheck all. +# authorspace: if more than 1: a fieldset with legend: Select the Authoring Space, +# or if 1: an input (hidden) with available author/coauthor role. +# if there are multiple possible author/coauthor roles (i.e., $home > 1), +# incerement startcount by 1 for the dropdown list uses to select the target. +# +# If there are published files, increment startcount by 3: +# fieldset (legend: Published Resources), and two radio buttons (Yes/No). +# + my $startcount = 9; + if ($home > 1) { + $startcount ++; + } + if ($numpub) { + $startcount += 3; + } my $lastcontainer = $startcount; $display .= &Apache::loncommon::start_data_table()."\n". &Apache::loncommon::start_data_table_header_row(). @@ -8644,10 +8684,12 @@ sub generate_admin_menu { if (grep(/^\Q$crshome\E$/,@ids)) { $linkurl = $crsauthorurl; } else { - $linkurl = - &Apache::lonhtmlcommon::jump_to_editres($crsauthorurl,$crshome,1); + my $jscall = &Apache::lonhtmlcommon::jump_to_editres($crsauthorurl,$crshome,1); + if ($jscall) { + $linkurl = 'javascript:'.$jscall; + } } - if ((ref($menu[0]) eq 'HASH') && (ref($menu[0]->{'items'}) eq 'ARRAY')) { + if ((ref($menu[0]) eq 'HASH') && (ref($menu[0]->{'items'}) eq 'ARRAY') && ($linkurl)) { push(@{$menu[0]->{items}}, { linktext => $lt{'ca'}, url => $linkurl,