Diff for /loncom/interface/portfolio.pm between versions 1.82 and 1.89

version 1.82, 2005/04/07 06:56:23 version 1.89, 2005/12/09 23:49:45
Line 34  use Apache::lonnet; Line 34  use Apache::lonnet;
 # receives a file name and path stub from username/userfiles/portfolio/  # receives a file name and path stub from username/userfiles/portfolio/
 # returns an anchor tag consisting encoding filename and currentpath  # returns an anchor tag consisting encoding filename and currentpath
 sub make_anchor {  sub make_anchor {
     my ($filename, $current_path, $current_mode, $field_name) = @_;      my ($filename, $current_path, $current_mode, $field_name, $continue_select) = @_;
     my $anchor = '<a href="/adm/portfolio?selectfile='.$filename.'&currentpath='.$current_path.'&mode='.$current_mode.'&fieldname='.$field_name.'">'.$filename.'</a>';      if ($continue_select ne 'true') {$continue_select = 'false'};
       my $anchor = '<a href="/adm/portfolio?selectfile='.$filename.'&currentpath='.$current_path.'&mode='.$current_mode.'&continue='.$continue_select.'&fieldname='.$field_name.'">'.$filename.'</a>';
     return $anchor;      return $anchor;
 }  }
 my $dirptr=16384;  my $dirptr=16384;
 sub display_common {  sub display_common {
     my ($r,$current_path,$is_empty,$dir_list)=@_;      my ($r,$current_path,$is_empty,$dir_list)=@_;
     my $iconpath= $r->dir_config('lonIconsURL') . "/";      my $iconpath= $r->dir_config('lonIconsURL') . "/";
     $r->print('<table border="0" cellspacing="2" cellpadding="2"><tr valign="middle">');      my %text=&Apache::lonlocal::texthash('upload' => 'Upload',
     $r->print('<td bgcolor="#ccddaa" align="center">');   'upload_label' =>  
     my $displayOut = '<form method="post" enctype="multipart/form-data">';   'Upload file to current directory:',
     $displayOut .= '<input name="uploaddoc" type="file" />'.   'createdir' => 'Create Subdirectory',
         '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.   'createdir_label' => 
         '<input type="hidden" name="action" value="'.$env{"form.action"}.'" />'.   'Create subdirectory in current directory:');
         '<input type="hidden" name="fieldname" value="'.$env{"form.fieldname"}.'" />'.      $r->print(<<"TABLE"); 
         '<input type="hidden" name="mode" value="'.$env{"form.mode"}.'" />'.   <table border="0" cellspacing="2" cellpadding="2">
         '<input type="submit" name="storeupl" value="Upload" />'.    <form method="post" enctype="multipart/form-data">
         '</form>';      <tr valign="middle">
     $r->print($displayOut);        <td bgcolor="#ccddaa" align="right">
     $r->print('</td></tr><tr><td bgcolor="#ccddaa" align="center">');          $text{'upload_label'}
     $displayOut = '<form method="post">';        </td>
     $displayOut .= '<input name="newdir" type="input" />'.        <td bgcolor="#ccddaa" align="left">
         '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.          <input name="uploaddoc" type="file" />
         '<input type="hidden" name="action" value="'.$env{"form.action"}.'" />'.   <input type="hidden" name="currentpath" value="$current_path" />
         '<input type="hidden" name="fieldname" value="'.$env{"form.fieldname"}.'" />'.   <input type="hidden" name="action" value="$env{"form.action"}" />
         '<input type="hidden" name="mode" value="'.$env{"form.mode"}.'" />'.    <input type="hidden" name="fieldname" value="$env{"form.fieldname"}" />
         '<input type="submit" name="createdir" value="'.&mt("Create Directory").'" />'.   <input type="hidden" name="mode" value="$env{"form.mode"}" />
         '</form>';   <input type="submit" name="storeupl" value="$text{'upload'}" />
     $r->print($displayOut);        </td>
     $r->print('</td></tr></table>');      </tr>
     </form>
     <form method="post">
       <tr>
         <td bgcolor="#ccddaa" align="right">
           $text{'createdir_label'}
         </td>
         <td bgcolor="#ccddaa" align="left">
           <input name="newdir" type="input" />
           <input type="hidden" name="currentpath" value="$current_path" />
           <input type="hidden" name="action" value="$env{"form.action"}" />
           <input type="hidden" name="fieldname" value="$env{"form.fieldname"}" />
           <input type="hidden" name="mode" value="$env{"form.mode"}" />
           <input type="submit" name="createdir" value="$text{'createdir'}" />
         </td>
       </tr>
     </form>
   </table>
   TABLE
     my @tree = split (/\//,$current_path);      my @tree = split (/\//,$current_path);
     $r->print('<font size="+2">'.&make_anchor('portfolio','/',$env{"form.mode"},$env{"form.fieldname"}).'/');      $r->print('<font size="+2">'.&make_anchor('portfolio','/',$env{"form.mode"},$env{"form.fieldname"},$env{"form.continue"}).'/');
     if (@tree > 1){      if (@tree > 1){
         my $newCurrentPath = '';          my $newCurrentPath = '';
         for (my $i = 1; $i< @tree; $i++){          for (my $i = 1; $i< @tree; $i++){
             $newCurrentPath .= $tree[$i].'/';              $newCurrentPath .= $tree[$i].'/';
             $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}).'/');              $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}, $env{"form.continue"}).'/');
         }          }
     }      }
     $r->print('</font>');      $r->print('</font>');
Line 124  sub display_directory { Line 143  sub display_directory {
     #$dom       #$dom 
     my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);       my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); 
     $filename =~ s/\s+$//;      $filename =~ s/\s+$//;
     if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ )) {      if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(.*)\.(.*)/)) {
             if ($dirptr&$testdir) {              if ($dirptr&$testdir) {
                 if ($select_mode eq 'true'){                  if ($select_mode eq 'true'){
                     $r->print('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>');                      $r->print('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>');
Line 132  sub display_directory { Line 151  sub display_directory {
                     $r->print('<tr bgcolor="#FFAA99"><td colspan="2"><img src="'.$iconpath.'folder_closed.gif"></td>');                      $r->print('<tr bgcolor="#FFAA99"><td colspan="2"><img src="'.$iconpath.'folder_closed.gif"></td>');
                 }                  }
                 $r->print('<td>Go to ...</td>');                  $r->print('<td>Go to ...</td>');
                 $r->print('<td>'.&make_anchor($filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"}).'</td>');                   $r->print('<td>'.&make_anchor($filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'}).'</td>'); 
                 $r->print('</tr>');                   $r->print('</tr>'); 
             } else {              } else {
                 $r->print('<tr bgcolor="#CCCCFF">');                  $r->print('<tr bgcolor="#CCCCFF">');
                 if ($select_mode eq 'true'){                  if ($select_mode eq 'true'){
                     $r->print('<td><input type="checkbox" name="selectfile" value="'.$filename.'"');                       $r->print('<td><input type="checkbox" name="checkfile" value="'.$filename.'"'); 
                     if ($$checked_files{$filename} eq 'selected') {                      if ($$checked_files{$filename} eq 'selected') {
                         $r->print("CHECKED");                          $r->print("CHECKED");
                     }                      }
Line 146  sub display_directory { Line 165  sub display_directory {
                     if (exists $locked_files{$current_path.$filename}){                      if (exists $locked_files{$current_path.$filename}){
                         $r->print('<td colspan="2"><a href="portfolio?lockinfo='.$current_path.$filename.'">Locked</a></td>');                          $r->print('<td colspan="2"><a href="portfolio?lockinfo='.$current_path.$filename.'">Locked</a></td>');
                     } else {                      } else {
    my $cat='<img alt="'.&mt('Catalog Information').
       '" src="'.&Apache::loncommon::lonhttpdurl('/res/adm/pages/catalog.gif').'" />';
                         $r->print('<td><input type="checkbox" name="selectfile" value="'.$filename.'" />                          $r->print('<td><input type="checkbox" name="selectfile" value="'.$filename.'" />
                             <a href="/adm/portfolio?rename='.$filename.'&amp;currentpath='.$current_path.'">Rename</a></td>                              <a href="/adm/portfolio?rename='.$filename.'&amp;currentpath='.$current_path.'">Rename</a></td>
                             <td><a href="'.$href_edit_location.$filename.'.meta">Meta</a>                              <td><a href="'.$href_edit_location.$filename.'.meta">'.$cat.'</a>
                             </td>');                              </td>');
                     }                      }
                 }                  }
Line 351  sub select_files { Line 372  sub select_files {
     if ($env{'form.continue'} eq 'true') {      if ($env{'form.continue'} eq 'true') {
         # here we update the selections for the currentpath          # here we update the selections for the currentpath
         # eventually, have to handle removing those not checked, but . . .           # eventually, have to handle removing those not checked, but . . . 
         my @items=&Apache::loncommon::get_env_multiple('form.selectfile');          my @items=&Apache::loncommon::get_env_multiple('form.checkfile');
         &Apache::lonnet::save_selected_files($env{'user.name'}, $env{'form.currentpath'}, @items);          if (scalar(@items)){
                &Apache::lonnet::save_selected_files($env{'user.name'}, $env{'form.currentpath'}, @items);
           }
     } else {      } else {
         if ($env{'form.currentpath'} eq '/') {  
             #empty the file for a fresh start              #empty the file for a fresh start
             # &Apache::lonnet::clear_selected_files($env{'user.name'});              &Apache::lonnet::clear_selected_files($env{'user.name'});
         }  
     }      }
     my @files = &Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'});      my @files = &Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'});
     my $java_files = join ",", @files;      my $java_files = join ",", @files;
Line 386  ENDSMP Line 407  ENDSMP
 ENDSMP  ENDSMP
     $r->print($javascript);      $r->print($javascript);
     $r->print("<h1>Select portfolio files</h1>      $r->print("<h1>Select portfolio files</h1>
                 Check as many as you wish in response to the essay problem.<br />");                  Check as many as you wish in response to the problem.<br />");
     $r->print("<strong>Files selected from other directories:</strong><br />");      my @otherfiles=&Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'});
     foreach (&Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'})) {      if (@otherfiles) {
         $r->print($_."<br />");   $r->print("<strong>Files selected from other directories:</strong><br />");
    foreach my $file (@otherfiles) {
       $r->print($file."<br />");
    }
     }      }
 }  }
 sub upload {  sub upload {
Line 417  sub upload { Line 441  sub upload {
         }          }
     }      }
     my $current_disk_usage = &Apache::lonnet::diskusage($env{'user.domain'}, $env{'user.name'},$portfolio_root);      my $current_disk_usage = &Apache::lonnet::diskusage($env{'user.domain'}, $env{'user.name'},$portfolio_root);
     if ((($current_disk_usage/1000) + $filesize) > $disk_quota){      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.'.          $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.');                    '<br />Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.');
         $r->print(&done('Back'));          $r->print(&done('Back'));
     }       } 
Line 446  sub upload { Line 470  sub upload {
 }  }
 sub lock_info {  sub lock_info {
     my ($r) = @_;      my ($r) = @_;
     $r->print("lock info here");      my %current_permissions = &Apache::lonnet::dump('file_permissions',$env{'user.domain'},$env{'user.name'});
       my $file_name = $env{'form.lockinfo'};
       foreach my $key(keys(%current_permissions)) {
           if ($file_name eq $key) {
               foreach my $array_item (@{$current_permissions{$key}}) {
                   if (ref($array_item)) {
                       $r->print('<strong>'.$key.'</strong> was submitted in response to problem: <strong>'.
                               &Apache::lonnet::gettitle($$array_item[0]).'</strong><br />');
                       my %course_description = &Apache::lonnet::coursedescription($$array_item[1]);
                       $r->print('In the course: <strong>'.$course_description{'description'}.'</strong><br />');
                       # $r->print('the third is '.$$array_item[2].'<br>');
                       # $r->print("item is $$array_item[0]<br> and $$array_item[0]");
                   }
               }
           }    
       }
       $r->print(&done('Back'));
     return 'ok';      return 'ok';
 }  }
 sub createdir {  sub createdir {
Line 497  sub handler { Line 537  sub handler {
  '/userfiles/portfolio';   '/userfiles/portfolio';
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['selectfile','currentpath','meta','lockinfo',                                              ['selectfile','currentpath','meta','lockinfo',
      'currentfile','action','fieldname','mode','rename']);       'currentfile','action','fieldname','mode','rename','continue']);
     &Apache::loncommon::no_cache($r);      &Apache::loncommon::no_cache($r);
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
Line 512  sub handler { Line 552  sub handler {
         $r->print(&Apache::loncommon::bodytag('Portfolio Manager'));          $r->print(&Apache::loncommon::bodytag('Portfolio Manager'));
     }      }
     $r->rflush();      $r->rflush();
  if (($env{'form.storeupl'} eq 'Upload') & (!$env{'form.uploaddoc.filename'})){   if (($env{'form.storeupl'}) & (!$env{'form.uploaddoc.filename'})){
        $r->print('<font color="red"> No file was selected to upload.'.         $r->print('<font color="red"> No file was selected to upload.'.
                'To upload a file, click <strong>Browse...</strong>'.                 'To upload a file, click <strong>Browse...</strong>'.
                ', select a file, then click <strong>Upload</strong>,</font>');                 ', select a file, then click <strong>Upload</strong>,</font>');

Removed from v.1.82  
changed lines
  Added in v.1.89


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