--- loncom/interface/loncreateuser.pm 2007/12/21 12:41:25 1.213 +++ loncom/interface/loncreateuser.pm 2008/02/22 05:05:57 1.235 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.213 2007/12/21 12:41:25 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.235 2008/02/22 05:05:57 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); @@ -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,66 +220,60 @@ 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,}); - if ($env{'form.action'} eq 'singleuser') { + if ($env{'form.action'} eq 'custom') { &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:backPage(document.crtuser)", - text=>"Single user search", - faq=>282,bug=>'Instructor Interface',}); - } elsif ($env{'form.action'} eq 'custom') { + text=>"Pick custom role",}); + } else { &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:backPage(document.crtuser)", - text=>"Pick custom role",}); + 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 edit user information or add/modify roles", ); - 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 'singleuser') { - $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'}); + if ($env{'form.popup'}) { + $r->print(''); + } else { + $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 { @@ -2324,7 +2411,7 @@ sub update_result_form { } $outcome .= ''."\n". ''."\n". - ''."\n". + ''."\n". ''; return $outcome; } @@ -2460,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( @@ -2600,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"]); @@ -2677,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 @@ -2708,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('