--- loncom/interface/portfolio.pm 2006/07/19 15:31:05 1.138
+++ 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.138 2006/07/19 15:31:05 albertel Exp $
+# $Id: portfolio.pm,v 1.171 2006/11/06 20:02:58 rezaferry Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,17 +60,21 @@ sub group_form_data {
$env{'form.ref'}.'" />';
}
}
+ return $output;
}
# 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;
}
@@ -91,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");
@@ -105,7 +116,7 @@ sub display_common {
-
+ $help_fileupload
@@ -120,7 +131,7 @@ sub display_common {
-
+ $help_createdir
@@ -128,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') {
@@ -754,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();
@@ -822,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;
@@ -845,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;
}
@@ -867,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;
@@ -949,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') {
@@ -972,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').' | ');
@@ -992,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).' | ');
@@ -1000,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').
@@ -1011,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).' | ');
@@ -1020,36 +1233,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 {
@@ -1084,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 ++;
@@ -1094,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,
@@ -1171,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,
@@ -1191,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'}}))) {
@@ -1261,7 +1509,12 @@ sub actionbox {
my ($status,$num,$scope) = @_;
my $output = '
|