--- loncom/lonsql 2007/07/30 23:52:06 1.83 +++ loncom/lonsql 2007/08/08 22:24:36 1.84 @@ -3,7 +3,7 @@ # The LearningOnline Network # lonsql - LON TCP-MySQL-Server Daemon for handling database requests. # -# $Id: lonsql,v 1.83 2007/07/30 23:52:06 albertel Exp $ +# $Id: lonsql,v 1.84 2007/08/08 22:24:36 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -387,7 +387,7 @@ sub make_new_child { print $client "$queryid\n"; # # &logthis("QUERY: $query - $arg1 - $arg2 - $arg3 - $queryid"); - sleep 1; + # sleep 1; # my $result=''; # @@ -492,6 +492,8 @@ sub make_new_child { 'WARNING: Could not retrieve from database:'. $sth->errstr().''); } + } elsif ($query eq 'instdirsearch') { + $result = &do_inst_dir_search($searchdomain,$arg1,$arg2,$arg3); } elsif ($query eq 'prepare activity log') { my ($cid,$domain) = map {&unescape($_);} ($arg1,$arg2); &logthis('preparing activity log tables for '.$cid); @@ -543,6 +545,30 @@ sub make_new_child { } } +sub do_inst_dir_search { + my ($domain,$srchby,$srchterm,$srchtype) = @_; + $srchby = &unescape($srchby); + $srchterm = &unescape($srchterm); + $srchtype = &unescape($srchtype); + my (%instusers,%instids,$result,$response); + eval { + local($SIG{__DIE__})='DEFAULT'; + $result=&localenroll::get_userinfo($domain,undef,undef,\%instusers, + \%instids,undef,$srchby,$srchterm, + $srchtype); + }; + if ($result eq 'ok') { + if (%instusers) { + foreach my $key (keys(%instusers)) { + my $usrstr = &Apache::lonnet::freeze_escape($instusers{$key}); + $response .=&escape(&escape($key).'='.$usrstr).'&'; + } + } + $response=~s/\&$//; + } + return $response; +} + ######################################################## ########################################################