--- loncom/interface/portfolio.pm 2004/12/06 18:13:10 1.63 +++ loncom/interface/portfolio.pm 2005/01/18 02:18:29 1.71 @@ -83,12 +83,7 @@ sub display_directory { my ($r,$current_path,$is_empty,$dir_list)=@_; my $iconpath= $r->dir_config('lonIconsURL') . "/"; my $display_out; - my %locked_files=&Apache::lonnet::dump('file_permissions', - $ENV{'user.domain'},$ENV{'user.name'}); - my $locked_file; - foreach my $key (keys %locked_files) { - $locked_file .= $locked_files{$key}.':'; - } + my %locked_files = &Apache::lonnet::get_marked_as_readonly_hash ($ENV{'user.domain'},$ENV{'user.name'}); if ($is_empty && ($current_path ne '/')) { $display_out = '
'. ''. @@ -101,8 +96,9 @@ sub display_directory { return; } $r->print(''. - ''); + ''); my $href_location="/uploaded/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path"; + $r->print(''); foreach my $line (sort { my ($afile)=split('&',$a,2); @@ -114,24 +110,20 @@ sub display_directory { my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); if (($filename ne '.') && ($filename ne '..')) { if ($dirptr&$testdir) { - $r->print(''); + $r->print(''); $r->print(''); $r->print(''); $r->print(''); } else { $r->print(''); - $r->print(''); + if (exists $locked_files{$current_path.$filename}){ + $r->print(''); + } else { + $r->print(' + '); + } $r->print(''); $r->print(''); @@ -146,16 +138,17 @@ sub display_directory { # $r->print(&display_directory($current_path, $currentFile, @dir_list)); # $r->print('>
Actions NameSizeLast Modified
Actions NameSizeLast Modified
Go to ...'.&make_anchor($filename.'/',$current_path.$filename.'/',$ENV{'form.mode'},$ENV{"form.fieldname"}).'
- - - - - - - Locked + RenameMeta + '. $filename.''); # $r->print(&display_actions($current_path, $currentFile, $isEmpty)); - $r->print('
'); + $r->print(' + + + + '); } sub display_file_select { my ($r,$current_path,$is_empty,$dir_list)=@_; my $iconpath= $r->dir_config('lonIconsURL') . "/"; my $display_out; my $checked_files = &Apache::lonnet::files_in_path($ENV{'user.name'}, $ENV{'form.currentpath'}); - foreach my $key (keys %$checked_files) { - &Apache::lonnet::logthis("a key is $key $$checked_files{$key} is the value"); - } if ($is_empty && ($current_path ne '/')) { $display_out = '
'. ''. @@ -190,12 +183,9 @@ sub display_file_select { $r->print(''); } else { $r->print(''); - $r->print('print('print("CHECKED"); - &Apache::lonnet::logthis("checked"); - } else { - &Apache::lonnet::logthis("not checked $$checked_files{$filename} $filename"); } $r->print('>'); $r->print(''); @@ -216,15 +206,202 @@ sub display_file_select {
'); } - +sub prettyinput { + my ($type,$value,$fieldname,$formname, + $relatedsearchflag,$relatedsep,$relatedvalue,$size)=@_; + if (! defined($size)) { + $size = 80; + } + # Language + if ($type eq 'language') { + return &Apache::lonmeta::selectbox($fieldname, + $value, + \&Apache::loncommon::languagedescription, + (&Apache::loncommon::languageids)). + &relatedfield(0,$relatedsearchflag,$relatedsep); + } + # Copyright + if ($type eq 'copyright') { + return &Apache::lonmeta::selectbox($fieldname, + $value, + \&Apache::loncommon::copyrightdescription, + (&Apache::loncommon::copyrightids)). + &relatedfield(0,$relatedsearchflag,$relatedsep); + } + # Source Copyright + if ($type eq 'sourceavail') { + return &Apache::lonmeta::selectbox($fieldname, + $value, + \&Apache::loncommon::source_copyrightdescription, + (&Apache::loncommon::source_copyrightids)). + &relatedfield(0,$relatedsearchflag,$relatedsep); + } + # Gradelevels + if (($type eq 'lowestgradelevel') || + ($type eq 'highestgradelevel')) { + return &Apache::loncommon::select_level_form($value,$fieldname). + &relatedfield(0,$relatedsearchflag,$relatedsep); + } + # Obsolete + if ($type eq 'obsolete') { + return ''. + &relatedfield(0,$relatedsearchflag,$relatedsep); + } + # Obsolete replacement file + if ($type eq 'obsoletereplacement') { + return '".&mt('Select').''. + &relatedfield(0,$relatedsearchflag,$relatedsep); + } + # Customdistribution file + if ($type eq 'customdistributionfile') { + return '".&mt('Select').''. + &relatedfield(0,$relatedsearchflag,$relatedsep); + } + # Source Customdistribution file + if ($type eq 'sourcerights') { + return '".&mt('Select').''. + &relatedfield(0,$relatedsearchflag,$relatedsep); + } + # Dates + if (($type eq 'creationdate') || + ($type eq 'lastrevisiondate')) { + return + &Apache::lonhtmlcommon::date_setter($formname,$fieldname,$value). + &relatedfield(0,$relatedsearchflag,$relatedsep); + } + # No pretty input found + $value=~s/^\s+//gs; + $value=~s/\s+$//gs; + $value=~s/\s+/ /gs; + $value=~s/\"/\"\;/gs; + return + ''. + &relatedfield(1,$relatedsearchflag,$relatedsep,$fieldname, + $relatedvalue); +} + +sub relatedfield { + my ($show,$relatedsearchflag,$relatedsep,$fieldname,$relatedvalue)=@_; + if (! $relatedsearchflag) { + return ''; + } + if (! defined($relatedsep)) { + $relatedsep=' '; + } + if (! $show) { + return $relatedsep.' '; + } + return $relatedsep.''; +} + + +# The field names +sub fieldnames { + return &Apache::lonlocal::texthash + ( + 'title' => 'Title', + 'author' =>'Author(s)', + 'authorspace' => 'Author Space', + 'modifyinguser' => 'Last Modifying User', + 'subject' => 'Subject', + 'keywords' => 'Keyword(s)', + 'notes' => 'Notes', + 'abstract' => 'Abstract', + 'lowestgradelevel' => 'Lowest Grade Level', + 'highestgradelevel' => 'Highest Grade Level', + 'standards' => 'Standards', + 'mime' => 'MIME Type', + 'language' => 'Language', + 'creationdate' => 'Creation Date', + 'lastrevisiondate' => 'Last Revision Date', + 'owner' => 'Publisher/Owner', + 'copyright' => 'Copyright/Distribution', + 'customdistributionfile' => 'Custom Distribution File', + 'sourceavail' => 'Source Available', + 'sourcerights' => 'Source Custom Distribution File', + 'obsolete' => 'Obsolete', + 'obsoletereplacement' => 'Suggested Replacement for Obsolete File', + 'count' => 'Network-wide number of accesses (hits)', + 'course' => 'Network-wide number of courses using resource', + 'course_list' => 'Network-wide courses using resource', + 'sequsage' => 'Number of resources using or importing resource', + 'sequsage_list' => 'Resources using or importing resource', + 'goto' => 'Number of resources that follow this resource in maps', + 'goto_list' => 'Resources that follow this resource in maps', + 'comefrom' => 'Number of resources that lead up to this resource in maps', + 'comefrom_list' => 'Resources that lead up to this resource in maps', + 'clear' => 'Material presented in clear way', + 'depth' => 'Material covered with sufficient depth', + 'helpful' => 'Material is helpful', + 'correct' => 'Material appears to be correct', + 'technical' => 'Resource is technically correct', + 'avetries' => 'Average number of tries till solved', + 'stdno' => 'Total number of students who have worked on this problem', + 'difficulty' => 'Degree of difficulty', + 'disc' => 'Degree of discrimination', + 'dependencies' => 'Resources used by this resource', + ); +} + +sub edit_meta_data { + my ($r,$uri) = @_; + # Construction Space Call + # Header + my $disuri=$uri; + my $fn=&Apache::lonnet::filelocation('',$uri); + $disuri=~s/^\/\~/\/priv\//; + $disuri=~s/\.meta$//; + my $target=$uri; + $target=~s/^\/\~/\/res\/$ENV{'request.role.domain'}\//; + $target=~s/\.meta$//; + $r->print(''); + my %lt=&fieldnames(); + my $output; + foreach ('author','title','subject','keywords','abstract','notes', + 'copyright','customdistributionfile','language', + 'standards', + 'lowestgradelevel','highestgradelevel','sourceavail','sourcerights', + 'obsolete','obsoletereplacement') { + if (defined($ENV{'form.new_'.$_})) { + $Apache::lonpublisher::metadatafields{$_}= + $ENV{'form.new_'.$_}; + } + if (! $Apache::lonpublisher::metadatafields{'copyright'}) { + $Apache::lonpublisher::metadatafields{'copyright'}= + 'default'; + } + $output.=('

'.$lt{$_}.': '. + &prettyinput($_, + $Apache::lonpublisher::metadatafields{$_}, + 'new_'.$_,'defaultmeta').'

'); + } + return $output; +} sub open_form { my ($r)=@_; + my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); $r->print('
'); $r->print(''); $r->print(''); - $r->print(''); + foreach (@files) { + $r->print(''); + } $r->print(''); } @@ -244,9 +421,19 @@ sub close_form { sub display_file { my ($path,$filename)=@_; + my $display_file_text; if (!defined($path)) { $path=$ENV{'form.currentpath'}; } - if (!defined($filename)) { $filename=$ENV{'form.selectfile'}; } - return ''.$path.$filename.''; + if (!defined($filename)) { + $filename=$ENV{'form.selectfile'}; + $display_file_text = ''.$path.$filename.''; + } elsif (ref($filename) eq "ARRAY") { + foreach (@$filename) { + $display_file_text .= ''.$path.$_.'
'; + } + } elsif (ref($filename) eq "SCALAR") { + $display_file_text = ''.$path.$filename.''; + } + return $display_file_text; } sub done { @@ -261,25 +448,36 @@ sub delete { my ($r)=@_; my @check; my $file_name = $ENV{'form.currentpath'}.$ENV{'form.selectfile'}; + my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); + if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'} ) eq 'true') { $r->print ("The file is locked and cannot be deleted.
"); $r->print(&done()); } else { - &open_form($r); - $r->print('

'.&mt('Delete').' '.&display_file().'?

'); - &close_form($r); + if (scalar(@files)) { + &open_form($r); + $r->print('

'.&mt('Delete').' '.&display_file(undef,\@files).'?

'); + &close_form($r); + } else { + $r->print("No file was checked to delete.
"); + $r->print(&done()); + } } } sub delete_confirmed { my ($r)=@_; - my $result=&Apache::lonnet::removeuserfile($ENV{'user.name'}, + my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); + my $result; + foreach my $delete_file (@files) { + $result=&Apache::lonnet::removeuserfile($ENV{'user.name'}, $ENV{'user.domain'},'portfolio'. $ENV{'form.currentpath'}. - $ENV{'form.selectfile'}); - if ($result ne 'ok') { + $delete_file); + if ($result ne 'ok') { $r->print(' An error occured ('.$result. - ') while trying to delete '.&display_file().'
'); + ') while trying to delete '.&display_file(undef, $delete_file).'
'); + } } $r->print(&done()); } @@ -321,7 +519,7 @@ sub delete_dir_confirmed { sub rename { my ($r)=@_; - my $file_name = $ENV{'form.currentpath'}.$ENV{'form.selectfile'}; + my $file_name = $ENV{'form.currentpath'}.$ENV{'form.rename'}; if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'}) eq 'true') { $r->print ("The file is locked and cannot be renamed.
"); $r->print(&done()); @@ -352,6 +550,9 @@ sub rename_confirmed { ') while trying to rename '.&display_file().' to '. &display_file(undef,$filenewname).'
'); } + if ($filenewname ne $ENV{'form.filenewname'}) { + $r->print("The new file name was changed from:
".$ENV{'form.filenewname'}." to $filenewname "); + } $r->print(&done()); } sub select_files { @@ -359,7 +560,7 @@ 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.selectedfile'); + my @items=&Apache::loncommon::get_env_multiple('form.selectfile'); &Apache::lonnet::save_selected_files($ENV{'user.name'}, $ENV{'form.currentpath'}, @items); } else { if ($ENV{'form.currentpath'} eq '/') { @@ -421,7 +622,7 @@ sub upload { } } my $current_disk_usage = &Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root); - if (($current_disk_usage + $filesize) > $disk_quota){ + if ((($current_disk_usage/1000) + $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.'); } @@ -473,6 +674,9 @@ sub createdir { ') while trying to create a new directory '.&display_file().'

'); } } + if ($newdir ne $ENV{'form.newdir'}) { + $r->print("The new directory name was changed from:
".$ENV{'form.newdir'}." to $newdir "); + } $r->print(&done()); } @@ -492,13 +696,22 @@ sub handler { &Apache::loncommon::bodytag('Portfolio Manager')); $r->rflush(); &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['selectfile','currentpath', - 'currentfile','action','fieldname','mode']); + ['selectfile','currentpath','meta', + 'currentfile','action','fieldname','mode','rename']); if (($ENV{'form.storeupl'} eq 'Upload') & (!$ENV{'form.uploaddoc.filename'})){ $r->print(' No file was selected to upload.'. 'To upload a file, click Browse...'. ', select a file, then click Upload,'); } + if ($ENV{'form.meta'}) { + &open_form($r); + $r->print(&edit_meta_data($r, $ENV{'form.currentpath'}.$ENV{'form.selectfile'})); + $r->print('Edit the meta data
'); + &close_form($r); + } + if ($ENV{'form.store'}) { + } + if ($ENV{'form.uploaddoc.filename'}) { &upload($r); } elsif ($ENV{'form.action'} eq 'delete' && $ENV{'form.confirmed'}) { @@ -511,7 +724,9 @@ sub handler { &delete_dir($r); } elsif ($ENV{'form.action'} eq 'rename' && $ENV{'form.confirmed'}) { &rename_confirmed($r); - } elsif ($ENV{'form.action'} eq 'rename') { + } elsif ($ENV{'form.rename'}) { + $ENV{'form.selectfile'} = $ENV{'form.rename'}; + $ENV{'form.action'} = 'rename'; &rename($r); } elsif ($ENV{'form.createdir'}) { &createdir($r); 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.