--- loncom/interface/loncreateuser.pm 2023/11/03 21:40:22 1.471 +++ loncom/interface/loncreateuser.pm 2023/11/17 17:02:20 1.474 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.471 2023/11/03 21:40:22 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.474 2023/11/17 17:02:20 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -279,7 +279,7 @@ sub build_tools_display { 'aboutme' => "Personal Information Page", 'webdav' => "WebDAV access to Authoring Spaces (https)", 'editors' => "Available Editors", - 'managers' => "Co-authors who can add/revoke co-authors", + 'managers' => "Co-authors who can add/revoke roles", 'portfolio' => "Personal User Portfolio", 'portaccess' => "Portfolio Shareable", 'timezone' => "Can set Time Zone", @@ -340,10 +340,12 @@ sub build_tools_display { $currdisp,$custdisp,$custradio,$onclick); $cust_off = 'checked="checked" '; $tool_on = 'checked="checked" '; - $curr_access = - &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, - $context,\%userenv,'', - {'is_adv' => $isadv}); + unless (($context eq 'authordefaults') && ($item ne 'webdav')) { + $curr_access = + &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, + $context,\%userenv,'', + {'is_adv' => $isadv}); + } if ($context eq 'requestauthor') { if ($userenv{$context} ne '') { $cust_on = ' checked="checked" '; @@ -3781,7 +3783,10 @@ sub update_user_data { } if (($env{'user.name'} eq $env{'form.ccuname'}) && ($env{'user.domain'} eq $env{'form.ccdomain'})) { - my %newenvhash; + my (%newenvhash,$got_domdefs,%domdefaults,$got_userenv, + %userenv); + my @fromenv = keys(%changed); + push(@fromenv,'inststatus'); foreach my $key (keys(%changed)) { if (($key eq 'official') || ($key eq 'unofficial') || ($key eq 'community') || ($key eq 'textbook') || @@ -3791,28 +3796,55 @@ sub update_user_data { if ($changeHash{'requestcourses.'.$key}) { $newenvhash{'environment.canrequest.'.$key} = 1; } else { + unless ($got_domdefs) { + %domdefaults = + &Apache::lonnet::get_domain_defaults($env{'user.domain'}); + $got_domdefs = 1; + } + unless ($got_userenv) { + %userenv = + &Apache::lonnet::userenvironment($env{'user.domain'}, + $env{'user.name'},@fromenv); + $got_userenv = 1; + } $newenvhash{'environment.canrequest.'.$key} = &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, - $key,'reload','requestcourses'); + $key,'reload','requestcourses',\%userenv,\%domdefaults); } } elsif ($key eq 'requestauthor') { $newenvhash{'environment.'.$key} = $changeHash{$key}; if ($changeHash{$key}) { $newenvhash{'environment.canrequest.author'} = 1; } else { + unless ($got_domdefs) { + %domdefaults = + &Apache::lonnet::get_domain_defaults($env{'user.domain'}); + $got_domdefs = 1; + } + unless ($got_userenv) { + %userenv = + &Apache::lonnet::userenvironment($env{'user.domain'}, + $env{'user.name'},@fromenv); + $got_userenv = 1; + } $newenvhash{'environment.canrequest.author'} = &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, - $key,'reload','requestauthor'); + $key,'reload','requestauthor',\%userenv,\%domdefaults); } } elsif ($key eq 'editors') { $newenvhash{'environment.author'.$key} = $changeHash{'author'.$key}; - if ($key eq 'editors') { - if ($env{'form.customeditors'}) { - $newenvhash{'environment.editors'} = $changeHash{'author'.$key}; + if ($env{'form.customeditors'}) { + $newenvhash{'environment.editors'} = $changeHash{'author'.$key}; + } else { + unless ($got_domdefs) { + %domdefaults = + &Apache::lonnet::get_domain_defaults($env{'user.domain'}); + $got_domdefs = 1; + } + if ($domdefaults{'editors'} ne '') { + $newenvhash{'environment.editors'} = $domdefaults{'editors'}; } else { - $newenvhash{'environment.editors'} = - &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, - $key,'reload','authordefaults'); + $newenvhash{'environment.editors'} = 'edit,xml'; } } } elsif ($key ne 'quota') { @@ -3822,9 +3854,20 @@ sub update_user_data { $newenvhash{'environment.availabletools.'.$key} = $changeHash{'tools.'.$key}; } else { + unless ($got_domdefs) { + %domdefaults = + &Apache::lonnet::get_domain_defaults($env{'user.domain'}); + $got_domdefs = 1; + } + unless ($got_userenv) { + %userenv = + &Apache::lonnet::userenvironment($env{'user.domain'}, + $env{'user.name'},@fromenv); + $got_userenv = 1; + } $newenvhash{'environment.availabletools.'.$key} = &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, - $key,'reload','tools'); + $key,'reload','tools',\%userenv,\%domdefaults); } } } @@ -4025,7 +4068,7 @@ sub display_userinfo { 'prvs' => 'Previous Value:', 'chto' => 'Changed To:', 'editors' => "Available Editors in Authoring Space", - 'managers' => "Co-authors who can add/revoke co-authors", + 'managers' => "Co-authors who can add/revoke roles", 'edit' => 'Standard editor (Edit)', 'xml' => 'Text editor (EditXML)', 'daxe' => 'Daxe editor (Daxe)', @@ -5506,7 +5549,7 @@ sub display_coauthor_managers { } $output .= "

\n"; if (@possmanagers) { - $output .= '

'.&mt('Select manager(s)').': '; + $output .= '

'.&mt('If checked, can manage').': '; foreach my $user (@possmanagers) { my $checked; if (grep(/^\Q$user\E$/,@custommanagers)) { @@ -6350,7 +6393,7 @@ sub handler { if (($permission->{cusr}) && ($context eq 'author')) { push(@{$brcrum}, {href => '/adm/createuser?action=camanagers', - text => 'Co-authors who manage', + text => 'Co-author Managers', help => 'Author_Manage_Coauthors'}); if ($env{'form.state'} eq 'process') { push(@{$brcrum}, @@ -6510,6 +6553,15 @@ function updateCols(caller) { document.getElementById('showcolstart').checked = false; document.getElementById('showcolend').checked = false; } + if (context == 'author') { + if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Expired') { + document.getElementById('showcolmanager').checked = false; + document.getElementById('showcolmanager').disabled = 'disabled'; + } else if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value != 'aa') { + document.getElementById('showcolmanager').checked = true; + document.getElementById('showcolmanager').disabled = ''; + } + } } } if (caller == 'output') { @@ -6595,6 +6647,15 @@ function updateCols(caller) { } } } + if (context == 'author') { + if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'aa') { + document.getElementById('showcolmanager').checked = false; + document.getElementById('showcolmanager').disabled = 'disabled'; + } else if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value != 'Expired') { + document.getElementById('showcolmanager').checked = true; + document.getElementById('showcolmanager').disabled = ''; + } + } } return; } @@ -6900,16 +6961,16 @@ sub print_main_menu { linktitle => 'View change log.', }, { - linktext => 'Co-authors who can add/revoke co-author roles', - icon => 'helpdesk-access.png', + linktext => 'Co-author Managers', + icon => 'camanager.png', #help => 'Coauthor_Management', url => '/adm/createuser?action=camanagers', permission => $permission->{'author'}, linktitle => 'Assign/Revoke right to manage co-author roles', }, { - linktext => 'Configure coauthor-viewable listing', - icon => 'helpdesk-access.png', + linktext => 'Configure Co-author Listing', + icon => 'coauthors.png', #help => 'Coauthor_Settings', url => '/adm/createuser?action=calist&forceedit=1', permission => ($permission->{'cusr'}),