--- loncom/auth/restrictedaccess.pm	2006/07/14 21:38:26	1.2
+++ loncom/auth/restrictedaccess.pm	2006/07/17 19:49:14	1.3
@@ -102,21 +102,15 @@ function verify() {
 
 sub check_pass {
     my ($r,$origurl) = @_;
-    my ($udom,$unum,$group,$file_name,$result,$end);
-    if ($origurl =~  m-/+uploaded/([^/]+)/([^/]+)/portfolio(/.+)$-) {
-        $udom = $1;
-        $unum = $2;
-        $file_name = $3;
-    } elsif ($origurl =~ m-/+uploaded/([^/]+)/([^/]+)/groups/([^/]+)/portfolio/(.+)$-) {
-        $udom = $1;
-        $unum = $2;
-        $group = $3;
-        $file_name = $3.'/'.$4;
-    }
+    my (undef,$udom,$unum,$file_name,$group) = 
+	&Apache::lonacc::parse_portfolio_url($origurl);
+
     my $curr_perms = &Apache::lonnet::get_portfile_permissions($udom,$unum);
     my %acc_controls = &Apache::lonnet::get_access_controls($curr_perms,
                                                             $group,$file_name);
     my $access_hash = $acc_controls{$file_name};
+
+    my ($result,$end);
     foreach my $key (sort(keys(%{$access_hash}))) {
         if ($key =~ /^[^:]+:guest_(\d+)/) {
             $end = $1;