--- loncom/lonnet/perl/lonnet.pm	2012/11/29 03:23:52	1.1200
+++ loncom/lonnet/perl/lonnet.pm	2012/12/05 17:40:59	1.1206
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1200 2012/11/29 03:23:52 raeburn Exp $
+# $Id: lonnet.pm,v 1.1206 2012/12/05 17:40:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2732,7 +2732,11 @@ sub can_edit_resource {
                 $incourse = 1;
                 if ($file =~/\.(htm|html|css|js|txt)$/) {
                     $cfile = &hreflocation('',$file);
-                    $forceedit = 1;
+                    if ($env{'form.forceedit'}) {
+                        $forceview = 1;
+                    } else {
+                        $forceedit = 1;
+                    }
                 }
             } elsif ($resurl =~ m{^/public/$cdom/$cnum/syllabus}) {
                 $incourse = 1;
@@ -2820,8 +2824,8 @@ sub is_course_upload {
     my ($file,$cnum,$cdom) = @_;
     my $uploadpath = &LONCAPA::propath($cdom,$cnum);
     $uploadpath =~ s{^\/}{};
-    if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
-        ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
+    if (($file =~ m{^\Q$uploadpath\E/userfiles/(docs|supplemental)/}) ||
+        ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/(docs|supplemental)/})) {
         return 1;
     }
     return;
@@ -10320,7 +10324,8 @@ sub getdocspath {
                                  ':'.$res->randompick().
                                  ':'.$res->randomout().
                                  ':'.$res->encrypted().
-                                 ':'.$res->randomorder();
+                                 ':'.$res->randomorder().
+                                 ':'.$res->is_page();
                     }
                 }
             }
@@ -10335,19 +10340,24 @@ sub getdocspath {
                     ':'.$mapresobj->randompick().
                     ':'.$mapresobj->randomout().
                     ':'.$mapresobj->encrypted().
-                    ':'.$mapresobj->randomorder();
+                    ':'.$mapresobj->randomorder().
+                    ':'.$mapresobj->is_page();
         } else {
             my $maptitle = &gettitle($mapurl);
+            my $ispage;
+            if ($mapurl =~ /\.page$/) {
+                $ispage = 1;
+            }
             if ($mapurl eq 'default') {
                 $maptitle = 'Main Course Documents';
             }
             $path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
-                    &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
+                    &Apache::lonhtmlcommon::entity_encode($maptitle).':::::'.$ispage;
         }
         unless ($mapurl eq 'default') {
             $path = 'default&'.
                     &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
-                    '::::&'.$path;
+                    ':::::&'.$path;
         }
     }
     return $path;
@@ -10500,21 +10510,32 @@ sub symbverify {
 
     if (tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
                             &GDBM_READER(),0640)) {
+        my $noclutter;
         if (($thisurl =~ m{^/adm/wrapper/ext/}) || ($thisurl =~ m{^ext/})) {
             $thisurl =~ s/\?.+$//;
+            if ($map =~ m{^uploaded/.+\.page$}) {
+                $thisurl =~ s{^(/adm/wrapper|)/ext/}{http://};
+                $thisurl =~ s{^\Qhttp://https://\E}{https://};
+                $noclutter = 1;
+            }
+        }
+        my $ids;
+        if ($noclutter) {
+            $ids=$bighash{'ids_'.$thisurl};
+        } else {
+            $ids=$bighash{'ids_'.&clutter($thisurl)};
         }
-        my $ids=$bighash{'ids_'.&clutter($thisurl)};
         unless ($ids) {
             my $idkey = 'ids_'.($thisurl =~ m{^/}? '' : '/').$thisurl;  
             $ids=$bighash{$idkey};
         }
         if ($ids) {
 # ------------------------------------------------------------------- Has ID(s)
+            if ($thisfn =~ m{^/adm/wrapper/ext/}) {
+                $symb =~ s/\?.+$//;
+            }
 	    foreach my $id (split(/\,/,$ids)) {
 	       my ($mapid,$resid)=split(/\./,$id);
-               if ($thisfn =~ m{^/adm/wrapper/ext/}) {
-                   $symb =~ s/\?.+$//;
-               }
                if (
   &symbclean(&declutter($bighash{'map_id_'.$mapid}).'___'.$resid.'___'.$thisfn)
    eq $symb) {
@@ -10525,6 +10546,7 @@ sub symbverify {
 		       ($bighash{'encrypted_'.$id} eq $env{'request.enc'}) ||
                        ($thisurl eq '/adm/navmaps')) {
 		       $okay=1;
+                       last;
 		   }
 	       }
 	   }
@@ -10600,14 +10622,14 @@ sub deversion {
 
 sub symbread {
     my ($thisfn,$donotrecurse)=@_;
-    my $cache_str='request.symbread.cached.'.$thisfn;
-    if (defined($env{$cache_str})) {
-        if (($thisfn) || ($env{$cache_str} ne '')) {
+    my $cache_str;
+    if ($thisfn ne '') {
+        $cache_str='request.symbread.cached.'.$thisfn;
+        if ($env{$cache_str} ne '') {
             return $env{$cache_str};
         }
-    }
+    } else {
 # no filename provided? try from environment
-    unless ($thisfn) {
         if ($env{'request.symb'}) {
 	    return $env{$cache_str}=&symbclean($env{'request.symb'});
 	}