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

raeburn raeburn@source.lon-capa.org
Fri, 29 Oct 2010 23:22:43 -0000


raeburn		Fri Oct 29 23:22:43 2010 EDT

  Modified files:              
    /loncom/interface	portfolio.pm 
  Log:
  - Blank (0 bytes) files not selectable from portfolio for submission to
    dropbox or bridgetask.
  
  
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.228 loncom/interface/portfolio.pm:1.229
--- loncom/interface/portfolio.pm:1.228	Fri Oct 29 23:19:54 2010
+++ loncom/interface/portfolio.pm	Fri Oct 29 23:22:43 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # portfolio browser
 #
-# $Id: portfolio.pm,v 1.228 2010/10/29 23:19:54 raeburn Exp $
+# $Id: portfolio.pm,v 1.229 2010/10/29 23:22:43 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -303,7 +303,7 @@
     my %access_controls = &Apache::lonnet::get_access_controls($current_permissions,$group);
     my $now = time;
     if ($env{"form.mode"} eq 'selectfile') {
-        &select_files($r);
+        &select_files($r,$dir_list);
         $checked_files =&Apache::lonnet::files_in_path($uname,$env{'form.currentpath'});
         $select_mode = 'true';
     }
@@ -396,6 +396,7 @@
     	    push(@dir_lines, [$filename,$dom,$testdir,$size,$mtime,$obs]);
     	}
     }
+    my $zerobyte;
     foreach my $dir_line (@dir_lines) {
         my ($filename,$dom,$testdir,$size,$mtime,$obs) = @$dir_line;
         my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename);
@@ -455,11 +456,16 @@
 		my $css_class = 'LC_browser_file';
 		my $line;
                 if ($select_mode eq 'true') {
-                    $line='<td><input type="checkbox" name="checkfile" value="'.$filename.'"';
-		    if ($$checked_files{$filename} eq 'selected') {
-                        $line.=' checked="checked" ';
+                    if ($size > 0) {
+                        $line='<td><input type="checkbox" name="checkfile" value="'.$filename.'"';
+		        if ($$checked_files{$filename} eq 'selected') {
+                            $line.=' checked="checked" ';
+                        }
+		        $line.=' /></td>';
+                    } else {
+                        $line = '<td>&nbsp;</td>';
+                        $zerobyte ++;
                     }
-		    $line.=' /></td>';
                 } else {
                     if (exists $locked_files{$fullpath}) {
                         my %anchor_fields = (
@@ -539,7 +545,11 @@
         }
     }
     if ($select_mode eq 'true') {
-        $r->print(&Apache::loncommon::end_data_table().'
+        $r->print(&Apache::loncommon::end_data_table());
+        if ($zerobyte) {
+            $r->print('<p class="LC_warning">'.&mt('[quant,_1,file] in list not selectable as file size is 0 bytes.',$zerobyte).'</p>');
+        }
+        $r->print('
             <input type="hidden" name="continue" value="true" />
             <input type="hidden" name="fieldname" value="'.$env{'form.fieldname'}.'" />
             <input type="hidden" name="mode" value="selectfile" />
@@ -1854,13 +1864,24 @@
 }
 
 sub select_files {
-    my ($r) = @_;
+    my ($r,$dir_list) = @_;
     if ($env{'form.continue'} eq 'true') {
         # here we update the selections for the currentpath
         # eventually, have to handle removing those not checked, but . . . 
         my @items=&Apache::loncommon::get_env_multiple('form.checkfile');
         if (scalar(@items)){
-             &Apache::lonnet::save_selected_files($env{'user.name'}, $env{'form.currentpath'}, @items);
+            my @ok_items;
+            if (ref($dir_list) eq 'ARRAY') {
+                foreach my $dir_line (@{$dir_list}) {
+                    my ($filename,undef,undef,undef,undef,undef,undef,undef,$size)=split(/\&/,$dir_line,10);
+                    if (grep(/^\Q$filename\E$/,@items)) {
+                        if ($size) {
+                            push(@ok_items,$filename); 
+                        }
+                    }
+                }
+            }
+            &Apache::lonnet::save_selected_files($env{'user.name'}, $env{'form.currentpath'}, @ok_items);
         }
     } else {
             #empty the file for a fresh start