[LON-CAPA-cvs] cvs: loncom /interface lonmeta.pm portfolio.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Wed, 19 Jul 2006 15:31:09 -0000
This is a MIME encoded message
--albertel1153323069
Content-Type: text/plain
albertel Wed Jul 19 11:31:09 2006 EDT
Modified files:
/loncom/interface portfolio.pm lonmeta.pm
Log:
- eliminating some group info passing
--albertel1153323069
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20060719113109.txt"
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.137 loncom/interface/portfolio.pm:1.138
--- loncom/interface/portfolio.pm:1.137 Wed Jul 19 10:57:18 2006
+++ loncom/interface/portfolio.pm Wed Jul 19 11:31:05 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# portfolio browser
#
-# $Id: portfolio.pm,v 1.137 2006/07/19 14:57:18 albertel Exp $
+# $Id: portfolio.pm,v 1.138 2006/07/19 15:31:05 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -43,7 +43,7 @@
sub group_args {
my $output;
if (defined($env{'form.group'})) {
- $ouput .= '&group='.$env{'form.group'};
+ $output .= '&group='.$env{'form.group'};
if (defined($env{'form.ref'})) {
$output .= '&ref='.$env{'form.ref'};
}
@@ -54,7 +54,7 @@
sub group_form_data {
my $output;
if (defined($env{'form.group'})) {
- $ouput = '<input type="hidden" name="group" value="'.$env{'form.group'}.'" />';
+ $output = '<input type="hidden" name="group" value="'.$env{'form.group'}.'" />';
if (exists($env{'form.ref'})) {
$output .= '<input type="hidden" name="ref" value="'.
$env{'form.ref'}.'" />';
@@ -69,15 +69,16 @@
$continue_select) = @_;
if ($continue_select ne 'true') {$continue_select = 'false'};
my $anchor = '<a href="'.$url.'?selectfile='.$filename.'&currentpath='.$current_path.'&mode='.$current_mode.'&continue='.$continue_select.'&fieldname='.$field_name;
- $anchor .= &group_args()
+ $anchor .= &group_args();
$anchor .= '">'.$filename.'</a>';
return $anchor;
}
+
my $dirptr=16384;
sub display_common {
my ($r,$url,$current_path,$is_empty,$dir_list,$can_upload)=@_;
- my $namespace = &get_namespace($group);
- my $port_path = &get_port_path($group);
+ my $namespace = &get_namespace();
+ my $port_path = &get_port_path();
if ($can_upload) {
my $groupitem = &group_form_data();
@@ -167,14 +168,14 @@
}
sub display_directory {
- my ($r,$url,$current_path,$is_empty,$dir_list,$can_upload,
+ 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 $display_out;
my $select_mode;
my $checked_files;
- my $port_path = &get_port_path($group);
- my ($uname,$udom) = &get_name_dom($group);
+ my $port_path = &get_port_path();
+ my ($uname,$udom) = &get_name_dom();
my $access_admin_text = &mt('View Status');
if ($can_setacl) {
$access_admin_text = &mt('View/Change Status');
@@ -268,7 +269,7 @@
my $css_class = 'LC_browser_file';
my $line;
my $fullpath = $current_path.$filename;
- $fullpath = &prepend_group($fullpath,$group);
+ $fullpath = &prepend_group($fullpath);
if ($select_mode eq 'true') {
$line='<td><input type="checkbox" name="checkfile" value="'.$filename.'"';
if ($$checked_files{$filename} eq 'selected') {
@@ -400,7 +401,7 @@
'cancel' => &mt('Cancel'),
};
}
- $r->print('<p><input type="submit" value="'.$button_text->{'continue'}.'" />')
+ $r->print('<p><input type="submit" value="'.$button_text->{'continue'}.'" />');
$r->print(&group_form_data().'</p></form>');
$r->print('<form action="'.$url.'" method="post">
<p>
@@ -447,12 +448,12 @@
}
sub delete {
- my ($r,$url,$group)=@_;
+ my ($r,$url)=@_;
my @check;
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
- $file_name = &prepend_group($file_name,$group);
+ $file_name = &prepend_group($file_name);
my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
- my ($uname,$udom) = &get_name_dom($group);
+ my ($uname,$udom) = &get_name_dom();
if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') {
$r->print ("The file is locked and cannot be deleted.<br />");
$r->print(&done('Back',$url));
@@ -469,11 +470,11 @@
}
sub delete_confirmed {
- my ($r,$url,$group)=@_;
+ my ($r,$url)=@_;
my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
my $result;
- my ($uname,$udom) = &get_name_dom($group);
- my $port_path = &get_port_path($group);
+ my ($uname,$udom) = &get_name_dom();
+ my $port_path = &get_port_path();
foreach my $delete_file (@files) {
$result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path.
$env{'form.currentpath'}.
@@ -494,12 +495,12 @@
}
sub delete_dir_confirmed {
- my ($r,$url,$group)=@_;
+ my ($r,$url)=@_;
my $directory_name = $env{'form.currentpath'};
$directory_name =~ s|/$||; # remove any trailing slash
- my ($uname,$udom) = &get_name_dom($group);
- my $namespace = &get_namespace($group);
- my $port_path = &get_port_path($group);
+ my ($uname,$udom) = &get_name_dom();
+ my $namespace = &get_namespace();
+ my $port_path = &get_port_path();
my $result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path.
$directory_name);
@@ -523,10 +524,10 @@
}
sub rename {
- my ($r,$url,$group)=@_;
+ my ($r,$url)=@_;
my $file_name = $env{'form.currentpath'}.$env{'form.rename'};
- my ($uname,$udom) = &get_name_dom($group);
- $file_name = &prepend_group($file_name,$group);
+ my ($uname,$udom) = &get_name_dom();
+ $file_name = &prepend_group($file_name);
if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') {
$r->print ("The file is locked and cannot be renamed.<br />");
$r->print(&done(undef,$url));
@@ -539,10 +540,10 @@
}
sub rename_confirmed {
- my ($r,$url,$group)=@_;
+ my ($r,$url)=@_;
my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'});
- my ($uname,$udom) = &get_name_dom($group);
- my $port_path = &get_port_path($group);
+ my ($uname,$udom) = &get_name_dom();
+ my $port_path = &get_port_path();
if ($filenewname eq '') {
$r->print('<span class="LC_error">'.
&mt("Error: no valid filename was provided to rename to.").
@@ -570,9 +571,9 @@
sub display_access {
my ($r,$url,$group,$can_setacl,$port_path) = @_;
- my ($uname,$udom) = &get_name_dom($group);
+ my ($uname,$udom) = &get_name_dom();
my $file_name = $env{'form.currentpath'}.$env{'form.access'};
- $file_name = &prepend_group($file_name,$group);
+ $file_name = &prepend_group($file_name);
my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom,
$uname);
my %access_controls = &Apache::lonnet::get_access_controls($current_permissions,$group,$file_name);
@@ -755,8 +756,8 @@
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
$r->print('<h3>'.&mt('Allowing others to retrieve portfolio file: [_1]',
$port_path.$file_name).'</h3>'."\n");
- $file_name = &prepend_group($file_name,$group);
- my ($uname,$udom) = &get_name_dom($group);
+ $file_name = &prepend_group($file_name);
+ my ($uname,$udom) = &get_name_dom();
my ($errors,$outcome,$deloutcome,$new_values,$translation);
if ($totalprocessed) {
($outcome,$deloutcome,$new_values,$translation) =
@@ -827,7 +828,7 @@
if ($allnew > 0) {
my $now = time;
my $then = $now + (60*60*24*180); # six months approx.
- &open_form($r,$url,$group);
+ &open_form($r,$url);
foreach my $newitem ('course','group','domains','users') {
if ($env{'form.new'.$newitem} > 0) {
$r->print('<br />'.&mt('Add new <b>[_1]-based</b> access control for portfolio file: <b>[_2]</b>',$newitem,$env{'form.currentpath'}.$env{'form.selectfile'}).'<br /><br />');
@@ -845,7 +846,7 @@
&close_form($r,$url);
} else {
$r->print('<br /><a href="'.$url.'?access='.$env{'form.selectfile'}.
- '&currentpath='.$env{'form.currentpath'}.$group_arg.'">'.
+ '&currentpath='.$env{'form.currentpath'}.&group_args().'">'.
&mt('Display all access settings for this file').'</a>'.
' '.
'<a href="'.$url.'?currentpath='.$env{'form.currentpath'}.
@@ -1417,7 +1418,7 @@
}
sub select_files {
- my ($r,$group) = @_;
+ my ($r) = @_;
if ($env{'form.continue'} eq 'true') {
# here we update the selections for the currentpath
# eventually, have to handle removing those not checked, but . . .
@@ -1461,6 +1462,7 @@
}
}
}
+
sub upload {
my ($r,$url,$group)=@_;
my $fname=$env{'form.uploaddoc.filename'};
@@ -1476,19 +1478,20 @@
}
$fname=&Apache::lonnet::clean_filename($fname);
- my $portfolio_root=&get_portfolio_root($group);
- my ($uname,$udom) = &get_name_dom($group);
- my $port_path = &get_port_path($group);
+ my $portfolio_root=&get_portfolio_root();
+ my ($uname,$udom) = &get_name_dom();
+ my $port_path = &get_port_path();
# Fixme --- Move the checking for existing file to LOND error return
- my @dir_list=&get_dir_list($portfolio_root,$group);
+ my @dir_list=&get_dir_list($portfolio_root);
my $found_file = 0;
my $locked_file = 0;
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);
+ $file_name = &prepend_group($file_name);
$found_file = 1;
+ # FIXME I think this is incorrect, prepend_group took care of this?
if (defined($group)) {
$file_name = $group.'/'.$file_name;
}
@@ -1528,11 +1531,11 @@
sub lock_info {
my ($r,$url,$group) = @_;
- my ($uname,$udom) = &get_name_dom($group);
+ my ($uname,$udom) = &get_name_dom();
my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom,
$uname);
my $file_name = $env{'form.lockinfo'};
- $file_name = &prepend_group($file_name,$group);
+ $file_name = &prepend_group($file_name);
if (defined($file_name) && defined($$current_permissions{$file_name})) {
foreach my $array_item (@{$$current_permissions{$file_name}}) {
if (ref($array_item) eq 'ARRAY') {
@@ -1558,18 +1561,19 @@
$r->print(&done('Back',$url));
return 'ok';
}
+
sub createdir {
- my ($r,$url,$group)=@_;
+ my ($r,$url)=@_;
my $newdir=&Apache::lonnet::clean_filename($env{'form.newdir'});
if ($newdir eq '') {
$r->print('<span class="LC_error">'.
&mt("Error: no directory name was provided.").
'</span><br />');
- $r->print(&done(undef,$url,$group));
+ $r->print(&done(undef,$url));
return;
}
- my $portfolio_root = &get_portfolio_root($group);
- my @dir_list=&get_dir_list($portfolio_root,$group);
+ my $portfolio_root = &get_portfolio_root();
+ my @dir_list=&get_dir_list($portfolio_root);
my $found_file = 0;
foreach my $line (@dir_list) {
my ($filename)=split(/\&/,$line,2);
@@ -1581,8 +1585,8 @@
$r->print('<span class="LC_error">'.'Unable to create a directory named <strong>'.$newdir.
' </strong>a file or directory by that name already exists.</span><br />');
} else {
- my ($uname,$udom) = &get_name_dom($group);
- my $port_path = &get_port_path($group);
+ my ($uname,$udom) = &get_name_dom();
+ my $port_path = &get_port_path();
my $result=&Apache::lonnet::mkdiruserfile($uname,$udom,
$port_path.$env{'form.currentpath'}.$newdir);
if ($result ne 'ok') {
@@ -1597,11 +1601,10 @@
}
sub get_portfolio_root {
- my ($group) = @_;
- my ($uname,$udom) = &get_name_dom($group);
+ my ($uname,$udom) = &get_name_dom();
my $path;
- if (defined($group)) {
- $path = '/userfiles/groups/'.$group.'/portfolio';
+ if (defined($env{'form.group'})) {
+ $path = '/userfiles/groups/'.$env{'form.group'}.'/portfolio';
} else {
$path = '/userfiles/portfolio';
}
@@ -1626,16 +1629,15 @@
}
sub get_dir_list {
- my ($portfolio_root,$group) = @_;
- my ($uname,$udom) = &get_name_dom($group);
+ my ($portfolio_root) = @_;
+ my ($uname,$udom) = &get_name_dom();
return &Apache::lonnet::dirlist($env{'form.currentpath'},
$udom,$uname,$portfolio_root);
}
sub get_name_dom {
- my ($group) = @_;
my ($uname,$udom);
- if (defined($group)) {
+ if (defined($env{'form.group'})) {
$udom = $env{'course.'.$env{'request.course.id'}.'.domain'};
$uname = $env{'course.'.$env{'request.course.id'}.'.num'};
} else {
@@ -1646,28 +1648,26 @@
}
sub prepend_group {
- my ($filename,$group) = @_;
- if (defined($group)) {
- $filename = $group.$filename;
+ my ($filename) = @_;
+ if (defined($env{'form.group'})) {
+ $filename = $env{'form.group'}.$filename;
}
return $filename;
}
sub get_namespace {
- my ($group) = @_;
my $namespace = 'portfolio';
- if (defined($group)) {
- my ($uname,$udom) = &get_name_dom($group);
- $namespace .= '_'.$udom.'_'.$uname.'_'.$group;
+ if (defined($env{'form.group'})) {
+ my ($uname,$udom) = &get_name_dom();
+ $namespace .= '_'.$udom.'_'.$uname.'_'.$env{'form.group'};
}
return $namespace;
}
sub get_port_path {
- my ($group) = @_;
my $port_path;
- if (defined($group)) {
- $port_path = "groups/$group/portfolio";
+ if (defined($env{'form.group'})) {
+ $port_path = "groups/$env{'form.group'}/portfolio";
} else {
$port_path = 'portfolio';
}
@@ -1675,7 +1675,7 @@
}
sub missing_priv {
- my ($r,$url,$priv,$group) = @_;
+ my ($r,$url,$priv) = @_;
my $longtext = {
upload => 'upload files',
delete => 'delete files',
@@ -1693,7 +1693,7 @@
$r->print(&mt('<h3>Action disallowed</h3>'));
$r->print(&mt('You do not have sufficient privileges to [_1] ',
$longtext->{$priv}));
- if ($group) {
+ if (defined($env{'form.group'})) {
$r->print(&mt("in the group's file repository."));
$rtnlink .= &group_args()
} else {
@@ -1717,7 +1717,7 @@
title=>"Course Groups"});
}
&Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/$cdom/$cnum/$group/smppg?ref=$env{'form.ref'}",
+ ({href=>"/adm/$cdom/$cnum/$env{'form.group'}/smppg?ref=$env{'form.ref'}",
text=>"$ucgpterm: $grp_desc",
title=>"Go to group's home page"},
{href=>"/adm/coursegrp_portfolio?".&group_args(),
@@ -1736,7 +1736,7 @@
['selectfile','currentpath','meta','lockinfo','currentfile','action',
'fieldname','mode','rename','continue','group','access','setnum',
'cnum','cdom','type','setroles','showversions','ref']);
- my ($uname,$udom,$portfolio_root,$url,$group,$caller,$title,$grp_desc);
+ my ($uname,$udom,$portfolio_root,$url,$caller,$title,$group,$grp_desc);
if ($r->uri =~ m|^(/adm/)([^/]+)|) {
$url = $1.$2;
$caller = $2;
@@ -1754,9 +1754,9 @@
my $view_permission =
&Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
$env{'form.group'} =~ s/\W//g;
- my $group = $env{'form.group'};
+ $group = $env{'form.group'};
if ($group) {
- ($uname,$udom) = &get_name_dom($group);
+ ($uname,$udom) = &get_name_dom();
my %curr_groups = &Apache::longroup::coursegroups($udom,$uname,
$group);
if (%curr_groups) {
@@ -1765,7 +1765,7 @@
$grp_desc = &unescape($grp_content{'description'});
if (($view_permission) || (&Apache::lonnet::allowed('rgf',
$env{'request.course.id'}.'/'.$group))) {
- $portfolio_root = &get_portfolio_root($group);
+ $portfolio_root = &get_portfolio_root();
} else {
$r->print('You do not have the privileges required to access the shared files space for this group.');
$earlyout = 1;
@@ -1809,7 +1809,7 @@
$can_setacl = 1;
}
- my $port_path = &get_port_path($group);
+ my $port_path = &get_port_path();
&Apache::loncommon::no_cache($r);
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
@@ -1844,45 +1844,45 @@
if ($can_upload) {
&upload($r,$url,$group);
} else {
- &missing_priv($r,$url,'upload',$group,$refarg),
+ &missing_priv($r,$url,'upload');
}
} elsif ($env{'form.action'} eq 'delete' && $env{'form.confirmed'}) {
if ($can_delete) {
- &delete_confirmed($r,$url,$group);
+ &delete_confirmed($r,$url);
} else {
- &missing_priv($r,$url,'delete',$group);
+ &missing_priv($r,$url,'delete');
}
} elsif ($env{'form.action'} eq 'delete') {
if ($can_delete) {
- &delete($r,$url,$group,$refarg);
+ &delete($r,$url);
} else {
- &missing_priv($r,$url,'delete',$group);
+ &missing_priv($r,$url,'delete');
}
} elsif ($env{'form.action'} eq 'deletedir' && $env{'form.confirmed'}) {
if ($can_delete) {
- &delete_dir_confirmed($r,$url,$group);
+ &delete_dir_confirmed($r,$url);
} else {
- &missing_priv($r,$url,'delete',$group);
+ &missing_priv($r,$url,'delete');
}
} elsif ($env{'form.action'} eq 'deletedir') {
if ($can_delete) {
&delete_dir($r,$url);
} else {
- &missing_priv($r,$url,'delete',$group);
+ &missing_priv($r,$url,'delete');
}
} elsif ($env{'form.action'} eq 'rename' && $env{'form.confirmed'}) {
if ($can_modify) {
- &rename_confirmed($r,$url,$group);
+ &rename_confirmed($r,$url);
} else {
- &missing_priv($r,$url,'rename',$group);
+ &missing_priv($r,$url,'rename');
}
} elsif ($env{'form.rename'}) {
$env{'form.selectfile'} = $env{'form.rename'};
$env{'form.action'} = 'rename';
if ($can_modify) {
- &rename($r,$url,$group);
+ &rename($r,$url);
} else {
- &missing_priv($r,$url,'rename',$group);
+ &missing_priv($r,$url,'rename');
}
} elsif ($env{'form.access'}) {
$env{'form.selectfile'} = $env{'form.access'};
@@ -1892,19 +1892,19 @@
if ($can_setacl) {
&update_access($r,$url,$group,$port_path);
} else {
- &missing_priv($r,$url,'setacl',$group);
+ &missing_priv($r,$url,'setacl');
}
} elsif ($env{'form.action'} eq 'rolepicker') {
if ($can_setacl) {
&role_options_window($r);
} else {
- &missing_priv($r,$url,'setacl',$group);
+ &missing_priv($r,$url,'setacl');
}
} elsif ($env{'form.createdir'}) {
if ($can_upload) {
- &createdir($r,$url,$group);
+ &createdir($r,$url);
} else {
- &missing_priv($r,$url,'upload',$group);
+ &missing_priv($r,$url,'upload');
}
} elsif ($env{'form.lockinfo'}) {
&lock_info($r,$url,$group);
@@ -1917,14 +1917,14 @@
&Apache::lonhtmlcommon::clear_breadcrumbs();
$r->print(&coursegrp_portfolio_header($udom,$uname,$grp_desc));
}
- my @dir_list=&get_dir_list($portfolio_root,$group);
+ my @dir_list=&get_dir_list($portfolio_root);
if ($dir_list[0] eq 'no_such_dir'){
# two main reasons for this:
# 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,
- &get_port_path($group));
+ &get_port_path());
} else {
# some directory that snuck in get rid of the directory
# from the recent pulldown, just in case
@@ -1940,7 +1940,7 @@
my $is_empty=(@dir_list == 2);
&display_common($r,$url,$current_path,$is_empty,\@dir_list,
$can_upload);
- &display_directory($r,$url,$current_path,$is_empty,\@dir_list,
+ &display_directory($r,$url,$current_path,$is_empty,\@dir_list,$group,
$can_upload,$can_modify,$can_delete,$can_setacl);
$r->print(&Apache::loncommon::end_page());
}
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.159 loncom/interface/lonmeta.pm:1.160
--- loncom/interface/lonmeta.pm:1.159 Thu Jun 22 20:28:43 2006
+++ loncom/interface/lonmeta.pm Wed Jul 19 11:31:05 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.159 2006/06/23 00:28:43 raeburn Exp $
+# $Id: lonmeta.pm,v 1.160 2006/07/19 15:31:05 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -287,8 +287,7 @@
if ($group) {
$start = "groups/$group/".$start;
}
- my $result = &Apache::portfolio::make_anchor($port_path,$start,'/',
- undef,undef,undef,$group);
+ my $result = &Apache::portfolio::make_anchor($port_path,$start,'/');
my $fullpath = '/';
my (undef,@tree) = split('/',$path);
@@ -296,8 +295,7 @@
foreach my $dir (@tree) {
$fullpath .= $dir.'/';
$result .= '/';
- $result .= &Apache::portfolio::make_anchor($port_path,$dir,$fullpath,
- undef,undef,undef,$group);
+ $result .= &Apache::portfolio::make_anchor($port_path,$dir,$fullpath);
}
$result .= "/$filename";
return $result;
@@ -316,6 +314,9 @@
} else {
$port_path = '/adm/portfolio';
}
+ if ($env{'form.group'} ne $group) {
+ $env{'form.group'} = $group) {
+ }
return ($port_path,$group);
}
--albertel1153323069--