--- loncom/interface/portfolio.pm 2005/04/07 06:56:23 1.82 +++ loncom/interface/portfolio.pm 2006/01/25 22:56:11 1.93 @@ -34,43 +34,62 @@ use Apache::lonnet; # receives a file name and path stub from username/userfiles/portfolio/ # returns an anchor tag consisting encoding filename and currentpath sub make_anchor { - my ($filename, $current_path, $current_mode, $field_name) = @_; - my $anchor = ''.$filename.''; + my ($filename, $current_path, $current_mode, $field_name, $continue_select) = @_; + if ($continue_select ne 'true') {$continue_select = 'false'}; + my $anchor = ''.$filename.''; return $anchor; } my $dirptr=16384; sub display_common { my ($r,$current_path,$is_empty,$dir_list)=@_; my $iconpath= $r->dir_config('lonIconsURL') . "/"; - $r->print(''); - $r->print('
'); - my $displayOut = '
'; - $displayOut .= ''. - ''. - ''. - ''. - ''. - ''. - '
'; - $r->print($displayOut); - $r->print('
'); - $displayOut = '
'; - $displayOut .= ''. - ''. - ''. - ''. - ''. - ''. - '
'; - $r->print($displayOut); - $r->print('
'); + 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"); + + + + + + + + + + + + + +
+ $text{'upload_label'} + + + + + + + +
+ $text{'createdir_label'} + + + + + + + +
+TABLE my @tree = split (/\//,$current_path); - $r->print(''.&make_anchor('portfolio','/',$env{"form.mode"},$env{"form.fieldname"}).'/'); + $r->print(''.&make_anchor('portfolio','/',$env{"form.mode"},$env{"form.fieldname"},$env{"form.continue"}).'/'); if (@tree > 1){ my $newCurrentPath = ''; for (my $i = 1; $i< @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(''); @@ -124,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 !~ /(.*)\.(\d+)\.([^\.]*)$/)) { if ($dirptr&$testdir) { if ($select_mode eq 'true'){ $r->print(''); @@ -132,12 +151,12 @@ sub display_directory { $r->print(''); } $r->print('Go to ...'); - $r->print(''.&make_anchor($filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"}).''); + $r->print(''.&make_anchor($filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'}).''); $r->print(''); } else { $r->print(''); if ($select_mode eq 'true'){ - $r->print('print('print("CHECKED"); } @@ -146,13 +165,15 @@ sub display_directory { if (exists $locked_files{$current_path.$filename}){ $r->print('Locked'); } else { + my $cat=''.&mt('Catalog Information').
+			    ''; $r->print(' Rename - Meta + '.$cat.' '); } } - $r->print(''); + $r->print(''); $r->print(''. $filename.''); $r->print(''.$size.''); @@ -351,13 +372,13 @@ sub select_files { 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.selectfile'); - &Apache::lonnet::save_selected_files($env{'user.name'}, $env{'form.currentpath'}, @items); + my @items=&Apache::loncommon::get_env_multiple('form.checkfile'); + if (scalar(@items)){ + &Apache::lonnet::save_selected_files($env{'user.name'}, $env{'form.currentpath'}, @items); + } } else { - if ($env{'form.currentpath'} eq '/') { #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 $java_files = join ",", @files; @@ -386,10 +407,13 @@ ENDSMP ENDSMP $r->print($javascript); $r->print("

Select portfolio files

- Check as many as you wish in response to the essay problem.
"); - $r->print("Files selected from other directories:
"); - foreach (&Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'})) { - $r->print($_."
"); + Check as many as you wish in response to the problem.
"); + my @otherfiles=&Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'}); + if (@otherfiles) { + $r->print("Files selected from other directories:
"); + foreach my $file (@otherfiles) { + $r->print($file."
"); + } } } sub upload { @@ -417,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('Unable to upload '.$fname.' (size = '.$filesize.' kilobytes. Disk quota will be exceeded.'. + if (($current_disk_usage + $filesize) > $disk_quota){ + $r->print('Unable to upload '.$fname.' (size = '.$filesize.' kilobytes). Disk quota will be exceeded.'. '
Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.'); $r->print(&done('Back')); } @@ -446,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(''.$key.' was submitted in response to problem: '. + &Apache::lonnet::gettitle($$array_item[0]).'
'); + my %course_description = &Apache::lonnet::coursedescription($$array_item[1]); + $r->print('In the course: '.$course_description{'description'}.'
'); + # $r->print('the third is '.$$array_item[2].'
'); + # $r->print("item is $$array_item[0]
and $$array_item[0]"); + } + } + } + } + $r->print(&done('Back')); return 'ok'; } sub createdir { @@ -497,7 +537,7 @@ sub handler { '/userfiles/portfolio'; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['selectfile','currentpath','meta','lockinfo', - 'currentfile','action','fieldname','mode','rename']); + 'currentfile','action','fieldname','mode','rename','continue']); &Apache::loncommon::no_cache($r); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; @@ -512,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(' No file was selected to upload.'. 'To upload a file, click Browse...'. ', select a file, then click Upload,'); @@ -578,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("\n\n"); - return OK; } + return OK; } 1; __END__