--- loncom/interface/loncreateuser.pm 2023/11/03 01:12:15 1.470 +++ loncom/interface/loncreateuser.pm 2024/05/01 15:18:58 1.477 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.470 2023/11/03 01:12:15 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.477 2024/05/01 15:18:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -245,10 +245,15 @@ function toggleCustom(form,item,name) { if (radioname) { if (radioname.length > 0) { var setvis; + var RegExp = /^customtext_(aboutme|blog|portfolio|portaccess|timezone|webdav)\$/; for (var i=0; i "Personal User Blog", '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", + 'archive' => "Managers can download tar.gz file of Authoring Space", 'portfolio' => "Personal User Portfolio", 'portaccess' => "Portfolio Shareable", 'timezone' => "Can set Time Zone", @@ -324,8 +330,9 @@ sub build_tools_display { %domconfig = &Apache::lonnet::get_dom('configuration',['quotas','authordefaults'],$ccdomain); %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,'tools.webdav', - 'authoreditors','authormanagers'); - @usertools = ('webdav','editors','managers'); + 'authoreditors','authormanagers', + 'authorarchive','domcoord.author'); + @usertools = ('webdav','editors','managers','archive'); $colspan = ' colspan="2"'; } else { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, @@ -336,20 +343,22 @@ sub build_tools_display { } foreach my $item (@usertools) { my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off, - $currdisp,$custdisp,$custradio,$onclick); + $currdisp,$custdisp,$custradio,$onclick,$customsty,$editorsty); $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 eq '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" '; $cust_off = ''; } } elsif ($context eq 'authordefaults') { - if ($item eq 'editors') { + if (($item eq 'editors') || ($item eq 'archive')) { if ($userenv{'author'.$item} ne '') { $cust_on = ' checked="checked" '; $cust_off = ''; @@ -473,16 +482,14 @@ sub build_tools_display { ' '."\n". &Apache::loncommon::start_data_table_row()."\n"; if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { - my ($curroption,$currlimit,$customsty); + my ($curroption,$currlimit); my $envkey = $context.'.'.$item; if ($context eq 'requestauthor') { $envkey = $context; } if ($userenv{$envkey} ne '') { $curroption = $userenv{$envkey}; - $customsty = ' style="display:block"'; } else { - $customsty = ' style="display:none"'; my (@inststatuses); if ($context eq 'requestcourses') { $curroption = @@ -590,7 +597,9 @@ sub build_tools_display { } elsif ($item eq 'managers') { $output .= ''.$custom_access.''."\n". &Apache::loncommon::end_data_table_row()."\n"; - unless (&Apache::lonnet::allowed('udp',$ccdomain)) { + unless ((&Apache::lonnet::allowed('udp',$ccdomain)) || + (($userenv{'domcoord.author'} eq 'blocked') && + (($env{'user.name'} ne $ccuname) || ($env{'user.domain'} ne $ccdomain)))) { $output .= &Apache::loncommon::start_data_table_row()."\n". ''; @@ -3227,7 +3236,7 @@ sub update_user_data { my @usertools = ('aboutme','blog','portfolio','portaccess','timezone'); my @requestcourses = ('official','unofficial','community','textbook','placement','lti'); my @requestauthor = ('requestauthor'); - my @authordefaults = ('webdav','editors','managers'); + my @authordefaults = ('webdav','editors','archive'); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'}); my %canmodify_status = @@ -3359,6 +3368,12 @@ sub update_user_data { $changed{'webdav'} = &tool_admin('webdav',$newcustom{'webdav'}, \%changeHash,'authordefaults'); } + if ($env{'for.customarchive'} == 1) { + $newcustom{'archive'} = $env{'form.authordefaults_archive'}; + $changed{'archive'} = &tool_admin('archive',$newcustom{'archive'}, + \%changeHash,'authordefaults'); + + } } if ($canmodify_status{'inststatus'}) { if (exists($env{'form.inststatus'})) { @@ -3426,18 +3441,23 @@ sub update_user_data { 'id','permanentemail','portfolioquota','authorquota','inststatus', 'tools.aboutme','tools.blog','tools.webdav', 'tools.portfolio','tools.timezone','tools.portaccess', - 'authormanagers','authoreditors','requestauthor', + 'authormanagers','authoreditors','authorarchive','requestauthor', 'requestcourses.official','requestcourses.unofficial', 'requestcourses.community','requestcourses.textbook', 'requestcourses.placement','requestcourses.lti', 'reqcrsotherdom.official','reqcrsotherdom.unofficial', 'reqcrsotherdom.community','reqcrsotherdom.textbook', - 'reqcrsotherdom.placement'], + 'reqcrsotherdom.placement','domcoord.author'], $env{'form.ccdomain'},$env{'form.ccuname'}); my ($tmp) = keys(%userenv); if ($tmp =~ /^(con_lost|error)/i) { %userenv = (); } + unless (($userenv{'domcoord.author'} eq 'blocked') && + (($env{'user.name'} ne $env{'form.ccuname'}) || + ($env{'user.domain'} ne $env{'form.ccdomain'}))) { + push(@authordefaults,'managers'); + } my $no_forceid_alert; # Check to see if user information can be changed my %domconfig = @@ -3773,7 +3793,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') || @@ -3783,28 +3806,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') { @@ -3814,9 +3864,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); } } } @@ -4017,7 +4078,8 @@ 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", + 'archive' => "Managers can download tar.gz file of Authoring Space", 'edit' => 'Standard editor (Edit)', 'xml' => 'Text editor (EditXML)', 'daxe' => 'Daxe editor (Daxe)', @@ -4051,7 +4113,7 @@ sub display_userinfo { if ($entry eq 'requestauthor') { @items = ($entry); } elsif ($entry eq 'authordefaults') { - @items = ('webdav','managers','editors'); + @items = ('webdav','managers','editors','archive'); } else { @items = @{$requestcourses}; } @@ -4302,6 +4364,9 @@ sub tool_changes { } elsif ($tool eq 'webdav') { $envkey = 'tools.webdav'; $newval = $env{'form.'.$context.'_'.$tool}; + } elsif ($tool eq 'archive') { + $envkey = 'authorarchive'; + $newval = $env{'form.'.$context.'_'.$tool}; } } else { $newval = $env{'form.'.$context.'_'.$tool}; @@ -4333,7 +4398,7 @@ sub tool_changes { } elsif ($tool eq 'editors') { $oldaccesstext->{$tool} = &mt('can use: [_1]', join(', ', map { $tooldesc{$_} } split(/,/,$userenv->{$envkey}))); - } elsif ($tool eq 'webdav') { + } elsif (($tool eq 'webdav') || ($tool eq 'archive')) { if ($userenv->{$envkey}) { $oldaccesstext->{$tool} = &mt("availability set to 'on'"); } else { @@ -4379,7 +4444,7 @@ sub tool_changes { $managers =~ s/,/, /g; $newaccesstext->{$tool} = $managers; } - } elsif ($tool eq 'webdav') { + } elsif (($tool eq 'webdav') || ($tool eq 'archive')) { if ($newval) { $newaccesstext->{$tool} = &mt("availability set to 'on'"); } else { @@ -4419,7 +4484,7 @@ sub tool_changes { $managers =~ s/,/, /g; $newaccesstext->{$tool} = $managers; } - } elsif ($tool eq 'webdav') { + } elsif (($tool eq 'webdav') || ($tool eq 'archive')) { if ($userenv->{$envkey}) { $newaccesstext->{$tool} = &mt("availability set to 'on'"); } else { @@ -4468,7 +4533,7 @@ sub tool_changes { $managers =~ s/,/, /g; $newaccesstext->{$tool} = $managers; } - } elsif ($tool eq 'webdav') { + } elsif (($tool eq 'webdav') || ($tool eq 'archive')) { if ($userenv->{$envkey}) { $newaccesstext->{$tool} = &mt("availability set to 'on'"); } else { @@ -4516,7 +4581,7 @@ sub tool_changes { } elsif ($tool eq 'editors') { $newaccesstext->{$tool} = &mt('can use: [_1]', join(', ', map { $tooldesc{$_} } split(/,/,$newval))); - } elsif ($tool eq 'webdav') { + } elsif (($tool eq 'webdav') || ($tool eq 'archive')) { if ($newval) { $newaccesstext->{$tool} = &mt("availability set to 'on'"); } else { @@ -5180,7 +5245,7 @@ sub tool_admin { $toolchanged = 1; if ($tool eq 'requestauthor') { $changeHash->{$context} = $settool; - } elsif (($tool eq 'managers') || ($tool eq 'editors')) { + } elsif (($tool eq 'managers') || ($tool eq 'editors') || ($tool eq 'archive')) { $changeHash->{'author'.$tool} = $settool; } elsif ($tool eq 'webdav') { $changeHash->{'tools.'.$tool} = $settool; @@ -5498,7 +5563,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)) { @@ -6342,7 +6407,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}, @@ -6502,6 +6567,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') { @@ -6587,6 +6661,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; } @@ -6892,16 +6975,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'}),