--- loncom/interface/portfolio.pm 2006/06/20 01:56:17 1.105 +++ loncom/interface/portfolio.pm 2006/07/19 11:43:47 1.136 @@ -1,3 +1,8 @@ +# The LearningOnline Network +# portfolio browser +# +# $Id: portfolio.pm,v 1.136 2006/07/19 11:43:47 raeburn Exp $ +# # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). @@ -31,94 +36,131 @@ use Apache::lonfeedback; use Apache::lonlocal; use Apache::lonnet; use Apache::longroup; -use lib '/home/httpd/lib/perl'; +use Apache::lonhtmlcommon; +use HTML::Entities; use LONCAPA; # 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) = @_; + $continue_select,$group,$refarg) = @_; if ($continue_select ne 'true') {$continue_select = 'false'}; - my $anchor = ''; return $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,$refarg)=@_; 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 = ''; + if (exists($env{'form.ref'})) { + $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:'); - $r->print(<<"TABLE"); -
Select | Name | Size | Last Modified |
---|
Select | Name | Size | Last Modified |
---|
Actions | Name | Size | Last Modified | Current Access Status |
---|
Actions | Name | Size | Last Modified | Current Access Status | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
'); - } else { - $r->print(' | ||||||||||||||||
'); + undef($colspan); } + $r->print(' | ||||||||||||||||
'); $r->print(' | Go to ... | '); - $r->print(''.&make_anchor($url,$filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'},$group).' | '); + $r->print(''.$version_flag{$filename}.&make_anchor($url,$filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'},$group,$refarg).'/ | '); $r->print('|||||||||||||
print("CHECKED"); + if ($select_mode eq 'true') { + $line=' | print('> | '); + $line.=' />'; } else { if (exists $locked_files{$fullpath}) { - $r->print('Locked | '); + $line.='Locked | '; + $css_class= 'LC_browser_file_locked'; } else { - my $cat=''; - $r->print('- Rename | -'.$cat.' - | '); - } - } - my $curr_access; - my $pub_access = 0; - foreach my $key (sort(keys(%{$access_controls{$fullpath}}))) { - my ($scope,$end,$start) = ($key =~ /^[^:]+:([a-z]+)_(\d*)_?(\d*)$/); - if (($now > $start) && (!$end || $end > $now)) { - if ($scope eq 'public') { - $pub_access = 1; + if (!$can_modify) { + $line .= ''; + } else { + $line .= ' | '; } + if ($can_delete) { + $line .= ''; + } + if ($can_modify) { + my $cat=''; + $line .= 'Rename'; + $line .= ' | '.$version_flag{$filename}.''.$cat.''; + } + $line .= ' | '; } } - if (!$pub_access) { - $curr_access = 'Private' - } else { - $curr_access = 'Public'; - } - $r->print(''); - $r->print(' | '. - $filename.' | '); - $r->print(''.$size.' | '); - $r->print(''.&Apache::lonlocal::locallocaltime($mtime).' | '); - $r->print('||||
'); +# $r->print(' | '.$version_flag{$filename}.''. +# $filename.' | '); +# $r->print(''.$size.' | '); +# $r->print(''.&Apache::lonlocal::locallocaltime($mtime).' | '); +# if ($select_mode ne 'true') { +# $r->print(''. +# &mt($curr_access).' '); +# $r->print(''.$access_admin_text.' | '); +# } +# $r->print('
'); + my ($r,$url,$group,$button_text)=@_; + if (!defined($button_text)) { + $button_text = { + 'continue' => &mt('Continue'), + 'cancel' => &mt('Cancel'), + }; + } + $r->print('
'); if (defined($group)) { $r->print("\n".''); + if (exists($env{'form.ref'})) { + $r->print("\n".''); + } } $r->print('
'); - $r->print(''); if (defined($group)) { $r->print("\n".''); + $group.'" />'); + if (exists($env{'form.ref'})) { + $r->print("\n".''); + } } - $r->print("\n".' + $r->print("\n".'
'.&mt('Rename').' '.&display_file().' to
@@ -432,15 +562,15 @@ sub rename {
}
sub rename_confirmed {
- my ($r,$url,$group)=@_;
+ my ($r,$url,$group,$refarg)=@_;
my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'});
my ($uname,$udom) = &get_name_dom($group);
my $port_path = &get_port_path($group);
if ($filenewname eq '') {
- $r->print(''.
+ $r->print(''.
&mt("Error: no valid filename was provided to rename to.").
- '
');
- $r->print(&done(undef,$url,$group));
+ '
');
+ $r->print(&done(undef,$url,$group,$refarg));
return;
}
my $result=
@@ -448,41 +578,196 @@ sub rename_confirmed {
$port_path.$env{'form.currentpath'}.$env{'form.selectfile'},
$port_path.$env{'form.currentpath'}.$filenewname);
if ($result ne 'ok') {
- $r->print(' An errror occured ('.$result.
- ') while trying to rename '.&display_file().' to '.
- &display_file(undef,$filenewname).'
');
+ $r->print(''.
+ &mt('An errror occured ([_1]) while trying to rename [_2]'
+ .' to [_3]',$result,&display_file(),
+ &display_file('',$filenewname)).'
');
}
if ($filenewname ne $env{'form.filenewname'}) {
- $r->print("The new file name was changed from:
".$env{'form.filenewname'}." to $filenewname ");
+ $r->print(&mt("The new file name was changed from:
[_1] to [_2]",
+ ''.&display_file('',$env{'form.filenewname'}).'',
+ ''.&display_file('',$filenewname).''));
}
- $r->print(&done(undef,$url,$group));
+ $r->print(&done(undef,$url,$group,$refarg));
}
sub display_access {
- my ($r,$url,$group) = @_;
+ my ($r,$url,$group,$can_setacl,$port_path,$refarg) = @_;
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('Roles').' | '. + &mt('Access').' | '. + &mt('Sections').' | '); + if ($scope eq 'course') { + $r->print(''.&mt('Groups').' | '); + } else { + $r->print(''.&mt('Teams').' | '); + } + $r->print('
---|---|---|---|---|
'); + if ($item eq 'role') { + my $ucscope = $scope; + $ucscope =~ s/^(\w)/uc($1)/e; + my $role_output; + foreach my $role (@{$content->{'roles'}{$id}{$item}}) { + if ($role eq 'all') { + $role_output .= $role.','; + } elsif ($role =~ /^cr/) { + $role_output .= (split('/',$role))[3].','; + } else { + $role_output .= &Apache::lonnet::plaintext($role,$ucscope).','; + } + } + $role_output =~ s/,$//; + $r->print($role_output); + } else { + $r->print(join(',',@{$content->{'roles'}{$id}{$item}})); + } + $r->print(' |
');
+ $r->print(''.&mt('Public access:').' '.$publictext.''); $r->print(&Apache::loncommon::start_data_table()); + $r->print(&Apache::loncommon::start_data_table_header_row()); + $r->print(' | '.&mt('Action').' | '.&mt('Dates available').' | '); + $r->print(&Apache::loncommon::end_data_table_header_row()); $r->print(&Apache::loncommon::start_data_table_row()); - $r->print(''.&mt('Access Type').' | '. - &mt('Settings').' | '."\n"); + if ($public) { + $r->print(''.&actionbox('old',$publicnum,'public').' | '. + &dateboxes($publicnum,$start{$public},$end{$public}).' | '); + } else { + $r->print(''.&actionbox('new','0','public').' | '. + &dateboxes('0',$now,$then).' | '); + } $r->print(&Apache::loncommon::end_data_table_row()); - $r->print(&Apache::loncommon::start_data_table_row()); - $r->print('Public '.$publictext.' | '); + $r->print(&Apache::loncommon::end_data_table()); + $r->print(' | ');
+ $r->print(''.&mt('Passphrase-protected access:').' '.$guesttext.''); $r->print(&Apache::loncommon::start_data_table()); + $r->print(&Apache::loncommon::start_data_table_header_row()); + $r->print(' | '.&mt('Action').' | '.&mt('Dates available'). + ' | '. &mt('Passphrase').' | '); + $r->print(&Apache::loncommon::end_data_table_header_row()); $r->print(&Apache::loncommon::start_data_table_row()); - my ($pub_startdate,$pub_enddate,$pub_action,$pub_noend); - if ($public) { - my ($num,$end,$start) = ($public =~ /^([^:]+):[a-z]+_(\d*)_?(\d*)$/); - if ($end == 0) { - $pub_noend = 'checked="checked"'; - } - $pub_action = ''.&mt('Delete').' '.&mt('Update'). - ' | ';
- $pub_startdate = &Apache::lonhtmlcommon::date_setter('portform',
- 'startdate_'.$num,$start,undef,undef,undef,1,undef,
- undef,undef,1);
- $pub_enddate = &Apache::lonhtmlcommon::date_setter('portform',
- 'enddate_'.$num,$end,undef,undef,undef,1,undef,
- undef,undef,1).
- ' '.&actionbox('old',$guestnum,'guest').' | '. + &dateboxes($guestnum,$start{$guest},$end{$guest}).' | '); + } else { + $r->print(''.&actionbox('new','1','guest').' | '. + &dateboxes('1',$now,$then).' | '); } - $r->print(''.$pub_action.' | '.&mt('Start: ').$pub_startdate.
- ' '.&mt('End: ').$pub_enddate.' | ');
+ $r->print(''); $r->print(&Apache::loncommon::end_data_table_row()); $r->print(&Apache::loncommon::end_data_table()); + $r->print(' | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
'); + &access_element($r,'domains',\%acl_count,\@domains,$access_controls,$now,$then); + $r->print(' | '); + &access_element($r,'users',\%acl_count,\@users,$access_controls,$now,$then); + $r->print(' | ||||||||||||||||||||||||||
'); + } else { + $r->print(' | '); + } + &access_element($r,'course',\%acl_count,\@courses,$access_controls,$now,$then); $r->print(' | '); - $r->print(&Apache::loncommon::end_data_table_row()); - $r->print(&Apache::loncommon::end_data_table()); + if (@courses > 0 || @groups > 0) { + $r->print('||||||||||||||||||||||||||
'); + } else { + $r->print(' | '); + } + &access_element($r,'group',\%acl_count,\@groups,$access_controls,$now,$then); + $r->print(' |
'.&mt('Action').' | '.&mt('Roles').' | '. + &mt('Access').' | '.&mt('Sections').' | '. + &mt($crsgrptext).' |
---|---|---|---|---|
'.&mt('Roles').' | '.&mt('[_1] status',$type).' | '.&mt('Sections').' | '.&mt($grouptitle).' |
---|---|---|---|