--- loncom/interface/loncreateuser.pm 2023/09/04 16:16:19 1.406.2.20.2.4 +++ loncom/interface/loncreateuser.pm 2017/08/10 21:14:58 1.445 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.406.2.20.2.4 2023/09/04 16:16:19 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.445 2017/08/10 21:14:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -71,7 +71,6 @@ use Apache::longroup; use Apache::lonuserutils; use Apache::loncoursequeueadmin; use LONCAPA qw(:DEFAULT :match); -use HTML::Entities; my $loginscript; # piece of javascript used in two separate instances my $authformnop; @@ -244,7 +243,6 @@ sub build_tools_display { 'aboutme' => "Personal Information Page", 'webdav' => "WebDAV access to Authoring Spaces (if SSL and author/co-author)", 'portfolio' => "Personal User Portfolio", - 'timezone' => "Can set Time Zone", 'avai' => "Available", 'cusa' => "availability", 'chse' => "Change setting", @@ -254,14 +252,15 @@ sub build_tools_display { 'unofficial' => 'Can request creation of unofficial courses', 'community' => 'Can request creation of communities', 'textbook' => 'Can request creation of textbook courses', + 'placement' => 'Can request creation of placement tests', 'requestauthor' => 'Can request author space', ); - $isadv = &Apache::lonnet::is_advanced_user($ccdomain,$ccuname); if ($context eq 'requestcourses') { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'requestcourses.official','requestcourses.unofficial', - 'requestcourses.community','requestcourses.textbook'); - @usertools = ('official','unofficial','community','textbook'); + 'requestcourses.community','requestcourses.textbook', + 'requestcourses.placement'); + @usertools = ('official','unofficial','community','textbook','placement'); @options =('norequest','approval','autolimit','validate'); %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain); %reqtitles = &courserequest_titles(); @@ -269,6 +268,7 @@ sub build_tools_display { $colspan = ' colspan="2"'; %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain); + $isadv = &Apache::lonnet::is_advanced_user($ccdomain,$ccuname); } elsif ($context eq 'requestauthor') { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'requestauthor'); @@ -282,18 +282,17 @@ sub build_tools_display { } else { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'tools.aboutme','tools.portfolio','tools.blog', - 'tools.webdav','tools.timezone'); - @usertools = ('aboutme','blog','webdav','portfolio','timezone'); + 'tools.webdav'); + @usertools = ('aboutme','blog','webdav','portfolio'); } foreach my $item (@usertools) { my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off, $currdisp,$custdisp,$custradio); $cust_off = 'checked="checked" '; $tool_on = 'checked="checked" '; - $curr_access = + $curr_access = &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, - $context,\%userenv,'', - {'is_adv' => $isadv}); + $context); if ($context eq 'requestauthor') { if ($userenv{$context} ne '') { $cust_on = ' checked="checked" '; @@ -336,6 +335,7 @@ sub build_tools_display { ' '.$lt{$item}.''."\n". ' '."\n". &Apache::loncommon::start_data_table_row()."\n"; + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { my ($curroption,$currlimit); my $envkey = $context.'.'.$item; @@ -454,12 +454,14 @@ sub coursereq_externaluser { 'unofficial' => 'Can request creation of unofficial courses', 'community' => 'Can request creation of communities', 'textbook' => 'Can request creation of textbook courses', + 'placement' => 'Can request creation of placement tests', ); %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'reqcrsotherdom.official','reqcrsotherdom.unofficial', - 'reqcrsotherdom.community','reqcrsotherdom.textbook'); - @usertools = ('official','unofficial','community','textbook'); + 'reqcrsotherdom.community','reqcrsotherdom.textbook', + 'reqcrsotherdom.placement'); + @usertools = ('official','unofficial','community','textbook','placement'); @options = ('approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($cdom); my $optregex = join('|',@options); @@ -540,6 +542,7 @@ sub courserequest_titles { unofficial => 'Unofficial', community => 'Communities', textbook => 'Textbook', + placement => 'Placement Tests', norequest => 'Not allowed', approval => 'Approval by Dom. Coord.', validate => 'With validation', @@ -883,7 +886,15 @@ ENDBLOCK (!(($env{'form.action'} eq 'singleuser') && ($context eq 'domain') && (!&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))))) { my $defdom=$env{'request.role.domain'}; - my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); + my ($trustedref,$untrustedref); + if ($context eq 'course') { + ($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('enroll',$defdom); + } elsif ($context eq 'author') { + ($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('othcoau',$defdom); + } elsif ($context eq 'domain') { + ($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('domroles',$defdom); + } + my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain',undef,undef,undef,$trustedref,$untrustedref); my %lt=&Apache::lonlocal::texthash( 'enro' => 'Enroll one student', 'enrm' => 'Enroll one member', @@ -1473,8 +1484,10 @@ ENDAUTH if ($env{'request.role.domain'} eq $ccdomain) { $r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses')); } else { - $r->print(&coursereq_externaluser($ccuname,$ccdomain, - $env{'request.role.domain'})); + if (&Apache::lonnet::will_trust('reqcrs',$ccdomain,$env{'request.role.domain'})) { + $r->print(&coursereq_externaluser($ccuname,$ccdomain, + $env{'request.role.domain'})); + } } $r->print(&Apache::loncommon::end_data_table()); } @@ -1489,7 +1502,7 @@ ENDAUTH ($env{'request.role.domain'} eq $ccdomain)) { $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain); } - $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname,$crstype,$permission); + $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname); if ((&Apache::lonnet::allowed('mpq',$ccdomain)) || (&Apache::lonnet::allowed('mut',$ccdomain)) || (&Apache::lonnet::allowed('udp',$ccdomain))) { @@ -1594,7 +1607,7 @@ ENDNOTOOLSPRIV if ($newuser) { $r->print(' onclick="auth_check()" \>'."\n"); } else { - $r->print(' onclick="this.form.submit()" \>'."\n"); + $r->print('onclick="this.form.submit()" \>'."\n"); } } else { $r->print(''. @@ -2132,11 +2145,20 @@ sub new_domain_roles { ''.&mt('Start').''.&mt('End').''. &Apache::loncommon::end_data_table_header_row(); my @allroles = &Apache::lonuserutils::roles_by_context('domain'); + my $uprimary = &Apache::lonnet::domain($env{'request.role.domain'},'primary'); + my $uintdom = &Apache::lonnet::internet_dom($uprimary); foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) { foreach my $role (@allroles) { next if ($role eq 'ad'); next if (($role eq 'au') && ($ccdomain ne $thisdomain)); if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) { + if ($role eq 'dc') { + unless ($thisdomain eq $env{'request.role.domain'}) { + my $domprim = &Apache::lonnet::domain($thisdomain,'primary'); + my $intdom = &Apache::lonnet::internet_dom($domprim); + next unless ($uintdom eq $intdom); + } + } my $plrole=&Apache::lonnet::plaintext($role); my %lt=&Apache::lonlocal::texthash( 'ssd' => "Set Start Date", @@ -2167,7 +2189,7 @@ sub new_domain_roles { } sub user_authentication { - my ($ccuname,$ccdomain,$formname,$crstype,$permission) = @_; + my ($ccuname,$ccdomain,$formname) = @_; my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); my $outcome; my %lt=&Apache::lonlocal::texthash( @@ -2205,6 +2227,7 @@ $lt{'uuas'} ($currentauth). $lt{'adcs'}. ENDBADAUTH } } else { # Authentication type is valid + &initialize_authen_forms($ccdomain,$formname,$currentauth,'modifyuser'); my ($authformcurrent,$can_modify,@authform_others) = &modify_login_block($ccdomain,$currentauth); @@ -2239,43 +2262,6 @@ ENDBADAUTH } $outcome .= &Apache::loncommon::end_data_table(); } else { - if (($currentauth =~ /^internal:/) && - (&Apache::lonuserutils::can_change_internalpass($ccuname,$ccdomain,$crstype,$permission))) { - $outcome = <<"ENDJS"; - -ENDJS - - $outcome .= '

'.$lt{'ld'}.'

'. - &Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_row(). - ''.&mt('Internally authenticated').'
'.&mt("Change user's password?"). - ''.(' 'x2). - ''. - ''. - &Apache::loncommon::end_data_table_row(). - &Apache::loncommon::end_data_table(); - } if (&Apache::lonnet::allowed('udp',$ccdomain)) { # Current user has rights to view domain preferences for user's domain my $result; @@ -2384,8 +2370,8 @@ sub modify_login_block { } sub personal_data_display { - my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray,$now, - $captchaform,$emailusername,$usertype,$usernameset,$condition,$excluded,$showsubmit) = @_; + my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray, + $now,$captchaform,$emailusername,$usertype,$usernameset,$condition,$excluded) = @_; my ($output,%userenv,%canmodify,%canmodify_status); my @userinfo = ('firstname','middlename','lastname','generation', 'permanentemail','id'); @@ -2468,7 +2454,7 @@ sub personal_data_display { } else { undef($condition); } - } + } if ($excluded) { unless ($excluded =~ /^\@[^\@]+$/) { undef($condition); @@ -2495,8 +2481,8 @@ sub personal_data_display { } $rowcount ++; $output .= &Apache::lonhtmlcommon::row_closure(1); - my $upassone = ''; - my $upasstwo = ''; + my $upassone = ''; + my $upasstwo = ''; $output .= &Apache::lonhtmlcommon::row_title(&mt('Password').'*', 'LC_pick_box_title', 'LC_oddrow_value')."\n". @@ -2508,13 +2494,12 @@ sub personal_data_display { $upasstwo. &Apache::lonhtmlcommon::row_closure()."\n"; if ($usernameset eq 'free') { - my $onclick = "toggleUsernameDisp(this,'selfcreateusername');"; + my $onclick = "toggleUsernameDisp(this,'selfcreateusername');"; $output .= &Apache::lonhtmlcommon::row_title($lt{'username'},undef,'LC_oddrow_value')."\n". - ''.&mt('Use e-mail address: '). - ''.(' 'x2). - ''."\n". + &mt('Use e-mail address: '). + ''."\n". + (' 'x2). + ''."\n". ''); } else { $r->print('
'.&mt('No information to display for this account request.').'
'); @@ -5218,9 +5163,8 @@ sub handler { ''.&mt('You do not have permission to modify dates or sections for users').''); } } elsif ($env{'form.action'} eq 'selfenroll') { - my %currsettings; - if ($permission->{selfenrolladmin} || $permission->{selfenrollview}) { - %currsettings = ( + if ($permission->{selfenrolladmin}) { + my %currsettings = ( selfenroll_types => $env{'course.'.$cid.'.internal.selfenroll_types'}, selfenroll_registered => $env{'course.'.$cid.'.internal.selfenroll_registered'}, selfenroll_section => $env{'course.'.$cid.'.internal.selfenroll_section'}, @@ -5236,8 +5180,6 @@ sub handler { default_enrollment_end_date => $env{'course.'.$cid.'.default_enrollment_end_date'}, uniquecode => $env{'course.'.$cid.'.internal.uniquecode'}, ); - } - if ($permission->{selfenrolladmin}) { push(@{$brcrum}, {href => '/adm/createuser?action=selfenroll', text => "Configure Self-enrollment", @@ -5258,16 +5200,6 @@ sub handler { $r->print('

'.&mt('Self-enrollment with a student role').'

'."\n"); &update_selfenroll_config($r,$cid,$cdom,$cnum,$context,$crstype,\%currsettings); } - } elsif ($permission->{selfenrollview}) { - push(@{$brcrum}, - {href => '/adm/createuser?action=selfenroll', - text => "View Self-enrollment configuration", - help => 'Course_Self_Enrollment'}); - $args = { bread_crumbs => $brcrum, - bread_crumbs_component => 'Self-enrollment Settings'}; - $r->print(&header(undef,$args)); - $r->print('

'.&mt('Self-enrollment with a student role').'

'."\n"); - &print_selfenroll_menu($r,'course',$cid,$cdom,$cnum,\%currsettings,'',1); } else { $r->print(&header(undef,{'no_nav_bar' => 1}). ''.&mt('You do not have permission to configure self-enrollment').''); @@ -5311,8 +5243,7 @@ sub handler { ''.&mt('You do not have permission to view change logs').''); } } elsif ($env{'form.action'} eq 'helpdesk') { - if (($permission->{'owner'} || $permission->{'co-owner'}) && - ($permission->{'cusr'} || $permission->{'view'})) { + if (($permission->{'owner'}) || ($permission->{'co-owner'})) { if ($env{'form.state'} eq 'process') { if ($permission->{'owner'}) { &update_helpdeskaccess($r,$permission,$brcrum); @@ -5698,6 +5629,7 @@ sub print_main_menu { groups => 'Community Groups', }, ); + $linktext{'Placement'} = $linktext{'Course'}; my %linktitle = ( 'Course' => { @@ -5712,6 +5644,8 @@ sub print_main_menu { }, ); + $linktitle{'Placement'} = $linktitle{'Course'}; + push(@{ $menu[0]->{items} }, #Category: Single Users { linktext => $linktext{$crstype}{'single'}, @@ -5739,8 +5673,7 @@ sub print_main_menu { icon => 'helpdesk-access.png', #help => 'Course_Helpdesk_Access', url => '/adm/createuser?action=helpdesk', - permission => (($permission->{'owner'} || $permission->{'co-owner'}) && - ($permission->{'view'} || $permission->{'cusr'})), + permission => ($permission->{'owner'} || $permission->{'co-owner'}), linktitle => 'Helpdesk access options', }, { @@ -5775,7 +5708,7 @@ sub print_main_menu { icon => 'selfenrl-queue.png', #help => 'Course_Approve_Selfenroll', url => '/adm/createuser?action=selfenrollqueue', - permission => $permission->{'selfenrolladmin'} || $permission->{'selfenrollview'}, + permission => $permission->{'selfenrolladmin'}, linktitle =>'Approve or reject enrollment requests.', }, ); @@ -5802,7 +5735,7 @@ sub print_main_menu { icon => 'self_enroll.png', #help => 'Course_Self_Enrollment', url => '/adm/createuser?action=selfenroll', - permission => $permission->{'selfenrolladmin'} || $permission->{'selfenrollview'}, + permission => $permission->{'selfenrolladmin'}, linktitle => 'Configure user self-enrollment.', }, ); @@ -6051,7 +5984,8 @@ ENDSCRIPT '// ]]>'."\n". ''."\n". '

'.$lt->{'selfenroll'}.'

'."\n"; - my $visactions = &cat_visibility($cdom); + + my $visactions = &cat_visibility(); my ($cathash,%cattype); my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom); if (ref($domconfig{'coursecategories'}) eq 'HASH') { @@ -6214,10 +6148,11 @@ ENDSCRIPT } elsif ($curr_types eq '') { $add_domtitle = &mt('Users in other domain:'); } + my ($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('enroll',$cdom); $output .= &Apache::loncommon::start_data_table_row() .''.$add_domtitle.'
' .&Apache::loncommon::select_dom_form('','selfenroll_newdom', - $includeempty,$showdomdesc,'','','',$readonly) + $includeempty,$showdomdesc,'',$trustedref,$untrustedref,$readonly) .'' .''.&Apache::loncommon::end_data_table_row() .&Apache::loncommon::end_data_table(); @@ -6596,7 +6531,6 @@ sub visible_in_stdcat { } sub cat_visibility { - my ($cdom) = @_; my %visactions = &Apache::lonlocal::texthash( vis => 'This course/community currently appears in the Course/Community Catalog for this domain.', gen => 'Courses can be both self-cataloging, based on an institutional code (e.g., fs08phy231), or can be assigned categories from a hierarchy defined for the domain.', @@ -6609,24 +6543,13 @@ sub cat_visibility { dc_chgconf => 'Ask a domain coordinator to change the Catalog type for this domain.', dc_setcode => 'Ask a domain coordinator to assign a six character code to the course', dc_unhide => 'Ask a domain coordinator to change the "Exclude from course catalog" setting.', - dc_addinst => 'Ask a domain coordinator to enable catalog display of "Official courses (with institutional codes)".', + dc_addinst => 'Ask a domain coordinator to enable display the catalog of "Official courses (with institutional codes)".', dc_instcode => 'Ask a domain coordinator to assign an institutional code (if this is an official course).', dc_catalog => 'Ask a domain coordinator to enable or create at least one course category in the domain.', dc_categories => 'Ask a domain coordinator to create a hierarchy of categories and sub categories for courses in the domain.', 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.', ); - if ($env{'request.role'} eq "dc./$cdom/") { - $visactions{'dc_chgconf'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to change the Catalog type for this domain.','»'); - $visactions{'dc_setcode'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to assign a six character code to the course.','»'); - $visactions{'dc_unhide'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to change the "Exclude from course catalog" setting.','»'); - $visactions{'dc_addinst'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to enable catalog display of "Official courses (with institutional codes)".','»'); - $visactions{'dc_instcode'} = &mt('Use: "Main menu" [_1] "View or modify a course or community" [_1] "View/Modify course owner, institutional code ... " to assign an institutional code (if this is an official course).','»'); - $visactions{'dc_catalog'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to enable or create at least one course category in the domain.','»'); - $visactions{'dc_categories'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to create a hierarchy of categories and sub categories for courses in the domain.','»'); - $visactions{'dc_chgcat'} = &mt('Use: "Main menu" [_1] "View or modify a course or community" [_1] "View/Modify catalog settings for course" to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','»'); - $visactions{'dc_addcat'} = &mt('Use: "Main menu" [_1] "View or modify a course or community" [_1] "View/Modify catalog settings for course" 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.','"','"'); @@ -7117,10 +7040,9 @@ ENDSCRIPT my ($nav_script,$nav_links); # table header - my $heading = '

'. + my $tableheader = '

'. &mt('User access logs for: [_1]', - &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom)).'

'; - my $tableheader = $heading + &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom)).'' .&Apache::loncommon::start_data_table_header_row() .' ' .''.&mt('When').'' @@ -7238,7 +7160,7 @@ ENDSCRIPT $r->print(&Apache::loncommon::end_data_table(). &userlogdisplay_navlinks(\%curr,$more_records)); } else { # No content displayed above - $r->print($heading.'

' + $r->print('

' .&mt('There are no records to display.') .'

'); } @@ -7427,12 +7349,12 @@ sub role_display_filter { &mt('Context:').'