--- loncom/interface/portfolio.pm 2005/04/12 01:15:46 1.83 +++ loncom/interface/portfolio.pm 2005/12/19 20:41:45 1.91 @@ -43,28 +43,46 @@ my $dirptr=16384; sub display_common { my ($r,$current_path,$is_empty,$dir_list)=@_; my $iconpath= $r->dir_config('lonIconsURL') . "/"; - $r->print('<table border="0" cellspacing="2" cellpadding="2"><tr valign="middle">'); - $r->print('<td bgcolor="#ccddaa" align="center">'); - my $displayOut = '<form method="post" enctype="multipart/form-data">'; - $displayOut .= '<input name="uploaddoc" type="file" />'. - '<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="storeupl" value="Upload" />'. - '</form>'; - $r->print($displayOut); - $r->print('</td></tr><tr><td bgcolor="#ccddaa" align="center">'); - $displayOut = '<form method="post">'; - $displayOut .= '<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="'.&mt("Create Directory").'" />'. - '</form>'; - $r->print($displayOut); - $r->print('</td></tr></table>'); + my %text=&Apache::lonlocal::texthash('upload' => 'Upload', + 'upload_label' => + 'Upload file to current directory:', + 'createdir' => 'Create Subdirectory', + 'createdir_label' => + 'Create subdirectory in current directory:'); + $r->print(<<"TABLE"); +<table border="0" cellspacing="2" cellpadding="2"> + <form method="post" enctype="multipart/form-data"> + <tr valign="middle"> + <td bgcolor="#ccddaa" align="right"> + $text{'upload_label'} + </td> + <td bgcolor="#ccddaa" align="left"> + <input name="uploaddoc" type="file" /> + <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="storeupl" value="$text{'upload'}" /> + </td> + </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); $r->print('<font size="+2">'.&make_anchor('portfolio','/',$env{"form.mode"},$env{"form.fieldname"},$env{"form.continue"}).'/'); if (@tree > 1){ @@ -114,7 +132,7 @@ sub display_directory { $r->print('<form method="post" action="/adm/portfolio">'); } my $href_location="/uploaded/$env{'user.domain'}/$env{'user.name'}/portfolio$current_path"; - my $href_edit_location="/editupload/$env{'user.domain'}/$env{'user.name'}/portfolio$current_path"; + my $href_edit_location="/editupload/$env{'user.domain'}/$env{'user.name'}/portfolio$current_path/"; foreach my $line (sort { my ($afile)=split('&',$a,2); @@ -125,7 +143,7 @@ sub display_directory { #$dom my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); $filename =~ s/\s+$//; - if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ )) { + if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(.*)\.(.*)/)) { if ($dirptr&$testdir) { if ($select_mode eq 'true'){ $r->print('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>'); @@ -147,13 +165,15 @@ sub display_directory { if (exists $locked_files{$current_path.$filename}){ $r->print('<td colspan="2"><a href="portfolio?lockinfo='.$current_path.$filename.'">Locked</a></td>'); } 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.'" /> <a href="/adm/portfolio?rename='.$filename.'&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>'); } } - $r->print('<td><img src="'.$iconpath.'unknown.gif"></td>'); + $r->print('<td><img src="'.&Apache::loncommon::icon($filename).'"></td>'); $r->print('<td><a href="'.$href_location.$filename.'">'. $filename.'</a></td>'); $r->print('<td>'.$size.'</td>'); @@ -354,12 +374,10 @@ sub select_files { # eventually, have to handle removing those not checked, but . . . my @items=&Apache::loncommon::get_env_multiple('form.checkfile'); if (scalar(@items)){ - &Apache::lonnet::logthis("one of the items is $items[0]"); - &Apache::lonnet::save_selected_files($env{'user.name'}, $env{'form.currentpath'}, @items); + &Apache::lonnet::save_selected_files($env{'user.name'}, $env{'form.currentpath'}, @items); } } else { #empty the file for a fresh start - &Apache::lonnet::logthis("Clearing saved files"); &Apache::lonnet::clear_selected_files($env{'user.name'}); } my @files = &Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'}); @@ -389,10 +407,13 @@ ENDSMP ENDSMP $r->print($javascript); $r->print("<h1>Select portfolio files</h1> - Check as many as you wish in response to the essay problem.<br />"); - $r->print("<strong>Files selected from other directories:</strong><br />"); - foreach (&Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'})) { - $r->print($_."<br />"); + Check as many as you wish in response to the problem.<br />"); + my @otherfiles=&Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'}); + if (@otherfiles) { + $r->print("<strong>Files selected from other directories:</strong><br />"); + foreach my $file (@otherfiles) { + $r->print($file."<br />"); + } } } sub upload { @@ -420,8 +441,8 @@ sub upload { } } my $current_disk_usage = &Apache::lonnet::diskusage($env{'user.domain'}, $env{'user.name'},$portfolio_root); - if ((($current_disk_usage/1000) + $filesize) > $disk_quota){ - $r->print('<font color="red">Unable to upload <strong>'.$fname.' (size = '.$filesize.' kilobytes</strong>. Disk quota will be exceeded.'. + 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.'); $r->print(&done('Back')); } @@ -449,7 +470,23 @@ sub upload { } sub lock_info { 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'; } sub createdir { @@ -515,7 +552,7 @@ sub handler { $r->print(&Apache::loncommon::bodytag('Portfolio Manager')); } $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.'. 'To upload a file, click <strong>Browse...</strong>'. ', select a file, then click <strong>Upload</strong>,</font>'); @@ -581,8 +618,8 @@ sub handler { &display_common($r,$current_path,$is_empty,\@dir_list); &display_directory($r,$current_path,$is_empty,\@dir_list); $r->print("</body>\n</html>\n"); - return OK; } + return OK; } 1; __END__