--- loncom/interface/loncreateuser.pm 2007/12/21 16:23:54 1.218
+++ loncom/interface/loncreateuser.pm 2008/03/07 11:19:16 1.236
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.218 2007/12/21 16:23:54 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.236 2008/03/07 11:19:16 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -76,30 +76,30 @@ my $authformfsys;
my $authformloc;
sub initialize_authen_forms {
- my ($dom,$curr_authtype,$mode) = @_;
- my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/);
- $krbdefdom= uc($krbdefdom);
- my %param = ( formname => 'document.cu',
+ my ($dom,$formname,$curr_authtype,$mode) = @_;
+ my ($krbdef,$krbdefdom) = &Apache::loncommon::get_kerberos_defaults($dom);
+ my %param = ( formname => $formname,
kerb_def_dom => $krbdefdom,
+ kerb_def_auth => $krbdef,
domain => $dom,
);
my %abv_auth = &auth_abbrev();
- if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):$/) {
+ if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):(.*)$/) {
my $long_auth = $1;
+ my $curr_autharg = $2;
my %abv_auth = &auth_abbrev();
$param{'curr_authtype'} = $abv_auth{$long_auth};
if ($long_auth =~ /^krb(4|5)$/) {
$param{'curr_kerb_ver'} = $1;
+ $param{'curr_autharg'} = $curr_autharg;
}
if ($mode eq 'modifyuser') {
$param{'mode'} = $mode;
}
}
-# no longer static due to configurable kerberos defaults
-# $loginscript = &Apache::loncommon::authform_header(%param);
+ $loginscript = &Apache::loncommon::authform_header(%param);
+ $authformkrb = &Apache::loncommon::authform_kerberos(%param);
$authformnop = &Apache::loncommon::authform_nochange(%param);
-# no longer static due to configurable kerberos defaults
-# $authformkrb = &Apache::loncommon::authform_kerberos(%param);
$authformint = &Apache::loncommon::authform_internal(%param);
$authformfsys = &Apache::loncommon::authform_filesystem(%param);
$authformloc = &Apache::loncommon::authform_local(%param);
@@ -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,32 +231,29 @@ 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 $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management');
+ my $helpitem = 'Course_Change_Privileges';
+ if ($env{'form.action'} eq 'custom') {
+ $helpitem = 'Course_Editing_Custom_Roles';
+ } elsif ($env{'form.action'} eq 'singlestudent') {
+ $helpitem = 'Course_Add_Student';
+ }
+ my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management',
+ $helpitem);
my %existingroles=&Apache::lonuserutils::my_custom_roles();
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 $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges');
- my $helpsist=&Apache::loncommon::help_open_topic('Course_Add_Student');
- my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles');
- 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','/')) {
@@ -263,19 +261,19 @@ sub print_username_entry_form {
ENDCUSTOM
}
} else {
- my $actiontext = $lt{'mod'}.$helpsiur;
+ my $actiontext = $lt{'srad'};
if ($env{'form.action'} eq 'singlestudent') {
- $actiontext = $lt{'enrl'}.$helpsist;
+ $actiontext = $lt{'srst'};
}
$r->print("
-$lt{'srch'} $sellink $actiontext
");
+$actiontext
");
if ($env{'form.origform'} ne 'crtusername') {
$r->print("\n".$response);
}
@@ -287,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') &&
@@ -297,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 =
@@ -305,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 $helpcrt=&Apache::loncommon::help_open_topic('Course_Change_Privileges');
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";
+
@@ -377,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'};
@@ -412,27 +440,24 @@ 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',});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
+
+ 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(''.$lt{'usel'}.'
');
- } elsif ($operation eq 'enrollstudent') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.usersrchform,'','')",
- text=>"Create/modify student",
- faq=>282,bug=>'Instructor Interface',},
- {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
- text=>"Select Student",
- faq=>282,bug=>'Instructor Interface',});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
+ } elsif ($env{'form.action'} eq 'singlestudent') {
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
+ 'Course_Add_Student'));
$r->print($jscript."$lt{'stusrch'}
");
$r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
$r->print(''.$lt{'stusel'}.'
');
@@ -509,8 +534,7 @@ sub print_user_modification_page {
$formname = 'cu';
}
my %abv_auth = &auth_abbrev();
- my ($curr_authtype,%rulematch,%inst_results,$curr_kerb_ver,$newuser,
- %alerts,%curr_rules,%got_rules);
+ my (%rulematch,%inst_results,$newuser,%alerts,%curr_rules,%got_rules);
my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
if ($uhome eq 'no_host') {
my $usertype;
@@ -565,32 +589,10 @@ sub print_user_modification_page {
}
} else {
$newuser = 0;
- my $currentauth =
- &Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
- if ($currentauth =~ /^(krb4|krb5|unix|internal|localauth):/) {
- $curr_authtype = $abv_auth{$1};
- if ($currentauth =~ /^krb(4|5)/) {
- $curr_kerb_ver = $1;
- }
- }
}
if ($response) {
$response = '
'.$response;
}
- my $defdom=$env{'request.role.domain'};
-
- my ($krbdef,$krbdefdom) =
- &Apache::loncommon::get_kerberos_defaults($defdom);
-
- my %param = ( formname => 'document.cu',
- kerb_def_dom => $krbdefdom,
- kerb_def_auth => $krbdef,
- curr_authtype => $curr_authtype,
- curr_kerb_ver => $curr_kerb_ver,
- domain => $ccdomain,
- );
- $loginscript = &Apache::loncommon::authform_header(%param);
- $authformkrb = &Apache::loncommon::authform_kerberos(%param);
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
my $dc_setcourse_code = '';
@@ -601,9 +603,12 @@ sub print_user_modification_page {
my $js = &validation_javascript($context,$ccdomain,$pjump_def,
$groupslist,$newuser,$formname,\%loaditem);
+ my $args = {'add_entries' => \%loaditem};
+ if ($env{'form.popup'}) {
+ $args->{'no_nav_bar'} = 1;
+ }
my $start_page =
- &Apache::loncommon::start_page('User Management',
- $js,{'add_entries' => \%loaditem,});
+ &Apache::loncommon::start_page('User Management',$js,$args);
my %breadcrumb_text = &singleuser_breadcrumb();
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:backPage($form)",
@@ -620,7 +625,12 @@ sub print_user_modification_page {
({href=>"javascript:backPage($form,'$env{'form.phase'}','modify')",
text=>$breadcrumb_text{'modify'},
faq=>282,bug=>'Instructor Interface',});
- my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management');
+ my $helpitem = 'Course_Change_Privileges';
+ if ($env{'form.action'} eq 'singlestudent') {
+ $helpitem = 'Course_Add_Student';
+ }
+ my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management',
+ $helpitem);
my $forminfo =<<"ENDFORMINFO";
';
return $outcome;
}
@@ -2437,7 +2547,8 @@ sub custom_role_editor {
{href=>"javascript:backPage(document.form1,'','')",
text=>"Edit custom role",
faq=>282,bug=>'Instructor Interface',});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
+ 'Course_Editing_Custom_Roles'));
$r->print($body_top);
my %lt=&Apache::lonlocal::texthash(
@@ -2445,7 +2556,7 @@ sub custom_role_editor {
'crl' => "Course Level",
'dml' => "Domain Level",
'ssl' => "System Level");
- $r->print('Select a Template
');
+ $r->print(&mt('Select a Template').'
');
$r->print('');
@@ -2577,7 +2688,8 @@ sub set_custom_role {
{href=>"javascript:backPage(document.customresult,'set_custom_roles','')",
text=>"Result",
faq=>282,bug=>'Instructor Interface',});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
+ 'Course_Editing_Custom_Roles'));
my ($rdummy,$roledef)=
&Apache::lonnet::get('roles',["rolesdef_$rolename"]);
@@ -2654,7 +2766,8 @@ sub handler {
$context = 'domain';
}
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['action','state','callingform','roletype','showrole','bulkaction']);
+ ['action','state','callingform','roletype','showrole','bulkaction','popup','phase',
+ 'username','domain','srchterm','srchdomain','srchin','srchby','srchtype']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
if ($env{'form.action'} ne 'dateselect') {
&Apache::lonhtmlcommon::add_breadcrumb
@@ -2685,17 +2798,18 @@ sub handler {
({href=>'/adm/createuser?action=upload&state=',
text=>"Upload Users List"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Upload Users List',
- 'User_Management_Upload'));
+ 'Course_Create_Class_List'));
$r->print('