--- loncom/interface/portfolio.pm 2010/02/19 10:20:31 1.220 +++ loncom/interface/portfolio.pm 2010/03/26 22:27:06 1.221 @@ -1,7 +1,7 @@ # The LearningOnline Network # portfolio browser # -# $Id: portfolio.pm,v 1.220 2010/02/19 10:20:31 bisitz Exp $ +# $Id: portfolio.pm,v 1.221 2010/03/26 22:27:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,7 +38,7 @@ use Apache::lonnet; use Apache::longroup; use Apache::lonhtmlcommon; use HTML::Entities; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); sub group_args { my $output; @@ -880,7 +880,7 @@ sub display_access { sub explain_conditionals { return &mt('Conditional files are accessible to logged-in users with accounts in the LON-CAPA network, who satisfy the conditions you set.').'
'."\n". - &mt('The conditions can include affiliation with a particular course, or a user account in a specific domain.').'
'."\n". + &mt('The conditions can include affiliation with a particular course or community, or a user account in a specific domain.').'
'."\n". &mt('Alternatively access can be granted to people with specific LON-CAPA usernames and domains.'); } @@ -921,7 +921,7 @@ sub build_access_summary { guest => 'Passphrase-protected', domains => 'Conditional: domain-based', users => 'Conditional: user-based', - course => 'Conditional: course-based', + course => 'Conditional: course/community-based', ); my @allscopes = ('public','guest','domains','users','course'); foreach my $scope (@allscopes) { @@ -946,11 +946,16 @@ sub build_access_summary { } } $r->print(''.&mt($scope_desc{$scope})); + my $crstype; if ($scope eq 'course') { if ($chg ne 'delete') { my $cid = $content->{'domain'}.'_'.$content->{'number'}; my %course_description = &Apache::lonnet::coursedescription($cid); $r->print('
('.$course_description{'description'}.')'); + $crstype = 'Course'; + if ($course_description{'type'} ne '') { + $crstype = $course_description{'type'}; + } } } $r->print(''.&mt('Start: ').$showstart. @@ -970,8 +975,6 @@ sub build_access_summary { foreach my $item ('role','access','section','group') { $r->print(''); if ($item eq 'role') { - my $ucscope = $scope; - $ucscope =~ s/^(\w)/uc($1)/e; my $role_output; foreach my $role (@{$content->{'roles'}{$id}{$item}}) { if ($role eq 'all') { @@ -979,7 +982,7 @@ sub build_access_summary { } elsif ($role =~ /^cr/) { $role_output .= (split('/',$role))[3].','; } else { - $role_output .= &Apache::lonnet::plaintext($role,$ucscope).','; + $role_output .= &Apache::lonnet::plaintext($role,$crstype).','; } } $role_output =~ s/,$//; @@ -1105,16 +1108,22 @@ sub update_access { my $totalnew = 0; my $status = 'new'; my ($firstitem,$lastitem); - foreach my $newitem ('course','domains','users') { + my @types = ('course','domains','users'); + foreach my $newitem (@types) { $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','domains','users') { + my %showtypes = &Apache::lonlocal::texthash ( + course => 'course/community', + domains => 'domain', + users => 'user', + ); + foreach my $newitem (@types) { if ($env{'form.new'.$newitem} > 0) { - $r->print('
'.&mt('Add new [_1]-based access control for portfolio file: [_2]',&mt($newitem),$env{'form.currentpath'}.$env{'form.selectfile'}).'

'); + $r->print('
'.&mt('Add new [_1]-based[_2] access control for portfolio file: [_3]',''.$showtypes{$newitem},'',''.$env{'form.currentpath'}.$env{'form.selectfile'}.'').'

'); $firstitem = $totalnew; $lastitem = $totalnew + $env{'form.new'.$newitem}; $totalnew = $lastitem; @@ -1391,10 +1400,12 @@ sub acl_status { sub access_element { my ($r,$type,$acl_count,$items,$access_controls,$now,$then) = @_; - my $title = $type; - $title =~ s/s$//; - $title =~ s/^(\w)/uc($1)/e; - $r->print('

'.&mt('[_1]-based conditional access: ',&mt($title))); + my %typetext = &Apache::lonlocal::texthash( + domains => 'Domain', + users => 'User', + course => 'Course/Community' + ); + $r->print('

'.&mt('[_1]-based conditional access: ',$typetext{$type}).': '); if ($$acl_count{$type}) { $r->print($$acl_count{$type}.' '); if ($$acl_count{$type} > 1) { @@ -1412,17 +1423,24 @@ sub access_element { sub display_access_row { my ($r,$status,$type,$items,$access_controls,$now,$then) = @_; + my $showtype; + if ($type eq 'course') { + $showtype = &mt('Courses/Communities'); + } elsif ($type eq 'domains') { + $showtype = &mt('Domains'); + } elsif ($type eq 'users') { + $showtype = &mt('Users'); + } if (@{$items} > 0) { my @all_doms; my $colspan = 3; - my $uctype = $type; - $uctype =~ s/^(\w)/uc($1)/e; $r->print(&Apache::loncommon::start_data_table()); $r->print(&Apache::loncommon::start_data_table_header_row()); - $r->print(''.&mt('Action?').''.&mt($uctype).''. + $r->print(''.&mt('Action?').''.$showtype.''. &mt('Dates available').''); if ($type eq 'course' && $status eq 'old') { - $r->print(''.&mt('Allowed [_1] member affiliations',$type). + + $r->print(''.&mt('Allowed course/community affiliations'). ''); $colspan ++; } elsif ($type eq 'domains') { @@ -1449,8 +1467,8 @@ sub display_access_row { } $r->print(&Apache::loncommon::end_data_table()); } else { - $r->print(&mt('No [_1]-based conditions defined.',&mt($type)).'
' - .&additional_item($type)); + $r->print(&mt('No [_1]-based conditions defined.',$showtype).'
'. + &additional_item($type)); } return; } @@ -1511,17 +1529,20 @@ sub course_row { } my $js = &Apache::loncommon::coursebrowser_javascript($defdom) .&course_js(); - my $uctype = $type; - $uctype =~ s/^(\w)/uc($1)/e; + my $showtype = &mt('Course/Community'); + my $crstype = 'Course'; my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then, $type); $r->print(''.$js.&actionbox($status,$num,$scope).''); if ($status eq 'old') { my $cid = $content->{'domain'}.'_'.$content->{'number'}; my %course_description = &Apache::lonnet::coursedescription($cid); + if ($course_description{'type'} ne '') { + $crstype = $course_description{'type'}; + } $r->print(''.$course_description{'description'}.''); } elsif ($status eq 'new') { - $r->print(''.&Apache::loncommon::selectcourse_link('portform','crsnum_'.$num,'crsdom_'.$num,'description_'.$num,$num.'_1',undef,$uctype).'  '); + $r->print(''.&Apache::loncommon::selectcourse_link('portform','crsnum_'.$num,'crsdom_'.$num,'description_'.$num,$num.'_1',undef,$showtype).'  '); } $r->print(''.&dateboxes($num,$start,$end)); my $newrole_id = 1; @@ -1539,7 +1560,7 @@ sub course_row { $max_id = $role_id; } $max_id ++; - my $role_selects = &role_selectors($num,$role_id,$type,$content,'display'); + my $role_selects = &role_selectors($num,$role_id,$crstype,$content,'display'); $r->print('
'.$role_selects.''); } $r->print(''); @@ -1548,7 +1569,7 @@ sub course_row { ' {'domain'}','$content->{'number'}', - '$uctype'".')" value="" />'); + '$showtype'".')" value="" />'); $newrole_id = $max_id; } else { $r->print(''); @@ -1609,7 +1630,15 @@ sub users_row { sub additional_item { my ($type) = @_; - my $output = &mt('Add new [_1] condition(s)?',&mt($type)).' '.&mt('Number to add: ').''; + my $showtype; + if ($type eq 'course') { + $showtype = &mt('course/community'); + } elsif ($type eq 'domains') { + $showtype = &mt('domains'); + } elsif ($type eq 'users') { + $showtype = &mt('users'); + } + my $output = &mt('Add new [_1] condition(s)?',$showtype).' '.&mt('Number to add: ').''; return $output; } @@ -1680,10 +1709,12 @@ sub role_selectors { $cdom = $env{'form.cdom'}; $cnum = $env{'form.cnum'}; } - my $uctype = $type; - $uctype =~ s/^(\w)/uc($1)/e; + my $crstype = 'Course'; + if ($cnum =~ /^$match_community$/) { + $crstype = 'Community' + } my ($sections,$groups,$allroles,$rolehash,$accesshash) = - &Apache::loncommon::get_secgrprole_info($cdom,$cnum,1,$uctype); + &Apache::loncommon::get_secgrprole_info($cdom,$cnum,1,$crstype); if (!@{$sections}) { @{$sections} = ('none'); } else {