--- loncom/interface/portfolio.pm 2006/03/19 22:08:38 1.97 +++ loncom/interface/portfolio.pm 2006/06/07 21:15:01 1.103 @@ -30,6 +30,9 @@ use Apache::lontexconvert; use Apache::lonfeedback; use Apache::lonlocal; use Apache::lonnet; +use Apache::longroup; +use lib '/home/httpd/lib/perl'; +use LONCAPA; # receives a file name and path stub from username/userfiles/portfolio/ # returns an anchor tag consisting encoding filename and currentpath @@ -123,12 +126,16 @@ sub display_directory { my $checked_files; my $port_path = &get_port_path($group); my ($uname,$udom) = &get_name_dom($group); - my $namespace = &get_namespace($group); if (defined($group)) { $groupitem = ''; $groupecho = '&group='.$group; } - my %locked_files = &Apache::lonnet::get_marked_as_readonly_hash ($namespace,$udom,$uname); + my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom, + $uname); + my %locked_files = &Apache::lonnet::get_marked_as_readonly_hash( + $current_permissions,$group); + my %access_controls = &Apache::lonnet::get_access_controls($current_permissions,$group); + my $now = time; if ($env{"form.mode"} eq 'selectfile'){ &select_files($r); $checked_files =&Apache::lonnet::files_in_path($uname,$env{'form.currentpath'}); @@ -151,7 +158,7 @@ sub display_directory { $r->print('
'); } else { $r->print(''. - ''); + ''); $r->print(''); } if (defined($group)) { @@ -181,14 +188,16 @@ sub display_directory { $r->print(''); } else { $r->print(''); + my $fullpath = $current_path.$filename; + $fullpath = &prepend_group($fullpath,$group); if ($select_mode eq 'true'){ - $r->print(''); } else { - if (exists $locked_files{$current_path.$filename}){ + if (exists $locked_files{$fullpath}) { $r->print(''); } else { my $cat=''.&mt('Catalog Information').
@@ -199,11 +208,31 @@ sub display_directory {
                             </td>');
                     }
                 }
+                my $curr_access;
+                my $pub_access = 0;
+                foreach my $key (sort(keys(%{$access_controls{$fullpath}}))) {
+                    my ($scope,$end,$start) = ($key =~ /^\d+:(\w+)_(\d*)_?(\d*)$/);
+                    if (($now > $start) && (!$end || $end > $now)) {
+                        if ($scope eq 'public')  {
+                            $pub_access = 1;
+                            last;
+                        }
+                    }
+                }
+                if (!$pub_access) {
+                    $curr_access = 'Private'
+                } elsif ($pub_access) {
+                    $curr_access = 'Public';
+                }
                 $r->print('<td><img src='); $r->print(''); $r->print(''); $r->print(''); + $r->print(''); $r->print(''); } } @@ -229,7 +258,7 @@ sub display_directory { sub open_form { my ($r,$url)=@_; my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); - $r->print(''); + $r->print(''); $r->print(''); $r->print(''); @@ -298,6 +327,7 @@ sub delete { my ($r,$url,$group)=@_; my @check; my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'}; + $file_name = &prepend_group($file_name,$group); my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); my ($uname,$udom) = &get_name_dom($group); if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') { @@ -373,6 +403,7 @@ sub rename { my ($r,$url,$group)=@_; my $file_name = $env{'form.currentpath'}.$env{'form.rename'}; my ($uname,$udom) = &get_name_dom($group); + $file_name = &prepend_group($file_name,$group); if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') { $r->print ("The file is locked and cannot be renamed.
"); $r->print(&done(undef,$url,$group)); @@ -410,6 +441,7 @@ sub rename_confirmed { } $r->print(&done(undef,$url,$group)); } + sub select_files { my ($r,$group)=@_; if ($env{'form.continue'} eq 'true') { @@ -476,8 +508,13 @@ sub upload { foreach my $line (@dir_list) { my ($file_name)=split(/\&/,$line,2); if ($file_name eq $fname){ + $file_name = $env{'form.currentpath'}.$file_name; + $file_name = &prepend_group($file_name,$group); $found_file = 1; - if (&Apache::lonnet::is_locked($env{'form.currentpath'}.$file_name,$udom,$uname) eq 'true') { + if (defined($group)) { + $file_name = $group.'/'.$file_name; + } + if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') { $locked_file = 1; } } @@ -501,7 +538,6 @@ sub upload { } else { my $result=&Apache::lonnet::userfileupload('uploaddoc','', $port_path.$env{'form.currentpath'}); - print STDERR "result was $result for $port_path.$env{'form.currentpath'}\n"; if ($result !~ m|^/uploaded/|) { $r->print(' An errror occured ('.$result. ') while trying to upload '.&display_file().'
'); @@ -514,21 +550,31 @@ sub upload { sub lock_info { my ($r,$url,$group) = @_; my ($uname,$udom) = &get_name_dom($group); - my %current_permissions = &Apache::lonnet::dump('file_permissions',$udom,$uname); + my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom, + $uname); 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]"); - } + $file_name = &prepend_group($file_name,$group); + 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]). + '
'); + my %course_description = &Apache::lonnet::coursedescription($$array_item[1]); + $r->print(&mt('In the course: [_1]
', + $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',$url,$group)); return 'ok'; @@ -603,6 +649,14 @@ sub get_name_dom { return ($uname,$udom); } +sub prepend_group { + my ($filename,$group) = @_; + if (defined($group)) { + $filename = $group.'/'.$filename; + } + return $filename; +} + sub get_namespace { my ($group) = @_; my $namespace = 'portfolio'; @@ -629,7 +683,7 @@ sub handler { my $r = shift; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['selectfile','currentpath','meta','lockinfo','currentfile', - 'action','fieldname','mode','rename','continue','group']); + 'action','fieldname','mode','rename','continue','group','access']); my ($uname,$udom,$portfolio_root,$url,$group,$caller,$title); if ($r->uri =~ m|^(/adm/)([^/]+)|) { $url = $1.$2; @@ -649,10 +703,10 @@ sub handler { $group = $env{'form.group'}; $group =~ s/\W//g; if ($group) { - my %curr_groups = (); ($uname,$udom) = &get_name_dom($group); - if (&Apache::loncommon::coursegroups(\%curr_groups,$udom,$uname, - $group)) { + my %curr_groups = &Apache::longroup::coursegroups($udom,$uname, + $group); + if (%curr_groups) { if (($view_permission) || (&Apache::lonnet::allowed('rgf', $env{'request.course.id'}.'/'.$group))) { $portfolio_root = &get_portfolio_root($group); @@ -732,7 +786,8 @@ sub handler { # 1) never been here, so directory structure not created # 2) back-button navigation after deleting a directory if ($current_path eq '/'){ - &Apache::lonnet::mkdiruserfile($uname,$udom,'portfolio'); + &Apache::lonnet::mkdiruserfile($uname,$udom, + &get_port_path($group)); } else { # some directory that snuck in get rid of the directory # from the recent pulldown, just in case
Actions NameSizeLast Modified
Actions NameSizeLast ModifiedCurrent Access Status
print('print("CHECKED"); } $r->print('>Locked'. $filename.''.$size.''.&Apache::lonlocal::locallocaltime($mtime).''.&mt($curr_access).'   '. + ''.&mt('View/Change').'