--- loncom/interface/portfolio.pm 2006/07/19 21:59:10 1.121.2.8
+++ loncom/interface/portfolio.pm 2006/11/06 20:02:58 1.171
@@ -1,7 +1,7 @@
# The LearningOnline Network
# portfolio browser
#
-# $Id: portfolio.pm,v 1.121.2.8 2006/07/19 21:59:10 albertel Exp $
+# $Id: portfolio.pm,v 1.171 2006/11/06 20:02:58 rezaferry Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -66,12 +66,15 @@ sub group_form_data {
# 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) = @_;
- if ($continue_select ne 'true') {$continue_select = 'false'};
- my $anchor = '';
+ $anchor .= '">'.$inner_text.' ';
return $anchor;
}
@@ -92,6 +95,13 @@ sub display_common {
'createdir_label' =>
'Create subdirectory in current directory:');
my $escuri = &HTML::Entities::encode($r->uri,'&<>"');
+ my $help_fileupload = &Apache::loncommon::help_open_topic('Portfolio AddFiles');
+ my $help_createdir = &Apache::loncommon::help_open_topic('Portfolio CreateDirectory');
+
+ # FIXME: This line should be deleted once Portfolio uses breadcrumbs
+ $r->print(&Apache::loncommon::help_open_topic('Portfolio About', 'Help on the portfolio'));
+
+
$r->print(<<"TABLE");
@@ -106,7 +116,7 @@ sub display_common {
-
+ $help_fileupload
@@ -121,7 +131,7 @@ sub display_common {
-
+ $help_createdir
@@ -129,15 +139,30 @@ sub display_common {
TABLE
}
my @tree = split (/\//,$current_path);
- $r->print(''.&make_anchor($url,$port_path,'/',$env{"form.mode"},$env{"form.fieldname"},$env{"form.continue"}).'/');
+ my %anchor_fields = (
+ 'selectfile' => $port_path,
+ 'currentpath' => '/',
+ 'mode' => $env{"form.mode"},
+ 'fieldname' => $env{"form.fieldname"},
+ 'continue' => $env{"form.continue"}
+ );
+ $r->print(''.&make_anchor($url,\%anchor_fields,$port_path).'/');
if (@tree > 1){
my $newCurrentPath = '';
for (my $i = 1; $i< @tree; $i++){
$newCurrentPath .= $tree[$i].'/';
- $r->print(&make_anchor($url,$tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}, $env{"form.continue"}).'/');
+ my %anchor_fields = (
+ 'selectfile' => $tree[$i],
+ 'currentpath' => '/',
+ 'mode' => $env{"form.mode"},
+ 'fieldname' => $env{"form.fieldname"},
+ 'continue' => $env{"form.continue"}
+ );
+ $r->print(&make_anchor($url,\%anchor_fields,$tree[$i]).'/');
}
}
$r->print(' ');
+ $r->print(&Apache::loncommon::help_open_topic('Portfolio ChangeDirectory'));
&Apache::lonhtmlcommon::store_recent($namespace,$current_path,$current_path);
$r->print(' ");
}
+sub display_directory_line {
+ my ($r,$select_mode, $filename, $mtime, $size, $css_class,
+ $line, $access_controls, $curr_access, $now, $version_flag,
+ $href_location, $url, $current_path, $access_admin_text, $versions)=@_;
+
+ my $fullpath = &prepend_group($current_path.$filename);
+ $r->print('');
+ $r->print($line); # contains first two cells of table
+ my $lock_info;
+ if ($version_flag) { # versioned can't be versioned, so TRUE when root file
+ $r->print(' ');
+ $r->print(''.$version_flag.' ');
+ } else { # this is a graded or handed back file
+ my ($user,$domain) = &get_name_dom();
+ my $permissions_hash = &Apache::lonnet::get_portfile_permissions($domain,$user);
+ if (defined($$permissions_hash{$fullpath})) {
+ foreach my $array_item (@{$$permissions_hash{$fullpath}}) {
+ if (ref($array_item) eq 'ARRAY') {
+ if ($$array_item[-1] eq 'handback') {
+ $lock_info = 'Handback';
+ } elsif ($$array_item[-1] eq 'graded') {
+ $lock_info = 'Graded';
+ }
+ }
+ }
+ }
+ 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);
+ $fname =~ s|^/||;
+ $anchor_fields{'showversions'} = $fname.'.'.$extension;
+ }
+ $lock_info = &make_anchor(undef,\%anchor_fields,$lock_info);
+ }
+ $r->print(''.$lock_info.' ');
+ }
+ # $r->print(''.$$version_flag{$filename}.' ');
+ $r->print(' '.&make_anchor($href_location.$filename,undef,$filename).' ');
+ $r->print(''.$size.' ');
+ $r->print(''.&Apache::lonlocal::locallocaltime($mtime).' ');
+ if ($select_mode ne 'true') {
+ $r->print(''.
+ &mt($curr_access).' ');
+ my %anchor_fields = (
+ 'access' => $filename,
+ 'currentpath' => $current_path
+ );
+ $r->print(&make_anchor($url, \%anchor_fields, $access_admin_text).' ');
+ }
+ $r->print(' '.$/);
+}
+
sub display_directory {
my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload,
$can_modify,$can_delete,$can_setacl)=@_;
@@ -166,7 +244,7 @@ sub display_directory {
$current_permissions,$group);
my %access_controls = &Apache::lonnet::get_access_controls($current_permissions,$group);
my $now = time;
- if ($env{"form.mode"} eq 'selectfile'){
+ if ($env{"form.mode"} eq 'selectfile') {
&select_files($r);
$checked_files =&Apache::lonnet::files_in_path($uname,$env{'form.currentpath'});
$select_mode = 'true';
@@ -186,11 +264,19 @@ sub display_directory {
if ($select_mode eq 'true') {
$r->print('
');
} elsif ($scope eq 'domains') {
$r->print(&mt('Domains: ').join(',',@{$content->{'dom'}}));
} elsif ($scope eq 'users') {
@@ -730,7 +952,7 @@ sub update_access {
}
}
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
- $r->print(''.&mt('Allowing others to retrieve portfolio file: [_1]',
+ $r->print(''.&mt('Allowing others to retrieve file: [_1]',
$port_path.$file_name).' '."\n");
$file_name = &prepend_group($file_name);
my ($uname,$udom) = &get_name_dom();
@@ -798,14 +1020,14 @@ sub update_access {
my $totalnew = 0;
my $status = 'new';
my ($firstitem,$lastitem);
- foreach my $newitem ('course','group','domains','users') {
+ foreach my $newitem ('course','domains','users') {
$allnew += $env{'form.new'.$newitem};
}
if ($allnew > 0) {
my $now = time;
my $then = $now + (60*60*24*180); # six months approx.
&open_form($r,$url);
- foreach my $newitem ('course','group','domains','users') {
+ foreach my $newitem ('course','domains','users') {
if ($env{'form.new'.$newitem} > 0) {
$r->print(' '.&mt('Add new [_1]-based access control for portfolio file: [_2] ',$newitem,$env{'form.currentpath'}.$env{'form.selectfile'}).' ');
$firstitem = $totalnew;
@@ -821,12 +1043,13 @@ sub update_access {
}
&close_form($r,$url);
} else {
- $r->print(''.
- &mt('Display all access settings for this file').' '.
- ' '.
- ''.&mt('Return to directory listing').' ');
+ my %anchor_fields = (
+ 'currentpath' => $env{'form.currentpath'},
+ 'access' => $env{'form.selectfile'}
+ );
+ $r->print(' '.&make_anchor($url, \%anchor_fields, &mt('Display all access settings for this file')));
+ delete $anchor_fields{'access'};
+ $r->print(' '.&make_anchor($url,\%anchor_fields,&mt('Return to directory listing')));
}
return;
}
@@ -843,7 +1066,7 @@ sub build_access_record {
if ($scope eq 'guest') {
$record->{'password'} = $env{'form.password'};
- } elsif (($scope eq 'course') || ($scope eq 'group')) {
+ } elsif ($scope eq 'course') {
$record->{'domain'} = $env{'form.crsdom_'.$num};
$record->{'number'} = $env{'form.crsnum_'.$num};
my @role_ids;
@@ -925,19 +1148,18 @@ sub sort_users {
}
sub access_setting_table {
- my ($r,$access_controls) = @_;
+ my ($r,$url,$filename,$access_controls,$action) = @_;
my ($public,$publictext);
- $publictext = &mt('Off');
+ $publictext ='Off';
my ($guest,$guesttext);
- $guesttext = &mt('Off');
+ $guesttext = 'Off';
my @courses = ();
- my @groups = ();
my @domains = ();
my @users = ();
my $now = time;
my $then = $now + (60*60*24*180); # six months approx.
my ($num,$scope,$publicnum,$guestnum);
- my (%acl_count,%end,%start);
+ my (%acl_count,%end,%start,%conditionals);
foreach my $key (sort(keys(%{$access_controls}))) {
($num,$scope,$end{$key},$start{$key}) = &unpack_acc_key($key);
if ($scope eq 'public') {
@@ -948,19 +1170,34 @@ sub access_setting_table {
$guest=$key;
$guestnum = $num;
$guesttext = &acl_status($start{$key},$end{$key},$now);
- } elsif ($scope eq 'course') {
- push(@courses,$key);
- } elsif ($scope eq 'group') {
- push(@groups,$key);
- } elsif ($scope eq 'domains') {
- push(@domains,$key);
- } elsif ($scope eq 'users') {
- push(@users,$key);
+ } else {
+ $conditionals{$scope}{$key} = $$access_controls{$key};
+ if ($scope eq 'course') {
+ push(@courses,$key);
+ } elsif ($scope eq 'domains') {
+ push(@domains,$key);
+ } elsif ($scope eq 'users') {
+ push(@users,$key);
+ }
}
$acl_count{$scope} ++;
}
$r->print(' ');
- $r->print(''.&mt('Public access:').' '.$publictext.' ');
+ if ($action eq 'chgaccess') {
+ &standard_settings($r,$now,$then,$url,$filename,\%acl_count,\%start,
+ \%end,$public,$publicnum,$publictext,$guest,$guestnum,
+ $guesttext,$access_controls,%conditionals);
+ } else {
+ &condition_setting($r,$access_controls,$now,$then,\%acl_count,
+ \@domains,\@users,\@courses);
+ }
+ $r->print('
');
+}
+
+sub standard_settings {
+ my ($r,$now,$then,$url,$filename,$acl_count,$start,$end,$public,$publicnum,
+ $publictext,$guest,$guestnum,$guesttext,$access_controls,%conditionals)=@_;
+ $r->print(''.&mt('Public access: [_1]',$publictext).' ');
$r->print(&Apache::loncommon::start_data_table());
$r->print(&Apache::loncommon::start_data_table_header_row());
$r->print(''.&mt('Action').' '.&mt('Dates available').' ');
@@ -968,7 +1205,7 @@ sub access_setting_table {
$r->print(&Apache::loncommon::start_data_table_row());
if ($public) {
$r->print(''.&actionbox('old',$publicnum,'public').' '.
- &dateboxes($publicnum,$start{$public},$end{$public}).' ');
+ &dateboxes($publicnum,$start->{$public},$end->{$public}).'');
} else {
$r->print(''.&actionbox('new','0','public').' '.
&dateboxes('0',$now,$then).' ');
@@ -976,7 +1213,7 @@ sub access_setting_table {
$r->print(&Apache::loncommon::end_data_table_row());
$r->print(&Apache::loncommon::end_data_table());
$r->print(' ');
- $r->print(''.&mt('Passphrase-protected access:').' '.$guesttext.' ');
+ $r->print(''.&mt('Passphrase-protected access: [_1]',$guesttext).' ');
$r->print(&Apache::loncommon::start_data_table());
$r->print(&Apache::loncommon::start_data_table_header_row());
$r->print(' '.&mt('Action').' '.&mt('Dates available').
@@ -987,7 +1224,7 @@ sub access_setting_table {
if ($guest) {
$passwd = $$access_controls{$guest}{'password'};
$r->print(' '.&actionbox('old',$guestnum,'guest').' '.
- &dateboxes($guestnum,$start{$guest},$end{$guest}).' ');
+ &dateboxes($guestnum,$start->{$guest},$end->{$guest}).'');
} else {
$r->print(''.&actionbox('new','1','guest').' '.
&dateboxes('1',$now,$then).' ');
@@ -996,37 +1233,75 @@ sub access_setting_table {
$passwd.'" />');
$r->print(&Apache::loncommon::end_data_table_row());
$r->print(&Apache::loncommon::end_data_table());
+ $r->print(' '.
+ '');
+ my $numconditionals = 0;
+ my $conditionstext;
+ my %cond_status;
+ foreach my $scope ('domains','users','course') {
+ $numconditionals += $acl_count->{$scope};
+ if ($acl_count->{$scope} > 0) {
+ if ($conditionstext ne 'Active') {
+ foreach my $key (keys(%{$conditionals{$scope}})) {
+ $conditionstext = &acl_status($start->{$key},$end->{$key},$now);
+ if ($conditionstext eq 'Active') {
+ last;
+ }
+ }
+ }
+ }
+ }
+ if ($conditionstext eq '') {
+ $conditionstext = 'Off';
+ }
+ my %anchor_fields = (
+ 'access' => $env{'form.selectfile'},
+ 'action' => 'chgconditions',
+ 'currentpath' => $env{'form.currentpath'},
+ );
+ $r->print(''.&mt('Conditional access: [_1]',$conditionstext).' ');
+ if ($numconditionals > 0) {
+ my $count = 1;
+ my $chg = 'none';
+ $r->print(&mt('You have previously set [_1] conditional access controls.',$numconditionals).' '.&make_anchor($url,\%anchor_fields,&mt('Change Conditions')).' ');
+ $r->print(&Apache::loncommon::start_data_table());
+ $r->print(&Apache::loncommon::start_data_table_header_row());
+ $r->print(' '.&mt('Access control').' '.&mt('Dates available').
+ ' '.&mt('Additional information').' ');
+ $r->print(&Apache::loncommon::end_data_table_header_row());
+ &build_access_summary($r,$count,$chg,%conditionals);
+ $r->print(&Apache::loncommon::end_data_table());
+ } else {
+ $r->print(&make_anchor($url,\%anchor_fields,&mt('Add conditional access')).' '.&mt('based on domain, username, or course affiliation.'));
+ }
+}
- #$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(' ');
- #if (@courses > 0 || @groups > 0) {
- # $r->print('');
- #} else {
- # $r->print(' ');
- #}
- #&access_element($r,'course',\%acl_count,\@courses,$access_controls,$now,$then);
- #$r->print(' ');
- #if (@courses > 0 || @groups > 0) {
- # $r->print(' ');
- #} else {
- # $r->print(' ');
- #}
- #&access_element($r,'group',\%acl_count,\@groups,$access_controls,$now,$then);
+sub condition_setting {
+ my ($r,$access_controls,$now,$then,$acl_count,$domains,$users,$courses) = @_;
+ $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(' ');
+ if ($acl_count->{course} > 0) {
+ $r->print('');
+ } else {
+ $r->print(' ');
+ }
+ &access_element($r,'course',$acl_count,$courses,$access_controls,$now,$then);
+ $r->print(' ');
$r->print(' ');
}
sub acl_status {
my ($start,$end,$now) = @_;
if ($start > $now) {
- return &mt('Inactive');
+ return 'Inactive';
}
if ($end && $end<$now) {
- return &mt('Inactive');
+ return 'Inactive';
}
- return &mt('Active');
+ return 'Active';
}
sub access_element {
@@ -1061,7 +1336,7 @@ sub display_access_row {
$r->print(&Apache::loncommon::start_data_table_header_row());
$r->print(''.&mt('Action?').' '.&mt($uctype).' '.
&mt('Dates available').' ');
- if (($type eq 'course') || ($type eq 'group')) {
+ if ($type eq 'course') {
$r->print(''.&mt('Allowed [_1] member affiliations',$type).
' ');
$colspan ++;
@@ -1071,7 +1346,7 @@ sub display_access_row {
$r->print(&Apache::loncommon::end_data_table_header_row());
foreach my $key (@{$items}) {
$r->print(&Apache::loncommon::start_data_table_row());
- if (($type eq 'course') || ($type eq 'group')) {
+ if ($type eq 'course') {
&course_row($r,$status,$type,$key,$access_controls,$now,$then);
} elsif ($type eq 'domains') {
&domains_row($r,$status,$key,\@all_doms,$access_controls,$now,
@@ -1148,10 +1423,6 @@ sub course_row {
}
my $js = &Apache::loncommon::coursebrowser_javascript($defdom)
.&course_js();
- my $crsgrptext = 'Groups';
- if ($type eq 'group') {
- $crsgrptext = 'Teams';
- }
my $uctype = $type;
$uctype =~ s/^(\w)/uc($1)/e;
my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then,
@@ -1168,7 +1439,7 @@ sub course_row {
$r->print('');
$r->print(''.&mt('Action').' '.&mt('Roles').' '.
&mt('Access').' '.&mt('Sections').' '.
- &mt($crsgrptext).' ');
+ &mt('Groups').'');
if ($status eq 'old') {
my $max_id = 0;
foreach my $role_id (sort(keys(%{$content->{'roles'}}))) {
@@ -1238,7 +1509,12 @@ sub actionbox {
my ($status,$num,$scope) = @_;
my $output = '';
if ($status eq 'new') {
- $output .= ' '.
+ my $checkstate;
+ if ($scope eq 'domains' || $scope eq 'users' || $scope eq 'course') {
+ $checkstate = 'checked="checked"';
+ }
+ $output .= ' '.
&mt('Activate');
} else {
$output .= '
@@ -1390,7 +1662,7 @@ function setRoles() {
END_SCRIPT
$r->print(&mt('Select roles, course status, section(s) and group(s) for users who will be able to access the portfolio file.'));
- $r->print(''.&mt('Roles').' '.&mt('[_1] status',$type).' '.&mt('Sections').' '.&mt($grouptitle).' '.$role_selects.'
');
+ $r->print(''.&mt('Roles').' '.&mt('[_1] status',$type).' '.&mt('Sections').' '.&mt('Groups').' '.$role_selects.'
');
return;
}
@@ -1468,10 +1740,6 @@ sub upload {
$file_name = $env{'form.currentpath'}.$file_name;
$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;
- }
if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') {
$locked_file = 1;
}
@@ -1515,24 +1783,35 @@ sub lock_info {
$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') {
- my $filetext;
- if (defined($group)) {
- $filetext = ''.$env{'form.lockinfo'}.
- ' (group: '.$group.')';
- } else {
- $filetext = ''.$file_name.' ';
- }
- $r->print(&mt('[_1] was submitted in response to problem: ',
- $filetext).
- ''.&Apache::lonnet::gettitle($$array_item[0]).
- ' ');
- my %course_description = &Apache::lonnet::coursedescription($$array_item[1]);
- $r->print(&mt('In the course: [_1] ',
- $course_description{'description'}));
- # $r->print('the third is '.$$array_item[2].' ');
- # $r->print("item is $$array_item[0] and $$array_item[0]");
- }
+ next if (ref($array_item) ne 'ARRAY');
+
+ my $filetext;
+ if (defined($group)) {
+ $filetext = ''.$env{'form.lockinfo'}.
+ ' (group: '.$group.')';
+ } else {
+ $filetext = ''.$file_name.' ';
+ }
+
+ my $title =''.&Apache::lonnet::gettitle($$array_item[0]).
+ ' ';
+ if ($$array_item[-1] eq 'graded') {
+ $r->print(&mt('[_1] was submitted in response to problem: [_2]',
+ $filetext,$title));
+ } elsif ($$array_item[-1] eq 'handback') {
+ $r->print(&mt('[_1] was handed back in response to problem: [_2]',
+ $filetext,$title));
+ } else {
+ # submission style lock
+ $r->print(&mt('[_1] was submitted in response to problem: [_2]',
+ $filetext,$title));
+ }
+ my %course_description =
+ &Apache::lonnet::coursedescription($$array_item[1]);
+ if ( $course_description{'description'} ne '') {
+ $r->print(&mt('In the course: [_1] ',
+ $course_description{'description'}));
+ }
}
}
$r->print(&done('Back',$url));
@@ -1578,13 +1857,19 @@ sub createdir {
}
sub get_portfolio_root {
- my ($uname,$udom) = &get_name_dom();
- my $path;
- if (defined($env{'form.group'})) {
- $path = '/userfiles/groups/'.$env{'form.group'}.'/portfolio';
- } else {
- $path = '/userfiles/portfolio';
+ my ($udom,$uname,$group) = @_;
+ if (!(defined($udom)) || !(defined($uname))) {
+ ($uname,$udom) = &get_name_dom();
+ }
+ my $path = '/userfiles/portfolio';
+ if (!defined($group)) {
+ if (defined($env{'form.group'})) {
+ $group = $env{'form.group'};
+ }
}
+ if (defined($group)) {
+ $path = '/userfiles/groups/'.$group.'/portfolio';
+ }
return (&Apache::loncommon::propath($udom,$uname).$path);
}
@@ -1712,8 +1997,8 @@ sub handler {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['selectfile','currentpath','meta','lockinfo','currentfile','action',
'fieldname','mode','rename','continue','group','access','setnum',
- 'cnum','cdom','type','setroles']);
- my ($uname,$udom,$portfolio_root,$url,$group,$caller,$title,$grp_desc);
+ 'cnum','cdom','type','setroles','showversions','ref']);
+ my ($uname,$udom,$portfolio_root,$url,$caller,$title,$group,$grp_desc);
if ($r->uri =~ m|^(/adm/)([^/]+)|) {
$url = $1.$2;
$caller = $2;
@@ -1825,7 +2110,7 @@ sub handler {
}
} elsif ($env{'form.action'} eq 'delete' && $env{'form.confirmed'}) {
if ($can_delete) {
- &delete_confirmed($r,$url);
+ &delete_confirmed($r,$url,$group);
} else {
&missing_priv($r,$url,'delete');
}
@@ -1849,7 +2134,7 @@ sub handler {
}
} elsif ($env{'form.action'} eq 'rename' && $env{'form.confirmed'}) {
if ($can_modify) {
- &rename_confirmed($r,$url);
+ &rename_confirmed($r,$url,$group);
} else {
&missing_priv($r,$url,'rename');
}
@@ -1863,9 +2148,12 @@ sub handler {
}
} elsif ($env{'form.access'}) {
$env{'form.selectfile'} = $env{'form.access'};
- $env{'form.action'} = 'chgaccess';
- &display_access($r,$url,$group,$can_setacl,$port_path);
- } elsif ($env{'form.action'} eq 'chgaccess') {
+ if (!defined($env{'form.action'})) {
+ $env{'form.action'} = 'chgaccess';
+ }
+ &display_access($r,$url,$group,$can_setacl,$port_path,$env{'form.action'});
+ } elsif (($env{'form.action'} eq 'chgaccess') ||
+ ($env{'form.action'} eq 'chgconditions')) {
if ($can_setacl) {
&update_access($r,$url,$group,$port_path);
} else {