--- loncom/lonnet/perl/lonnet.pm 2012/11/11 17:33:26 1.1198 +++ loncom/lonnet/perl/lonnet.pm 2012/11/27 23:45:22 1.1199 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1198 2012/11/11 17:33:26 raeburn Exp $ +# $Id: lonnet.pm,v 1.1199 2012/11/27 23:45:22 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2671,7 +2671,7 @@ sub can_edit_resource { # # For aboutme pages user can only edit his/her own. # - if ($resurl =~ m{^/adm/($match_domain)/($match_username)/aboutme$}) { + if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) { my ($sdom,$sname) = ($1,$2); if (($sdom eq $env{'user.domain'}) && ($sname eq $env{'user.name'})) { $home = $env{'user.home'}; @@ -2751,12 +2751,17 @@ sub can_edit_resource { $forceedit = 1; } $cfile = $resurl; - } elsif (($resurl eq '/res/lib/templates/simpleproblem.problem')) { + } elsif ($resurl eq '/res/lib/templates/simpleproblem.problem') { $incourse = 1; $cfile = $resurl.'/smpedit'; - } elsif ($resurl =~ /ext/) { + } elsif ($resurl =~ m{^/adm/wrapper/ext/}) { $incourse = 1; - # is external + if ($env{'form.forceedit'}) { + $forceview = 1; + } else { + $forceedit = 1; + } + $cfile = $resurl; } } elsif ($resurl eq '/res/lib/templates/simpleproblem.problem/smpedit') { my $template = '/res/lib/templates/simpleproblem.problem'; @@ -2765,6 +2770,26 @@ sub can_edit_resource { $forceview = 1; $cfile = $template; } + } elsif (($resurl =~ m{^/adm/wrapper/ext/}) && ($env{'form.folderpath'} =~ /^supplemental/)) { + $incourse = 1; + if ($env{'form.forceedit'}) { + $forceview = 1; + } else { + $forceedit = 1; + } + $cfile = $resurl; + } elsif (($resurl eq '/adm/extresedit') && ($symb || $env{'form.folderpath'})) { + $incourse = 1; + $forceview = 1; + if ($symb) { + my ($map,$id,$res)=&decode_symb($symb); + $env{'request.symb'} = $symb; + $cfile = &clutter($res); + } else { + $cfile = $env{'form.suppurl'}; + $cfile =~ s{^http://}{}; + $cfile = '/adm/wrapper/ext/'.$cfile; + } } } if ($uploaded || $incourse) { @@ -10262,6 +10287,72 @@ sub gettitle { return $title; } +sub getdocspath { + my ($symb) = @_; + my $path; + if ($symb) { + my ($mapurl,$id,$resurl) = &decode_symb($symb); + if ($resurl=~/\.(sequence|page)$/) { + $mapurl=$resurl; + } elsif ($resurl eq 'adm/navmaps') { + $mapurl=$env{'course.'.$env{'request.course.id'}.'.url'}; + } + my $mapresobj; + my $navmap = Apache::lonnavmaps::navmap->new(); + if (ref($navmap)) { + $mapresobj = $navmap->getResourceByUrl($mapurl); + } + $mapurl=~s{^.*/([^/]+)\.(\w+)$}{$1}; + my $type=$2; + if (ref($mapresobj)) { + my $pcslist = $mapresobj->map_hierarchy(); + if ($pcslist ne '') { + foreach my $pc (split(/,/,$pcslist)) { + next if ($pc <= 1); + my $res = $navmap->getByMapPc($pc); + if (ref($res)) { + my $thisurl = $res->src(); + $thisurl=~s{^.*/([^/]+)\.\w+$}{$1}; + my $thistitle = $res->title(); + $path .= '&'. + &Apache::lonhtmlcommon::entity_encode($thisurl).'&'. + &Apache::lonhtmlcommon::entity_encode($thistitle). + ':'.$res->randompick(). + ':'.$res->randomout(). + ':'.$res->encrypted(). + ':'.$res->randomorder(); + } + } + } + $path =~ s/^\&//; + my $maptitle = $mapresobj->title(); + if ($mapurl eq 'default') { + $maptitle = 'Main Course Documents'; + } + $path .= ($path ne '')? '&' : ''. + &Apache::lonhtmlcommon::entity_encode($mapurl).'&'. + &Apache::lonhtmlcommon::entity_encode($maptitle). + ':'.$mapresobj->randompick(). + ':'.$mapresobj->randomout(). + ':'.$mapresobj->encrypted(). + ':'.$mapresobj->randomorder(); + } else { + my $maptitle = &gettitle($mapurl); + if ($mapurl eq 'default') { + $maptitle = 'Main Course Documents'; + } + $path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'. + &Apache::lonhtmlcommon::entity_encode($maptitle).'::::'; + } + unless ($mapurl eq 'default') { + $path = 'default&'. + &Apache::lonhtmlcommon::entity_encode('Main Course Documents'). + '::::&'.$path; + } + } + return $path; +} + sub get_slot { my ($which,$cnum,$cdom)=@_; if (!$cnum || !$cdom) {