version 1.176, 2007/08/25 17:46:24
|
version 1.178, 2007/08/26 15:31:03
|
Line 2203 sub user_search_result {
|
Line 2203 sub user_search_result {
|
if ($srch->{'srchin'} !~ /^(crs|dom|alc|instd)$/) { |
if ($srch->{'srchin'} !~ /^(crs|dom|alc|instd)$/) { |
$response = &mt('Invalid search.'); |
$response = &mt('Invalid search.'); |
} |
} |
if ($srch->{'srchtype'} !~ /^(exact|contains)$/) { |
if ($srch->{'srchtype'} !~ /^(exact|contains|begins)$/) { |
$response = &mt('Invalid search.'); |
$response = &mt('Invalid search.'); |
} |
} |
if ($srch->{'srchterm'} eq '') { |
if ($srch->{'srchterm'} eq '') { |
Line 2274 sub user_search_result {
|
Line 2274 sub user_search_result {
|
foreach my $user (keys(%$courseusers)) { |
foreach my $user (keys(%$courseusers)) { |
my ($cuname,$cudomain) = split(/:/,$user); |
my ($cuname,$cudomain) = split(/:/,$user); |
if ($cudomain eq $srch->{'srchdomain'}) { |
if ($cudomain eq $srch->{'srchdomain'}) { |
if ($cuname =~ /\Q$srch->{'srchterm'}\E/i) { |
my $matched = 0; |
|
if ($srch->{'srchtype'} eq 'begins') { |
|
if ($cuname =~ /^\Q$srch->{'srchterm'}\E/i) { |
|
$matched = 1; |
|
} |
|
} else { |
|
if ($cuname =~ /\Q$srch->{'srchterm'}\E/i) { |
|
$matched = 1; |
|
} |
|
} |
|
if ($matched) { |
$srch_results{$user} = |
$srch_results{$user} = |
{&Apache::lonnet::get('environment', |
{&Apache::lonnet::get('environment', |
['firstname', |
['firstname', |
Line 2309 sub user_search_result {
|
Line 2319 sub user_search_result {
|
if ($srch->{'srchby'} eq 'lastname') { |
if ($srch->{'srchby'} eq 'lastname') { |
if ((($srch->{'srchtype'} eq 'exact') && |
if ((($srch->{'srchtype'} eq 'exact') && |
($names{'lastname'} eq $srch->{'srchterm'})) || |
($names{'lastname'} eq $srch->{'srchterm'})) || |
|
(($srch->{'srchtype'} eq 'begins') && |
|
($names{'lastname'} =~ /^\Q$srch->{'srchterm'}\E/i)) || |
(($srch->{'srchtype'} eq 'contains') && |
(($srch->{'srchtype'} eq 'contains') && |
($names{'lastname'} =~ /\Q$srch->{'srchterm'}\E/i))) { |
($names{'lastname'} =~ /\Q$srch->{'srchterm'}\E/i))) { |
$srch_results{$user} = {firstname => $names{'firstname'}, |
$srch_results{$user} = {firstname => $names{'firstname'}, |
Line 2318 sub user_search_result {
|
Line 2330 sub user_search_result {
|
} |
} |
} elsif ($srch->{'srchby'} eq 'lastfirst') { |
} elsif ($srch->{'srchby'} eq 'lastfirst') { |
my ($srchlast,$srchfirst) = split(/,/,$srch->{'srchterm'}); |
my ($srchlast,$srchfirst) = split(/,/,$srch->{'srchterm'}); |
|
$srchlast =~ s/\s+$//; |
|
$srchfirst =~ s/^\s+//; |
if ($srch->{'srchtype'} eq 'exact') { |
if ($srch->{'srchtype'} eq 'exact') { |
if (($names{'lastname'} eq $srchlast) && |
if (($names{'lastname'} eq $srchlast) && |
($names{'firstname'} eq $srchfirst)) { |
($names{'firstname'} eq $srchfirst)) { |
Line 2327 sub user_search_result {
|
Line 2341 sub user_search_result {
|
|
|
}; |
}; |
} |
} |
} elsif ($srch->{'srchtype'} eq 'contains') { |
} elsif ($srch->{'srchtype'} eq 'begins') { |
|
if (($names{'lastname'} =~ /^\Q$srchlast\E/i) && |
|
($names{'firstname'} =~ /^\Q$srchfirst\E/i)) { |
|
$srch_results{$user} = {firstname => $names{'firstname'}, |
|
lastname => $names{'lastname'}, |
|
permanentemail => $emails{'permanentemail'}, |
|
}; |
|
} |
|
} else { |
if (($names{'lastname'} =~ /\Q$srchlast\E/i) && |
if (($names{'lastname'} =~ /\Q$srchlast\E/i) && |
($names{'firstname'} =~ /\Q$srchfirst\E/i)) { |
($names{'firstname'} =~ /\Q$srchfirst\E/i)) { |
$srch_results{$user} = {firstname => $names{'firstname'}, |
$srch_results{$user} = {firstname => $names{'firstname'}, |
Line 2397 sub directorysrch_check {
|
Line 2419 sub directorysrch_check {
|
lastfirst => 'last name, first name', |
lastfirst => 'last name, first name', |
lastname => 'last name', |
lastname => 'last name', |
contains => 'contains', |
contains => 'contains', |
exact => 'as exact match to' |
exact => 'as exact match to', |
|
begins => 'begins with', |
); |
); |
if ($can_search) { |
if ($can_search) { |
if (ref($dom_inst_srch{'directorysrch'}{'searchby'}) eq 'ARRAY') { |
if (ref($dom_inst_srch{'directorysrch'}{'searchby'}) eq 'ARRAY') { |
Line 2409 sub directorysrch_check {
|
Line 2432 sub directorysrch_check {
|
} |
} |
} |
} |
if ($can_search) { |
if ($can_search) { |
if (($dom_inst_srch{'directorysrch'}{'searchtypes'} eq 'specify') || |
if (ref($dom_inst_srch{'directorysrch'}{'searchtypes'}) eq 'ARRAY') { |
($dom_inst_srch{'directorysrch'}{'searchtypes'} eq $srch->{'srchtype'})) { |
if (grep(/^\Q$srch->{'srchtype'}\E/,@{$dom_inst_srch{'directorysrch'}{'searchtypes'}})) { |
return 'ok'; |
return 'ok'; |
} else { |
} else { |
return &mt('Directory search in domain [_1] is not available for the requested search type: "[_2]"',$srch->{'srchdomain'},$longtext{$srch->{'srchtype'}}); |
return &mt('Directory search in domain [_1] is not available for the requested search type: "[_2]"',$srch->{'srchdomain'},$longtext{$srch->{'srchtype'}}); |
|
} |
|
} else { |
|
if ((($dom_inst_srch{'directorysrch'}{'searchtypes'} eq 'specify') && |
|
($srch->{'srchtype'} eq 'exact' || $srch->{'srchtype'} eq 'contains')) || |
|
($dom_inst_srch{'directorysrch'}{'searchtypes'} eq $srch->{'srchtype'})) { |
|
return 'ok'; |
|
} else { |
|
return &mt('Directory search in domain [_1] is not available for the requested search type: "[_2]"',$srch->{'srchdomain'},$longtext{$srch->{'srchtype'}}); |
|
} |
} |
} |
} |
} |
} |
} |