--- loncom/lonnet/perl/lonnet.pm 2017/01/28 03:49:00 1.1334 +++ loncom/lonnet/perl/lonnet.pm 2017/01/28 21:35:54 1.1335 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1334 2017/01/28 03:49:00 raeburn Exp $ +# $Id: lonnet.pm,v 1.1335 2017/01/28 21:35:54 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4550,20 +4550,26 @@ sub get_my_adhocroles { 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; + 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 ($tstart,$tend)=split(/\./,$env{"user.role.$role./$cdom/"}); my $limit = $update; if ($env{'request.role'} eq "$role./$cdom/") { $limit = $then; } - if ($tstart && $tstart>$limit) { $liverole = 0; } - if ($tend && $tend <$limit) { $liverole = 0; } - last if ($liverole); + my $activerole = 1; + if ($tstart && $tstart>$limit) { $activerole = 0; } + if ($tend && $tend <$limit) { $activerole = 0; } + if ($activerole) { + push(@liveroles,$role); + } } } - if ($liverole) { + 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); @@ -4618,6 +4624,18 @@ sub get_my_adhocroles { next; } elsif ($curraccess eq 'all') { push(@possroles,$role); + } elsif ($curraccess eq 'anydh') { + if (grep(/^dh$/,@liveroles)) { + push(@possroles,$role); + } else { + next; + } + } elsif ($curraccess eq 'anyda') { + if (grep(/^da$/,@liveroles)) { + push(@possroles,$role); + } else { + next; + } } elsif ($curraccess eq 'status') { if (@okstatus) { if (!@statuses) {