Diff for /loncom/interface/portfolio.pm between versions 1.36 and 1.38

version 1.36, 2004/09/06 23:11:57 version 1.38, 2004/09/08 17:53:37
Line 376  sub rename_confirmed { Line 376  sub rename_confirmed {
 sub upload {  sub upload {
     my ($r)=@_;      my ($r)=@_;
     my $fname=$ENV{'form.uploaddoc.filename'};      my $fname=$ENV{'form.uploaddoc.filename'};
       my $filesize = (length($ENV{'form.uploaddoc'})) / 1000; #express in k (1024?)
       my $disk_quota = 20000; # expressed in k
     $fname=&Apache::lonnet::clean_filename($fname);      $fname=&Apache::lonnet::clean_filename($fname);
     my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},      my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
  $ENV{'user.name'}).   $ENV{'user.name'}).
  '/userfiles/portfolio';   '/userfiles/portfolio';
       # Fixme --- Move the checking for existing file to LOND error return
     my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'},      my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'},
   $ENV{'user.domain'},    $ENV{'user.domain'},
   $ENV{'user.name'},$portfolio_root);    $ENV{'user.name'},$portfolio_root);
Line 390  sub upload { Line 393  sub upload {
             $found_file = 1;              $found_file = 1;
         }          }
     }      }
     $r->print('<br />'.&Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root).'<br />');      my $current_disk_usage = &Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root);
     if ($found_file){         if (($current_disk_usage + $filesize) > $disk_quota){
           $r->print('<font color="red">Unable to upload <strong>'.$fname.' (size = '.$filesize.' kilobytes</strong>. Disk quota will be exceeded.'.
                     '<br />Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.');
       } 
       elsif ($found_file){   
         $r->print('<font color="red">Unable to upload <strong>'.$fname.'</strong>, a file by that name was found in <strong>'.$ENV{'form.currentpath'}.'</strong></font>'.          $r->print('<font color="red">Unable to upload <strong>'.$fname.'</strong>, a file by that name was found in <strong>'.$ENV{'form.currentpath'}.'</strong></font>'.
                   '<br />To upload, rename or delete existing '.$fname.' in '.$ENV{'form.currentpath'});                    '<br />To upload, rename or delete existing '.$fname.' in '.$ENV{'form.currentpath'});
     } else {      } else {
Line 407  sub upload { Line 414  sub upload {
   
 sub createdir {  sub createdir {
     my ($r)=@_;      my ($r)=@_;
     #FIXME 1) file exists in place of dir (errormessage needs improvement)  
     my $newdir=&Apache::lonnet::clean_filename($ENV{'form.newdir'});      my $newdir=&Apache::lonnet::clean_filename($ENV{'form.newdir'});
     if ($newdir eq '') {      if ($newdir eq '') {
  $r->print('<font color="red">'.      $r->print('<font color="red">'.
   &mt("Error: no valid directory name was provided.").        &mt("Error: no directory name was provided.").
   '</font><br />');        '</font><br />');
  $r->print(&done());      $r->print(&done());
  return;      return;
     }       } 
     my $result=&Apache::lonnet::mkdiruserfile($ENV{'user.name'},      my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
      $ENV{'user.domain'},'portfolio'.$ENV{'form.currentpath'}.$newdir);   $ENV{'user.name'}).
     if ($result ne 'ok') {   '/userfiles/portfolio';
  $r->print('<font color="red"> An errror occured ('.$result.      my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'},
   ') while trying to create a new directory '.&display_file().'</font><br />');    $ENV{'user.domain'},
     $ENV{'user.name'},$portfolio_root);
       my $found_file = 0;
       foreach my $line (@dir_list) {
           my ($filename)=split(/\&/,$line,2);
           if ($filename eq $newdir){
               $found_file = 1;
           }
       }
       if ($found_file){
          $r->print('<font color="red"> Unable to create a directory named <strong>'.$newdir.
                  ' </strong>a file or directory by that name already exists.</font><br />');
       } else {
           my $result=&Apache::lonnet::mkdiruserfile($ENV{'user.name'},
            $ENV{'user.domain'},'portfolio'.$ENV{'form.currentpath'}.$newdir);
           if ($result ne 'ok') {
          $r->print('<font color="red"> An errror occured ('.$result.
             ') while trying to create a new directory '.&display_file().'</font><br />');
           }
     }      }
     $r->print(&done());      $r->print(&done());
 }  }
Line 444  sub handler { Line 468  sub handler {
                                             ['selectfile','currentpath',                                              ['selectfile','currentpath',
      'currentfile']);       'currentfile']);
  # make sure there is a portfolio directory off /userfiles   # make sure there is a portfolio directory off /userfiles
    # Fixme -- Do this in a better way -- offload it to the LOND routine
  my @dir_list=&Apache::lonnet::dirlist('/',   my @dir_list=&Apache::lonnet::dirlist('/',
     $ENV{'user.domain'},      $ENV{'user.domain'},
     $ENV{'user.name'},$portfolio_root);      $ENV{'user.name'},$portfolio_root);
Line 472  sub handler { Line 497  sub handler {
  if ($ENV{'form.currentpath'}) {   if ($ENV{'form.currentpath'}) {
     $current_path = $ENV{'form.currentpath'};      $current_path = $ENV{'form.currentpath'};
  }   }
  my @dir_list=&Apache::lonnet::dirlist($current_path,   @dir_list=&Apache::lonnet::dirlist($current_path,
     $ENV{'user.domain'},      $ENV{'user.domain'},
     $ENV{'user.name'},$portfolio_root);      $ENV{'user.name'},$portfolio_root);
           

Removed from v.1.36  
changed lines
  Added in v.1.38


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