--- loncom/interface/loncreateuser.pm 2010/01/19 21:29:50 1.295.2.23 +++ loncom/interface/loncreateuser.pm 2009/09/23 03:47:53 1.295.8.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.295.2.23 2010/01/19 21:29:50 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.295.8.1 2009/09/23 03:47:53 gci Exp $ # # Copyright Michigan State University Board of Trustees # @@ -466,7 +466,7 @@ sub courserequest_display { # =================================================================== Phase one sub print_username_entry_form { - my ($r,$context,$response,$srch,$forcenewuser,$crstype) = @_; + my ($r,$context,$response,$srch,$forcenewuser) = @_; my $defdom=$env{'request.role.domain'}; my $formtoset = 'crtuser'; if (exists($env{'form.startrolename'})) { @@ -488,7 +488,7 @@ sub print_username_entry_form { my %loaditems = ( 'onload' => "javascript:setFormElements(document.$formtoset)", ); - my %breadcrumb_text = &singleuser_breadcrumb($crstype); + my %breadcrumb_text = &singleuser_breadcrumb(); my $start_page = &Apache::loncommon::start_page('User Management', $jscript,{'add_entries' => \%loaditems,}); @@ -515,8 +515,6 @@ sub print_username_entry_form { ('make new role' => 'Generate new role ...',%existingroles)); my %lt=&Apache::lonlocal::texthash( 'srst' => 'Search for a user and enroll as a student', - 'srme' => 'Search for a user and enroll as a member', - 'srad' => 'Search for a user and modify/add user information or roles', 'usr' => "Username", 'dom' => "Domain", @@ -540,23 +538,20 @@ ENDCUSTOM } else { my $actiontext = $lt{'srad'}; if ($env{'form.action'} eq 'singlestudent') { - if ($crstype eq 'Community') { - $actiontext = $lt{'srme'}; - } else { - $actiontext = $lt{'srst'}; - } + $actiontext = $lt{'srst'}; } - $r->print("

$actiontext

"); + $r->print(" +

$actiontext

"); if ($env{'form.origform'} ne 'crtusername') { $r->print("\n".$response); } - $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype)); + $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response)); } $r->print(&Apache::loncommon::end_page()); } sub entry_form { - my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype) = @_; + my ($dom,$srch,$forcenewuser,$context,$responsemsg) = @_; my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); my ($usertype,$inexact); if (ref($srch) eq 'HASH') { @@ -596,7 +591,6 @@ ENDBLOCK my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); my %lt=&Apache::lonlocal::texthash( 'enro' => 'Enroll one student', - 'enrm' => 'Enroll one member', 'admo' => 'Add/modify a single user', 'crea' => 'create new user if required', 'uskn' => "username is known", @@ -609,11 +603,7 @@ ENDBLOCK my $sellink=&Apache::loncommon::selectstudent_link('crtusername','srchterm','srchdomain'); my ($title,$buttontext,$showresponse); if ($env{'form.action'} eq 'singlestudent') { - if ($crstype eq 'Community') { - $title = $lt{'enrm'}; - } else { - $title = $lt{'enro'}; - } + $title = $lt{'enro'}; $buttontext = $lt{'enrl'}; } else { $title = $lt{'admo'}; @@ -684,7 +674,7 @@ END # =================================================================== Phase two sub print_user_selection_page { - my ($r,$response,$srch,$srch_results,$srcharray,$context,$opener_elements,$crstype) = @_; + my ($r,$response,$srch,$srch_results,$srcharray,$context,$opener_elements) = @_; my @fields = ('username','domain','lastname','firstname','permanentemail'); my $sortby = $env{'form.sortby'}; @@ -712,10 +702,8 @@ ENDSCRIPT my %lt=&Apache::lonlocal::texthash( 'usrch' => "User Search to add/modify roles", 'stusrch' => "User Search to enroll student", - 'memsrch' => "User Search to enroll member", 'usel' => "Select a user to add/modify roles", - 'stusel' => "Select a user to enroll as a student", - 'memsel' => "Select a user to enroll as a member", + 'stusel' => "Select a user to enroll as a student", 'username' => "username", 'domain' => "domain", 'lastname' => "last name", @@ -727,7 +715,7 @@ ENDSCRIPT } else { $r->print(&Apache::loncommon::start_page('User Management',$jscript)); - my %breadcrumb_text = &singleuser_breadcrumb($crstype); + my %breadcrumb_text = &singleuser_breadcrumb(); &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:backPage(document.usersrchform,'','')", text=>$breadcrumb_text{'search'}, @@ -739,26 +727,14 @@ ENDSCRIPT $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management', 'Course_Change_Privileges')); $r->print("$lt{'usrch'}
"); - $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context,undef,$crstype)); + $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context)); $r->print('

'.$lt{'usel'}.'

'); } elsif ($env{'form.action'} eq 'singlestudent') { $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management', 'Course_Add_Student')); - $r->print($jscript.""); - if ($crstype eq 'Community') { - $r->print($lt{'memsrch'}); - } else { - $r->print($lt{'stusrch'}); - } - $r->print("
"); - $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context,undef,$crstype)); - $r->print('

'); - if ($crstype eq 'Community') { - $r->print($lt{'memsel'}); - } else { - $r->print($lt{'stusel'}); - } - $r->print('

'); + $r->print($jscript."$lt{'stusrch'}
"); + $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context)); + $r->print('

'.$lt{'stusel'}.'

'); } } $r->print('
'. @@ -833,11 +809,11 @@ sub print_user_query_page { } sub print_user_modification_page { - my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission,$crstype) = @_; + my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission) = @_; if (($ccuname eq '') || ($ccdomain eq '')) { my $usermsg = &mt('No username and/or domain provided.'); $env{'form.phase'} = ''; - &print_username_entry_form($r,$context,$usermsg,'','',$crstype); + &print_username_entry_form($r,$context,$usermsg); return; } my ($form,$formname); @@ -878,7 +854,7 @@ sub print_user_modification_page { ,'','') .'


'; $env{'form.phase'} = ''; - &print_username_entry_form($r,$context,$response,undef,undef,$crstype); + &print_username_entry_form($r,$context,$response); return; } $newuser = 1; @@ -902,7 +878,7 @@ sub print_user_modification_page { 'username'); } $env{'form.phase'} = ''; - &print_username_entry_form($r,$context,$userchkmsg,undef,undef,$crstype); + &print_username_entry_form($r,$context,$userchkmsg); return; } } @@ -929,7 +905,7 @@ sub print_user_modification_page { } my $start_page = &Apache::loncommon::start_page('User Management',$js,$args); - my %breadcrumb_text = &singleuser_breadcrumb($crstype); + my %breadcrumb_text = &singleuser_breadcrumb(); &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:backPage($form)", text=>$breadcrumb_text{'search'}, @@ -978,7 +954,6 @@ ENDFORMINFO my %lt=&Apache::lonlocal::texthash( 'cnu' => 'Create New User', 'ast' => 'as a student', - 'ame' => 'as a member', 'ind' => 'in domain', 'lg' => 'Login Data', 'hs' => "Home Server", @@ -997,11 +972,7 @@ $loginscript

$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain ENDTITLE if ($env{'form.action'} eq 'singlestudent') { - if ($crstype eq 'Community') { - $r->print(' ('.$lt{'ame'}.')'); - } else { - $r->print(' ('.$lt{'ast'}.')'); - } + $r->print(' ('.$lt{'ast'}.')'); } $r->print('

'."\n".'
'); my $personal_table = @@ -1020,7 +991,7 @@ $lt{'hs'}: $home_server_pick $r->print($home_server_pick); } if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { - $r->print('

'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'

'. + $r->print('

'.&mt('User Can Request Creation of Courses in this Domain?').'

'. &Apache::loncommon::start_data_table(). &build_tools_display($ccuname,$ccdomain, 'requestcourses'). @@ -1094,7 +1065,6 @@ ENDAUTH my %lt=&Apache::lonlocal::texthash( 'cup' => "Modify existing user: ", 'ens' => "Enroll one student: ", - 'enm' => "Enroll one member: ", 'id' => "in domain", ); $r->print(< ENDCHANGEUSER if ($env{'form.action'} eq 'singlestudent') { - if ($crstype eq 'Community') { - $r->print($lt{'enm'}); - } else { - $r->print($lt{'ens'}); - } + $r->print($lt{'ens'}); } else { $r->print($lt{'cup'}); } @@ -1122,7 +1088,7 @@ ENDCHANGEUSER $r->print(&Apache::lonuserutils::forceid_change($context)); } if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { - $r->print('

'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'

'. + $r->print('

'.&mt('User Can Request Creation of Courses in this Domain?').'

'. &Apache::loncommon::start_data_table()); if ($env{'request.role.domain'} eq $ccdomain) { $r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses')); @@ -1206,13 +1172,7 @@ ENDNOTOOLSPRIV } ## End of new user/old user logic if ($env{'form.action'} eq 'singlestudent') { - my $btntxt; - if ($crstype eq 'Community') { - $btntxt = &mt('Enroll Member'); - } else { - $btntxt = &mt('Enroll Student'); - } - $r->print('
'."\n"); + $r->print('
'."\n"); } else { $r->print('

'.&mt('Add Roles').'

'); my $addrolesdisplay = 0; @@ -1251,14 +1211,9 @@ ENDNOTOOLSPRIV } sub singleuser_breadcrumb { - my ($crstype) = @_; my %breadcrumb_text; if ($env{'form.action'} eq 'singlestudent') { - if ($crstype eq 'Community') { - $breadcrumb_text{'search'} = 'Enroll a member'; - } else { - $breadcrumb_text{'search'} = 'Enroll a student'; - } + $breadcrumb_text{'search'} = 'Enroll a student'; $breadcrumb_text{'userpicked'} = 'Select a user', $breadcrumb_text{'modify'} = 'Set section/dates', } else { @@ -1473,9 +1428,9 @@ sub display_existing_roles { } $row.= ''.$plaintext. ''.$area. - ''.($role_start_time?&Apache::lonlocal::locallocaltime($role_start_time) + ''.($role_start_time?localtime($role_start_time) : ' ' ). - ''.($role_end_time ?&Apache::lonlocal::locallocaltime($role_end_time) + ''.($role_end_time ?localtime($role_end_time) : ' ' ) .""; $sortrole{$sortkey}=$envkey; @@ -1486,7 +1441,7 @@ sub display_existing_roles { } # end of foreach (table building loop) my $rolesdisplay = 0; my %output = (); - foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') { + foreach my $type ('Construction Space','Course','Group','Domain','System','Unknown') { $output{$type} = ''; foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) { if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) { @@ -1506,8 +1461,7 @@ sub display_existing_roles { if ($rolesdisplay == 1) { my $contextrole=''; if ($env{'request.course.id'}) { - my $crstype = &Apache::loncommon::course_type(); - $contextrole = "Existing Roles in this $crstype"; + $contextrole = 'Existing Roles in this Course'; } elsif ($env{'request.role'} =~ /^au\./) { $contextrole = 'Existing Co-Author Roles in your Construction Space'; } else { @@ -1522,7 +1476,7 @@ sub display_existing_roles { ''.$lt{'rol'}.''.$lt{'ext'}. ''.$lt{'sta'}.''.$lt{'end'}.''. &Apache::loncommon::end_data_table_header_row()); - foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') { + foreach my $type ('Construction Space','Course','Group','Domain','System','Unknown') { if ($output{$type}) { $r->print($output{$type}."\n"); } @@ -2017,7 +1971,7 @@ sub get_inststatuses { # ================================================================= Phase Three sub update_user_data { - my ($r,$context,$crstype) = @_; + my ($r,$context) = @_; my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'}, $env{'form.ccdomain'}); # Error messages @@ -2041,7 +1995,7 @@ sub update_user_data { $jsback."\n". '// ]]>'."\n". ''."\n"; - my %breadcrumb_text = &singleuser_breadcrumb($crstype); + my %breadcrumb_text = &singleuser_breadcrumb(); my $args; if ($env{'form.popup'}) { $args->{'no_nav_bar'} = 1; @@ -2273,10 +2227,9 @@ sub update_user_data { } } ## - my (@userroles,%userupdate,$cnum,$cdom,$crstype,$namechanged); + my (@userroles,%userupdate,$cnum,$cdom,$namechanged); if ($context eq 'course') { ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity(); - $crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum); } if (! $env{'form.makeuser'} ) { # Check for need to change @@ -2360,7 +2313,7 @@ sub update_user_data { if ($role eq 'cr') { push(@longroles,'Custom'); } else { - push(@longroles,&Apache::lonnet::plaintext($role,$crstype)); + push(@longroles,&Apache::lonnet::plaintext($role)); } } my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); @@ -2545,7 +2498,8 @@ sub update_user_data { $newenvhash{'environment.requestcourses.'.$key} = $changeHash{'requestcourses.'.$key}; if ($changeHash{'requestcourses.'.$key} ne '') { - $newenvhash{'environment.canrequest.'.$key} = 1; + $newenvhash{'environment.canrequest.'.$key} = + $changeHash{'requestcourses.'.$key}; } else { $newenvhash{'environment.canrequest.'.$key} = &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, @@ -2825,14 +2779,9 @@ END .''); } if ($env{'form.action'} eq 'singlestudent') { - &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype); - $r->print('

'); - if ($crstype eq 'Community') { - $r->print(&mt('Enroll Another Member')); - } else { - $r->print(&mt('Enroll Another Student')); - } - $r->print('

'); + &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context); + $r->print('

'. + &mt('Enroll Another Student').'

'); } else { my @rolechanges = &update_roles($r,$context); if ($namechanged) { @@ -3301,14 +3250,8 @@ sub update_roles { } sub enroll_single_student { - my ($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype) = @_; - $r->print('

'); - if ($crstype eq 'Community') { - $r->print(&mt('Enrolling Member')); - } else { - $r->print(&mt('Enrolling Student')); - } - $r->print('

'); + my ($r,$uhome,$amode,$genpwd,$now,$newuser,$context) = @_; + $r->print('

'.&mt('Enrolling Student').'

'); # Remove non alphanumeric values from section $env{'form.sections'}=~s/\W//g; @@ -3341,13 +3284,7 @@ sub enroll_single_student { } $r->print('.
'.$showstart.'; '.$showend); if ($startdate <= $now && !$newuser) { - $r->print('

'); - if ($crstype eq 'Community') { - $r->print(&mt('If the member is currently logged-in to LON-CAPA, the new role will be available when the member next logs in.')); - } else { - $r->print(&mt('If the student is currently logged-in to LON-CAPA, the new role will be available when the student next logs in.')); - } - $r->print('

'); + $r->print("

".&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); @@ -3542,19 +3479,10 @@ sub custom_role_editor { my $head_script = "\n"; $head_script .= '