--- loncom/interface/loncreateuser.pm 2007/12/21 15:22:01 1.216 +++ loncom/interface/loncreateuser.pm 2008/01/01 17:24:59 1.227 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.216 2007/12/21 15:22:01 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.227 2008/01/01 17:24:59 raeburn 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); @@ -233,7 +233,14 @@ sub print_username_entry_form { text=>"Single user 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)); @@ -249,9 +256,6 @@ sub print_username_entry_form { '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; @@ -263,16 +267,16 @@ sub print_username_entry_form {
ENDCUSTOM } } else { - my $actiontext = $lt{'mod'}.$helpsiur; + my $actiontext = $lt{'mod'}; if ($env{'form.action'} eq 'singlestudent') { - $actiontext = $lt{'enrl'}.$helpsist; + $actiontext = $lt{'enrl'}; } $r->print("'. &mt('Enroll Another Student').'
'); + } else { + my @rolechanges = &update_roles($r); + if ($namechanged) { + if ($context eq 'course') { + if (@userroles > 0) { + if ((@rolechanges == 0) || + (!(grep(/^st$/,@rolechanges)))) { + if (grep(/^st$/,@userroles)) { + my $classlistupdated = + &Apache::lonuserutils::update_classlist($cdom, + $cnum,$env{'form.ccdomain'}, + $env{'form.ccuname'},\%userupdate); + } + } + } + } + } + my $userinfo = &Apache::loncommon::plainname($env{'form.ccuname'}, + $env{'form.ccdomain'}); + $r->print(''.&mt('Modify this user: ([_1])',$userinfo).''.(' 'x5).''.&mt('Create/Modify Another User').'
'); + } + $r->print(&Apache::loncommon::end_page()); +} + +sub update_roles { + my ($r) = @_; my $now=time; - my $rolechanges = 0; + my @rolechanges; + my %disallowed; $r->print(''.&mt('ERROR').': '.&mt('Unknown command').' '.$key.'
".&mt('If the student is currently logged-in to LON-CAPA, the new role will be available when the student next logs in.')."
"); + } + } else { + $r->print(&mt('unable to enroll').": ".$enroll_result); + } + return; } sub get_defaultquota_text { @@ -2265,7 +2357,7 @@ sub update_result_form { } $outcome .= ''."\n". ''."\n". - ''."\n". + ''."\n". ''; return $outcome; } @@ -2401,7 +2493,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( @@ -2541,7 +2634,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"]); @@ -2649,17 +2743,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('