--- loncom/interface/portfolio.pm 2006/07/19 15:31:05 1.138 +++ loncom/interface/portfolio.pm 2007/07/10 20:51:46 1.186 @@ -1,7 +1,7 @@ # The LearningOnline Network # portfolio browser # -# $Id: portfolio.pm,v 1.138 2006/07/19 15:31:05 albertel Exp $ +# $Id: portfolio.pm,v 1.186 2007/07/10 20:51:46 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -60,17 +60,21 @@ sub group_form_data { $env{'form.ref'}.'" />'; } } + return $output; } # receives a file name and path stub from username/userfiles/portfolio/ # returns an anchor tag consisting encoding filename and currentpath sub make_anchor { - my ($url, $filename, $current_path, $current_mode, $field_name, - $continue_select) = @_; - if ($continue_select ne 'true') {$continue_select = 'false'}; - my $anchor = ''; + $anchor .= '">'.$inner_text.''; return $anchor; } @@ -91,6 +95,12 @@ sub display_common { 'createdir_label' => 'Create subdirectory in current directory:'); my $escuri = &HTML::Entities::encode($r->uri,'&<>"'); + my $help_fileupload = &Apache::loncommon::help_open_topic('Portfolio AddFiles'); + my $help_createdir = &Apache::loncommon::help_open_topic('Portfolio CreateDirectory'); + + # FIXME: This line should be deleted once Portfolio uses breadcrumbs + $r->print(&Apache::loncommon::help_open_topic('Portfolio About', 'Help on the portfolio')); + $r->print(<<"TABLE");
'.&mt('Roles').' | '.&mt('[_1] status',$type).' | '.&mt('Sections').' | '.&mt($grouptitle).' |
---|---|---|---|
'.&mt('Roles').' | '.&mt('[_1] status',$type).' | '.&mt('Sections').' | '.&mt('Groups').' |
---|---|---|---|
".&mt("Completed upload of the file. This file contained references to other files. You must upload the referenced files or else the uploaded file may not work properly.")."
"); + $r->print("".&mt("Please select the locations from which the referenced files are to be uploaded.")."
"); + $r->print(&Apache::londocs::ask_for_embedded_content('/adm/portfolio',$state,\%allfiles,\%codebase, + {'error_on_invalid_names' => 1, + 'ignore_remote_references' => 1,})); + $r->print('Or '.&done('Return to directory listing',$url).'
'); + } else { + $r->print(&done(undef,$url)); + } + } +} + +sub upload_embedded { + my ($r,$url,$group)=@_; + for (my $i=0; $i<$env{'form.number_embedded_items'}; $i++) { + next if (!exists($env{'form.embedded_item_'.$i.'.filename'})); + my $orig_uploaded_filename = + $env{'form.embedded_item_'.$i.'.filename'}; + + $env{'form.embedded_orig_'.$i} = + &unescape($env{'form.embedded_orig_'.$i}); + my ($path,$fname) = + ($env{'form.embedded_orig_'.$i} =~ m{(.*/)([^/]*)}); + # no path, whole string is fname + if (!$fname) { $fname = $env{'form.embedded_orig_'.$i} }; + + $path = $env{'form.currentpath'}.$path; + $fname = &Apache::lonnet::clean_filename($fname); + + my ($state,$msg) = &check_for_upload($path,$fname,$group, + 'embedded_item_'.$i); + + if ($state eq 'will_exceed_quota' + || $state eq 'file_locked' + || $state eq 'file_exists' ) { + $r->print($msg); + next; + } + + my $port_path = &get_port_path(); + my $src_path = $env{'form.embedded_orig_'.$i}; + $env{'form.embedded_item_'.$i.'.filename'}=$fname; + + my $result= + &Apache::lonnet::userfileupload('embedded_item_'.$i,'', + $port_path.$path); + if ($result !~ m|^/uploaded/|) { + $r->print(''.'An error occurred ('.$result. + ') while trying to upload '.$orig_uploaded_filename.' for embedded element '.$env{'form.embedded_orig_'.$i}.'Uploaded ". + &display_file($port_path.$path,$fname).'
'); + } } + $r->print(&done(undef,$url)); } sub lock_info { @@ -1538,27 +1899,38 @@ sub lock_info { $file_name = &prepend_group($file_name); if (defined($file_name) && defined($$current_permissions{$file_name})) { foreach my $array_item (@{$$current_permissions{$file_name}}) { - if (ref($array_item) eq 'ARRAY') { - my $filetext; - if (defined($group)) { - $filetext = ''.$env{'form.lockinfo'}. - ' (group: '.$group.')'; - } else { - $filetext = ''.$file_name.''; - } - $r->print(&mt('[_1] was submitted in response to problem: ', - $filetext). - ''.&Apache::lonnet::gettitle($$array_item[0]). - '