--- loncom/interface/loncreateuser.pm 2021/12/13 20:53:06 1.406.2.20 +++ loncom/interface/loncreateuser.pm 2023/09/04 16:16:19 1.406.2.20.2.4 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.406.2.20 2021/12/13 20:53:06 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.406.2.20.2.4 2023/09/04 16:16:19 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -244,6 +244,7 @@ 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", @@ -255,6 +256,7 @@ sub build_tools_display { 'textbook' => 'Can request creation of textbook courses', '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', @@ -267,7 +269,6 @@ 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'); @@ -281,17 +282,18 @@ sub build_tools_display { } else { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'tools.aboutme','tools.portfolio','tools.blog', - 'tools.webdav'); - @usertools = ('aboutme','blog','webdav','portfolio'); + 'tools.webdav','tools.timezone'); + @usertools = ('aboutme','blog','webdav','portfolio','timezone'); } 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); + $context,\%userenv,'', + {'is_adv' => $isadv}); if ($context eq 'requestauthor') { if ($userenv{$context} ne '') { $cust_on = ' checked="checked" '; @@ -1592,7 +1594,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(''. @@ -2493,8 +2495,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". @@ -2849,7 +2851,7 @@ sub update_user_data { my (%alerts,%rulematch,%inst_results,%curr_rules); my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); - my @usertools = ('aboutme','blog','webdav','portfolio'); + my @usertools = ('aboutme','blog','webdav','portfolio','timezone'); my @requestcourses = ('official','unofficial','community','textbook'); my @requestauthor = ('requestauthor'); my ($othertitle,$usertypes,$types) = @@ -3025,7 +3027,8 @@ sub update_user_data { my %userenv = &Apache::lonnet::get ('environment',['firstname','middlename','lastname','generation', 'id','permanentemail','portfolioquota','authorquota','inststatus', - 'tools.aboutme','tools.blog','tools.webdav','tools.portfolio', + 'tools.aboutme','tools.blog','tools.webdav', + 'tools.portfolio','tools.timezone', 'requestcourses.official','requestcourses.unofficial', 'requestcourses.community','requestcourses.textbook', 'reqcrsotherdom.official','reqcrsotherdom.unofficial', @@ -3358,6 +3361,10 @@ sub update_user_data { &Apache::lonnet::appenv(\%newenvhash); } } + if ($changed{'aboutme'}) { + &Apache::loncommon::devalidate_aboutme_cache($env{'form.ccuname'}, + $env{'form.ccdomain'}); + } } } if (keys(%namechanged) > 0) { @@ -3527,6 +3534,7 @@ sub display_userinfo { 'webdav' => 'WebDAV Availability', 'aboutme' => 'Personal Information Page Availability', 'portfolio' => 'Portfolio Availability', + 'timezone' => 'Can set own Time Zone', 'official' => 'Can Request Official Courses', 'unofficial' => 'Can Request Unofficial Courses', 'community' => 'Can Request Communities', @@ -4670,7 +4678,7 @@ sub handler { if (&Apache::lonnet::auto_run($cnum,$cdom) && (($permission->{'cusr'}) || ($permission->{'view'}))) { push(@allhelp,'Course_Automated_Enrollment'); } - if ($permission->{'selfenrolladmin'}) { + if (($permission->{'selfenrolladmin'}) || ($permission->{'selfenrollview'})) { push(@allhelp,'Course_Approve_Selfenroll'); } } @@ -5210,8 +5218,9 @@ sub handler { ''.&mt('You do not have permission to modify dates or sections for users').''); } } elsif ($env{'form.action'} eq 'selfenroll') { - if ($permission->{selfenrolladmin}) { - my %currsettings = ( + my %currsettings; + if ($permission->{selfenrolladmin} || $permission->{selfenrollview}) { + %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'}, @@ -5227,6 +5236,8 @@ 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", @@ -5247,6 +5258,16 @@ 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').''); @@ -5290,7 +5311,8 @@ sub handler { ''.&mt('You do not have permission to view change logs').''); } } elsif ($env{'form.action'} eq 'helpdesk') { - if (($permission->{'owner'}) || ($permission->{'co-owner'})) { + if (($permission->{'owner'} || $permission->{'co-owner'}) && + ($permission->{'cusr'} || $permission->{'view'})) { if ($env{'form.state'} eq 'process') { if ($permission->{'owner'}) { &update_helpdeskaccess($r,$permission,$brcrum); @@ -5717,7 +5739,8 @@ sub print_main_menu { icon => 'helpdesk-access.png', #help => 'Course_Helpdesk_Access', url => '/adm/createuser?action=helpdesk', - permission => ($permission->{'owner'} || $permission->{'co-owner'}), + permission => (($permission->{'owner'} || $permission->{'co-owner'}) && + ($permission->{'view'} || $permission->{'cusr'})), linktitle => 'Helpdesk access options', }, { @@ -5752,7 +5775,7 @@ sub print_main_menu { icon => 'selfenrl-queue.png', #help => 'Course_Approve_Selfenroll', url => '/adm/createuser?action=selfenrollqueue', - permission => $permission->{'selfenrolladmin'}, + permission => $permission->{'selfenrolladmin'} || $permission->{'selfenrollview'}, linktitle =>'Approve or reject enrollment requests.', }, ); @@ -5779,7 +5802,7 @@ sub print_main_menu { icon => 'self_enroll.png', #help => 'Course_Self_Enrollment', url => '/adm/createuser?action=selfenroll', - permission => $permission->{'selfenrolladmin'}, + permission => $permission->{'selfenrolladmin'} || $permission->{'selfenrollview'}, linktitle => 'Configure user self-enrollment.', }, ); @@ -6028,8 +6051,7 @@ ENDSCRIPT '// ]]>'."\n". ''."\n". '

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

'."\n"; - - my $visactions = &cat_visibility(); + my $visactions = &cat_visibility($cdom); my ($cathash,%cattype); my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom); if (ref($domconfig{'coursecategories'}) eq 'HASH') { @@ -6574,6 +6596,7 @@ 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.', @@ -6586,13 +6609,24 @@ 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 display the catalog of "Official courses (with institutional codes)".', + dc_addinst => 'Ask a domain coordinator to enable catalog display 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.','"','"'); @@ -9548,7 +9582,7 @@ sub update_selfenroll_config { } else { $r->print(&mt('No changes were made to the existing self-enrollment settings in this course.')); } - my $visactions = &cat_visibility(); + my $visactions = &cat_visibility($cdom); my ($cathash,%cattype); my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom); if (ref($domconfig{'coursecategories'}) eq 'HASH') {