[LON-CAPA-cvs] cvs: loncom /interface londocs.pm

raeburn raeburn at source.lon-capa.org
Tue Sep 13 09:54:03 EDT 2022


raeburn		Tue Sep 13 13:54:03 2022 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - If a custom role has mdc but not adv priv, links to display resource 
    in modal window within Course Editor need to be encrypted when hidden URL 
    param is in effect.
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.679 loncom/interface/londocs.pm:1.680
--- loncom/interface/londocs.pm:1.679	Tue Sep 13 12:22:14 2022
+++ loncom/interface/londocs.pm	Tue Sep 13 13:54:02 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.679 2022/09/13 12:22:14 raeburn Exp $
+# $Id: londocs.pm,v 1.680 2022/09/13 13:54:02 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4241,30 +4241,10 @@
                     $nomodal = 1;
                 }
             }
-            if (&Apache::lonnet::symbverify($symb,$url)) {
-                $shownsymb = $symb;
-                if ($isexternal) {
-                    $url =~ s/\#[^#]+$//;
-                    if ($container eq 'page') {
-                        $url = &Apache::lonnet::clutter($url);
-                    }
-                }
-                unless ($env{'request.role.adv'}) {
-                    if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
-                        $url = '';
-                    }
-                    if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
-                        $url = '';
-                        $hiddenres = 1;
-                    }
-                }
-                if ($url ne '') {
-                    $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
-                }
-            } elsif (!$env{'request.role.adv'}) {
-                my $checkencrypt;
+            my ($checkencrypt,$shownurl);
+            if (!$env{'request.role.adv'}) {
                 if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
-                      $isencrypted || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
+                    ($isencrypted) || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
                     $checkencrypt = 1;
                 } elsif (ref($navmapref)) {
                     unless (ref($$navmapref)) {
@@ -4272,26 +4252,43 @@
                     }
                     if (ref($$navmapref)) {
                         if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') {
-                            $checkencrypt = 1;       
+                            $checkencrypt = 1;
                         }
                     }
                 }
-                if ($checkencrypt) {
-                    $shownsymb = &Apache::lonenc::encrypted($symb);
-                    my $shownurl = &Apache::lonenc::encrypted($url);
-                    if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {
-                        $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
-                        if ($env{'request.enc'} ne '') {
-                            delete($env{'request.enc'});
-                        }
-                    } else {
-                        $url='';
-                    }
+            }
+            if ($checkencrypt) {
+                my $currenc = $env{'request.enc'};
+                $env{'request.enc'} = 1;
+                $shownsymb = &Apache::lonenc::encrypted($symb);
+                $shownurl = &Apache::lonenc::encrypted($url);
+                if (&Apache::lonnet::symbverify($symb,$url)) {
+                    $url = $shownurl;
                 } else {
-                    $url='';
+                    $url = '';
                 }
-            } else {
-                $url='';
+                $env{'request.enc'} = $currenc;
+            } elsif (&Apache::lonnet::symbverify($symb,$url)) {
+                $shownsymb = $symb;
+                if ($isexternal) {
+                    $url =~ s/\#[^#]+$//;
+                    if ($container eq 'page') {
+                        $url = &Apache::lonnet::clutter($url);
+                    }
+                }
+                $shownurl = $url;
+            }
+            unless ($env{'request.role.adv'}) {
+                if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
+                    $url = '';
+                }
+                if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
+                    $url = '';
+                    $hiddenres = 1;
+                }
+            }
+            if ($url ne '') {
+                $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
             }
 	}
     } elsif ($supplementalflag) {




More information about the LON-CAPA-cvs mailing list