';
+ }
}
}
- return ($state,$response,$forcenewuser,\%srch_results);
+ return ($currstate,$response,$forcenewuser,\%srch_results);
}
sub directorysrch_check {
@@ -2352,13 +2422,14 @@ sub directorysrch_check {
my $response;
my %dom_inst_srch = &Apache::lonnet::get_dom('configuration',
['directorysrch'],$srch->{'srchdomain'});
+ my $showdom = &display_domain_info($srch->{'srchdomain'});
if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') {
if (!$dom_inst_srch{'directorysrch'}{'available'}) {
- return &mt('Institutional directory search unavailable in domain: [_1]',$srch->{'srchdomain'});
+ return &mt('Institutional directory search is not available in domain: [_1]',$showdom);
}
if ($dom_inst_srch{'directorysrch'}{'localonly'}) {
if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) {
- return &mt('Insitutional directory search in domain: [_1] is only allowed for users with a current role in the domain.',$srch->{'srchdomain'});
+ return &mt('Institutional directory search in domain: [_1] is only allowed for users with a current role in the domain.',$showdom);
}
my @usertypes = split(/:/,$env{'environment.inststatus'});
if (!@usertypes) {
@@ -2379,36 +2450,46 @@ sub directorysrch_check {
push (@longtypes,$insttypes->{$item});
}
my $insttype_str = join(', ',@longtypes);
- return &mt('Directory search in domain: [_1] is unavailable to your user type: ',$srch->{'srchdomain'}).$insttype_str;
+ return &mt('Institutional directory search in domain: [_1] is not available to your user type: ',$showdom).$insttype_str;
}
} else {
$can_search = 1;
}
} else {
- return &mt('Directory search has not been configured for domain: [_1]',$srch->{'srchdomain'});
+ return &mt('Institutional directory search has not been configured for domain: [_1]',$showdom);
}
my %longtext = &Apache::lonlocal::texthash (
uname => 'username',
lastfirst => 'last name, first name',
lastname => 'last name',
- contains => 'is contained in',
- exact => 'as exact match to'
+ contains => 'contains',
+ exact => 'as exact match to',
+ begins => 'begins with',
);
if ($can_search) {
if (ref($dom_inst_srch{'directorysrch'}{'searchby'}) eq 'ARRAY') {
if (!grep(/^\Q$srch->{'srchby'}\E$/,@{$dom_inst_srch{'directorysrch'}{'searchby'}})) {
- return &mt('Directory search in domain: [_1] is not available for searching by [_2]',$srch->{'srchdomain'},$longtext{$srch->{'srchby'}});
+ return &mt('Institutional directory search in domain: [_1] is not available for searching by "[_2]"',$showdom,$longtext{$srch->{'srchby'}});
}
} else {
- return &mt('Directory search in domain: [_1] is not available.', $srch->{'srchdomain'});
+ return &mt('Institutional directory search in domain: [_1] is not available.', $showdom);
}
}
if ($can_search) {
- if (($dom_inst_srch{'directorysrch'}{'searchtypes'} eq 'specify') ||
- ($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'}});
+ if (ref($dom_inst_srch{'directorysrch'}{'searchtypes'}) eq 'ARRAY') {
+ if (grep(/^\Q$srch->{'srchtype'}\E/,@{$dom_inst_srch{'directorysrch'}{'searchtypes'}})) {
+ return 'ok';
+ } else {
+ return &mt('Institutional directory search in domain [_1] is not available for the requested search type: "[_2]"',$showdom,$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('Institutional directory search in domain [_1] is not available for the requested search type: "[_2]"',$showdom,$longtext{$srch->{'srchtype'}});
+ }
}
}
}
@@ -2430,32 +2511,41 @@ sub get_courseusers {
sub build_search_response {
my ($srch,%srch_results) = @_;
- my ($state,$response,$forcenewuser);
+ my ($currstate,$response,$forcenewuser);
my %names = (
'uname' => 'username',
'lastname' => 'last name',
'lastfirst' => 'last name, first name',
'crs' => 'this course',
- 'dom' => 'this domain',
- 'instd' => "your institution's directory",
+ 'dom' => 'LON-CAPA domain: ',
+ 'instd' => 'the institutional directory for domain: ',
);
my %single = (
+ begins => 'A match',
contains => 'A match',
- exact => 'An exact match',
+ exact => 'An exact match',
);
my %nomatch = (
+ begins => 'No match',
contains => 'No match',
- exact => 'No exact match',
+ exact => 'No exact match',
);
if (keys(%srch_results) > 1) {
- $state = 'select';
+ $currstate = 'select';
} else {
if (keys(%srch_results) == 1) {
- $state = 'modify';
- $response = &mt("$single{$srch->{'srchtype'}} was found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
+ $currstate = 'modify';
+ $response = &mt("$single{$srch->{'srchtype'}} was found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
+ if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
+ $response .= &display_domain_info($srch->{'srchdomain'});
+ }
} else {
- $response = ''.&mt("$nomatch{$srch->{'srchtype'}} found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'}).'';
+ $response = ''.&mt("$nomatch{$srch->{'srchtype'}} found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}",$srch->{'srchterm'});
+ if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
+ $response .= &display_domain_info($srch->{'srchdomain'});
+ }
+ $response .= '';
if ($srch->{'srchin'} ne 'alc') {
$forcenewuser = 1;
my $cansrchinst = 0;
@@ -2467,27 +2557,43 @@ sub build_search_response {
}
}
}
- if (($srch->{'srchby'} eq 'lastfirst') ||
- ($srch->{'srchby'} eq 'lastname')) {
- if ($srch->{'srchin'} eq 'crs') {
- $response .= ' '.&mt('You may want to broaden your search to the whole domain.');
- } elsif ($srch->{'srchin'} eq 'dom') {
- if ($cansrchinst) {
- $response .= ' '.&mt('You may want to broaden your search to a search of the institutional directory for this domain.');
- }
+ if ((($srch->{'srchby'} eq 'lastfirst') ||
+ ($srch->{'srchby'} eq 'lastname')) &&
+ ($srch->{'srchin'} eq 'dom')) {
+ if ($cansrchinst) {
+ $response .= ' '.&mt('You may want to broaden your search to a search of the institutional directory for the domain.');
}
}
+ if ($srch->{'srchin'} eq 'crs') {
+ $response .= ' '.&mt('You may want to broaden your search to the selected LON-CAPA domain.');
+ }
+ }
+ if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) {
+ my $showdom = &display_domain_info($env{'request.role.domain'});
+ $response .= '
'.&mt("To add a new user (you can only create new users in your current role's domain - [_1]):",$env{'request.role.domain'}).'
'.&mt("Set 'Domain/institution to search' to: [_1]",$showdom).'
'.&mt("Set 'Search criteria' to: 'username is ...... in selected LON-CAPA domain'").'