--- loncom/interface/londependencies.pm 2012/11/29 20:37:07 1.3 +++ loncom/interface/londependencies.pm 2013/05/03 21:57:13 1.4 @@ -2,7 +2,7 @@ # Handler to manage dependencies for HTML files uploaded directly # to a course. # -# $Id: londependencies.pm,v 1.3 2012/11/29 20:37:07 raeburn Exp $ +# $Id: londependencies.pm,v 1.4 2013/05/03 21:57:13 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -103,7 +103,8 @@ sub handler { my ($mimetype,$numpathchgs,$numrefchanges,%allfiles,%codebase,$url); if ($symb) { (undef,undef,$url) = &Apache::lonnet::decode_symb($symb); - } elsif (($docs_url) && ($env{'httpref.'.$docs_url} ne '')) { + } elsif (($docs_url) && (($env{'httpref.'.$docs_url} ne '') || + ($docs_url =~ m{^\Q/uploaded/$cdom/$cnum/\E(portfolio/syllabus)/}))) { $url = $docs_url; $url =~ s{^/}{}; } @@ -113,8 +114,15 @@ sub handler { ''."\n". ''."\n"; my $dir_root = '/userfiles'; - my ($destination) = - ($url =~ m{^\Quploaded/$cdom/$cnum/\E((?:docs|supplemental)/(?:default|\d+)/\d+)/}); + my ($destination,$context); + if ($url =~ m{^\Quploaded/$cdom/$cnum/\E(portfolio/syllabus)/}) { + $destination = $1; + $context = 'syllabus'; + } else { + ($destination) = + ($url =~ m{^\Quploaded/$cdom/$cnum/\E((?:docs|supplemental)/(?:default|\d+)/\d+)/}); + $context = 'coursedoc'; + } my $js = &Apache::loncommon::ask_embedded_js(); my $output = &Apache::loncommon::start_page($title,$js, {'only_body' => 1}); @@ -126,7 +134,7 @@ sub handler { $numrefchanges = $count + $codebasecount; } elsif ($action eq 'process_changes') { (my $result,$numpathchgs) = - &process_changes($cdom,$cnum,$chome,$url,$destination,$dir_root,$state); + &process_changes($cdom,$cnum,$chome,$url,$destination,$dir_root,$state,$context); $output .= $result; } unless ((($action eq 'process_changes') && ($numpathchgs > 0)) || @@ -148,7 +156,7 @@ sub handler { } sub process_changes { - my ($cdom,$cnum,$chome,$url,$destination,$dir_root,$state) = @_; + my ($cdom,$cnum,$chome,$url,$destination,$dir_root,$state,$context) = @_; my ($output,$numpathchgs); my ($numnew,$numtodelete,$numtomod) = (0,0,0); my $url_root = "/uploaded/$cdom/$cnum"; @@ -199,11 +207,20 @@ sub process_changes { } if ((@modifications > 0) || ($numnew > 0)) { (my $result,my $flag,$numpathchgs) = - &Apache::loncommon::upload_embedded('coursedoc',$destination,$cnum,$cdom, + &Apache::loncommon::upload_embedded($context,$destination,$cnum,$cdom, $dir_root,$url_root,undef,undef,undef, $state,'/adm/dependencies'); $output .= '

'.&mt('Uploaded files').'

'. $result; + unless ($numpathchgs) { + if ($context eq 'syllabus') { + my $modres = + &Apache::loncommon::modify_html_refs($context,'portfolio/syllabus', + $cnum,$cdom, + '/userfiles',"/$url"); + $result .= $modres; + } + } } } else { $output .= ''.