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

raeburn raeburn at source.lon-capa.org
Sat May 31 09:55:17 EDT 2014


raeburn		Sat May 31 13:55:17 2014 EDT

  Modified files:              
    /loncom/publisher	lonpubdir.pm 
  Log:
  - Early out if top level directory in Authoring Space is empty.
  - &handler() returns 'OK'; no need to return 'OK' from other subroutines.
  
  
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.153 loncom/publisher/lonpubdir.pm:1.154
--- loncom/publisher/lonpubdir.pm:1.153	Tue May 20 19:53:59 2014
+++ loncom/publisher/lonpubdir.pm	Sat May 31 13:55:17 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Authoring Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.153 2014/05/20 19:53:59 raeburn Exp $
+# $Id: lonpubdir.pm,v 1.154 2014/05/31 13:55:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -40,7 +40,7 @@
 use Apache::lonmsg;
 use Apache::lonmenu;
 use Apache::lonnet;
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
 
 sub handler {
 
@@ -87,6 +87,16 @@
     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>');
+        $r->print(&Apache::loncommon::end_page());
+        return OK;
+    }
+
     # Start off the directory table.
     $r->print(&Apache::loncommon::start_data_table()
         .&Apache::loncommon::start_data_table_header_row()
@@ -119,10 +129,7 @@
     );
 
     my $dirptr=16384;		# Mask indicating a directory in stat.cmode.
-
-    opendir(DIR,$fn);
     my $filehash = {};
-    my @files= readdir(DIR);
     foreach my $filename (@files) {
         # Skip .DS_Store and hidden files
         my ($extension) = ($filename=~/\.(\w+)$/);
@@ -221,12 +228,10 @@
         }
     }
 
-    closedir(DIR);
-
     $r->print( &Apache::loncommon::end_data_table()
         .&Apache::loncommon::end_page() );
 
-    return OK;  
+    return OK;
 }
 
 
@@ -627,7 +632,7 @@
 	          '<td></td>'.
 		  "</tr>\n");
     }
-    return OK;
+    return;
 }
 
 sub getTitle {
@@ -776,7 +781,7 @@
 	      '<td>'.sprintf("%.1f",$size).'</td>'.
 	      &Apache::loncommon::end_data_table_row()
     );
-    return OK;
+    return;
 }
 
 sub create_pubselect {
@@ -829,6 +834,7 @@
             $versions ++;        
         }
     }
+    closedir(DIR);
     return $versions;
 }
 




More information about the LON-CAPA-cvs mailing list