--- loncom/interface/loncreateuser.pm 2023/11/17 17:02:20 1.474 +++ loncom/interface/loncreateuser.pm 2024/05/21 02:57:15 1.480 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.474 2023/11/17 17:02:20 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.480 2024/05/21 02:57:15 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|archive)\$/; 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 roles", + 'archive' => "Managers can download tar.gz file of Authoring Space", 'portfolio' => "Personal User Portfolio", 'portaccess' => "Portfolio Shareable", 'timezone' => "Can set Time Zone", @@ -325,8 +331,8 @@ sub build_tools_display { &Apache::lonnet::get_dom('configuration',['quotas','authordefaults'],$ccdomain); %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,'tools.webdav', 'authoreditors','authormanagers', - 'domcoord.author'); - @usertools = ('webdav','editors','managers'); + 'authorarchive','domcoord.author'); + @usertools = ('webdav','editors','managers','archive'); $colspan = ' colspan="2"'; } else { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, @@ -337,10 +343,10 @@ 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" '; - unless (($context eq 'authordefaults') && ($item ne 'webdav')) { + unless (($context eq 'authordefaults') || ($item eq 'webdav')) { $curr_access = &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, $context,\%userenv,'', @@ -352,10 +358,18 @@ sub build_tools_display { $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 = ''; + if ($item eq 'archive') { + $curr_access = $userenv{'author'.$item}; + } + } elsif ($item eq 'archive') { + $curr_access = 0; + if (ref($domconfig{'authordefaults'}) eq 'HASH') { + $curr_access = $domconfig{'authordefaults'}{'archive'}; + } } } elsif ($item eq 'webdav') { if ($userenv{'tools.'.$item} ne '') { @@ -452,6 +466,8 @@ sub build_tools_display { my $current = $userenv{$context.'.'.$item}; if ($item eq 'webdav') { $current = $userenv{'tools.webdav'}; + } elsif ($item eq 'archive') { + $current = $userenv{'author'.$item}; } if ($current eq '') { $custom_access = @@ -476,16 +492,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 = @@ -1520,7 +1534,7 @@ sub print_user_modification_page { unless ($isauthor) { push(@toggles,'requestauthor'); } - push(@toggles,('webdav','editors')); + push(@toggles,('webdav','editors','archive')); } if (&Apache::lonnet::allowed('mut',$ccdomain)) { push(@toggles,('aboutme','blog','portfolio','portaccess','timezone')); @@ -3232,7 +3246,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'); + my @authordefaults = ('webdav','editors','archive'); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'}); my %canmodify_status = @@ -3362,7 +3376,13 @@ sub update_user_data { if ($env{'form.customwebdav'} == 1) { $newcustom{'webdav'} = $env{'form.authordefaults_webdav'}; $changed{'webdav'} = &tool_admin('webdav',$newcustom{'webdav'}, - \%changeHash,'authordefaults'); + \%changeHash,'authordefaults'); + } + if ($env{'form.customarchive'} == 1) { + $newcustom{'archive'} = $env{'form.authordefaults_archive'}; + $changed{'archive'} = &tool_admin('archive',$newcustom{'archive'}, + \%changeHash,'authordefaults'); + } } if ($canmodify_status{'inststatus'}) { @@ -3431,7 +3451,7 @@ 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', @@ -3847,6 +3867,21 @@ sub update_user_data { $newenvhash{'environment.editors'} = 'edit,xml'; } } + } elsif ($key eq 'archive') { + $newenvhash{'environment.author.'.$key} = + $changeHash{'author.'.$key}; + if ($changeHash{'author.'.$key} ne '') { + $newenvhash{'environment.canarchive'} = + $changeHash{'author.'.$key}; + } else { + unless ($got_domdefs) { + %domdefaults = + &Apache::lonnet::get_domain_defaults($env{'user.domain'}); + $got_domdefs = 1; + } + $newenvhash{'environment.canarchive'} = + $domdefaults{'archive'}; + } } elsif ($key ne 'quota') { $newenvhash{'environment.tools.'.$key} = $changeHash{'tools.'.$key}; @@ -4069,6 +4104,7 @@ sub display_userinfo { 'chto' => 'Changed To:', 'editors' => "Available Editors in Authoring Space", '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)', @@ -4102,7 +4138,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}; } @@ -4353,6 +4389,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}; @@ -4384,7 +4423,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 { @@ -4430,7 +4469,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 { @@ -4470,7 +4509,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 { @@ -4519,7 +4558,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 { @@ -4567,7 +4606,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 { @@ -5231,7 +5270,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;