--- loncom/lonnet/perl/lonnet.pm 2017/01/22 17:41:07 1.1172.2.89 +++ loncom/lonnet/perl/lonnet.pm 2017/01/30 19:29:57 1.1172.2.90 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1172.2.89 2017/01/22 17:41:07 raeburn Exp $ +# $Id: lonnet.pm,v 1.1172.2.90 2017/01/30 19:29:57 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3917,7 +3917,7 @@ sub flushcourselogs { } } # -# Reverse lookup of domain roles (dc, ad, li, sc, dh, au) +# Reverse lookup of domain roles (dc, ad, li, sc, dh, da, au) # my %domrolebuffer = (); foreach my $entry (keys(%domainrolehash)) { @@ -4064,7 +4064,7 @@ sub userrolelog { {$trole.':'.$username.':'.$domain.':'.$env{'user.name'}.':'.$env{'user.domain'}.':'} =$tend.':'.$tstart; } - if ($trole =~ /^(dc|ad|li|au|dg|sc|dh)/ ) { + if ($trole =~ /^(dc|ad|li|au|dg|sc|dh|da)/ ) { my (undef,$rudom,$runame,$rsec)=split(/\//,$area); $domainrolehash {$trole.':'.$username.':'.$domain.':'.$runame.':'.$rudom.':'.$rsec} @@ -4348,18 +4348,29 @@ sub get_my_adhocroles { } } if (($cdom ne '') && ($cnum ne '')) { - if ($env{"user.role.dh./$cdom/"}) { + if (($env{"user.role.dh./$cdom/"}) || ($env{"user.role.da./$cdom/"})) { my $then=$env{'user.login.time'}; my $update=$env{'user.update.time'}; - my $liverole = 1; - my ($tstart,$tend)=split(/\./,$env{'user.role.dh./'.$cdom}); - my $limit = $update; - if ($env{'request.role'} eq 'dh./'.$cdom.'/') { - $limit = $then; - } - if ($tstart && $tstart>$limit) { $liverole = 0; } - if ($tend && $tend <$limit) { $liverole = 0; } - if ($liverole) { + if (!$update) { + $update = $then; + } + my @liveroles; + foreach my $role ('dh','da') { + if ($env{"user.role.$role./$cdom/"}) { + my ($tstart,$tend)=split(/\./,$env{"user.role.$role./$cdom/"}); + my $limit = $update; + if ($env{'request.role'} eq "$role./$cdom/") { + $limit = $then; + } + my $activerole = 1; + if ($tstart && $tstart>$limit) { $activerole = 0; } + if ($tend && $tend <$limit) { $activerole = 0; } + if ($activerole) { + push(@liveroles,$role); + } + } + } + if (@liveroles) { if (&homeserver($cnum,$cdom) ne 'no_host') { my ($accessref,$accessinfo,%access_in_dom); ($roles_by_num,$description,$accessref,$accessinfo) = &get_all_adhocroles($cdom); @@ -4414,6 +4425,18 @@ sub get_my_adhocroles { next; } elsif ($curraccess eq 'all') { push(@possroles,$role); + } elsif ($curraccess eq 'dh') { + if (grep(/^dh$/,@liveroles)) { + push(@possroles,$role); + } else { + next; + } + } elsif ($curraccess eq 'da') { + if (grep(/^da$/,@liveroles)) { + push(@possroles,$role); + } else { + next; + } } elsif ($curraccess eq 'status') { if (@okstatus) { if (!@statuses) { @@ -8997,7 +9020,8 @@ sub assignrole { &courserolelog($role,$uname,$udom,$url,$origstart,$origend,$delflag, $selfenroll,$context); } elsif (($role eq 'li') || ($role eq 'dg') || ($role eq 'sc') || - ($role eq 'au') || ($role eq 'dc') || ($role eq 'dh')) { + ($role eq 'au') || ($role eq 'dc') || ($role eq 'dh') || + ($role eq 'da')) { &domainrolelog($role,$uname,$udom,$url,$origstart,$origend,$delflag, $context); } elsif (($role eq 'ca') || ($role eq 'aa')) {