--- loncom/interface/portfolio.pm 2006/06/26 22:23:27 1.121
+++ loncom/interface/portfolio.pm 2006/08/16 17:58:54 1.159
@@ -1,3 +1,8 @@
+# The LearningOnline Network
+# portfolio browser
+#
+# $Id: portfolio.pm,v 1.159 2006/08/16 17:58:54 banghart Exp $
+#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
@@ -31,32 +36,56 @@ use Apache::lonfeedback;
use Apache::lonlocal;
use Apache::lonnet;
use Apache::longroup;
+use Apache::lonhtmlcommon;
use HTML::Entities;
use LONCAPA;
+sub group_args {
+ my $output;
+ if (defined($env{'form.group'})) {
+ $output .= '&group='.$env{'form.group'};
+ if (defined($env{'form.ref'})) {
+ $output .= '&ref='.$env{'form.ref'};
+ }
+ }
+ return $output;
+}
+
+sub group_form_data {
+ my $output;
+ if (defined($env{'form.group'})) {
+ $output = '';
+ if (exists($env{'form.ref'})) {
+ $output .= '';
+ }
+ }
+ 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,$group) = @_;
- if ($continue_select ne 'true') {$continue_select = 'false'};
- my $anchor = ''.$filename.'';
+ my ($url, $anchor_fields, $inner_text) = @_;
+ if ($$anchor_fields{'continue'} ne 'true') {$$anchor_fields{'continue'} = 'false'};
+ my $anchor = ''.$inner_text.'';
return $anchor;
}
+
my $dirptr=16384;
sub display_common {
- my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload)=@_;
- my $namespace = &get_namespace($group);
- my $port_path = &get_port_path($group);
+ my ($r,$url,$current_path,$is_empty,$dir_list,$can_upload)=@_;
+ my $namespace = &get_namespace();
+ my $port_path = &get_port_path();
if ($can_upload) {
- my $groupitem;
- if (defined($group)) {
- $groupitem = '';
- }
+ my $groupitem = &group_form_data();
+
my $iconpath= $r->dir_config('lonIconsURL') . "/";
my %text=&Apache::lonlocal::texthash(
'upload' => 'Upload',
@@ -103,43 +132,98 @@ sub display_common {
TABLE
}
my @tree = split (/\//,$current_path);
- $r->print(''.&make_anchor($url,$port_path,'/',$env{"form.mode"},$env{"form.fieldname"},$env{"form.continue"},$group).'/');
+ my %anchor_fields = (
+ 'selectfile' => $port_path,
+ 'currentpath' => '/',
+ 'mode' => $env{"form.mode"},
+ 'fieldname' => $env{"form.fieldname"},
+ 'continue' => $env{"form.continue"}
+ );
+ $r->print(''.&make_anchor($url,\%anchor_fields,$port_path).'/');
if (@tree > 1){
my $newCurrentPath = '';
for (my $i = 1; $i< @tree; $i++){
$newCurrentPath .= $tree[$i].'/';
- $r->print(&make_anchor($url,$tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}, $env{"form.continue"},$group).'/');
+ my %anchor_fields = (
+ 'selectfile' => $tree[$i],
+ 'currentpath' => '/',
+ 'mode' => $env{"form.mode"},
+ 'fieldname' => $env{"form.fieldname"},
+ 'continue' => $env{"form.continue"}
+ );
+ $r->print(&make_anchor($url,\%anchor_fields,$tree[$i]).'/');
}
}
$r->print('');
&Apache::lonhtmlcommon::store_recent($namespace,$current_path,$current_path);
- $r->print(' ");
}
+
+sub display_directory_line {
+ my ($r,$select_mode, $filename, $mtime, $size, $css_class,
+ $line, $access_controls, $curr_access, $now, $version_flag,
+ $href_location, $url, $current_path, $access_admin_text, $versions)=@_;
+
+ my $fullpath = &prepend_group($current_path.$filename);
+ $r->print('
');
+ $r->print($line); # contains first two cells of table
+ my $lock_info;
+ if ($version_flag) { # versioned can't be versioned, so TRUE when root file
+ $r->print('
');
+ $r->print('
'.$version_flag.'
');
+ } else { # this is a graded or handed back file
+ my ($user,$domain) = &get_name_dom();
+ my $permissions_hash = &Apache::lonnet::get_portfile_permissions($domain,$user);
+ if (defined($$permissions_hash{$fullpath})) {
+ foreach my $array_item (@{$$permissions_hash{$fullpath}}) {
+ if (ref($array_item) eq 'ARRAY') {
+ if ($$array_item[-1] eq 'handback') {
+ $lock_info = 'Handback';
+ } elsif ($$array_item[-1] eq 'graded') {
+ $lock_info = 'Graded';
+ }
+ }
+ }
+ }
+ if ($lock_info) {
+ my %anchor_fields = ('lockinfo' => $fullpath);
+ $lock_info = &make_anchor(undef,\%anchor_fields,$lock_info);
+ }
+ $r->print('