Diff for /loncom/interface/portfolio.pm between versions 1.222 and 1.225

version 1.222, 2010/03/26 23:08:41 version 1.225, 2010/10/23 19:28:12
Line 287  sub display_directory { Line 287  sub display_directory {
     my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload,      my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload,
         $can_modify,$can_delete,$can_setacl)=@_;          $can_modify,$can_delete,$can_setacl)=@_;
     my $iconpath= $r->dir_config('lonIconsURL') . "/";      my $iconpath= $r->dir_config('lonIconsURL') . "/";
     my $display_out;  
     my $select_mode;      my $select_mode;
     my $checked_files;      my $checked_files;
     my $port_path = &get_port_path();      my $port_path = &get_port_path();
Line 304  sub display_directory { Line 303  sub display_directory {
     my %access_controls = &Apache::lonnet::get_access_controls($current_permissions,$group);      my %access_controls = &Apache::lonnet::get_access_controls($current_permissions,$group);
     my $now = time;      my $now = time;
     if ($env{"form.mode"} eq 'selectfile') {      if ($env{"form.mode"} eq 'selectfile') {
  &select_files($r);          &select_files($r);
  $checked_files =&Apache::lonnet::files_in_path($uname,$env{'form.currentpath'});          $checked_files =&Apache::lonnet::files_in_path($uname,$env{'form.currentpath'});
  $select_mode = 'true';          $select_mode = 'true';
     }   
     if ($is_empty && ($current_path ne '/') && $can_delete) {  
         $display_out = '<form method="post" action="'.$url.'">'.  
     &group_form_data().  
         '<input type="hidden" name="action" value="deletedir" />'.  
         '<p>'.  
         '<input type="submit" name="deletedir" value="'.&mt("Delete Directory").'" />'.  
         '</p>'.  
         '<input type="hidden" name="selectfile" value="" />'.  
         '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.  
         '</form>';  
           
         $r->print($display_out);  
  return;  
     }      }
     if ($select_mode eq 'true') {      if ($select_mode eq 'true') {
         $r->print('<form method="post" name="checkselect" action="'.$url.'">');          $r->print('<form method="post" name="checkselect" action="'.$url.'">');
         $r->print(&Apache::loncommon::start_data_table()          $r->print(&Apache::loncommon::start_data_table()
                  .&Apache::loncommon::start_data_table_header_row()                   .&Apache::loncommon::start_data_table_header_row()
                  .'<th>'.&mt('Select').'</th>'                   .'<th>'.&mt('Select').'</th>'
                  .'<th>&nbsp;</th><th>&nbsp;</th>'                   .'<th>&nbsp;</th>'
                    .'<th>&nbsp;</th>'
                  .'<th>'.&mt('Name').'</th>'                   .'<th>'.&mt('Name').'</th>'
                  .'<th>'.&mt('Size').'</th>'                   .'<th>'.&mt('Size').'</th>'
                  .'<th>'.&mt('Last Modified').'</th>'                   .'<th>'.&mt('Last Modified').'</th>'
Line 336  sub display_directory { Line 322  sub display_directory {
         );          );
     } else {      } else {
         $r->print('<form method="post" action="'.$url.'">');          $r->print('<form method="post" action="'.$url.'">');
  $r->print(&Apache::loncommon::help_open_topic('Portfolio FileList',          $r->print(
       &mt('Using the portfolio file list')));              '<p>'
              .&Apache::loncommon::help_open_topic(
                   'Portfolio FileList',
                   &mt('Using the portfolio file list'))
              .'</p>'
           );
         $r->print(&Apache::loncommon::start_data_table()          $r->print(&Apache::loncommon::start_data_table()
                  .&Apache::loncommon::start_data_table_header_row()                   .&Apache::loncommon::start_data_table_header_row()
                  .'<th colspan="2">'.&mt('Actions'). &Apache::loncommon::help_open_topic('Portfolio FileAction').'</th>'                   .'<th colspan="2">'.&mt('Actions'). &Apache::loncommon::help_open_topic('Portfolio FileAction').'</th>'
                  .'<th>&nbsp;</th><th>&nbsp;</th>'                   .'<th>&nbsp;</th>'
                    .'<th>&nbsp;</th>'
                  .'<th>'.&mt('Name').&Apache::loncommon::help_open_topic('Portfolio OpenFile').'</th>'                   .'<th>'.&mt('Name').&Apache::loncommon::help_open_topic('Portfolio OpenFile').'</th>'
                  .'<th>'.&mt('Size').'</th>'                   .'<th>'.&mt('Size').'</th>'
                  .'<th>'.&mt('Last Modified').'</th>'                   .'<th>'.&mt('Last Modified').'</th>'
Line 349  sub display_directory { Line 341  sub display_directory {
                  .'<th>'.&mt('Current Access Status').&Apache::loncommon::help_open_topic('Portfolio ShareFile').'</th>'                   .'<th>'.&mt('Current Access Status').&Apache::loncommon::help_open_topic('Portfolio ShareFile').'</th>'
                  .&Apache::loncommon::end_data_table_header_row());                   .&Apache::loncommon::end_data_table_header_row());
     }      }
   
       # Empty directory?
       if ($is_empty && ($current_path ne '/') && $can_delete) {
           my $cols = ($select_mode eq 'true') ? 7 : 9;
           # Empty message
           $r->print(
               &Apache::loncommon::start_data_table_row()
              .'<td colspan="'.$cols.'">'
              .'<p class="LC_info">'
              .&mt('This directory is empty.')
              .'</p>'
              .'</td>'
              .&Apache::loncommon::end_data_table_row()
              .&Apache::loncommon::end_data_table()
              .'</form>'
           );
           # Delete button
           $r->print(
               '<form method="post" action="'.$url.'">'.
               &group_form_data().
               '<input type="hidden" name="action" value="deletedir" />'.
               '<p>'.
               '<input type="submit" name="deletedir" value="'.&mt("Delete Directory").'" />'.
               '</p>'.
               '<input type="hidden" name="selectfile" value="" />'.
               '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
               '</form>'
           );
           # Directory is empty, so nothing else to display
           return;
       }
   
     $r->print("\n".&group_form_data()."\n");      $r->print("\n".&group_form_data()."\n");
   
     my $href_location="/uploaded/$udom/$uname/$port_path".$current_path;      my $href_location="/uploaded/$udom/$uname/$port_path".$current_path;
Line 1889  ENDSMP Line 1913  ENDSMP
     );      );
 }  }
   
   
 sub check_for_upload {  
     my ($path,$fname,$group,$element) = @_;  
     my $disk_quota = &get_quota($group);  
     my $filesize = (length($env{'form.'.$element})) / 1000; #express in k (1024?)  
     my $portfolio_root = &get_portfolio_root();  
     my $port_path = &get_port_path();  
     my ($uname,$udom) = &get_name_dom($group);  
     # Fixme --- Move the checking for existing file to LOND error return  
     my @dir_list=&get_dir_list($portfolio_root,$path,$group);  
     my $found_file = 0;  
     my $locked_file = 0;  
     foreach my $line (@dir_list) {  
         my ($file_name)=split(/\&/,$line,2);  
         if ($file_name eq $fname){  
             $file_name = $path.$file_name;  
             $file_name = &prepend_group($file_name);  
             $found_file = 1;  
             if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') {  
                 $locked_file = 1;  
             }   
         }  
     }  
     my $getpropath = 1;  
     my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,$portfolio_root,$getpropath);  
   
     if (($current_disk_usage + $filesize) > $disk_quota){  
         my $msg = '<span class="LC_error">'.  
                 &mt('Unable to upload [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.','<span class="LC_filename">'.$fname.'</span>',$filesize).'</span>'.  
                   '<br />'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',$disk_quota,$current_disk_usage);  
  return ('will_exceed_quota',$msg);  
     } elsif ($found_file) {  
         if ($locked_file) {  
             my $msg = '<span class="LC_error">';  
             $msg .= &mt('Unable to upload [_1]. A locked file by that name was found in [_2].','<span class="LC_filename">'.$fname.'</span>','<span class="LC_filename">'.$port_path.$env{'form.currentpath'}.'</span>');  
             $msg .= '</span><br />';  
             $msg .= &mt('You will be able to rename or delete existing [_1] after a grade has been assigned.','<span class="LC_filename">'.$fname.'</span>');  
     return ('file_locked',$msg);  
  } else {  
             my $msg = '<span class="LC_error">';  
             $msg .= &mt('Unable to upload [_1]. A file by that name was found in [_2].','<span class="LC_filename">'.$fname.'</span>',$port_path.$env{'form.currentpath'});  
             $msg .= '</span>';  
             $msg .= '<br />';  
             $msg .= &mt('To upload, rename or delete existing [_1] in [_2].','<span class="LC_filename">'.$fname.'</span>', $port_path.$env{'form.currentpath'});  
     return ('file_exists',$msg);  
  }  
     }  
 }  
   
 sub upload {  sub upload {
     my ($r,$url,$group)=@_;      my ($r,$url,$group)=@_;
     my $fname=&Apache::lonnet::clean_filename($env{'form.uploaddoc.filename'});      my $fname=&Apache::lonnet::clean_filename($env{'form.uploaddoc.filename'});

Removed from v.1.222  
changed lines
  Added in v.1.225


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>