--- loncom/interface/portfolio.pm 2006/08/04 20:41:32 1.144
+++ loncom/interface/portfolio.pm 2006/11/05 21:08:53 1.170
@@ -1,7 +1,7 @@
# The LearningOnline Network
# portfolio browser
#
-# $Id: portfolio.pm,v 1.144 2006/08/04 20:41:32 albertel Exp $
+# $Id: portfolio.pm,v 1.170 2006/11/05 21:08:53 raeburn 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('
');
} elsif ($scope eq 'domains') {
$r->print(&mt('Domains: ').join(',',@{$content->{'dom'}}));
} elsif ($scope eq 'users') {
@@ -821,14 +1018,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;
@@ -844,12 +1041,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;
}
@@ -866,7 +1064,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;
@@ -948,19 +1146,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') {
@@ -971,19 +1168,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').' | ');
@@ -991,7 +1203,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).' | ');
@@ -999,7 +1211,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').
@@ -1010,7 +1222,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).' | ');
@@ -1019,36 +1231,75 @@ sub access_setting_table {
$passwd.'" />');
$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(' |
|
'.
+ '');
+ 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.'));
+ }
+}
+
+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);
+ &access_element($r,'users',$acl_count,$users,$access_controls,$now,$then);
$r->print(' |
|
');
- if (@courses > 0 || @groups > 0) {
+ if ($acl_count->{course} > 0) {
$r->print('');
} else {
$r->print(' | ');
}
- &access_element($r,'course',\%acl_count,\@courses,$access_controls,$now,$then);
+ &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);
$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 {
@@ -1083,7 +1334,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 ++;
@@ -1093,7 +1344,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,
@@ -1170,10 +1421,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,
@@ -1190,7 +1437,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'}}))) {
@@ -1260,7 +1507,12 @@ sub actionbox {
my ($status,$num,$scope) = @_;
my $output = '
|