--- loncom/interface/portfolio.pm 2023/01/23 18:09:36 1.254.2.6.2.1
+++ loncom/interface/portfolio.pm 2014/12/07 19:45:19 1.255
@@ -1,7 +1,7 @@
# The LearningOnline Network
# portfolio browser
#
-# $Id: portfolio.pm,v 1.254.2.6.2.1 2023/01/23 18:09:36 raeburn Exp $
+# $Id: portfolio.pm,v 1.255 2014/12/07 19:45:19 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -112,17 +112,13 @@ sub display_common {
END
}
- # Find space available before uploading
- my $free_space = &free_space($group);
-
# Upload File
$r->print('
'
.'
'
.''
- .&Apache::lonhtmlcommon::display_usage($current_disk_usage,
- $disk_quota,'portfolio')
+ .&Apache::lonhtmlcommon::display_usage($current_disk_usage,$disk_quota)
.'
');
}
@@ -237,7 +232,7 @@ sub display_directory_line {
if ($lock_info) {
my %anchor_fields = ('lockinfo' => $fullpath);
if ($versions) { # hold the folder open
- my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($fullpath);
+ my ($fname,$version,$extension) = &Apache::lonnet::file_name_version_ext($fullpath);
$fname =~ s|^/||;
$anchor_fields{'showversions'} = $fname.'.'.$extension;
}
@@ -370,7 +365,7 @@ sub display_directory {
} (@{$dir_list})) {
my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
$filename =~ s/\s+$//;
- my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename);
+ my ($fname,$version,$extension) = &Apache::lonnet::file_name_version_ext($filename);
if ($version) {
my $fullpath = &prepend_group($current_path.$fname.'.'.$extension);
push(@{ $versioned{$fullpath} },
@@ -383,7 +378,7 @@ sub display_directory {
my $zerobyte;
foreach my $dir_line (@dir_lines) {
my ($filename,$dom,$testdir,$size,$mtime,$obs) = @$dir_line;
- my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename);
+ my ($fname,$version,$extension) = &Apache::lonnet::file_name_version_ext($filename);
if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/)) {
my $version_flag;
my $show_versions;
@@ -897,8 +892,6 @@ sub display_access {
my $aclcount = keys(%access_controls);
my ($header,$info);
if ($action eq 'chgaccess') {
- my $uhome = &Apache::lonnet::homeserver($uname,$udom);
- my $prefix = &Apache::lonnet::url_prefix($r,$udom,$uhome,'web');
$header =
''
.&mt('Allowing others to retrieve file: [_1]'
@@ -911,13 +904,13 @@ sub display_access {
$info .= '
'.&mt('Passphrase-protected files do not require log-in, but will require the viewer to enter the passphrase you set.');
$info .= ''.&explain_conditionals();
$info .= ''.
- &mt('A listing of files viewable without log-in is available at: ')."$prefix/adm/$udom/$uname/aboutme/portfolio.
";
+ &mt('A listing of files viewable without log-in is available at: ')."".&Apache::lonnet::absolute_url($ENV{'SERVER_NAME'})."/adm/$udom/$uname/aboutme/portfolio.
";
if ($group eq '') {
$info .= &mt("For logged in users a 'Display file listing' link will also appear (when there are viewable files) on your personal information page:");
} else {
$info .= &mt("For logged in users a 'Display file listing' link will also appear (when there are viewable files) on the course information page:");
}
- $info .= "
$prefix/adm/$udom/$uname/aboutme
";
+ $info .= "
".&Apache::lonnet::absolute_url($ENV{'SERVER_NAME'})."/adm/$udom/$uname/aboutme
";
if ($group ne '') {
$info .= &mt("Users with course editing rights may add a 'Group Portfolio' item using the Course Editor (Collaboration tab), to provide access to viewable group portfolio files.").'
';
}
@@ -1075,7 +1068,7 @@ sub build_access_summary {
$r->print(&mt('Users: ').$curr_user_list);
} elsif ($scope eq 'ip') {
my $curr_ips_list = &sort_ips($content->{'ip'});
- $r->print(&mt('IP(s):').' '.$curr_ips_list);
+ $r->print(&mt('IP(s): ').$curr_ips_list);
} else {
$r->print(' ');
}
@@ -2551,15 +2544,13 @@ sub coursegrp_portfolio_header {
}
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"/adm/$cdom/$cnum/$env{'form.group'}/smppg?ref=$env{'form.ref'}",
- text=>&mt('Group').": $grp_desc",
- title=>&mt("Go to group's home page"),
- no_mt=>1},
+ text=>"$ucgpterm: $grp_desc",
+ title=>"Go to group's home page"},
{href=>"/adm/coursegrp_portfolio?".&group_args(),
text=>"Group Portfolio",
title=>"Display group portfolio"});
my $output = &Apache::lonhtmlcommon::breadcrumbs(
- &mt('Group portfolio files - [_1]',$grp_desc),
- undef,undef,undef,undef,1);
+ &mt('[_1] portfolio files - [_2]',$gpterm,$grp_desc));
return $output;
}
@@ -2576,7 +2567,7 @@ sub get_quota {
} else {
$disk_quota = &Apache::loncommon::get_user_quota($env{'user.name'},
$env{'user.domain'}); #expressed in MB
- $disk_quota = 1024 * $disk_quota; # convert from MB to kB
+ $disk_quota = 1000 * $disk_quota; # convert from MB to kB
}
return $disk_quota;
}
@@ -2606,58 +2597,6 @@ STATE
return $state;
}
-# Find space available in a user's portfolio (convert to bytes)
-sub free_space {
- my ($group) = @_;
- my $disk_quota = &get_quota($group); # Expressed in kB
- my ($uname,$udom) = &get_name_dom($group);
- my $portfolio_root = &get_portfolio_root();
- my $getpropath = 1;
- my $current_disk_usage = &Apache::lonnet::diskusage($udom, $uname,
- $portfolio_root, $getpropath); # Expressed in kB
- my $free_space = 1024 * ($disk_quota - $current_disk_usage);
- return $free_space;
-}
-
-sub valid_container {
- my ($uname,$udom,$group) = @_;
- my $container_prefix;
- if ($group ne '') {
- $container_prefix = "/uploaded/$udom/$uname/groups/$group/portfolio";
- } else {
- $container_prefix = "/uploaded/$udom/$uname/portfolio";
- }
- if ($env{'form.currentpath'}) {
- $container_prefix .= $env{'form.currentpath'};
- } else {
- $container_prefix .= '/';
- }
- if ($env{'form.container'} =~ m{^\Q$container_prefix\E(.+)$}) {
- my $filename = $1;
- if ($filename eq &Apache::lonnet::clean_filename($filename)) {
- return 1;
- }
- }
- return;
-}
-
-sub invalid_parms {
- my ($r,$url,$currentpath) = @_;
- my $escpath = &HTML::Entities::encode($currentpath,'&<>"');
- my $rtnlink = ''.&mt('Return to directory').'';
- $r->print(''.&mt('Action disallowed').'
');
- $r->print(&mt('Some of the data included with this request were invalid'));
- $r->print('
'.$rtnlink);
- return;
-}
-
sub handler {
# this handles file management
my $r = shift;
@@ -2745,19 +2684,16 @@ sub handler {
# Give the LON-CAPA page header
my $brcrum = [{href=>"/adm/portfolio",text=>"Portfolio Manager"}];
- my $js = '';
-
if ($env{"form.mode"} eq 'selectfile'){
- $r->print(&Apache::loncommon::start_page($title, $js,
+ $r->print(&Apache::loncommon::start_page($title,undef,
{'only_body' => 1}));
} elsif ($env{'form.action'} eq 'rolepicker') {
- $r->print(&Apache::loncommon::start_page('New role-based condition', $js,
+ $r->print(&Apache::loncommon::start_page('New role-based condition',undef,
{'no_nav_bar' => 1, }));
} elsif ($caller eq 'coursegrp_portfolio') {
- $r->print(&Apache::loncommon::start_page($title, $js));
+ $r->print(&Apache::loncommon::start_page($title));
} else {
- $r->print(&Apache::loncommon::start_page($title, $js,
+ $r->print(&Apache::loncommon::start_page($title,undef,
{'bread_crumbs' => $brcrum}));
if (!&Apache::lonnet::usertools_access($uname,$udom,'portfolio')) {
$r->print(''.&mt('No user portfolio available') .'
'.
@@ -2771,9 +2707,8 @@ sub handler {
}
$r->rflush();
# Check if access to portfolio is blocked by one or more blocking events in courses.
- my $clientip = &Apache::lonnet::get_requestor_ip($r);
my ($blocked,$blocktext) =
- &Apache::loncommon::blocking_status('port',$clientip,$uname,$udom);
+ &Apache::loncommon::blocking_status('port',$uname,$udom);
if ($blocked) {
my $evade_block;
# If portfolio display is in a window popped up from a "Select Portfolio Files"
@@ -2807,21 +2742,6 @@ sub handler {
$r->print(&Apache::loncommon::end_page());
return OK;
}
- }
- if (($env{'form.currentpath'}) && ($env{'form.currentpath'} ne '/')) {
- my $clean_currentpath = '/'.&Apache::loncommon::clean_path($env{'form.currentpath'}).'/';
- unless ($env{'form.currentpath'} eq $clean_currentpath) {
- &invalid_parms($r,$url);
- $r->print(&Apache::loncommon::end_page());
- return OK;
- }
- }
- if ($env{'form.container'}) {
- unless (&valid_container($uname,$udom,$group)) {
- &invalid_parms($r,$url,$env{'form.currentpath'});
- $r->print(&Apache::loncommon::end_page());
- return OK;
- }
}
if (($env{'form.storeupl'}) & (!$env{'form.uploaddoc.filename'})){
$r->print(