--- loncom/lond 2010/07/22 22:08:06 1.449 +++ loncom/lond 2010/07/26 21:52:10 1.450 @@ -2,7 +2,7 @@ # The LearningOnline Network # lond "LON Daemon" Server (port "LOND" 5663) # -# $Id: lond,v 1.449 2010/07/22 22:08:06 raeburn Exp $ +# $Id: lond,v 1.450 2010/07/26 21:52:10 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -58,7 +58,7 @@ my $DEBUG = 0; # Non zero to ena my $status=''; my $lastlog=''; -my $VERSION='$Revision: 1.449 $'; #' stupid emacs +my $VERSION='$Revision: 1.450 $'; #' stupid emacs my $remoteVERSION; my $currenthostid="default"; my $currentdomainid; @@ -3144,7 +3144,7 @@ sub dump_with_regexp { my $userinput = "$cmd:$tail"; - my ($udom,$uname,$namespace,$regexp,$range)=split(/:/,$tail); + my ($udom,$uname,$namespace,$regexp,$range,$extra)=split(/:/,$tail); if (defined($regexp)) { $regexp=&unescape($regexp); } else { @@ -3162,21 +3162,49 @@ sub dump_with_regexp { } my $hashref = &tie_user_hash($udom, $uname, $namespace, &GDBM_READER()); + my $clientcheckrole; if ($hashref) { my $qresult=''; my $count=0; + if ($extra ne '') { + $extra = &Apache::lonnet::thaw_unescape($extra); + $clientcheckrole = $extra->{'clientcheckrole'}; + } + my @ids = &Apache::lonnet::current_machine_ids(); while (my ($key,$value) = each(%$hashref)) { if ($namespace eq 'roles') { - if ($key =~ m{^/($LONCAPA::match_domain)/($LONCAPA::match_community)_(cc|co|in|ta|ep|ad|st|cr)}) { + if ($key =~ m{^/($LONCAPA::match_domain)/($LONCAPA::match_courseid)_(cc|co|in|ta|ep|ad|st|cr)}) { my $cdom = $1; my $cnum = $2; - if ($clientversion =~ /^\'?(\d+)\.(\d+)/) { - my $major = $1; - my $minor = $2; - next if (($major < 2) || (($major == 2) && ($minor < 9))); - } else { - my $homeserver = &Apache::lonnet::homeserver($cnum,$cdom); - next unless ($currenthostid eq $homeserver); + unless ($clientcheckrole) { + my $home = &Apache::lonnet::homeserver($cnum,$cdom); + my $loncaparev = $clientversion; + if ($loncaparev eq '') { + $loncaparev = $Apache::lonnet::loncaparevs{$clientname}; + } + my ($major,$minor); + if ($loncaparev =~ /^\'?(\d+)\.(\d+)\.[\d.\-]+\'?/) { + $major = $1; + $minor = $2; + } + if ($key =~ m{^/($LONCAPA::match_domain)/($LONCAPA::match_community)_(co|in|ta|ep|ad|st|cr)}) { + if ($major eq '' && $minor eq '') { + next unless (($home ne 'no_host') && grep(/^\Q$home\E$/,@ids)); + } + } + unless ($home eq 'no_host') { + my $courseinfo = &get_courseinfo_hash($cnum,$cdom,$home); + if (ref($courseinfo) eq 'HASH') { + if (exists($courseinfo->{'releaserequired'})) { + my ($reqdmajor,$reqdminor) = split(/\./,$courseinfo->{'releaserequired'}); + if ($reqdmajor ne '' && $reqdminor ne '') { + next if (($major eq '' && $minor eq '') || + ($major < $reqdmajor) || + (($major == $reqdmajor) && ($minor < $reqdminor))); + } + } + } + } } } } @@ -7268,6 +7296,21 @@ sub get_usersession_config { } } return; +} + +sub get_courseinfo_hash { + my ($cnum,$cdom,$home) = @_; + my $hashid = $cdom.':'.$cnum; + my ($courseinfo,$cached)=&Apache::lonnet::is_cached_new('courseinfo',$hashid); + if (defined($cached)) { + return $courseinfo; + } else { + my %info = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,1,[$home],'.'); + if (ref($info{$cdom.'_'.$cnum}) eq 'HASH') { + return &Apache::lonnet::do_cache_new('courseinfo',$hashid,$info{$cdom.'_'.$cnum},600); + } + } + return; } # ----------------------------------- POD (plain old documentation, CPAN style)