--- loncom/interface/loncreateuser.pm 2008/01/02 09:16:59 1.228
+++ loncom/interface/loncreateuser.pm 2008/01/21 01:45:04 1.234
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.228 2008/01/02 09:16:59 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.234 2008/01/21 01:45:04 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -156,21 +156,21 @@ END_SCRIPT
$custom_off = ' ';
$showquota = $currquota;
if ($longinsttype eq '') {
- $defaultinfo = &mt('For this user, the default quota would be [_1]
- Mb.',$defquota);
+ $defaultinfo = &mt('For this user, the default quota would be [_1]'
+ .' Mb.',$defquota);
} else {
- $defaultinfo = &mt("For this user, the default quota would be [_1]
- Mb, as determined by the user's institutional
- affiliation ([_2]).",$defquota,$longinsttype);
+ $defaultinfo = &mt("For this user, the default quota would be [_1]".
+ " Mb, as determined by the user's institutional".
+ " affiliation ([_2]).",$defquota,$longinsttype);
}
} else {
if ($longinsttype eq '') {
- $defaultinfo = &mt('For this user, the default quota is [_1]
- Mb.',$defquota);
+ $defaultinfo = &mt('For this user, the default quota is [_1]'
+ .' Mb.',$defquota);
} else {
- $defaultinfo = &mt("For this user, the default quota of [_1]
- Mb, is determined by the user's institutional
- affiliation ([_2]).",$defquota,$longinsttype);
+ $defaultinfo = &mt("For this user, the default quota of [_1]".
+ " Mb, is determined by the user's institutional".
+ " affiliation ([_2]).",$defquota,$longinsttype);
}
}
my $output = $quota_javascript.
@@ -220,6 +220,7 @@ sub print_username_entry_form {
my %loaditems = (
'onload' => "javascript:setFormElements(document.$formtoset)",
);
+ my %breadcrumb_text = &singleuser_breadcrumb();
my $start_page =
&Apache::loncommon::start_page('User Management',
$jscript,{'add_entries' => \%loaditems,});
@@ -230,7 +231,7 @@ sub print_username_entry_form {
} else {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:backPage(document.crtuser)",
- text=>"Single user search",
+ text=>$breadcrumb_text{'search'},
faq=>282,bug=>'Instructor Interface',});
}
my $helpitem = 'Course_Change_Privileges';
@@ -245,21 +246,14 @@ sub print_username_entry_form {
my $choice=&Apache::loncommon::select_form('make new role','rolename',
('make new role' => 'Generate new role ...',%existingroles));
my %lt=&Apache::lonlocal::texthash(
- 'srch' => "User Search",
- or => "or",
+ 'srst' => 'Search for a user and enroll as a student',
+ 'srad' => 'Search for a user and modify/add user information or roles',
'usr' => "Username",
'dom' => "Domain",
'ecrp' => "Edit Custom Role Privileges",
'nr' => "Name of Role",
'cre' => "Custom Role Editor",
- 'mod' => "to modify user information or add/modify roles",
- 'enrl' => "to enroll one student",
);
- my $help = &Apache::loncommon::help_open_menu(undef,undef,282,'Instructor Interface');
- my $sellink=&Apache::loncommon::selectstudent_link('crtuser','srchterm','srchdomain');
- if ($sellink) {
- $sellink = "$lt{'or'} ".$sellink;
- }
$r->print($start_page."\n".$crumbs);
if ($env{'form.action'} eq 'custom') {
if (&Apache::lonnet::allowed('mcr','/')) {
@@ -274,12 +268,12 @@ $lt{'nr'}: $choice print("
-
$lt{'srch'} $sellink $actiontext
");
+
$actiontext
");
if ($env{'form.origform'} ne 'crtusername') {
$r->print("\n".$response);
}
@@ -291,7 +285,7 @@ ENDCUSTOM
sub entry_form {
my ($dom,$srch,$forcenewuser,$context,$responsemsg) = @_;
my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
- my $usertype;
+ my ($usertype,$inexact);
if (ref($srch) eq 'HASH') {
if (($srch->{'srchin'} eq 'dom') &&
($srch->{'srchby'} eq 'uname') &&
@@ -301,6 +295,8 @@ sub entry_form {
my ($rules,$ruleorder) =
&Apache::lonnet::inst_userrules($srch->{'srchdomain'},'username');
$usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules);
+ } else {
+ $inexact = 1;
}
}
my $cancreate =
@@ -309,6 +305,11 @@ sub entry_form {
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser,
'document.crtuser',$cancreate,$usertype);
my $srchbutton = &mt('Search');
+ if ($env{'form.action'} eq 'singlestudent') {
+ $srchbutton = &mt('Search and Enroll');
+ } elsif ($cancreate && $responsemsg ne '' && $inexact) {
+ $srchbutton = &mt('Search or Add New User');
+ }
my $output = <<"ENDBLOCK";
ENDBLOCK
- if ($cancreate && $env{'form.phase'} eq '') {
+ if ($env{'form.phase'} eq '') {
my $defdom=$env{'request.role.domain'};
my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
my %lt=&Apache::lonlocal::texthash(
+ 'enro' => 'Enroll one student',
+ 'admo' => 'Add/modify a single user',
+ 'crea' => 'create new user if required',
+ 'uskn' => "username is known",
'crnu' => 'Create a new user',
'usr' => 'Username',
'dom' => 'in domain',
- 'cra' => 'Create user',
+ 'enrl' => 'Enroll',
+ 'cram' => 'Create/Modify user',
);
+ my $sellink=&Apache::loncommon::selectstudent_link('crtusername','srchterm','srchdomain');
+ my ($title,$buttontext,$showresponse);
+ if ($env{'form.action'} eq 'singlestudent') {
+ $title = $lt{'enro'};
+ $buttontext = $lt{'enrl'};
+ } else {
+ $title = $lt{'admo'};
+ $buttontext = $lt{'cram'};
+ }
+ if ($cancreate) {
+ $title .= ' ('.$lt{'crea'}.')';
+ } else {
+ $title .= ' ('.$lt{'uskn'}.')';
+ }
+ if ($env{'form.origform'} eq 'crtusername') {
+ $showresponse = $responsemsg;
+ }
$output .= <<"ENDDOCUMENT";
+
@@ -380,7 +405,7 @@ END
# =================================================================== Phase two
sub print_user_selection_page {
- my ($r,$response,$srch,$srch_results,$operation,$srcharray,$context) = @_;
+ my ($r,$response,$srch,$srch_results,$srcharray,$context) = @_;
my @fields = ('username','domain','lastname','firstname','permanentemail');
my $sortby = $env{'form.sortby'};
@@ -415,27 +440,22 @@ ENDSCRIPT
'permanentemail' => "permanent e-mail",
);
$r->print(&Apache::loncommon::start_page('User Management',$jscript));
- if ($operation eq 'createuser') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.usersrchform,'','')",
- text=>"Create/modify user",
- faq=>282,bug=>'Instructor Interface',},
- {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
- text=>"Select User",
- faq=>282,bug=>'Instructor Interface',});
+
+ my %breadcrumb_text = &singleuser_breadcrumb();
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:backPage(document.usersrchform,'','')",
+ text=>$breadcrumb_text{'search'},
+ faq=>282,bug=>'Instructor Interface',},
+ {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
+ text=>$breadcrumb_text{'userpicked'},
+ faq=>282,bug=>'Instructor Interface',});
+ if ($env{'form.action'} eq 'singleuser') {
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
'Course_Change_Privileges'));
$r->print("$lt{'usrch'} ");
$r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
$r->print('
'.&mt("You are not authorized to create new users in your current role's domain - [_1].",$env{'request.role.domain'}).' '.&mt('Contact the helpdesk if you need to create a new user.',$helplink).'