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

raeburn raeburn at source.lon-capa.org
Mon Jun 23 13:02:49 EDT 2014


raeburn		Mon Jun 23 17:02:49 2014 EDT

  Modified files:              
    /loncom/publisher	lonpubdir.pm 
  Log:
  - More specific feedback to user when attempting to list contents of a
    directory in authoring space when there is nothing to list.
  
  
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.156 loncom/publisher/lonpubdir.pm:1.157
--- loncom/publisher/lonpubdir.pm:1.156	Mon Jun 23 03:22:39 2014
+++ loncom/publisher/lonpubdir.pm	Mon Jun 23 17:02:49 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Authoring Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.156 2014/06/23 03:22:39 raeburn Exp $
+# $Id: lonpubdir.pm,v 1.157 2014/06/23 17:02:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -88,6 +88,26 @@
     my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom);
 
     &startpage($r, $uname, $udom, $thisdisfn);  # Put out the start of page.
+
+    if (!-d $fn) {
+        if (-e $fn) {
+            $r->print('<p class="LC_info">'.&mt('Requested item is a file not a directory.').'</p>');
+        } else {
+            $r->print('<p class="LC_info">'.&mt('The requested subdirectory does not exist.').'</p>');
+        }
+        $r->print(&Apache::loncommon::end_page());
+        return OK;
+    }
+    my @files;
+    if (opendir(DIR,$fn)) {
+        @files = readdir(DIR);
+        closedir(DIR);
+    } else {
+        $r->print('<p class="LC_error">'.&mt('Could not open directory.').'</p>');
+        $r->print(&Apache::loncommon::end_page());
+        return OK;
+    }
+
     &dircontrols($r,$uname,$udom,$thisdisfn);   # Put out actions for directory, 
                                                 # browse/upload + new file page.
     &resourceactions($r,$uname,$udom,$thisdisfn); # Put out form used for printing/deletion etc.
@@ -106,12 +126,12 @@
     my $sortby = $env{'form.sortby'};
     my $sortorder = $env{'form.sortorder'};
 
-    opendir(DIR,$fn);
-    my @files = readdir(DIR);
-    closedir(DIR);
-
-    if ((@files == 0) && ($thisdisfn =~ m{^/$match_domain/$match_username})) {
-        $r->print('<p class="LC_info">'.&mt('This Authoring Space is currently empty.').'</p>');
+    if ((@files == 0) && ($thisdisfn =~ m{^/$match_domain/$match_username/priv})) {
+        if ($thisdisfn =~ m{^/$match_domain/$match_username/priv$}) {
+            $r->print('<p class="LC_info">'.&mt('This Authoring Space is currently empty.').'</p>');
+        } else {
+            $r->print('<p class="LC_info">'.&mt('This subdirectory is currently empty.').'</p>');
+        }
         $r->print(&Apache::loncommon::end_page());
         return OK;
     }




More information about the LON-CAPA-cvs mailing list