--- loncom/auth/lonroles.pm 2011/10/21 16:28:49 1.262 +++ loncom/auth/lonroles.pm 2012/07/21 21:09:03 1.269 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.262 2011/10/21 16:28:49 www Exp $ +# $Id: lonroles.pm,v 1.269 2012/07/21 21:09:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -221,7 +221,7 @@ sub handler { } else { $checkingtxt = &mt('Checking for new roles ...'); } - $updateresult = '
' @@ -1614,19 +1620,17 @@ sub check_forcc { } else { $ccrole = 'cc'; } - if ($cdom ne '' && $cnum ne '') { - if (&Apache::lonnet::is_course($cdom,$cnum)) { - my $envkey = 'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum; - if (defined($env{$envkey})) { - $is_cc = 1; - my ($tstart,$tend)=split(/\./,$env{$envkey}); - my $limit = $update; - if ($env{'request.role'} eq $ccrole.'./'.$cdom.'/'.$cnum) { - $limit = $then; - } - if ($tstart && $tstart>$refresh) { $is_cc = 0; } - if ($tend && $tend <$limit) { $is_cc = 0; } + if (&Apache::lonnet::is_course($cdom,$cnum)) { + my $envkey = 'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum; + if (defined($env{$envkey})) { + $is_cc = 1; + my ($tstart,$tend)=split(/\./,$env{$envkey}); + my $limit = $update; + if ($env{'request.role'} eq $ccrole.'./'.$cdom.'/'.$cnum) { + $limit = $then; } + if ($tstart && $tstart>$refresh) { $is_cc = 0; } + if ($tend && $tend <$limit) { $is_cc = 0; } } } return $is_cc; @@ -1684,43 +1688,6 @@ sub check_release_required { return ($switchserver,$warning); } -sub update_content_constraints { - my ($cdom,$cnum,$chome,$cid) = @_; - my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired'); - my ($reqdmajor,$reqdminor) = split(/\./,$curr_reqd_hash{'internal.releaserequired'}); - my %checkresponsetypes; - foreach my $key (keys(%Apache::lonnet::needsrelease)) { - my ($item,$name,$value) = split(/:/,$key); - if ($item eq 'resourcetag') { - if ($name eq 'responsetype') { - $checkresponsetypes{$value} = $Apache::lonnet::needsrelease{$key} - } - } - } - my $navmap = Apache::lonnavmaps::navmap->new(); - if (defined($navmap)) { - my %allresponses; - foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) { - my %responses = $res->responseTypes(); - foreach my $key (keys(%responses)) { - next unless(exists($checkresponsetypes{$key})); - $allresponses{$key} += $responses{$key}; - } - } - foreach my $key (keys(%allresponses)) { - my ($major,$minor) = split(/\./,$checkresponsetypes{$key}); - if (($major > $reqdmajor) || ($major == $reqdmajor && $minor > $reqdminor)) { - ($reqdmajor,$reqdminor) = ($major,$minor); - } - } - undef($navmap); - } - unless (($reqdmajor eq '') && ($reqdminor eq '')) { - &Apache::lonnet::update_released_required($reqdmajor.'.'.$reqdminor,$cdom,$cnum,$chome,$cid); - } - return; -} - sub courselink { my ($dcdom,$rowtype) = @_; my $courseform=&Apache::loncommon::selectcourse_link @@ -1872,7 +1839,7 @@ sub update_session_roles { ['active','future','previous'], undef,undef,1); my ($msg,@newsec,$oldsec,$currrole_expired,@changed_roles, - %changed_groups,%dbroles, %deletedroles,%allroles,%allgroups, + %changed_groups,%dbroles,%deletedroles,%allroles,%allgroups, %userroles,%checkedgroup,%crprivs,$hasgroups,%rolechange, %groupchange,%newrole,%newgroup,%customprivchg,%groups_roles, @rolecodes); @@ -2109,7 +2076,9 @@ sub update_session_roles { foreach my $priv (@privs) { my ($blank,@prv) = split(/:/,$priv); @prv = map { $_ .= (/\&\w+$/ ? '':'&F') } @prv; - $priv = ':'.join(':',sort(@prv)); + if (@prv) { + $priv = ':'.join(':',sort(@prv)); + } $crprivs{$rest}{$scopes[$i]} = $priv; $i++; } @@ -2213,21 +2182,30 @@ sub update_session_roles { $msg .= ''.&mt('However you can continue to use this role until you logout, click the "Re-Select" button, or your session has been idle for more than 24 hours.').'