version 1.190, 2008/02/05 05:54:59
|
version 1.191, 2008/04/16 23:11:06
|
Line 183 sub display_directory_line {
|
Line 183 sub display_directory_line {
|
$r->print('<td><img alt="" src="'.&Apache::loncommon::icon($filename).'" /></td>'); |
$r->print('<td><img alt="" src="'.&Apache::loncommon::icon($filename).'" /></td>'); |
$r->print('<td>'.$version_flag.'</td>'); |
$r->print('<td>'.$version_flag.'</td>'); |
} else { # this is a graded or handed back file |
} else { # this is a graded or handed back file |
my ($user,$domain) = &get_name_dom(); |
my ($user,$domain) = &get_name_dom($env{'form.group'}); |
my $permissions_hash = &Apache::lonnet::get_portfile_permissions($domain,$user); |
my $permissions_hash = &Apache::lonnet::get_portfile_permissions($domain,$user); |
if (defined($$permissions_hash{$fullpath})) { |
if (defined($$permissions_hash{$fullpath})) { |
foreach my $array_item (@{$$permissions_hash{$fullpath}}) { |
foreach my $array_item (@{$$permissions_hash{$fullpath}}) { |
Line 231 sub display_directory {
|
Line 231 sub display_directory {
|
my $select_mode; |
my $select_mode; |
my $checked_files; |
my $checked_files; |
my $port_path = &get_port_path(); |
my $port_path = &get_port_path(); |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($group); |
my $access_admin_text = &mt('View Status'); |
my $access_admin_text = &mt('View Status'); |
if ($can_setacl) { |
if ($can_setacl) { |
$access_admin_text = &mt('View/Change Status'); |
$access_admin_text = &mt('View/Change Status'); |
Line 531 sub done {
|
Line 531 sub done {
|
} |
} |
|
|
sub delete { |
sub delete { |
my ($r,$url)=@_; |
my ($r,$url,$group)=@_; |
my @check; |
my @check; |
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'}; |
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'}; |
$file_name = &prepend_group($file_name); |
$file_name = &prepend_group($file_name); |
my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); |
my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($group); |
if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') { |
if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') { |
$r->print(&mt('The file is locked and cannot be deleted.').'<br />'); |
$r->print(&mt('The file is locked and cannot be deleted.').'<br />'); |
$r->print(&done('Back',$url)); |
$r->print(&done('Back',$url)); |
Line 556 sub delete_confirmed {
|
Line 556 sub delete_confirmed {
|
my ($r,$url,$group)=@_; |
my ($r,$url,$group)=@_; |
my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); |
my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); |
my $result; |
my $result; |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($group); |
my $port_path = &get_port_path(); |
my $port_path = &get_port_path(); |
my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom, |
my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom, |
$uname); |
$uname); |
Line 615 sub delete_dir {
|
Line 615 sub delete_dir {
|
} |
} |
|
|
sub delete_dir_confirmed { |
sub delete_dir_confirmed { |
my ($r,$url)=@_; |
my ($r,$url,$group)=@_; |
my $directory_name = $env{'form.currentpath'}; |
my $directory_name = $env{'form.currentpath'}; |
$directory_name =~ s|/$||; # remove any trailing slash |
$directory_name =~ s|/$||; # remove any trailing slash |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($group); |
my $namespace = &get_namespace(); |
my $namespace = &get_namespace(); |
my $port_path = &get_port_path(); |
my $port_path = &get_port_path(); |
my $result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path. |
my $result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path. |
Line 643 sub delete_dir_confirmed {
|
Line 643 sub delete_dir_confirmed {
|
} |
} |
|
|
sub rename { |
sub rename { |
my ($r,$url)=@_; |
my ($r,$url,$group)=@_; |
my $file_name = $env{'form.currentpath'}.$env{'form.rename'}; |
my $file_name = $env{'form.currentpath'}.$env{'form.rename'}; |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($group); |
$file_name = &prepend_group($file_name); |
$file_name = &prepend_group($file_name); |
if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') { |
if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') { |
$r->print("The file is locked and cannot be renamed.<br />"); |
$r->print("The file is locked and cannot be renamed.<br />"); |
Line 661 sub rename {
|
Line 661 sub rename {
|
sub rename_confirmed { |
sub rename_confirmed { |
my ($r,$url,$group)=@_; |
my ($r,$url,$group)=@_; |
my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'}); |
my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'}); |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($group); |
my $port_path = &get_port_path(); |
my $port_path = &get_port_path(); |
if ($filenewname eq '') { |
if ($filenewname eq '') { |
$r->print('<span class="LC_error">'. |
$r->print('<span class="LC_error">'. |
Line 745 sub access_for_renamed {
|
Line 745 sub access_for_renamed {
|
|
|
sub display_access { |
sub display_access { |
my ($r,$url,$group,$can_setacl,$port_path,$action) = @_; |
my ($r,$url,$group,$can_setacl,$port_path,$action) = @_; |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($group); |
my $file_name = $env{'form.currentpath'}.$env{'form.access'}; |
my $file_name = $env{'form.currentpath'}.$env{'form.access'}; |
$file_name = &prepend_group($file_name); |
$file_name = &prepend_group($file_name); |
my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom, |
my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom, |
Line 959 sub update_access {
|
Line 959 sub update_access {
|
$r->print('<h3>'.&mt('Allowing others to retrieve file: [_1]', |
$r->print('<h3>'.&mt('Allowing others to retrieve file: [_1]', |
$port_path.$file_name).'</h3>'."\n"); |
$port_path.$file_name).'</h3>'."\n"); |
$file_name = &prepend_group($file_name); |
$file_name = &prepend_group($file_name); |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($group); |
my ($errors,$outcome,$deloutcome,$new_values,$translation); |
my ($errors,$outcome,$deloutcome,$new_values,$translation); |
if ($totalprocessed) { |
if ($totalprocessed) { |
($outcome,$deloutcome,$new_values,$translation) = |
($outcome,$deloutcome,$new_values,$translation) = |
Line 1754 sub check_for_upload {
|
Line 1754 sub check_for_upload {
|
my ($path,$fname,$group,$element) = @_; |
my ($path,$fname,$group,$element) = @_; |
my $disk_quota = &get_quota($group); |
my $disk_quota = &get_quota($group); |
my $filesize = (length($env{'form.'.$element})) / 1000; #express in k (1024?) |
my $filesize = (length($env{'form.'.$element})) / 1000; #express in k (1024?) |
|
|
my $portfolio_root = &get_portfolio_root(); |
my $portfolio_root = &get_portfolio_root(); |
my $port_path = &get_port_path(); |
my $port_path = &get_port_path(); |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($group); |
# Fixme --- Move the checking for existing file to LOND error return |
# Fixme --- Move the checking for existing file to LOND error return |
my @dir_list=&get_dir_list($portfolio_root,$path); |
my @dir_list=&get_dir_list($portfolio_root,$path,$group); |
my $found_file = 0; |
my $found_file = 0; |
my $locked_file = 0; |
my $locked_file = 0; |
foreach my $line (@dir_list) { |
foreach my $line (@dir_list) { |
Line 1773 sub check_for_upload {
|
Line 1772 sub check_for_upload {
|
} |
} |
} |
} |
} |
} |
my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,$portfolio_root); |
my $getpropath = 1; |
|
my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,$portfolio_root,$getpropath); |
|
|
if (($current_disk_usage + $filesize) > $disk_quota){ |
if (($current_disk_usage + $filesize) > $disk_quota){ |
my $msg = '<span class="LC_error">'. |
my $msg = '<span class="LC_error">'. |
Line 1897 sub upload_embedded {
|
Line 1897 sub upload_embedded {
|
|
|
sub lock_info { |
sub lock_info { |
my ($r,$url,$group) = @_; |
my ($r,$url,$group) = @_; |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($group); |
my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom, |
my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom, |
$uname); |
$uname); |
my $file_name = $env{'form.lockinfo'}; |
my $file_name = $env{'form.lockinfo'}; |
Line 1939 sub lock_info {
|
Line 1939 sub lock_info {
|
} |
} |
|
|
sub createdir { |
sub createdir { |
my ($r,$url)=@_; |
my ($r,$url,$group)=@_; |
my $newdir=&Apache::lonnet::clean_filename($env{'form.newdir'}); |
my $newdir=&Apache::lonnet::clean_filename($env{'form.newdir'}); |
if ($newdir eq '') { |
if ($newdir eq '') { |
$r->print('<span class="LC_error">'. |
$r->print('<span class="LC_error">'. |
Line 1949 sub createdir {
|
Line 1949 sub createdir {
|
return; |
return; |
} |
} |
my $portfolio_root = &get_portfolio_root(); |
my $portfolio_root = &get_portfolio_root(); |
my @dir_list=&get_dir_list($portfolio_root); |
my @dir_list=&get_dir_list($portfolio_root,undef,$group); |
my $found_file = 0; |
my $found_file = 0; |
foreach my $line (@dir_list) { |
foreach my $line (@dir_list) { |
my ($filename)=split(/\&/,$line,2); |
my ($filename)=split(/\&/,$line,2); |
Line 1962 sub createdir {
|
Line 1962 sub createdir {
|
.&mt('Unable to create a directory named [_1].','<strong>'.$newdir.'</strong>') |
.&mt('Unable to create a directory named [_1].','<strong>'.$newdir.'</strong>') |
.' '.&mt('A file or directory by that name already exists.').'</span><br />'); |
.' '.&mt('A file or directory by that name already exists.').'</span><br />'); |
} else { |
} else { |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($group); |
my $port_path = &get_port_path(); |
my $port_path = &get_port_path(); |
my $result=&Apache::lonnet::mkdiruserfile($uname,$udom, |
my $result=&Apache::lonnet::mkdiruserfile($uname,$udom, |
$port_path.$env{'form.currentpath'}.$newdir); |
$port_path.$env{'form.currentpath'}.$newdir); |
Line 1983 sub createdir {
|
Line 1983 sub createdir {
|
sub get_portfolio_root { |
sub get_portfolio_root { |
my ($udom,$uname,$group) = @_; |
my ($udom,$uname,$group) = @_; |
if (!(defined($udom)) || !(defined($uname))) { |
if (!(defined($udom)) || !(defined($uname))) { |
($uname,$udom) = &get_name_dom(); |
($uname,$udom) = &get_name_dom($group); |
} |
} |
my $path = '/userfiles/portfolio'; |
my $path = '/userfiles/portfolio'; |
if (!defined($group)) { |
if (!defined($group)) { |
Line 1994 sub get_portfolio_root {
|
Line 1994 sub get_portfolio_root {
|
if (defined($group)) { |
if (defined($group)) { |
$path = '/userfiles/groups/'.$group.'/portfolio'; |
$path = '/userfiles/groups/'.$group.'/portfolio'; |
} |
} |
return (&Apache::loncommon::propath($udom,$uname).$path); |
return $path; |
} |
} |
|
|
sub get_group_quota { |
sub get_group_quota { |
Line 2009 sub get_group_quota {
|
Line 2009 sub get_group_quota {
|
$group_quota = $group_info{'quota'}; #expressed in Mb |
$group_quota = $group_info{'quota'}; #expressed in Mb |
if ($group_quota) { |
if ($group_quota) { |
$group_quota = 1000 * $group_quota; #expressed in k |
$group_quota = 1000 * $group_quota; #expressed in k |
} |
} |
} |
} |
return $group_quota; |
return $group_quota; |
} |
} |
|
|
sub get_dir_list { |
sub get_dir_list { |
my ($portfolio_root,$path) = @_; |
my ($portfolio_root,$path,$group) = @_; |
$path ||= $env{'form.currentpath'}; |
$path ||= $env{'form.currentpath'}; |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($group); |
return &Apache::lonnet::dirlist($path,$udom,$uname,$portfolio_root); |
my $getpropath = 1; |
|
return &Apache::lonnet::dirlist($portfolio_root.$path,$udom,$uname,$getpropath); |
} |
} |
|
|
sub get_name_dom { |
sub get_name_dom { |
|
my ($group) = @_; |
my ($uname,$udom); |
my ($uname,$udom); |
if (defined($env{'form.group'})) { |
if (defined($group)) { |
$udom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$udom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$uname = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$uname = $env{'course.'.$env{'request.course.id'}.'.num'}; |
} else { |
} else { |
Line 2044 sub prepend_group {
|
Line 2046 sub prepend_group {
|
sub get_namespace { |
sub get_namespace { |
my $namespace = 'portfolio'; |
my $namespace = 'portfolio'; |
if (defined($env{'form.group'})) { |
if (defined($env{'form.group'})) { |
my ($uname,$udom) = &get_name_dom(); |
my ($uname,$udom) = &get_name_dom($env{'form.group'}); |
$namespace .= '_'.$udom.'_'.$uname.'_'.$env{'form.group'}; |
$namespace .= '_'.$udom.'_'.$uname.'_'.$env{'form.group'}; |
} |
} |
return $namespace; |
return $namespace; |
Line 2158 sub handler {
|
Line 2160 sub handler {
|
&Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); |
&Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); |
$env{'form.group'} =~ s/\W//g; |
$env{'form.group'} =~ s/\W//g; |
$group = $env{'form.group'}; |
$group = $env{'form.group'}; |
if ($group) { |
if ($group ne '') { |
($uname,$udom) = &get_name_dom(); |
($uname,$udom) = &get_name_dom($group); |
my %curr_groups = &Apache::longroup::coursegroups($udom,$uname, |
my %curr_groups = &Apache::longroup::coursegroups($udom,$uname, |
$group); |
$group); |
if (%curr_groups) { |
if (%curr_groups) { |
Line 2268 sub handler {
|
Line 2270 sub handler {
|
} |
} |
} elsif ($env{'form.action'} eq 'delete') { |
} elsif ($env{'form.action'} eq 'delete') { |
if ($can_delete) { |
if ($can_delete) { |
&delete($r,$url); |
&delete($r,$url,$group); |
} else { |
} else { |
&missing_priv($r,$url,'delete'); |
&missing_priv($r,$url,'delete'); |
} |
} |
} elsif ($env{'form.action'} eq 'deletedir' && $env{'form.confirmed'}) { |
} elsif ($env{'form.action'} eq 'deletedir' && $env{'form.confirmed'}) { |
if ($can_delete) { |
if ($can_delete) { |
&delete_dir_confirmed($r,$url); |
&delete_dir_confirmed($r,$url,$group); |
} else { |
} else { |
&missing_priv($r,$url,'delete'); |
&missing_priv($r,$url,'delete'); |
} |
} |
Line 2294 sub handler {
|
Line 2296 sub handler {
|
$env{'form.selectfile'} = $env{'form.rename'}; |
$env{'form.selectfile'} = $env{'form.rename'}; |
$env{'form.action'} = 'rename'; |
$env{'form.action'} = 'rename'; |
if ($can_modify) { |
if ($can_modify) { |
&rename($r,$url); |
&rename($r,$url,$group); |
} else { |
} else { |
&missing_priv($r,$url,'rename'); |
&missing_priv($r,$url,'rename'); |
} |
} |
Line 2319 sub handler {
|
Line 2321 sub handler {
|
} |
} |
} elsif ($env{'form.createdir'}) { |
} elsif ($env{'form.createdir'}) { |
if ($can_upload) { |
if ($can_upload) { |
&createdir($r,$url); |
&createdir($r,$url,$group); |
} else { |
} else { |
&missing_priv($r,$url,'upload'); |
&missing_priv($r,$url,'upload'); |
} |
} |
Line 2334 sub handler {
|
Line 2336 sub handler {
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
$r->print(&coursegrp_portfolio_header($udom,$uname,$grp_desc)); |
$r->print(&coursegrp_portfolio_header($udom,$uname,$grp_desc)); |
} |
} |
my @dir_list=&get_dir_list($portfolio_root); |
my @dir_list=&get_dir_list($portfolio_root,undef,$group); |
if ($dir_list[0] eq 'no_such_dir'){ |
if ($dir_list[0] eq 'no_such_dir'){ |
# two main reasons for this: |
# two main reasons for this: |
# 1) never been here, so directory structure not created |
# 1) never been here, so directory structure not created |
Line 2350 sub handler {
|
Line 2352 sub handler {
|
$current_path = '/'; # force it back to the root |
$current_path = '/'; # force it back to the root |
} |
} |
# now grab the directory list again, for the first time |
# now grab the directory list again, for the first time |
@dir_list=&Apache::lonnet::dirlist($current_path, |
@dir_list= |
$udom,$uname,$portfolio_root); |
&Apache::lonnet::dirlist($portfolio_root.$current_path, |
|
$udom,$uname,$getpropath); |
} |
} |
# need to know if directory is empty so it can be removed if desired |
# need to know if directory is empty so it can be removed if desired |
my $is_empty=(@dir_list == 2); |
my $is_empty=(@dir_list == 2); |