--- loncom/interface/loncreateuser.pm 2007/08/15 16:25:14 1.172
+++ loncom/interface/loncreateuser.pm 2007/08/26 15:31:03 1.178
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.172 2007/08/15 16:25:14 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.178 2007/08/26 15:31:03 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -783,7 +783,7 @@ ENDCHANGEUSER
'
'.$lt{'fn'}.' | '.$lt{'mn'}.' | '.$lt{'ln'}.' | '.$lt{'gen'}.' | '.$lt{'email'}.' | '.
&Apache::loncommon::end_data_table_header_row().
&Apache::loncommon::start_data_table_row());
- foreach my $item ('firstname','middlename','lastname','generation','permenanentemail') {
+ foreach my $item ('firstname','middlename','lastname','generation','permanentemail') {
if (&Apache::lonnet::allowed('mau',$ccdomain)) {
$r->print(<<"END");
|
@@ -1446,7 +1446,7 @@ sub update_user_data {
$changeHash{'middlename'} = $env{'form.cmiddlename'};
$changeHash{'lastname'} = $env{'form.clastname'};
$changeHash{'generation'} = $env{'form.cgeneration'};
- $changeHash{'permanentemail'} = $env{'form.permanentemail'};
+ $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
my $putresult = &Apache::lonnet::put
('environment',\%changeHash,
$env{'form.ccdomain'},$env{'form.ccuname'});
@@ -1471,7 +1471,8 @@ sub update_user_data {
$lt{'mddl'} |
$lt{'lst'} |
$lt{'gen'} |
- $lt{'disk'} |
+ | $lt{'mail'} |
+ $lt{'disk'} |
$lt{'prvs'} |
$userenv{'firstname'} |
$userenv{'middlename'} |
@@ -2193,14 +2194,16 @@ sub user_search_result {
my %inst_matches;
my %srch_results;
my ($response,$state,$forcenewuser);
+ $srch->{'srchterm'} =~ s/^\s+//;
+ $srch->{'srchterm'} =~ s/\s+$//;
- if ($srch->{'srchby'} !~ /^(uname|lastname|lastfirst)$/) {
+ if ($srch->{'srchby'} !~ /^(uname|lastname|lastfirst)$/) {
$response = &mt('Invalid search.');
}
if ($srch->{'srchin'} !~ /^(crs|dom|alc|instd)$/) {
$response = &mt('Invalid search.');
}
- if ($srch->{'srchtype'} !~ /^(exact|contains)$/) {
+ if ($srch->{'srchtype'} !~ /^(exact|contains|begins)$/) {
$response = &mt('Invalid search.');
}
if ($srch->{'srchterm'} eq '') {
@@ -2214,8 +2217,10 @@ sub user_search_result {
}
if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs') ||
($srch->{'srchin'} eq 'alc')) {
- if ($srch->{'srchterm'} !~ /^$match_username$/) {
- $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');
+ if ($srch->{'srchby'} eq 'uname') {
+ if ($srch->{'srchterm'} !~ /^$match_username$/) {
+ $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');
+ }
}
}
if ($srch->{'srchin'} eq 'instd') {
@@ -2269,7 +2274,17 @@ sub user_search_result {
foreach my $user (keys(%$courseusers)) {
my ($cuname,$cudomain) = split(/:/,$user);
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} =
{&Apache::lonnet::get('environment',
['firstname',
@@ -2304,6 +2319,8 @@ sub user_search_result {
if ($srch->{'srchby'} eq 'lastname') {
if ((($srch->{'srchtype'} eq 'exact') &&
($names{'lastname'} eq $srch->{'srchterm'})) ||
+ (($srch->{'srchtype'} eq 'begins') &&
+ ($names{'lastname'} =~ /^\Q$srch->{'srchterm'}\E/i)) ||
(($srch->{'srchtype'} eq 'contains') &&
($names{'lastname'} =~ /\Q$srch->{'srchterm'}\E/i))) {
$srch_results{$user} = {firstname => $names{'firstname'},
@@ -2313,6 +2330,8 @@ sub user_search_result {
}
} elsif ($srch->{'srchby'} eq 'lastfirst') {
my ($srchlast,$srchfirst) = split(/,/,$srch->{'srchterm'});
+ $srchlast =~ s/\s+$//;
+ $srchfirst =~ s/^\s+//;
if ($srch->{'srchtype'} eq 'exact') {
if (($names{'lastname'} eq $srchlast) &&
($names{'firstname'} eq $srchfirst)) {
@@ -2322,7 +2341,15 @@ 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) &&
($names{'firstname'} =~ /\Q$srchfirst\E/i)) {
$srch_results{$user} = {firstname => $names{'firstname'},
@@ -2392,7 +2419,8 @@ sub directorysrch_check {
lastfirst => 'last name, first name',
lastname => 'last name',
contains => 'contains',
- exact => 'as exact match to'
+ exact => 'as exact match to',
+ begins => 'begins with',
);
if ($can_search) {
if (ref($dom_inst_srch{'directorysrch'}{'searchby'}) eq 'ARRAY') {
@@ -2404,11 +2432,20 @@ sub directorysrch_check {
}
}
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('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'}});
+ }
}
}
}