--- loncom/interface/portfolio.pm 2006/06/22 20:09:51 1.119
+++ loncom/interface/portfolio.pm 2006/07/08 01:20:40 1.132
@@ -1,3 +1,8 @@
+# The LearningOnline Network
+# portfolio browser
+#
+# $Id: portfolio.pm,v 1.132 2006/07/08 01:20:40 raeburn Exp $
+#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
@@ -31,6 +36,7 @@ use Apache::lonfeedback;
use Apache::lonlocal;
use Apache::lonnet;
use Apache::longroup;
+use Apache::lonhtmlcommon;
use HTML::Entities;
use LONCAPA;
@@ -49,29 +55,32 @@ sub make_anchor {
}
my $dirptr=16384;
sub display_common {
- my ($r,$url,$current_path,$is_empty,$dir_list,$group)=@_;
- my $groupitem;
+ my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload)=@_;
my $namespace = &get_namespace($group);
my $port_path = &get_port_path($group);
- if (defined($group)) {
- $groupitem = '';
- }
- my $iconpath= $r->dir_config('lonIconsURL') . "/";
- my %text=&Apache::lonlocal::texthash('upload' => 'Upload',
+ if ($can_upload) {
+ my $groupitem;
+ if (defined($group)) {
+ $groupitem = '';
+ }
+ my $iconpath= $r->dir_config('lonIconsURL') . "/";
+ my %text=&Apache::lonlocal::texthash(
+ 'upload' => 'Upload',
'upload_label' =>
'Upload file to current directory:',
'createdir' => 'Create Subdirectory',
'createdir_label' =>
'Create subdirectory in current directory:');
- my $escuri = &HTML::Entities::encode($r->uri,'&<>"');
- $r->print(<<"TABLE");
+ my $escuri = &HTML::Entities::encode($r->uri,'&<>"');
+ $r->print(<<"TABLE");
$text{'upload_label'}
-
$groupitem
+
TABLE
+ }
my @tree = split (/\//,$current_path);
$r->print(''.&make_anchor($url,$port_path,'/',$env{"form.mode"},$env{"form.fieldname"},$env{"form.continue"},$group).'/');
if (@tree > 1){
@@ -119,7 +129,8 @@ TABLE
$r->print("");
}
sub display_directory {
- my ($r,$url,$current_path,$is_empty,$dir_list,$group)=@_;
+ my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload,
+ $can_modify,$can_delete,$can_setacl)=@_;
my $iconpath= $r->dir_config('lonIconsURL') . "/";
my ($groupitem,$groupecho);
my $display_out;
@@ -127,10 +138,15 @@ sub display_directory {
my $checked_files;
my $port_path = &get_port_path($group);
my ($uname,$udom) = &get_name_dom($group);
- if (defined($group)) {
+ my $access_admin_text = &mt('View Status');
+ if ($can_setacl) {
+ $access_admin_text = &mt('View/Change Status');
+ }
+ if ((defined($group)) && (defined($env{'request.course.id'}))) {
$groupitem = '';
$groupecho = '&group='.$group;
}
+
my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom,
$uname);
my %locked_files = &Apache::lonnet::get_marked_as_readonly_hash(
@@ -142,7 +158,7 @@ sub display_directory {
$checked_files =&Apache::lonnet::files_in_path($uname,$env{'form.currentpath'});
$select_mode = 'true';
}
- if ($is_empty && ($current_path ne '/')) {
+ if ($is_empty && ($current_path ne '/') && $can_delete) {
$display_out = '');
} else {
- $r->print('
+ $r->print('');
+ if ($can_delete) {
+ $r->print('
- ');
+ '
+ );
+ }
}
}
@@ -493,24 +534,169 @@ sub rename_confirmed {
}
sub display_access {
- my ($r,$url,$group) = @_;
+ my ($r,$url,$group,$can_setacl) = @_;
my ($uname,$udom) = &get_name_dom($group);
my $file_name = $env{'form.currentpath'}.$env{'form.access'};
$file_name = &prepend_group($file_name,$group);
my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom,
$uname);
my %access_controls = &Apache::lonnet::get_access_controls($current_permissions,$group,$file_name);
- &open_form($r,$url);
- $r->print('
'.&mt('Allowing others to retrieve portfolio file: [_1]',$env{'form.currentpath'}.$env{'form.access'}).'
'."\n");
- $r->print(&mt('Access to this file by others can be set to be one or more of the following types: public, password-protected or conditional.').'
'.&mt('Public files are available to anyone without the need for login.').'
'.&mt('Password-protected files do not require log-in, but will require the viewer to enter the password you set.').'
'.&mt('Conditional files are accessible to logged-in users with accounts in the LON-CAPA network, who satify the conditions you set.').' '.&mt('The conditions can include affiliation with a particular course or group, or a user account in a specific domain.').' '.&mt('Alternatively you can grant access to people with specific LON-CAPA usernames and domains.').'
');
- &access_setting_table($r,$access_controls{$file_name});
- my $button_text = {
+ my $aclcount = keys(%access_controls);
+ my $header = '
'.&mt('Allowing others to retrieve portfolio file: [_1]',$env{'form.currentpath'}.$env{'form.access'}).'
';
+ my $info .= &mt('Access to this file by others can be set to be one or more of the following types: public, passphrase-protected or conditional.').'
'.&mt('Public files are available to anyone without the need for login.').'
'.&mt('Passphrase-protected files do not require log-in, but will require the viewer to enter the passphrase you set.').'
'.&mt('Conditional files are accessible to logged-in users with accounts in the LON-CAPA network, who satisfy the conditions you set.').' '.&mt('The conditions can include affiliation with a particular course or group, or a user account in a specific domain.').' '.&mt('Alternatively access can be granted to people with specific LON-CAPA usernames and domains.').'
';
+ if ($can_setacl) {
+ &open_form($r,$url);
+ $r->print($header.$info);
+ &access_setting_table($r,$access_controls{$file_name});
+ my $button_text = {
'continue' => &mt('Proceed'),
'cancel' => &mt('Back to directory listing'),
};
- &close_form($r,$url,$group,$button_text);
+ &close_form($r,$url,$group,$button_text);
+ } else {
+ $r->print($header);
+ if ($aclcount) {
+ $r->print($info);
+ }
+ &view_access_settings($r,$url,$group,$access_controls{$file_name},
+ $aclcount);
+ }
}
+sub view_access_settings {
+ my ($r,$url,$group,$access_controls,$aclcount) = @_;
+ my ($showstart,$showend);
+ my %todisplay;
+ foreach my $key (sort(keys(%{$access_controls}))) {
+ my ($num,$scope,$end,$start) = &unpack_acc_key($key);
+ $todisplay{$scope}{$key} = $$access_controls{$key};
+ }
+ if ($aclcount) {
+ $r->print(&mt('