[LON-CAPA-cvs] cvs: loncom /publisher lonunauthorized.pm

raeburn raeburn at source.lon-capa.org
Sun Nov 25 22:49:05 EST 2018


raeburn		Mon Nov 26 03:49:05 2018 EDT

  Modified files:              
    /loncom/publisher	lonunauthorized.pm 
  Log:
  - More meaningful messages when HTTP_NOT_ACCEPTABLE encountered for:
    /adm/upload
  
  
Index: loncom/publisher/lonunauthorized.pm
diff -u loncom/publisher/lonunauthorized.pm:1.18 loncom/publisher/lonunauthorized.pm:1.19
--- loncom/publisher/lonunauthorized.pm:1.18	Sun Jun 19 04:27:58 2016
+++ loncom/publisher/lonunauthorized.pm	Mon Nov 26 03:49:04 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Unauthorized to access construction space
 #
-# $Id: lonunauthorized.pm,v 1.18 2016/06/19 04:27:58 raeburn Exp $
+# $Id: lonunauthorized.pm,v 1.19 2018/11/26 03:49:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -102,7 +102,8 @@
         if ($ENV{'REDIRECT_URL'} =~ m{^/adm/([^/]+)}) {
             my $action = $1;   
             my ($option,$filename,$filename1,$filename2,$decompress,
-                $qualifiedfilename);
+                $qualifiedfilename,$warning);
+            my %deniedactions = &get_denied_action_text();
             if ($ENV{'REDIRECT_QUERY_STRING'} ne '') {
                 foreach my $pair (split(/&/,$ENV{'REDIRECT_QUERY_STRING'})) {
                     my ($name,$value) = split(/=/,$pair);
@@ -130,11 +131,11 @@
                             $option = 'cstr';
                         }
                     } elsif ($name eq 'filetwo') {
-                        $option = $value; 
+                        $option = $value;
                     }
                 }
                 if (($action eq 'upload') || ($action eq 'testbank')) {
-                    if (($filename1 ne '') && ($filename ne '')) {
+                    if (($filename1 ne '') && ($filename2 ne '')) {
                         $filename = $filename1.$filename2;
                     }
                 } elsif ($action eq 'cfile') {
@@ -144,8 +145,6 @@
                         $filename = $qualifiedfilename;
                     }
                 }
-                my %deniedactions = &get_denied_action_text();
-                my $warning;
                 if ($option eq 'decompress') {
                     $warning = $deniedactions{$option};
                 } else {
@@ -173,6 +172,33 @@
                               &mt('You are not permitted to take this action.').
                               '</p>');
                 }
+            } elsif (($action eq 'upload') || ($action eq 'testbank')) {
+                $filename1 = $env{'form.filename1'};
+                $filename2 = $env{'form.filename2'};
+                if (($filename1 ne '') && ($filename2 ne '')) {
+                    $filename = $filename1.$filename2;
+                }
+                $warning = $deniedactions{$action};
+                if ($warning) {
+                    if ($filename =~ m{^/priv/.+\.\d+\.[^.]+$}) {
+                        $r->print('<p class="LC_error">'.
+                                  &mt('There is a problem with the filename').' '.
+                                  '<span class="LC_filename">'.$filename.'</span></p>'.
+                                  '<p class="LC_warning">'.
+                                  &mt('The suggested filename may not include the pattern ".number.extension" as LON-CAPA reserves that pattern for its internal versioning mechanism.').
+                                  '</p>');
+                    } else {
+                        $r->print('<p class="LC_error">'.
+                                  $deniedactions{$action}.'</p><p class="LC_warning">'.
+                                  &mt('You do not have authoring privileges for this resource').' '.
+                                      '<span class="LC_filename">'.$filename.'</span>'.
+                                  '</p>');
+                    }
+                } else {
+                    $r->print('<p class="LC_error">'.
+                              &mt('You are not permitted to take this action.').
+                              '</p>');
+                }
             }
         } elsif ($r->uri =~ m{priv/.+\.\d+\.[^.]+$}) {
             $r->print('<p class="LC_error">'.




More information about the LON-CAPA-cvs mailing list