--- loncom/interface/loncommon.pm 2011/11/02 23:05:07 1.1027 +++ loncom/interface/loncommon.pm 2011/11/14 00:20:34 1.1028 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1027 2011/11/02 23:05:07 raeburn Exp $ +# $Id: loncommon.pm,v 1.1028 2011/11/14 00:20:34 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4532,29 +4532,39 @@ sub designparm { =item * &authorspace() -Inputs: ./. +Inputs: $url (usually will be undef). -Returns: Path to the Construction Space of the current user's - accessed author space - The author space will be that of the current user - when accessing the own author space - and that of the co-author/assistent co-author - when accessing the co-author's/assistent co-author's - space +Returns: Path to Construction Space containing the resource or + directory being viewed (or for which action is being taken). + If $url is provided, and begins /priv// + the path will be that portion of the $context argument. + Otherwise the path will be for the author space of the current + user when the current role is author, or for that of the + co-author/assistant co-author space when the current role + is co-author or assistant co-author. =cut sub authorspace { + my ($url) = @_; + if ($url ne '') { + if ($url =~ m{^(/priv/$match_domain/$match_username/)}) { + return $1; + } + } my $caname = ''; my $cadom = ''; - if ($env{'request.role'} =~ /^ca|^aa/) { + if ($env{'request.role'} =~ /^(?:ca|aa)/) { ($cadom,$caname) = ($env{'request.role'}=~/($match_domain)\/($match_username)$/); - } else { + } elsif ($env{'request.role'} =~ m{^au\./($match_domain)/}) { $caname = $env{'user.name'}; $cadom = $env{'user.domain'}; } - return '/priv/'.$cadom.'/'.$caname.'/'; + if (($caname ne '') && ($cadom ne '')) { + return "/priv/$cadom/$caname/"; + } + return; } ##############################################