--- loncom/auth/lonroles.pm 2011/09/09 16:34:41 1.261 +++ loncom/auth/lonroles.pm 2012/08/14 17:35:04 1.271 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.261 2011/09/09 16:34:41 bisitz Exp $ +# $Id: lonroles.pm,v 1.271 2012/08/14 17:35:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -221,10 +221,100 @@ sub handler { } else { $checkingtxt = &mt('Checking for new roles ...'); } - $updateresult = '
'.$do_update.'
'); + if ($do_update && $requestauthor) { + $r->print(''.$do_update.'
'); + } elsif ($requestauthor) { + $r->print(''.$requestauthor.'
'); + } if ($countactive > 0) { $r->print(&Apache::loncoursequeueadmin::queued_selfenrollment()); my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); @@ -955,7 +1112,12 @@ ENDHEADER $r->print(''
@@ -970,6 +1132,33 @@ ENDHEADER
return OK;
}
+sub is_active_author {
+ if ($env{'user.role.au./'.$env{'user.domain'}.'/'} =~ /^(\d*)\.(\d*)$/) {
+ if ((!$1 || $1 < time) &&
+ (!$2 || $2 > time)) {
+ return 1;
+ }
+ }
+ return;
+}
+
+sub reqauthor_check {
+ my $queued = $env{'environment.requestauthorqueued'};
+ my %reqauthor = &Apache::lonnet::get('requestauthor',['author_status','author'],
+ $env{'user.domain'},$env{'user.name'});
+ my $reqstatus = $reqauthor{'author_status'};
+ if (($reqstatus eq '' && $queued ne '') ||
+ ($env{'environment.requestauthorqueued'} !~ /^\Q$reqstatus\E/)) {
+ if (ref($reqauthor{'author'}) eq 'HASH') {
+ $queued = $reqstatus.':'.$reqauthor{'author'}{'timestamp'};
+ } else {
+ undef($queued);
+ }
+ &Apache::lonnet::appenv({'environment.requestauthorqueued' => $queued});
+ }
+ return $queued;
+}
+
sub gather_roles {
my ($update,$refresh,$now,$reinit,$nochoose,$roletext,$sortrole,$roleclass,$futureroles,$timezones,$loncaparev) = @_;
my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,'');
@@ -1614,19 +1803,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 +1871,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 +2022,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);
@@ -1922,7 +2072,7 @@ sub update_session_roles {
}
if ($env{$envkey} eq '') {
my $status_in_db =
- &curr_role_status($tstart,$tend,$refresh,$now);
+ &curr_role_status($tstart,$tend,$now,$now);
&gather_roleprivs(\%allroles,\%allgroups,\%userroles,$where,$role,$tstart,$tend,$status_in_db);
if (($role eq 'st') && ($env{'request.role'} =~ m{^\Q$role\E\.\Q/$udom/$uname\E})) {
if ($status_in_db eq 'active') {
@@ -1966,7 +2116,7 @@ sub update_session_roles {
my $status_in_env =
&curr_role_status($currstart,$currend,$refresh,$update);
my $status_in_db =
- &curr_role_status($tstart,$tend,$refresh,$now);
+ &curr_role_status($tstart,$tend,$now,$now);
if ($status_in_env ne $status_in_db) {
if ($status_in_env eq 'active') {
if ($role eq 'st') {
@@ -2109,7 +2259,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 +2365,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.').'';
}
if (!@changed_roles || !(keys(%changed_groups))) {
- $msg .= '';
+ my ($rolesmsg,$groupsmsg);
if (!@changed_roles) {
- $msg .= '
';
if (!@changed_roles && !(keys(%changed_groups))) {
+ if (($msg ne '') || ($groupsmsg ne '')) {
+ $msg .= '';
+ if ($rolesmsg) {
+ $msg .= '
';
+ } else {
+ $msg = ' '.$rolesmsg.'
';
+ }
return $msg;
}
}
@@ -2280,7 +2441,7 @@ sub update_session_roles {
}
if (keys(%deletedroles) > 0) {
$changemsg .= '';
foreach my $item (sort(keys(%deletedroles))) {
$changemsg .= '