--- loncom/interface/loncreateuser.pm 2007/08/31 03:21:27 1.180
+++ loncom/interface/loncreateuser.pm 2007/10/03 13:45:58 1.184.2.1
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.180 2007/08/31 03:21:27 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.184.2.1 2007/10/03 13:45:58 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -699,12 +699,14 @@ ENDFORMINFO
if (($instsrch->{'srchterm'} ne '') && ($instsrch->{'srchdomain'} ne '')) {
$newuser = $instsrch->{'srchterm'}.':'.$instsrch->{'srchdomain'};
}
- my (%dirsrch_results,%inst_results);
+ my (%dirsrch_results,%inst_results,$dirsrchres);
if ($newuser) {
if (&directorysrch_check($instsrch) eq 'ok') {
- %dirsrch_results = &Apache::lonnet::inst_directory_query($instsrch);
- if (ref($dirsrch_results{$newuser}) eq 'HASH') {
- %inst_results = %{$dirsrch_results{$newuser}};
+ ($dirsrchres,%dirsrch_results) = &Apache::lonnet::inst_directory_query($instsrch);
+ if ($dirsrchres eq 'ok') {
+ if (ref($dirsrch_results{$newuser}) eq 'HASH') {
+ %inst_results = %{$dirsrch_results{$newuser}};
+ }
}
}
}
@@ -1012,11 +1014,8 @@ END
$loginscript = &Apache::loncommon::authform_header(%param);
}
# Check for a bad authentication type
- unless ($currentauth=~/^krb(4|5):/ or
- $currentauth=~/^unix:/ or
- $currentauth=~/^internal:/ or
- $currentauth=~/^localauth:/
- ) { # bad authentication scheme
+ if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) {
+ # bad authentication scheme
if (&Apache::lonnet::allowed('mau',$ccdomain)) {
&initialize_authen_forms();
my %lt=&Apache::lonlocal::texthash(
@@ -1111,11 +1110,22 @@ $lt{'yodo'} $lt{'ifch'}: $ccdomain
ENDNOPRIV
}
}
- if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
- # Current user has quota modification privileges
- $r->print(&portfolio_quota($ccuname,$ccdomain));
- }
} ## End of "check for bad authentication type" logic
+ if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
+ # Current user has quota modification privileges
+ $r->print(&portfolio_quota($ccuname,$ccdomain));
+ } elsif (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
+ my %lt=&Apache::lonlocal::texthash(
+ 'dska' => "Disk space allocated to user's portfolio files",
+ 'youd' => "You do not have privileges to modify the portfolio quota for this user.",
+ 'ichr' => "If a change is required, contact a domain coordinator for the domain",
+ );
+ $r->print(<
+
$lt{'dska'}
+$lt{'youd'} $lt{'ichr'}: $ccdomain
+ENDNOPORTPRIV
+ }
} ## End of new user/old user logic
$r->print('
'.&mt('Add Roles').'
');
#
@@ -1357,7 +1367,7 @@ sub update_user_data {
($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cstid'},
$amode,$genpwd,$env{'form.cfirst'},
$env{'form.cmiddle'},$env{'form.clast'},$env{'form.cgen'},
- undef,$desiredhost
+ undef,$desiredhost,$env{'form.cemail'}
);
$r->print(&mt('Generating user').': '.$result);
my $home = &Apache::lonnet::homeserver($env{'form.ccuname'},
@@ -2211,10 +2221,8 @@ sub user_search_result {
my %allhomes;
my %inst_matches;
my %srch_results;
- my ($response,$currstate,$forcenewuser);
- $srch->{'srchterm'} =~ s/^\s+//;
- $srch->{'srchterm'} =~ s/\s+$//;
-
+ my ($response,$currstate,$forcenewuser,$dirsrchres);
+ $srch->{'srchterm'} =~ s/\s+/ /g;
if ($srch->{'srchby'} !~ /^(uname|lastname|lastfirst)$/) {
$response = &mt('Invalid search.');
}
@@ -2227,6 +2235,9 @@ sub user_search_result {
if ($srch->{'srchterm'} eq '') {
$response = &mt('You must enter a search term.');
}
+ if ($srch->{'srchterm'} =~ /^\s+$/) {
+ $response = &mt('Your search term must contain more than just spaces.');
+ }
if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'instd')) {
if (($srch->{'srchdomain'} eq '') ||
! (&Apache::lonnet::domain($srch->{'srchdomain'}))) {
@@ -2324,9 +2335,18 @@ sub user_search_result {
} elsif ($srch->{'srchin'} eq 'alc') {
$currstate = 'query';
} elsif ($srch->{'srchin'} eq 'instd') {
- %srch_results = &Apache::lonnet::inst_directory_query($srch);
- ($currstate,$response,$forcenewuser) =
- &build_search_response($srch,%srch_results);
+ ($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch);
+ if ($dirsrchres eq 'ok') {
+ ($currstate,$response,$forcenewuser) =
+ &build_search_response($srch,%srch_results);
+ } else {
+ my $showdom = &display_domain_info($srch->{'srchdomain'});
+ $response = ''.
+ &mt('Institutional directory search is not available in domain: [_1]',$showdom).
+ '
'.
+ &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
+ '
';
+ }
}
} else {
if ($srch->{'srchin'} eq 'dom') {
@@ -2388,9 +2408,17 @@ sub user_search_result {
} elsif ($srch->{'srchin'} eq 'alc') {
$currstate = 'query';
} elsif ($srch->{'srchin'} eq 'instd') {
- %srch_results = &Apache::lonnet::inst_directory_query($srch);
- ($currstate,$response,$forcenewuser) =
- &build_search_response($srch,%srch_results);
+ ($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch);
+ if ($dirsrchres eq 'ok') {
+ ($currstate,$response,$forcenewuser) =
+ &build_search_response($srch,%srch_results);
+ } else {
+ my $showdom = &display_domain_info($srch->{'srchdomain'}); $response = ''.
+ &mt('Institutional directory search is not available in domain: [_1]',$showdom).
+ '
'.
+ &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
+ '
';
+ }
}
}
return ($currstate,$response,$forcenewuser,\%srch_results);
@@ -2549,7 +2577,8 @@ sub build_search_response {
}
}
if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $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 'Make new user if no match found' to 'Yes'").'
- '.&mt('Provide the proposed username').'
- '.&mt('Search').'
';
+ 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'").'
- '.&mt('Provide the proposed username').'
- '.&mt('Search').'
';
}
}
}