[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm
raeburn
raeburn at source.lon-capa.org
Wed Sep 6 09:57:05 EDT 2023
raeburn Wed Sep 6 13:57:05 2023 EDT
Modified files:
/loncom/interface domainprefs.pm
Log:
- Add "Authoring Space defaults" domain configuration
- Two types: defaults which author or co-author can override; defaults
which domain coordinator can override.
- Setting of existing domain defaults for Authoring Space disk quota
and availability of webDAV moved from Blogs, ... , webDAV/quotas, ...
panel to new panel.
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.428 loncom/interface/domainprefs.pm:1.429
--- loncom/interface/domainprefs.pm:1.428 Sat Jul 29 20:33:25 2023
+++ loncom/interface/domainprefs.pm Wed Sep 6 13:57:05 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.428 2023/07/29 20:33:25 raeburn Exp $
+# $Id: domainprefs.pm,v 1.429 2023/09/06 13:57:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -95,8 +95,7 @@
institutional affiliation in the domain (e.g., Faculty, Staff, Student etc.),
but is now also used to manage availability of user tools:
i.e., blogs, aboutme page, and portfolios, and the course request tool,
-used by course owners to request creation of a course, and to display/store
-default quota sizes for Authoring Spaces.
+used by course owners to request creation of a course.
Outputs: 1
@@ -223,7 +222,8 @@
'coursedefaults','usersessions','loadbalancing',
'requestauthor','selfenrollment','inststatus',
'ltitools','toolsec','ssl','trust','lti','ltisec',
- 'privacy','passwords','proctoring','wafproxy','ipaccess'],$dom);
+ 'privacy','passwords','proctoring','wafproxy',
+ 'ipaccess','authordefaults'],$dom);
my %encconfig =
&Apache::lonnet::get_dom('encconfig',['ltitools','lti','proctoring','linkprot'],$dom,undef,1);
my ($checked_is_home,$is_home);
@@ -305,8 +305,8 @@
'contacts','privacy','usercreation','selfcreation',
'usermodification','scantron','requestcourses','requestauthor',
'coursecategories','serverstatuses','helpsettings','coursedefaults',
- 'ltitools','proctoring','selfenrollment','usersessions','ssl',
- 'trust','lti');
+ 'authordefaults','ltitools','proctoring','selfenrollment',
+ 'usersessions','ssl','trust','lti');
my %existing;
if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
%existing = %{$domconfig{'loadbalancing'}};
@@ -382,11 +382,11 @@
modify => \&modify_passwords,
},
'quotas' =>
- { text => 'Blogs, personal pages/timezones, webDAV/quotas, portfolio',
+ { text => 'Blogs, personal pages/timezones, portfolio/quotas',
help => 'Domain_Configuration_Quotas',
header => [{col1 => 'User affiliation',
col2 => 'Available tools',
- col3 => 'Quotas, MB; (Authoring requires role)',}],
+ col3 => 'Portfilo quota (MB)',}],
print => \&print_quotas,
modify => \&modify_quotas,
},
@@ -684,6 +684,16 @@
print => \&print_ipaccess,
modify => \&modify_ipaccess,
},
+ 'authordefaults' =>
+ {text => 'Authoring Space defaults',
+ help => 'Domain_Configuration_Author_Defaults',
+ header => [{col1 => 'Defaults which can be overridden by Author',
+ col2 => 'Settings',},
+ {col1 => 'Defaults which can be overridden by a Dom. Coord.',
+ col2 => 'Settings',},],
+ print => \&print_authordefaults,
+ modify => \&modify_authordefaults,
+ },
);
if (keys(%servers) > 1) {
$prefs{'login'} = { text => 'Log-in page options',
@@ -889,6 +899,8 @@
$output = &modify_wafproxy($dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'ipaccess') {
$output = &modify_ipaccess($dom,$lastactref,%domconfig);
+ } elsif ($action eq 'authordefaults') {
+ $output = &modify_authordefaults($dom,$lastactref,%domconfig);
}
return $output;
}
@@ -936,6 +948,8 @@
$output .= &saml_javascript();
} elsif ($action eq 'ipaccess') {
$output .= &ipaccess_javascript($settings);
+ } elsif ($action eq 'authordefaults') {
+ $output .= &authordefaults_javascript();
}
$output .=
'<table class="LC_nested_outer">
@@ -978,7 +992,7 @@
($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'ssl') ||
($action eq 'directorysrch') || ($action eq 'trust') || ($action eq 'helpsettings') ||
($action eq 'contacts') || ($action eq 'privacy') || ($action eq 'wafproxy') ||
- ($action eq 'lti') || ($action eq 'ltitools')) {
+ ($action eq 'lti') || ($action eq 'ltitools') || ($action eq 'authordefaults')) {
$output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'passwords') {
$output .= $item->{'print'}->('top',$dom,$confname,$settings,\$rowtotal);
@@ -1103,7 +1117,7 @@
$rowtotal ++;
} elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
($action eq 'directorysrch') || ($action eq 'helpsettings') ||
- ($action eq 'wafproxy')) {
+ ($action eq 'wafproxy') || ($action eq 'authordefaults')) {
$output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= $item->{'print'}->($r,'bottom',$dom,$confname,$settings,\$rowtotal);
@@ -2397,7 +2411,7 @@
} else {
$context = $action;
}
- my ($datatable,$defaultquota,$authorquota, at usertools, at options,%validations);
+ my ($datatable,$defaultquota, at usertools, at options,%validations);
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
my $typecount = 0;
my ($css_class,%titles);
@@ -2411,12 +2425,12 @@
@options = ('norequest','approval','automatic');
%titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','webdav','portfolio','timezone');
+ @usertools = ('aboutme','blog','portfolio','timezone');
%titles = &tool_titles();
}
if (ref($types) eq 'ARRAY') {
foreach my $type (@{$types}) {
- my ($currdefquota,$currauthorquota);
+ my $currdefquota;
unless (($context eq 'requestcourses') ||
($context eq 'requestauthor')) {
if (ref($settings) eq 'HASH') {
@@ -2425,9 +2439,6 @@
} else {
$currdefquota = $settings->{$type};
}
- if (ref($settings->{authorquota}) eq 'HASH') {
- $currauthorquota = $settings->{authorquota}->{$type};
- }
}
}
if (defined($usertypes->{$type})) {
@@ -2545,13 +2556,9 @@
($context eq 'requestauthor')) {
$datatable .=
'<td class="LC_right_item">'.
- '<span class="LC_nobreak">'.&mt('Portfolio').': '.
+ '<span class="LC_nobreak">'.
'<input type="text" name="quota_'.$type.
'" value="'.$currdefquota.
- '" size="5" /></span>'.(' ' x 2).
- '<span class="LC_nobreak">'.&mt('Authoring').': '.
- '<input type="text" name="authorquota_'.$type.
- '" value="'.$currauthorquota.
'" size="5" /></span></td>';
}
$datatable .= '</tr>';
@@ -2560,16 +2567,12 @@
}
unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
$defaultquota = '20';
- $authorquota = '500';
if (ref($settings) eq 'HASH') {
if (ref($settings->{'defaultquota'}) eq 'HASH') {
$defaultquota = $settings->{'defaultquota'}->{'default'};
} elsif (defined($settings->{'default'})) {
$defaultquota = $settings->{'default'};
}
- if (ref($settings->{'authorquota'}) eq 'HASH') {
- $authorquota = $settings->{'authorquota'}->{'default'};
- }
}
}
$typecount ++;
@@ -2681,12 +2684,9 @@
$datatable .= '</td>';
unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
$datatable .= '<td class="LC_right_item">'.
- '<span class="LC_nobreak">'.&mt('Portfolio').': '.
+ '<span class="LC_nobreak">'.
'<input type="text" name="defaultquota" value="'.
- $defaultquota.'" size="5" /></span>'.(' ' x2).
- '<span class="LC_nobreak">'.&mt('Authoring').': '.
- '<input type="text" name="authorquota" value="'.
- $authorquota.'" size="5" /></span></td>';
+ $defaultquota.'" size="5" /></span></td>';
}
$datatable .= '</tr>';
$typecount ++;
@@ -3942,6 +3942,39 @@
ENDSCRIPT
}
+sub authordefaults_javascript {
+ my %alert = &Apache::lonlocal::texthash (
+ reqd => 'Warning: at least one editor needs to be available.',
+ rest => 'Unchecking this editor disallowed while others unchecked.',
+ );
+ &js_escape(\%alert);
+ return <<"ENDSCRIPT";
+<script type="text/javascript">
+// <![CDATA[
+
+function checkEditors(form,checkbox,current) {
+ if (form.elements[checkbox].length != undefined) {
+ var count = 0;
+ for (var i=0; i<form.elements[checkbox].length; i++) {
+ if (form.elements[checkbox][i].checked) {
+ count ++;
+ }
+ }
+ if (count == 0) {
+ if (current.type =='radio') {
+ current.checked = true;
+ alert('$alert{reqd}\\n$alert{rest}');
+ }
+ }
+ }
+ return;
+}
+// ]]>
+</script>
+
+ENDSCRIPT
+}
+
sub print_autoenroll {
my ($dom,$settings,$rowtotal) = @_;
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
@@ -7168,6 +7201,214 @@
return $datatable;
}
+sub print_authordefaults {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable,%checkedon,%checkedoff);
+ my $itemcount = 1;
+ my %titles = &authordefaults_titles();
+ if ($position eq 'top') {
+ my %defaultchecked = (
+ 'nocodemirror' => 'off',
+ 'domcoordacc' => 'on',
+ );
+ my @toggles = ('nocodemirror','domcoordacc');
+ ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
+ \%titles,$itemcount);
+ my %staticdefaults = (
+ 'copyright' => 'default',
+ 'sourceavail' => 'closed',
+ );
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my %currrights;
+ foreach my $item ('copyright','sourceavail') {
+ $currrights{$item} = $staticdefaults{$item};
+ if (ref($settings) eq 'HASH') {
+ if (exists($settings->{$item})) {
+ $currrights{$item} = $settings->{$item};
+ }
+ }
+ }
+ $datatable .= '<tr'.$css_class.'><td style="vertical-align: top">'.
+ '<span class="LC_nobreak">'.$titles{'copyright'}.
+ '</span></td><td class="LC_right_item">'.
+ &selectbox('copyright',$currrights{'copyright'},'',
+ \&Apache::loncommon::copyrightdescription,
+ (grep !/^priv|custom$/,(&Apache::loncommon::copyrightids))).
+ '</td></tr>'."\n";
+ $itemcount ++;
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= '<tr'.$css_class.'><td style="vertical-align: top">'.
+ '<span class="LC_nobreak">'.$titles{'sourceavail'}.
+ '</span></td><td class="LC_right_item">'.
+ &selectbox('sourceavail',$currrights{'sourceavail'},'',
+ \&Apache::loncommon::source_copyrightdescription,
+ (&Apache::loncommon::source_copyrightids)).
+ '</td></tr>'."\n";
+ } else {
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ my $curreditors;
+ my %staticdefaults = (
+ editors => ['edit','xml'],
+ authorquota => 500,
+ webdav => 0,
+ );
+ my $curreditors = $staticdefaults{'editors'};
+ if ((ref($settings) eq 'HASH') &&
+ (ref($settings->{'editors'}) eq 'ARRAY')) {
+ $curreditors = $settings->{'editors'};
+ } else {
+ $curreditors = $staticdefaults{'editors'};
+ }
+ my @editors = ('edit','xml','daxe');
+ $datatable = '<tr'.$css_class.'>'."\n".
+ '<td>'.$titles{'editors'}.'</td>'."\n".
+ '<td class="LC_left_item">'."\n".
+ '<span class="LC_nobreak">';
+ foreach my $editor (@editors) {
+ my $checked;
+ if (grep(/^\Q$editor\E$/,@{$curreditors})) {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= '<label>'.
+ '<input type="checkbox" name="author_editors" '.
+ $checked.' value="'.$editor.'" '.
+ 'onclick="javascript:checkEditors(this.form,'."'author_editors'".',this);" />'.
+ $titles{$editor}.'</label> ';
+ }
+ $datatable .= '</span>'."\n".'</td>'."\n".'</tr>'."\n";
+ $itemcount ++;
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ my @insttypes;
+ if (ref($types) eq 'ARRAY') {
+ @insttypes = @{$types};
+ }
+ my $typecount = 0;
+ my %domconf = &Apache::lonnet::get_dom('configuration',['quotas'],$dom);
+ my @items = ('webdav','authorquota');
+ my %quotas;
+ if (ref($domconf{'quotas'}) eq 'HASH') {
+ %quotas = %{$domconf{'quotas'}};
+ foreach my $item (@items) {
+ if (ref($quotas{$item}) eq 'HASH') {
+ foreach my $type (@insttypes,'default') {
+ if ($item eq 'authorquota') {
+ if ($quotas{$item}{$type} !~ /^\d+$/) {
+ $quotas{$item}{$type} = $staticdefaults{$item};
+ }
+ } elsif ($item eq 'webdav') {
+ if ($quotas{$item}{$type} !~ /^(0|1)$/) {
+ $quotas{$item}{$type} = $staticdefaults{$item};
+ }
+ }
+ }
+ } else {
+ foreach my $type (@insttypes,'default') {
+ $quotas{$item}{$type} = $staticdefaults{$item};
+ }
+ }
+ }
+ } else {
+ foreach my $item (@items) {
+ foreach my $type (@insttypes,'default') {
+ $quotas{$item}{$type} = $staticdefaults{$item};
+ }
+ }
+ }
+ if (ref($usertypes) eq 'HASH') {
+ my $numinrow = 4;
+ my $onclick = '';
+ $datatable .= &insttypes_row(\%quotas,$types,$usertypes,$dom,
+ $numinrow,$othertitle,'authorquota',
+ \$itemcount,$onclick);
+ $itemcount ++;
+ $datatable .= &insttypes_row(\%quotas,$types,$usertypes,$dom,
+ $numinrow,$othertitle,'webdav',
+ \$itemcount);
+ $itemcount ++;
+ }
+ my $checkedno = ' checked="checked"';
+ my ($checkedon,$checkedoff);
+ if (ref($quotas{'webdav'}) eq 'HASH') {
+ if ($quotas{'webdav'}{'_LC_adv'} =~ /^0|1$/) {
+ if ($quotas{'webdav'}{'_LC_adv'}) {
+ $checkedon = $checkedno;
+ } else {
+ $checkedoff = $checkedno;
+ }
+ undef($checkedno);
+ }
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= '<tr'.$css_class.'>'.
+ '<td>'.$titles{'webdav_LC_adv'}.'<br />'.
+ $titles{'webdav_LC_adv_over'}.
+ '</td>'.
+ '<td class="LC_left_item">';
+ foreach my $option ('none','off','on') {
+ my ($text,$val,$checked);
+ if ($option eq 'none') {
+ $text = $titles{'none'};
+ $val = '';
+ $checked = $checkedno;
+ } elsif ($option eq 'off') {
+ $text = $titles{'overoff'};
+ $val = 0;
+ $checked = $checkedoff;
+ } elsif ($option eq 'on') {
+ $text = $titles{'overon'};
+ $val = 1;
+ $checked = $checkedon;
+ }
+ $datatable .= '<span class="LC_nobreak"><label>'.
+ '<input type="radio" name="webdav_LC_adv"'.
+ ' value="'.$val.'"'.$checked.' />'.
+ $text.'</label></span> ';
+ }
+ $datatable .= '</td></tr>';
+ $itemcount ++;
+ }
+ $$rowtotal += $itemcount;
+ return $datatable;
+}
+
+sub authordefaults_titles {
+ return &Apache::lonlocal::texthash(
+ copyright => 'Copyright/Distribution',
+ sourceavail => ' Source Available',
+ editors => 'Available Editors',
+ webdav => 'WebDAV',
+ authorquota => 'Authoring Space quotas (MB)',
+ nocodemirror => 'Deactivate CodeMirror for EditXML editor',
+ domcoordacc => 'Dom. Coords. can enter Authoring Spaces in domain',
+ edit => 'Standard editor (Edit)',
+ xml => 'Text editor (EditXML)',
+ daxe => 'Daxe editor (Daxe)',
+ webdav_LC_adv => 'WebDAV access for LON-CAPA "advanced" users',
+ webdav_LC_adv_over => '(overrides access based on affiliation, if set)',
+ none => 'No override set',
+ overon => 'Override -- webDAV on',
+ overoff => 'Override -- webDAV off',
+ );
+}
+
+sub selectbox {
+ my ($name,$value,$readonly,$functionref, at idlist)=@_;
+ my $selout = '<select name="'.$name.'">';
+ foreach my $id (@idlist) {
+ $selout.='<option value="'.$id.'"';
+ if ($id eq $value) {
+ $selout.=' selected="selected"';
+ }
+ if ($readonly) {
+ $selout .= ' disabled="disabled"';
+ }
+ $selout.='>'.&{$functionref}($id).'</option>';
+ }
+ $selout.='</select>';
+ return $selout;
+}
+
sub print_selfenrollment {
my ($position,$dom,$settings,$rowtotal) = @_;
my ($css_class,$datatable);
@@ -9410,7 +9651,6 @@
my %titles = &Apache::lonlocal::texthash (
aboutme => 'Personal web page',
blog => 'Blog',
- webdav => 'WebDAV',
portfolio => 'Portfolio',
timezone => 'Can set time zone',
official => 'Official courses (with institutional codes)',
@@ -11848,15 +12088,19 @@
my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context,$rowtotal,$onclick,
$customcss,$rowstyle) = @_;
my %lt = &Apache::lonlocal::texthash (
- cansearch => 'Users allowed to search',
+ cansearch => 'Users allowed to search',
statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)',
- lockablenames => 'User preference to lock name',
- selfassign => 'Self-reportable affiliations',
- overrides => "Override domain's helpdesk settings based on requester's affiliation",
+ lockablenames => 'User preference to lock name',
+ selfassign => 'Self-reportable affiliations',
+ overrides => "Override domain's helpdesk settings based on requester's affiliation",
+ webdav => 'WebDAV access available',
+ authorquota => 'Authoring Space quota (MB)',
);
- my $showdom;
+ my ($showdom,$defaultquota);
if ($context eq 'cansearch') {
$showdom = ' ('.$dom.')';
+ } elsif ($context eq 'authorquota') {
+ $defaultquota = 500;
}
my $class = 'LC_left_item';
if ($context eq 'statustocreate') {
@@ -11893,25 +12137,44 @@
}
$output .= '<tr>';
}
- my $check = ' ';
- if (ref($settings) eq 'HASH') {
- if (ref($settings->{$context}) eq 'ARRAY') {
- if (grep(/^\Q$types->[$i]\E$/,@{$settings->{$context}})) {
- $check = ' checked="checked" ';
- }
- } elsif (ref($settings->{$context}) eq 'HASH') {
- if (ref($settings->{$context}->{$types->[$i]}) eq 'HASH') {
+ if ($context eq 'authorquota') {
+ my $currquota;
+ if ($settings->{$context}->{$types->[$i]} =~ /^\d+$/) {
+ $currquota = $settings->{$context}->{$types->[$i]};
+ } else {
+ $currquota = $defaultquota;
+ }
+ $output .= '<td class="LC_left_item">'."\n".
+ '<label><span class="LC_nobreak">'."\n".
+ $usertypes->{$types->[$i]}.'</span><br />'."\n".
+ '<input type="text" name="'.$context.'_'.$types->[$i].'" '.
+ 'value="'.$currquota.'" size="5"'.$onclick.'/>'."\n".
+ '</label></td>';
+ } else {
+ my $check = ' ';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$context}) eq 'ARRAY') {
+ if (grep(/^\Q$types->[$i]\E$/,@{$settings->{$context}})) {
+ $check = ' checked="checked" ';
+ }
+ } elsif (ref($settings->{$context}) eq 'HASH') {
+ if (ref($settings->{$context}->{$types->[$i]}) eq 'HASH') {
+ $check = ' checked="checked" ';
+ } elsif ($context eq 'webdav') {
+ if ($settings->{$context}->{$types->[$i]}) {
+ $check = ' checked="checked" ';
+ }
+ }
+ } elsif ($context eq 'statustocreate') {
$check = ' checked="checked" ';
}
- } elsif ($context eq 'statustocreate') {
- $check = ' checked="checked" ';
}
+ $output .= '<td class="LC_left_item">'.
+ '<span class="LC_nobreak"><label>'.
+ '<input type="checkbox" name="'.$context.'" '.
+ 'value="'.$types->[$i].'"'.$check.$onclick.'/>'.
+ $usertypes->{$types->[$i]}.'</label></span></td>';
}
- $output .= '<td class="LC_left_item">'.
- '<span class="LC_nobreak"><label>'.
- '<input type="checkbox" name="'.$context.'" '.
- 'value="'.$types->[$i].'"'.$check.$onclick.' />'.
- $usertypes->{$types->[$i]}.'</label></span></td>';
}
}
$rem = @{$types}%($numinrow);
@@ -11933,20 +12196,41 @@
} else {
$output .= '<td class="LC_left_item">';
}
- my $defcheck = ' ';
- if (ref($settings) eq 'HASH') {
- if (ref($settings->{$context}) eq 'ARRAY') {
- if (grep(/^default$/,@{$settings->{$context}})) {
+ if ($context eq 'authorquota') {
+ my $currquota = 500;
+ if ((ref($settings) eq 'HASH') && (ref($settings->{$context}) eq 'HASH')) {
+ if ($settings->{$context}{'default'} =~ /^\d+$/) {
+ $currquota = $settings->{$context}{'default'};
+ }
+ }
+ $output .= '<label><span class="LC_nobreak">'.$othertitle.'</span><br />'."\n".
+ '<input type="text" name="'.$context.'_default" '.
+ 'value="'.$currquota.'" size="5"'.$onclick.'/>'."\n".
+ '</label>';
+ } else {
+ my $defcheck = ' ';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$context}) eq 'ARRAY') {
+ if (grep(/^default$/,@{$settings->{$context}})) {
+ $defcheck = ' checked="checked" ';
+ }
+ } elsif (ref($settings->{$context}) eq 'HASH') {
+ if (ref($settings->{$context}->{'default'}) eq 'HASH') {
+ $defcheck = ' checked="checked" ';
+ } elsif ($context eq 'webdav') {
+ if ($settings->{$context}->{'default'}) {
+ $defcheck = ' checked="checked" ';
+ }
+ }
+ } elsif ($context eq 'statustocreate') {
$defcheck = ' checked="checked" ';
}
- } elsif ($context eq 'statustocreate') {
- $defcheck = ' checked="checked" ';
}
+ $output .= '<span class="LC_nobreak"><label>'.
+ '<input type="checkbox" name="'.$context.'" '.
+ 'value="default"'.$defcheck.$onclick.'/>'.
+ $othertitle.'</label></span>';
}
- $output .= '<span class="LC_nobreak"><label>'.
- '<input type="checkbox" name="'.$context.'" '.
- 'value="default"'.$defcheck.$onclick.' />'.
- $othertitle.'</label></span>';
}
$output .= '</td></tr></table></td></tr>';
return $output;
@@ -12960,6 +13244,235 @@
return ($id,$error);
}
+sub modify_authordefaults {
+ my ($dom,$lastactref,%domconfig) = @_;
+#
+# Retrieve current domain configuration for webDAV and Authoring Space quotas from $domconfig{'quotas'}.
+#
+ my (%curr_quotas,%save_quotas,%confhash,%changes,%newvalues);
+ if (ref($domconfig{'quotas'}) eq 'HASH') {
+ foreach my $key (keys(%{$domconfig{'quotas'}})) {
+ if ($key =~ /^webdav|authorquota$/) {
+ $curr_quotas{$key} = $domconfig{'quotas'}{$key};
+ } else {
+ $save_quotas{$key} = $domconfig{'quotas'}{$key};
+ }
+ }
+ }
+ my %staticdefaults = (
+ 'copyright' => 'default',
+ 'sourceavail' => 'closed',
+ 'nocodemirror' => 'off',
+ 'domcoordacc' => 'on',
+ 'editors' => ['edit','xml'].
+ 'authorquota' => 500,
+ 'webdav' => 0,
+ );
+ my %titles = &authordefaults_titles();
+ foreach my $item ('nocodemirror','domcoordacc') {
+ if ($env{'form.'.$item} =~ /^(0|1)$/) {
+ $confhash{$item} = $env{'form.'.$item};
+ }
+ }
+ if ($env{'form.copyright'} =~ /^(default|domain|public)$/) {
+ $confhash{'copyright'} = $1;
+ }
+ if ($env{'form.sourceavail'} =~ /^(closed|open)$/) {
+ $confhash{'sourceavail'} = $1;
+ }
+ my @posseditors = &Apache::loncommon::get_env_multiple('form.author_editors');
+ my @okeditors = ('edit','xml','daxe');
+ my @editors;
+ foreach my $item (@posseditors) {
+ if (grep(/^\Q$item\E$/, at okeditors)) {
+ push(@editors,$item);
+ }
+ }
+ $confhash{'editors'} = \@editors;
+
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ my @insttypes;
+ if (ref($types) eq 'ARRAY') {
+ @insttypes = @{$types};
+ }
+ my @webdavon = &Apache::loncommon::get_env_multiple('form.webdav');
+ my %webdav;
+ map { $webdav{$_} = 1; } @webdavon;
+ foreach my $type (@insttypes,'default') {
+ my $possquota = $env{'form.authorquota_'.$type};
+ if ($possquota =~ /^\d+$/) {
+ $save_quotas{'authorquota'}{$type} = $possquota;
+ }
+ if ($webdav{$type}) {
+ $save_quotas{'webdav'}{$type} = 1;
+ } else {
+ $save_quotas{'webdav'}{$type} = 0;
+ }
+ }
+ if ($env{'form.webdav_LC_adv'} =~ /^(0|1)$/) {
+ $save_quotas{'webdav'}{'_LC_adv'} = $env{'form.webdav_LC_adv'};
+ }
+ if (ref($domconfig{'authordefaults'}) eq 'HASH') {
+ foreach my $item ('nocodemirror','domcoordacc','copyright','sourceavail') {
+ if ($domconfig{'authordefaults'}{$item} ne $confhash{$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ if (ref($domconfig{'authordefaults'}{'editors'}) eq 'ARRAY') {
+ my @diffs =
+ &Apache::loncommon::compare_arrays($confhash{'editors'},
+ $domconfig{'authordefaults'}{'editors'});
+ unless (@diffs == 0) {
+ $changes{'editors'} = 1;
+ }
+ } else {
+ my @diffs =
+ &Apache::loncommon::compare_arrays($confhash{'editors'},
+ $staticdefaults{'editors'});
+ unless (@diffs == 0) {
+ $changes{'editors'} = 1;
+ }
+ }
+ } else {
+ my @offon = ('off','on');
+ foreach my $item ('nocodemirror','domcoordacc') {
+ if ($offon[$confhash{$item}] ne $staticdefaults{$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ foreach my $item ('copyright','sourceavail') {
+ if ($confhash{$item} ne $staticdefaults{$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ }
+ foreach my $key ('authorquota','webdav') {
+ if (ref($curr_quotas{$key}) eq 'HASH') {
+ foreach my $type (@insttypes,'default') {
+ if (exists($save_quotas{$key}{$type})) {
+ if ($save_quotas{$key}{$type} ne $curr_quotas{$key}{$type}) {
+ $changes{$key}{$type} = 1;
+ }
+ } elsif (exists($curr_quotas{$key}{$type})) {
+ $save_quotas{$key}{$type} = $curr_quotas{$key}{$type};
+ } else {
+ $save_quotas{$key}{$type} = $staticdefaults{$key};
+ }
+ }
+ } else {
+ foreach my $type (@insttypes,'default') {
+ if (exists($save_quotas{$key}{$type})) {
+ unless ($save_quotas{$key}{$type} eq $staticdefaults{$key}) {
+ $changes{$key}{$type} = 1;
+ }
+ } else {
+ $save_quotas{$key}{$type} = $staticdefaults{$key};
+ }
+ }
+ }
+ }
+ if (ref($curr_quotas{'webdav'}) eq 'HASH') {
+ if (exists($save_quotas{'webdav'}{'_LC_adv'})) {
+ if ($save_quotas{'webdav'}{'_LC_adv'} ne $curr_quotas{'webdav'}{'_LC_adv'}) {
+ $changes{'webdav_LC_adv'} = 1;
+ }
+ } elsif (exists($curr_quotas{'webdav'}{'_LC_adv'})) {
+ $changes{'webdav_LC_adv'} = 1;
+ }
+ } elsif (exists($save_quotas{'webdav'}{'_LC_adv'})) {
+ $changes{'webdav_LC_adv'} = 1;
+ }
+ my %confighash = (
+ quotas => \%save_quotas,
+ authordefaults => \%confhash,
+ );
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%confighash,
+ $dom);
+ my $resulttext;
+ if ($putresult eq 'ok') {
+ if (keys(%changes)) {
+ if ((exists($changes{'authorquota'})) || (exists($changes{'webdav'})) ||
+ ($changes{'webdav_LC_adv'})) {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
+ if ((exists($changes{'authorquota'})) && (ref($save_quotas{'authorquota'}) eq 'HASH')) {
+ $domdefaults{'authorquota'} = $save_quotas{'authorquota'};
+ }
+ if (((exists($changes{'webdav'})) || ($changes{'webdav_LC_adv'})) &&
+ (ref($save_quotas{'webdav'}) eq 'HASH')) {
+ $domdefaults{'webdav'} = $save_quotas{'webdav'};
+ }
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
+ }
+ $resulttext = &mt('Changes made:').'<ul>';
+ my $authoroverride;
+ foreach my $key ('nocodemirror','domcoordacc','copyright','sourceavail') {
+ if (exists($changes{$key})) {
+ my $shown;
+ unless ($authoroverride) {
+ $resulttext .= '<li>'.&mt('Defaults which can be overridden by Author').'<ul>';
+ $authoroverride = 1;
+ }
+ if (($key eq 'nocodemirror') || ($key eq 'domcoordacc')) {
+ $shown = ($confhash{$key} ? &mt('Yes') : &mt('No'));
+ } elsif ($key eq 'copyright') {
+ $shown = &Apache::loncommon::copyrightdescription($confhash{$key});
+ } elsif ($key eq 'sourceavail') {
+ $shown = &Apache::loncommon::source_copyrightdescription($confhash{$key});
+ }
+ $resulttext .= '<li>'.&mt('[_1] set to: [_2]',$titles{$key},$shown).'</li>';
+ }
+ }
+ if ($authoroverride) {
+ $resulttext .= '</ul></li>';
+ }
+ my $domcoordoverride;
+ foreach my $key ('editors','authorquota','webdav','webdav_LC_adv') {
+ if (exists($changes{$key})) {
+ my $shown;
+ unless ($domcoordoverride) {
+ $resulttext .= '<li>'.&mt('Defaults which can be overridden by a Domain Coodinator').'<ul>';
+ $domcoordoverride = 1;
+ }
+ if ($key eq 'editors') {
+ if (@{$confhash{'editors'}}) {
+ $shown = join(', ', map { $titles{$_} } @{$confhash{'editors'}});
+ } else {
+ $shown = &mt('None');
+ }
+ } elsif ($key eq 'authorquota') {
+ foreach my $type (@insttypes) {
+ $shown .= $usertypes->{$type}.' -- '.$save_quotas{$key}{$type}.', ';
+ }
+ $shown .= $othertitle.' -- '.$save_quotas{$key}{'default'};
+ } elsif ($key eq 'webdav') {
+ foreach my $type (@insttypes) {
+ $shown .= $usertypes->{$type}.' -- '. ($save_quotas{$key}{$type} ? &mt('Yes') : &mt('No')).', ';
+ }
+ $shown .= $othertitle.' -- '. ($save_quotas{$key}{'default'} ? &mt('Yes') : &mt('No'));
+ } elsif ($key eq 'webdav_LC_adv') {
+ if (exists($save_quotas{'webdav'}{'_LC_adv'})) {
+ $shown = ($save_quotas{'webdav'}{'_LC_adv'} ? $titles{'overon'} : $titles{'overoff'});
+ } else {
+ $shown = $titles{'none'};
+ }
+ }
+ $resulttext .= '<li>'.&mt('[_1] set to: [_2]',$titles{$key},$shown).'</li>';
+ }
+ }
+ if ($domcoordoverride) {
+ $resulttext .= '</ul></li>';
+ }
+ } else {
+ $resulttext = &mt('No changes made to Authoring Space defaults');
+ }
+ }
+ return $resulttext;
+}
+
sub modify_rolecolors {
my ($r,$dom,$confname,$roles,$lastactref,%domconfig) = @_;
my ($resulttext,%rolehash);
@@ -13513,7 +14026,7 @@
$author_ok,$switchserver,$errors,$validationitemsref,$validationnamesref,
$validationfieldsref);
if ($action eq 'quotas') {
- $context = 'tools';
+ $context = 'tools';
} else {
$context = $action;
}
@@ -13533,7 +14046,7 @@
@usertools = ('author');
%titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','webdav','portfolio','timezone');
+ @usertools = ('aboutme','blog','portfolio','timezone');
%titles = &tool_titles();
}
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
@@ -13556,8 +14069,6 @@
} else {
if ($key =~ /^form\.quota_(.+)$/) {
$confhash{'defaultquota'}{$1} = $env{$key};
- } elsif ($key =~ /^form\.authorquota_(.+)$/) {
- $confhash{'authorquota'}{$1} = $env{$key};
} elsif ($key =~ /^form\.\Q$context\E_(.+)$/) {
@{$toolshash{$1}} = &Apache::loncommon::get_env_multiple($key);
}
@@ -13851,7 +14362,6 @@
}
} else {
$confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
- $confhash{'authorquota'}{'default'} = $env{'form.authorquota'};
}
foreach my $item (@usertools) {
foreach my $type (@{$types},'default','_LC_adv') {
@@ -13940,15 +14450,10 @@
}
}
if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') {
- foreach my $key (keys(%{$domconfig{'quotas'}{'authorquota'}})) {
- if (exists($confhash{'authorquota'}{$key})) {
- if ($confhash{'authorquota'}{$key} ne $domconfig{'quotas'}{'authorquota'}{$key}) {
- $changes{'authorquota'}{$key} = 1;
- }
- } else {
- $confhash{'authorquota'}{$key} = $domconfig{'quotas'}{'authorquota'}{$key};
- }
- }
+ $confhash{'authorquota'} = $domconfig{'quotas'}{'authorquota'};
+ }
+ if (ref($domconfig{'quotas'}{'webdav'}) eq 'HASH') {
+ $confhash{'webdav'} = $domconfig{'quotas'}{'webdav'};
}
}
if (ref($confhash{'defaultquota'}) eq 'HASH') {
@@ -13968,21 +14473,6 @@
}
}
}
- if (ref($confhash{'authorquota'}) eq 'HASH') {
- foreach my $key (keys(%{$confhash{'authorquota'}})) {
- if (ref($domconfig{'quotas'}) eq 'HASH') {
- if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') {
- if (!exists($domconfig{'quotas'}{'authorquota'}{$key})) {
- $changes{'authorquota'}{$key} = 1;
- }
- } else {
- $changes{'authorquota'}{$key} = 1;
- }
- } else {
- $changes{'authorquota'}{$key} = 1;
- }
- }
- }
}
if ($context eq 'requestauthor') {
@@ -14023,19 +14513,6 @@
}
$resulttext .= '</ul></li>';
}
- if (ref($changes{'authorquota'}) eq 'HASH') {
- $resulttext .= '<li>'.&mt('Authoring Space default quotas').'<ul>';
- foreach my $type (@{$types},'default') {
- if (defined($changes{'authorquota'}{$type})) {
- my $typetitle = $usertypes->{$type};
- if ($type eq 'default') {
- $typetitle = $othertitle;
- }
- $resulttext .= '<li>'.&mt('[_1] set to [_2] MB',$typetitle,$confhash{'authorquota'}{$type}).'</li>';
- }
- }
- $resulttext .= '</ul></li>';
- }
}
my %newenv;
foreach my $item (@usertools) {
More information about the LON-CAPA-cvs
mailing list