--- loncom/interface/loncreateuser.pm 2010/12/05 21:58:11 1.329.2.7 +++ loncom/interface/loncreateuser.pm 2012/02/06 04:50:52 1.358.4.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.329.2.7 2010/12/05 21:58:11 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.358.4.1 2012/02/06 04:50:52 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -70,7 +70,6 @@ use Apache::lonlocal; use Apache::longroup; use Apache::lonuserutils; use Apache::loncoursequeueadmin; -use Apache::lonrequestcourse; use LONCAPA qw(:DEFAULT :match); my $loginscript; # piece of javascript used in two separate instances @@ -220,7 +219,7 @@ END_SCRIPT sub build_tools_display { my ($ccuname,$ccdomain,$context) = @_; my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay, - $colspan); + $colspan,$isadv,%domconfig); my %lt = &Apache::lonlocal::texthash ( 'blog' => "Personal User Blog", 'aboutme' => "Personal Information Page", @@ -244,6 +243,9 @@ sub build_tools_display { %reqtitles = &courserequest_titles(); %reqdisplay = &courserequest_display(); $colspan = ' colspan="2"'; + %domconfig = + &Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain); + $isadv = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain); } else { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'tools.aboutme','tools.portfolio','tools.blog'); @@ -290,7 +292,14 @@ sub build_tools_display { &Apache::loncommon::start_data_table_row()."\n"; if ($context eq 'requestcourses') { my ($curroption,$currlimit); - $curroption = $userenv{$context.'.'.$item}; + if ($userenv{$context.'.'.$item} ne '') { + $curroption = $userenv{$context.'.'.$item}; + } else { + my (@inststatuses); + $curroption = + &Apache::loncoursequeueadmin::get_processtype($ccuname,$ccdomain,$isadv,$ccdomain, + $item,\@inststatuses,\%domconfig); + } if (!$curroption) { $curroption = 'norequest'; } @@ -473,7 +482,6 @@ sub print_username_entry_form { my ($r,$context,$response,$srch,$forcenewuser,$crstype,$brcrum) = @_; my $defdom=$env{'request.role.domain'}; my $formtoset = 'crtuser'; - my $is_custom = &Apache::loncommon::needs_gci_custom(); if (exists($env{'form.startrolename'})) { $formtoset = 'docustom'; $env{'form.rolename'} = $env{'form.startrolename'}; @@ -495,12 +503,6 @@ sub print_username_entry_form { && (&Apache::lonnet::allowed('mcr','/'))) { $jscript .= &customrole_javascript(); } - my $title = 'User Management'; - if ($context eq 'course') { - if ($is_custom) { - $title = 'Enrollment and Student Activity'; - } - } my $helpitem = 'Course_Change_Privileges'; if ($env{'form.action'} eq 'custom') { $helpitem = 'Course_Editing_Custom_Roles'; @@ -529,7 +531,7 @@ sub print_username_entry_form { my $args = {bread_crumbs => $brcrum, bread_crumbs_component => 'User Management', add_entries => \%loaditems,}; - $r->print(&Apache::loncommon::start_page($title,$jscript,$args)); + $r->print(&Apache::loncommon::start_page('User Management',$jscript,$args)); my %lt=&Apache::lonlocal::texthash( 'srst' => 'Search for a user and enroll as a student', @@ -541,6 +543,7 @@ sub print_username_entry_form { 'nr' => "role name", 'cre' => "Next", ); + if ($env{'form.action'} eq 'custom') { if (&Apache::lonnet::allowed('mcr','/')) { my $newroletext = &mt('Define new custom role:'); @@ -635,7 +638,6 @@ END sub entry_form { my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype) = @_; - my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); my ($usertype,$inexact); if (ref($srch) eq 'HASH') { if (($srch->{'srchin'} eq 'dom') && @@ -643,9 +645,10 @@ sub entry_form { ($srch->{'srchtype'} eq 'exact') && ($srch->{'srchdomain'} ne '') && ($srch->{'srchterm'} ne '')) { + my (%curr_rules,%got_rules); my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($srch->{'srchdomain'},'username'); - $usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules); + $usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules,\%curr_rules,\%got_rules); } else { $inexact = 1; } @@ -765,7 +768,6 @@ sub print_user_selection_page { my ($r,$response,$srch,$srch_results,$srcharray,$context,$opener_elements,$crstype,$brcrum) = @_; my @fields = ('username','domain','lastname','firstname','permanentemail'); my $sortby = $env{'form.sortby'}; - my $is_custom = &Apache::loncommon::needs_gci_custom(); if (!grep(/^\Q$sortby\E$/,@fields)) { $sortby = 'lastname'; @@ -804,12 +806,6 @@ ENDSCRIPT if ($context eq 'requestcrs') { $r->print('
'
.&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.")
- .'
';
- if ($ccdomain =~ /^\w+citest$/) {
- $response .= &mt('Enter a valid e-mail address as the username for the new user.').' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.'
- ,'','')
- .'
'.&mt('You must specify a valid username. Only the following are allowed: letters numbers - . @').'
'; + my $response = ''. + &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @'). + '
'; $env{'form.phase'} = ''; &print_username_entry_form($r,$context,$response,$srch,undef,$crstype,$brcrum); } else { @@ -4172,7 +4116,7 @@ sub handler { my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'}); &print_user_modification_page($r,$ccuname,$ccdomain, $srch,$response,$context, - $permission,$crstype); + $permission,$crstype,$brcrum); } } elsif ($env{'form.phase'} eq 'get_user_info') { my ($currstate,$response,$forcenewuser,$results) = @@ -4182,7 +4126,8 @@ sub handler { } if ($currstate eq 'select') { &print_user_selection_page($r,$response,$srch,$results, - \@search,$context,undef,$crstype); + \@search,$context,undef,$crstype, + $brcrum); } elsif ($currstate eq 'modify') { my ($ccuname,$ccdomain); if (($srch->{'srchby'} eq 'uname') && @@ -4212,12 +4157,14 @@ sub handler { my $ccuname = &LONCAPA::clean_username($env{'form.seluname'}); my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'}); &print_user_modification_page($r,$ccuname,$ccdomain,$srch,'', - $context,$permission,$crstype,$brcrum); + $context,$permission,$crstype, + $brcrum); } } elsif ($env{'form.phase'} eq 'update_user_data') { &update_user_data($r,$context,$crstype,$brcrum); } else { - &print_username_entry_form($r,$context,undef,$srch,undef,$crstype,$brcrum); + &print_username_entry_form($r,$context,undef,$srch,undef,$crstype, + $brcrum); } } elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) { if ($env{'form.phase'} eq 'set_custom_roles') { @@ -4240,11 +4187,8 @@ sub handler { $r->print(&header(undef,$args)); my $setting = $env{'form.roletype'}; my $choice = $env{'form.bulkaction'}; - $r->print(&Apache::lonhtmlcommon::breadcrumbs("Update Users", - 'Course_View_Class_List')); if ($permission->{'cusr'}) { - &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice); - $r->print(&Apache::loncommon::end_page()); + &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice,$crstype); } else { $r->print(&mt('You are not authorized to make bulk changes to user roles')); $r->print(''.&mt('Display User Lists').''); @@ -4277,7 +4221,7 @@ sub handler { } $jscript .= &verify_user_display(); my $js = &add_script($jscript).$cb_jscript; - my $loadcode = + my $loadcode = &Apache::lonuserutils::course_selector_loadcode($formname); if ($loadcode ne '') { $args->{add_entries} = {onload => $loadcode}; @@ -4307,7 +4251,7 @@ sub handler { } $bread_crumbs_component = $brtext; $args = {bread_crumbs => $brcrum, - bread_crumbs_component => $bread_crumbs_component}; + bread_crumbs_component => $bread_crumbs_component}; $r->print(&header(undef,$args)); if (!exists($env{'form.state'})) { &Apache::lonuserutils::print_drop_menu($r,$context,$permission,$crstype); @@ -4317,12 +4261,12 @@ sub handler { } } elsif ($env{'form.action'} eq 'dateselect') { if ($permission->{'cusr'}) { - $r->print(&header(undef,undef,{'no_nav_bar' => 1}). + $r->print(&header(undef,{'no_nav_bar' => 1}). &Apache::lonuserutils::date_section_selector($context, $permission,$crstype)); } else { - $r->print(&header(). - ''.&mt('You do not have permission to modify dates or sections for users').''); + $r->print(&header(undef,{'no_nav_bar' => 1}). + ''.&mt('You do not have permission to modify dates or sections for users').''); } } elsif ($env{'form.action'} eq 'selfenroll') { push(@{$brcrum}, @@ -4385,6 +4329,7 @@ sub handler { $r->print(&header(undef,$args)); &print_userchangelogs_display($r,$context,$permission); } else { + $bread_crumbs_component = 'User Management'; $args = { bread_crumbs => $brcrum, bread_crumbs_component => $bread_crumbs_component}; $r->print(&header(undef,$args)); @@ -4396,18 +4341,11 @@ sub handler { sub header { my ($jscript,$args) = @_; - my $title = 'User Management'; - my $is_custom = &Apache::loncommon::needs_gci_custom(); - if ($env{'request.course.id'}) { - if ($is_custom) { - $title = 'Enrollment and Student Activity'; - } - } my $start_page; if (ref($args) eq 'HASH') { - $start_page=&Apache::loncommon::start_page($title,$jscript,$args); + $start_page=&Apache::loncommon::start_page('User Management',$jscript,$args); } else { - $start_page=&Apache::loncommon::start_page($title,$jscript); + $start_page=&Apache::loncommon::start_page('User Management',$jscript); } return $start_page; } @@ -4440,10 +4378,6 @@ END # Menu Phase One sub print_main_menu { my ($permission,$context,$crstype) = @_; - my $is_custom = &Apache::loncommon::needs_gci_custom(); - if (($context eq 'course') && ($is_custom)) { - return &print_gci_main_menu($permission,$context,$crstype) - } my $linkcontext = $context; my $stuterm = lc(&Apache::lonnet::plaintext('st',$crstype)); if (($context eq 'course') && ($crstype eq 'Community')) { @@ -4464,12 +4398,12 @@ sub print_main_menu { course => { upload => 'Upload a File of Course Users', singleuser => 'Add/Modify a Course User', - listusers => 'Manage Course Users', + listusers => 'List and Modify Multiple Course Users', }, community => { upload => 'Upload a File of Community Users', singleuser => 'Add/Modify a Community User', - listusers => 'Manage Community Users', + listusers => 'List and Modify Multiple Community Users', }, ); my %linktitles = ( @@ -4508,7 +4442,7 @@ sub print_main_menu { [ { linktext => $links{$linkcontext}{'upload'}, - icon => 'sctr.png', + icon => 'uplusr.png', #help => 'Course_Create_Class_List', url => '/adm/createuser?action=upload', permission => $permission->{'cusr'}, @@ -4516,7 +4450,7 @@ sub print_main_menu { }, { linktext => $links{$linkcontext}{'listusers'}, - icon => 'edit-find.png', + icon => 'mngcu.png', #help => 'Course_View_Class_List', url => '/adm/createuser?action=listusers', permission => ($permission->{'view'} || $permission->{'cusr'}), @@ -4603,7 +4537,7 @@ sub print_main_menu { }, { linktext => $linktext{$crstype}{'groups'}, - icon => 'conf.png', + icon => 'grps.png', #help => 'Course_Manage_Group', url => '/adm/coursegroups?refpage=cusr', permission => $permission->{'grp_manage'}, @@ -4648,7 +4582,7 @@ sub print_main_menu { push(@{ $menu[2]->{items} }, { linktext => 'User Self-Enrollment', - icon => 'cstr.png', + icon => 'self_enroll.png', #help => 'Course_Self_Enrollment', url => '/adm/createuser?action=selfenroll', permission => $permission->{'cusr'}, @@ -4665,82 +4599,6 @@ return Apache::lonhtmlcommon::generate_m # }); } -sub print_gci_main_menu { - my ($permission,$context,$crstype) = @_; - my $stuterm = lc(&Apache::lonnet::plaintext('st',$crstype)); - my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity(); - my %links = ( - course => { - single => 'Add/Modify a Student', - drop => 'Drop Students', - upload => 'Upload a File of Course Users', - singleuser => 'Add/Modify a Course User', - listusers => 'Concept Test Roster and Student Activity', - }, - ); - my %linktitles = ( - course => { - singleuser => 'Add a user with a certain role to this course.', - listusers => 'Show and manage users in this course.', - single => 'Add a user with the role of student to this course', - drop => 'Remove a student from this course.', - upload => 'Upload a CSV or a text file containing users.', - }, - ); - my @menu = ( {categorytitle => 'Manage Users', - items => - [ - { - linktext => $links{$context}{'single'}, - #help => 'Course_Add_Student', - icon => 'list-add.png', - url => '/adm/createuser?action=singlestudent', - permission => $permission->{'cusr'}, - linktitle => $linktitles{$context}{'single'}, - - }, - { - linktext => $links{$context}{'drop'}, - icon => 'edit-undo.png', - #help => 'Course_Drop_Student', - url => '/adm/createuser?action=drop', - permission => $permission->{'cusr'}, - linktitle => $linktitles{$context}{'drop'}, - }, - { - linktext => $links{$context}{'upload'}, - icon => 'sctr.png', - #help => 'Course_Create_Class_List', - url => '/adm/createuser?action=upload', - permission => $permission->{'cusr'}, - linktitle => $linktitles{$context}{'upload'}, - }, - { - linktext => $links{$context}{'listusers'}, - icon => 'edit-find.png', - #help => 'Course_View_Class_List', - url => '/adm/createuser?action=listusers', - permission => ($permission->{'view'} || $permission->{'cusr'}), - linktitle => $linktitles{$context}{'listusers'}, - }, - ]}, - {categorytitle => 'Administration', - items => [ ]}, - ); - - push(@{ $menu[1]->{items} }, #Category: Administration - { - linktext => 'Change Log', - icon => 'document-properties.png', - #help => 'Course_User_Logs', - url => '/adm/createuser?action=changelogs', - permission => $permission->{'cusr'}, - linktitle => 'View change log.', - }, - ); - return Apache::lonhtmlcommon::generate_menu(@menu); -} - sub restore_prev_selections { my %saveable_parameters = ('srchby' => 'scalar', 'srchin' => 'scalar', @@ -5150,7 +5008,7 @@ ENDSCRIPT ''. &Apache::loncommon::plainname($ccuname,$ccudom). ''; - $count; + $count ++; } my $rem = $count%$numcols; if ($rem) { @@ -5167,7 +5025,7 @@ ENDSCRIPT my $cid = $env{'request.course.id'}; my $currlim = $env{'course.'.$cid.'.internal.selfenroll_limit'}; my $currcap = $env{'course.'.$cid.'.internal.selfenroll_cap'}; - my $nolimit = ' checked="checked" '; + $nolimit = ' checked="checked" '; if ($currlim eq 'allstudents') { $crslimit = ' checked="checked" '; $selflimit = ' '; @@ -5223,9 +5081,9 @@ sub visible_in_cat { dc_chgcat => 'Ask a domain coordinator to change the category assigned to the course, as the one currently assigned is no longer used in the domain', dc_addcat => 'Ask a domain coordinator to assign a category to the course.', ); - $visactions{'unhide'} = &mt('Use [_1]Set course environment[_2] to change the "Exclude from course catalog" setting.','"','"'); - $visactions{'chgcat'} = &mt('Use [_1]Set course environment[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','"','"'); - $visactions{'addcat'} = &mt('Use [_1]Set course environment[_2] to assign a category to the course.','"','"'); + $visactions{'unhide'} = &mt('Use [_1]Categorize course[_2] to change the "Exclude from course catalog" setting.','','"'); + $visactions{'chgcat'} = &mt('Use [_1]Categorize course[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','"','"'); + $visactions{'addcat'} = &mt('Use [_1]Categorize course[_2] to assign a category to the course.','"','"'); if (ref($domconf{'coursecategories'}) eq 'HASH') { if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') { $settable{'togglecats'} = 1; @@ -5705,7 +5563,16 @@ sub role_display_filter { # Update Display button $output .= '
' .'' - .'
' + .&mt('Only changes made from servers running LON-CAPA [_1] or later are displayed.' + ,'2.6.99.0'); + if ($version) { + $output .= ' '.&mt('This LON-CAPA server is version [_1]',$version); + } + $output .= '
'.&mt('You must specify a valid domain when searching in a domain or institutional directory.').'
'; + $response = ''. + &mt('You must specify a valid domain when searching in a domain or institutional directory.'). + '
'; } } if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs') || @@ -5768,7 +5637,9 @@ sub user_search_result { } } if ($unamecheck !~ /^$match_username$/) { - $response = ''.&mt('You must specify a valid username. Only the following are allowed: letters numbers - . @').'
'; + $response = ''. + &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @'). + '
'; } } } @@ -6055,12 +5926,12 @@ sub build_search_response { my ($context,$srch,%srch_results) = @_; my ($currstate,$response,$forcenewuser); my %names = ( - 'uname' => 'username', - 'lastname' => 'last name', + 'uname' => 'username', + 'lastname' => 'last name', 'lastfirst' => 'last name, first name', - 'crs' => 'this course', - 'dom' => 'LON-CAPA domain: ', - 'instd' => 'the institutional directory for domain: ', + 'crs' => 'this course', + 'dom' => 'LON-CAPA domain', + 'instd' => 'the institutional directory for domain', ); my %single = ( @@ -6080,14 +5951,20 @@ sub build_search_response { $currstate = 'modify'; $response = &mt("$single{$srch->{'srchtype'}} was found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'}); if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') { - $response .= &display_domain_info($srch->{'srchdomain'}); + $response .= ': '.&display_domain_info($srch->{'srchdomain'}); } - } else { - $response = ''.&mt("$nomatch{$srch->{'srchtype'}} found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}",$srch->{'srchterm'}); + } else { # Search has nothing found. Prepare message to user. + $response = ''; if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') { - $response .= &display_domain_info($srch->{'srchdomain'}); + $response .= &mt("$nomatch{$srch->{'srchtype'}} found for the $names{$srch->{'srchby'}} [_1] in $names{$srch->{'srchin'}}: [_2]", + ''.$srch->{'srchterm'}.'', + &display_domain_info($srch->{'srchdomain'})); + } else { + $response .= &mt("$nomatch{$srch->{'srchtype'}} found for the $names{$srch->{'srchby'}} [_1] in $names{$srch->{'srchin'}}.", + ''.$srch->{'srchterm'}.''); } $response .= ''; + if ($srch->{'srchin'} ne 'alc') { $forcenewuser = 1; my $cansrchinst = 0; @@ -6348,8 +6225,8 @@ sub course_level_dc { my $hiddenitems = ''. ''. ''; - my $courseform=''.&Apache::loncommon::selectcourse_link - ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course/Community','crstype').''; + my $courseform=&Apache::loncommon::selectcourse_link + ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Select','crstype'); my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser'); my %lt=&Apache::lonlocal::texthash( 'rol' => "Role", @@ -6359,15 +6236,17 @@ sub course_level_dc { 'sta' => "Start", 'end' => "End", 'ssd' => "Set Start Date", - 'sed' => "Set End Date" + 'sed' => "Set End Date", + 'scc' => "Course/Community" ); my $header = '