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

raeburn raeburn at source.lon-capa.org
Fri Jul 14 10:32:57 EDT 2023


raeburn		Fri Jul 14 14:32:57 2023 EDT

  Modified files:              
    /loncom/publisher	loncfile.pm 
  Log:
  - Breadcrumbs text when creating new file in Course Authoring Space.
  - Creation of new files with extensions: .page, .sequence, .rights and
    .library is disabled in Course Authoring Space. 
  
  
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.125 loncom/publisher/loncfile.pm:1.126
--- loncom/publisher/loncfile.pm:1.125	Wed Mar  6 02:31:16 2019
+++ loncom/publisher/loncfile.pm	Fri Jul 14 14:32:57 2023
@@ -9,7 +9,7 @@
 #  and displays a page showing the results of the action.
 #
 #
-# $Id: loncfile.pm,v 1.125 2019/03/06 02:31:16 raeburn Exp $
+# $Id: loncfile.pm,v 1.126 2023/07/14 14:32:57 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1477,7 +1477,7 @@
 	return HTTP_NOT_FOUND;
     }
 
-    unless ($fn) { 
+    unless ($fn) {
 	&Debug($r, "loncfile::handler - doctored url is empty");
 	$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
 		       ' trying to cfile non-existing file', $r->filename); 
@@ -1520,20 +1520,33 @@
     my $londocroot = $r->dir_config('lonDocRoot');
     my $trailfile = $fn;
     $trailfile =~ s{^/(priv/)}{$londocroot/$1};
-    
+
     # Breadcrumbs
+    my $crsauthor;
+    my $text = 'Authoring Space';
+    my $title = 'Authoring Space File Operation',
+    my $href = &Apache::loncommon::authorspace(&url($fn));
+    if ($env{'request.course.id'}) {
+        my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+        my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+        if ($href eq "/priv/$cdom/$cnum/") {
+            $text = 'Course Authoring Space';
+            $title = 'Course Authoring Space File Operation',
+            $crsauthor = 1;
+        }
+    }
     &Apache::lonhtmlcommon::clear_breadcrumbs();
     &Apache::lonhtmlcommon::add_breadcrumb({
-        'text'  => 'Authoring Space',
-        'href'  => &Apache::loncommon::authorspace($fn),
+        'text'  => $text,
+        'href'  => $href,
     });
     &Apache::lonhtmlcommon::add_breadcrumb({
         'text'  => 'File Operation',
-        'title' => 'Authoring Space File Operation',
+        'title' => $title,
         'href'  => '',
     });
 
-    $r->print(&Apache::loncommon::start_page('Authoring Space File Operation',
+    $r->print(&Apache::loncommon::start_page($title,
 					     $js,
 					     {'add_entries' => \%loaditem,})
              .&Apache::lonhtmlcommon::breadcrumbs()
@@ -1544,10 +1557,12 @@
     $r->print('<p>'.&mt('Location').': '.&display($fn).'</p>');
   
     if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
-        $r->print('<p class="LC_info">'
-                 .&mt('Co-Author [_1]',$uname.':'.$udom)
-                 .'</p>'
-        );
+        unless ($crsauthor) {  
+            $r->print('<p class="LC_info">'
+                     .&mt('Co-Author [_1]',$uname.':'.$udom)
+                     .'</p>'
+            );
+        }
     }
 
 
@@ -1571,6 +1586,25 @@
 	'Select Action'   => 'New Resource',
     );
     if ($action{$env{'form.action'}}) {
+        if ($crsauthor) {
+            my @disallowed = qw(page sequence rights library);
+            my $newtype;
+            if ($env{'form.action'} =~ /^new(\w+)file$/) {
+                $newtype = $1;
+            } elsif ($env{'form.action'} eq 'newfile') {
+                ($newtype) = ($env{'form.newfilename'} =~ m{\.([^/.]+)$});
+                $newtype = lc($newtype);
+            }
+            if (($newtype ne '') &&
+                (grep(/^\Q$newtype\E$/, at disallowed))) {
+                $r->print('<p class="LC_error">'
+                         .&mt('Creation of a new file of type: [_1] is not permitted in Course Authoring Space',$newtype)
+                         .'</p>'
+                         .&Apache::loncommon::end_page()
+                );
+                return OK;
+            }
+        }
         $r->print('<h2>'.$action{$env{'form.action'}}.'</h2>');
     } else {
         $r->print('<p class="LC_error">'




More information about the LON-CAPA-cvs mailing list