--- loncom/interface/domainprefs.pm 2022/02/16 04:33:43 1.407
+++ loncom/interface/domainprefs.pm 2024/12/31 19:28:29 1.447
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.407 2022/02/16 04:33:43 raeburn Exp $
+# $Id: domainprefs.pm,v 1.447 2024/12/31 19:28:29 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -95,8 +95,7 @@ about default quota sizes for portfolio
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
@@ -105,7 +104,7 @@ $datatable - HTML containing form eleme
In the case of course requests, radio buttons are displayed for each institutional
affiliate type (and also default, and _LC_adv) for each of the course types
(official, unofficial, community, textbook, placement, and lti).
-In each case the radio buttons allow the selection of one of four values:
+In each case the radio buttons allow the selection of one of four values:
0, approval, validate, autolimit=N (where N is blank, or a positive integer).
which have the following effects:
@@ -167,6 +166,7 @@ use Apache::lonmsg();
use Apache::lonconfigsettings;
use Apache::lonuserutils();
use Apache::loncoursequeueadmin();
+use Apache::courseprefs();
use LONCAPA qw(:DEFAULT :match);
use LONCAPA::Enrollment;
use LONCAPA::lonauthcgi();
@@ -177,6 +177,7 @@ use DateTime::TimeZone;
use DateTime::Locale;
use Time::HiRes qw( sleep );
use Net::CIDR;
+use Crypt::CBC;
my $registered_cleanup;
my $modified_urls;
@@ -220,17 +221,28 @@ sub handler {
'serverstatuses','requestcourses','helpsettings',
'coursedefaults','usersessions','loadbalancing',
'requestauthor','selfenrollment','inststatus',
- 'ltitools','ssl','trust','lti','ltisec','privacy','passwords',
- 'proctoring','wafproxy','ipaccess'],$dom);
+ 'ltitools','toolsec','ssl','trust','lti','ltisec',
+ '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);
if (ref($domconfig{'ltitools'}) eq 'HASH') {
if (ref($encconfig{'ltitools'}) eq 'HASH') {
+ my $home = &Apache::lonnet::domain($dom,'primary');
+ unless (($home eq 'no_host') || ($home eq '')) {
+ my @ids=&Apache::lonnet::current_machine_ids();
+ if (grep(/^\Q$home\E$/,@ids)) {
+ $is_home = 1;
+ }
+ }
+ $checked_is_home = 1;
foreach my $id (keys(%{$domconfig{'ltitools'}})) {
if ((ref($domconfig{'ltitools'}{$id}) eq 'HASH') &&
(ref($encconfig{'ltitools'}{$id}) eq 'HASH')) {
- foreach my $item ('key','secret') {
- $domconfig{'ltitools'}{$id}{$item} = $encconfig{'ltitools'}{$id}{$item};
+ $domconfig{'ltitools'}{$id}{'key'} = $encconfig{'ltitools'}{$id}{'key'};
+ if (($is_home) && ($phase eq 'process')) {
+ $domconfig{'ltitools'}{$id}{'secret'} = $encconfig{'ltitools'}{$id}{'secret'};
}
}
}
@@ -238,11 +250,22 @@ sub handler {
}
if (ref($domconfig{'lti'}) eq 'HASH') {
if (ref($encconfig{'lti'}) eq 'HASH') {
+ unless ($checked_is_home) {
+ my $home = &Apache::lonnet::domain($dom,'primary');
+ unless (($home eq 'no_host') || ($home eq '')) {
+ my @ids=&Apache::lonnet::current_machine_ids();
+ if (grep(/^\Q$home\E$/,@ids)) {
+ $is_home = 1;
+ }
+ }
+ $checked_is_home = 1;
+ }
foreach my $id (keys(%{$domconfig{'lti'}})) {
if ((ref($domconfig{'lti'}{$id}) eq 'HASH') &&
(ref($encconfig{'lti'}{$id}) eq 'HASH')) {
- foreach my $item ('key','secret') {
- $domconfig{'lti'}{$id}{$item} = $encconfig{'lti'}{$id}{$item};
+ $domconfig{'lti'}{$id}{'key'} = $encconfig{'lti'}{$id}{'key'};
+ if (($is_home) && ($phase eq 'process')) {
+ $domconfig{'lti'}{$id}{'secret'} = $encconfig{'lti'}{$id}{'secret'};
}
}
}
@@ -282,8 +305,8 @@ sub handler {
'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'}};
@@ -327,7 +350,9 @@ sub handler {
header => [{col1 => 'Setting',
col2 => 'Value'},
{col1 => 'Institutional user types',
- col2 => 'Name displayed'}],
+ col2 => 'Name displayed'},
+ {col1 => 'Mapping for missing usernames via standard log-in',
+ col2 => 'Rules in use'}],
print => \&print_defaults,
modify => \&modify_defaults,
},
@@ -357,11 +382,11 @@ sub handler {
modify => \&modify_passwords,
},
'quotas' =>
- { text => 'Blogs, personal web pages, webDAV/quotas, portfolios',
+ { 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 => 'Portfolio quota (MB)',}],
print => \&print_quotas,
modify => \&modify_quotas,
},
@@ -447,6 +472,8 @@ sub handler {
header => [{col1 => 'Target user has role',
col2 => 'User information updatable in author context'},
{col1 => 'Target user has role',
+ col2 => 'User information updatable by co-author manager'},
+ {col1 => 'Target user has role',
col2 => 'User information updatable in course context'}],
print => \&print_usermodification,
modify => \&modify_usermodification,
@@ -543,7 +570,7 @@ sub handler {
modify => \&modify_selfenrollment,
},
'privacy' =>
- {text => 'Availability of User Information',
+ {text => 'Role assignments and user privacy',
help => 'Domain_Configuration_User_Privacy',
header => [{col1 => 'Role assigned in different domain',
col2 => 'Approval options'},
@@ -579,11 +606,15 @@ sub handler {
print => \&print_loadbalancing,
modify => \&modify_loadbalancing,
},
- 'ltitools' =>
+ 'ltitools' =>
{text => 'External Tools (LTI)',
help => 'Domain_Configuration_LTI_Tools',
- header => [{col1 => 'Setting',
- col2 => 'Value',}],
+ header => [{col1 => 'Encryption of shared secrets',
+ col2 => 'Settings'},
+ {col1 => 'Rules for shared secrets',
+ col2 => 'Settings'},
+ {col1 => 'Providers',
+ col2 => 'Settings',}],
print => \&print_ltitools,
modify => \&modify_ltitools,
},
@@ -633,13 +664,15 @@ sub handler {
print => \&print_trust,
modify => \&modify_trust,
},
- 'lti' =>
+ 'lti' =>
{text => 'LTI Link Protection and LTI Consumers',
help => 'Domain_Configuration_LTI_Provider',
header => [{col1 => 'Encryption of shared secrets',
col2 => 'Settings'},
- {col1 => 'Rules for shared secrets',
+ {col1 => 'Rules for shared secrets',
col2 => 'Settings'},
+ {col1 => 'Link Protectors in Courses',
+ col2 => 'Values'},
{col1 => 'Link Protectors',
col2 => 'Settings'},
{col1 => 'Consumers',
@@ -647,7 +680,7 @@ sub handler {
print => \&print_lti,
modify => \&modify_lti,
},
- 'ipaccess' =>
+ 'ipaccess' =>
{text => 'IP-based access control',
help => 'Domain_Configuration_IP_Access',
header => [{col1 => 'Setting',
@@ -655,6 +688,16 @@ sub handler {
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',
@@ -853,13 +896,15 @@ sub process_changes {
} elsif ($action eq 'lti') {
$output = &modify_lti($r,$dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'privacy') {
- $output = &modify_privacy($dom,%domconfig);
+ $output = &modify_privacy($dom,$lastactref,%domconfig);
} elsif ($action eq 'passwords') {
$output = &modify_passwords($r,$dom,$confname,$lastactref,%domconfig);
} elsif ($action eq 'wafproxy') {
$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;
}
@@ -888,12 +933,12 @@ sub print_config_box {
&Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent);
my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
$output =
- &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full,
+ &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full,
\@templateroles);
} elsif ($action eq 'ltitools') {
- $output .= <itools_javascript($settings);
+ $output .= &Apache::lonconfigsettings::ltitools_javascript($settings);
} elsif ($action eq 'lti') {
- $output .= &passwords_javascript('secrets')."\n".
+ $output .= &passwords_javascript('ltisecrets')."\n".
<i_javascript($dom,$settings);
} elsif ($action eq 'proctoring') {
$output .= &proctoring_javascript($settings);
@@ -907,6 +952,8 @@ sub print_config_box {
$output .= &saml_javascript();
} elsif ($action eq 'ipaccess') {
$output .= &ipaccess_javascript($settings);
+ } elsif ($action eq 'authordefaults') {
+ $output .= &authordefaults_javascript();
}
$output .=
'
+
+
+
+ '.&mt($item->{'header'}->[2]->{'col1'}).'
+ '.&mt($item->{'header'}->[2]->{'col2'}).'
+ '."\n".
+ $item->{'print'}->('middle',$dom,$settings,\$rowtotal);
} else {
$output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal);
}
@@ -1024,6 +1086,10 @@ sub print_config_box {
'.&mt($item->{'header'}->[8]->{'col2'}).' '.
$item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
} else {
+ my $hdridx = 2;
+ if ($action eq 'lti') {
+ $hdridx = 3;
+ }
$output .= '
@@ -1032,8 +1098,8 @@ sub print_config_box {
- '.&mt($item->{'header'}->[2]->{'col1'}).'
- '.&mt($item->{'header'}->[2]->{'col2'}).'
+ '.&mt($item->{'header'}->[$hdridx]->{'col1'}).'
+ '.&mt($item->{'header'}->[$hdridx]->{'col2'}).'
'."\n";
if ($action eq 'coursecategories') {
$output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
@@ -1044,6 +1110,7 @@ sub print_config_box {
} else {
$output .= $item->{'print'}->('lower',$dom,$settings,\$rowtotal);
}
+ $hdridx ++;
$output .= '
@@ -1053,8 +1120,8 @@ sub print_config_box {
- '.&mt($item->{'header'}->[3]->{'col1'}).'
- '.&mt($item->{'header'}->[3]->{'col2'}).' '."\n";
+ '.&mt($item->{'header'}->[$hdridx]->{'col1'}).'
+ '.&mt($item->{'header'}->[$hdridx]->{'col2'}).' '."\n";
if ($action eq 'passwords') {
$output .= $item->{'print'}->('bottom',$dom,$confname,$settings,\$rowtotal);
} else {
@@ -1070,9 +1137,9 @@ sub print_config_box {
}
}
$rowtotal ++;
- } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
- ($action eq 'defaults') || ($action eq 'directorysrch') ||
- ($action eq 'helpsettings') || ($action eq 'wafproxy')) {
+ } elsif (($action eq 'coursedefaults') || ($action eq 'authordefaults') ||
+ ($action eq 'directorysrch') || ($action eq 'helpsettings') ||
+ ($action eq 'wafproxy')) {
$output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= $item->{'print'}->($r,'bottom',$dom,$confname,$settings,\$rowtotal);
@@ -1275,8 +1342,7 @@ sub print_config_box {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
} elsif (($action eq 'autoenroll') || ($action eq 'autocreate') ||
($action eq 'serverstatuses') || ($action eq 'loadbalancing') ||
- ($action eq 'ltitools') || ($action eq 'proctoring') ||
- ($action eq 'ipaccess')) {
+ ($action eq 'proctoring') || ($action eq 'ipaccess')) {
$output .= $item->{'print'}->($dom,$settings,\$rowtotal);
}
}
@@ -1626,13 +1692,13 @@ sub print_login {
''.$choices{'hostid'}.' '.
''.$choices{'samllanding'}.' '.
''.$choices{'samloptions'}.' '."\n";
- my (%saml,%samltext,%samlimg,%samlalt,%samlurl,%samltitle,%samlnotsso,%styleon,%styleoff);
+ my (%saml,%samltext,%samlimg,%samlalt,%samlurl,%samltitle,%samlwindow,%samlnotsso,%styleon,%styleoff);
foreach my $lonhost (keys(%domservers)) {
$samlurl{$lonhost} = '/adm/sso';
$styleon{$lonhost} = 'display:none';
$styleoff{$lonhost} = '';
}
- if (ref($settings->{'saml'}) eq 'HASH') {
+ if ((ref($settings) eq 'HASH') && (ref($settings->{'saml'}) eq 'HASH')) {
foreach my $lonhost (keys(%{$settings->{'saml'}})) {
if (ref($settings->{'saml'}{$lonhost}) eq 'HASH') {
$saml{$lonhost} = 1;
@@ -1641,6 +1707,7 @@ sub print_login {
$samlalt{$lonhost} = $settings->{'saml'}{$lonhost}{'alt'};
$samlurl{$lonhost} = $settings->{'saml'}{$lonhost}{'url'};
$samltitle{$lonhost} = $settings->{'saml'}{$lonhost}{'title'};
+ $samlwindow{$lonhost} = $settings->{'saml'}{$lonhost}{'window'};
$samlnotsso{$lonhost} = $settings->{'saml'}{$lonhost}{'notsso'};
$styleon{$lonhost} = '';
$styleoff{$lonhost} = 'display:none';
@@ -1658,6 +1725,12 @@ sub print_login {
$samlon = $samloff;
$samloff = ' ';
}
+ my $samlwinon = '';
+ my $samlwinoff = ' checked="checked"';
+ if ($samlwindow{$lonhost}) {
+ $samlwinon = $samlwinoff;
+ $samlwinoff = '';
+ }
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .= ''.$domservers{$lonhost}.' '.
' '.
&mt('Yes').' '.
''.
- ''.&mt('SSO').' '.
- ''.&mt('Non-SSO').' '.
+ ' '.
+ ''.
' ';
@@ -1930,10 +2009,11 @@ sub commblocktype_text {
'passwd' => 'Change Password',
'grades' => 'Gradebook',
'search' => 'Course search',
+ 'index' => 'Course content index',
'wishlist' => 'Stored links',
'annotate' => 'Annotations',
);
- my $typeorder = ['com','chat','boards','port','groups','blogs','about','wishlist','printout','grades','search','annotate','passwd'];
+ my $typeorder = ['com','chat','boards','port','groups','blogs','about','wishlist','printout','grades','search','index','annotate','passwd'];
return ($typeorder,\%types);
}
@@ -1942,7 +2022,7 @@ sub print_rolecolors {
my %choices = &color_font_choices();
my @bgs = ('pgbg','tabbg','sidebg');
my @links = ('link','alink','vlink');
- my @images = ('img');
+ my @images = ();
my %alt_text = &Apache::lonlocal::texthash(img => "Banner for $role role");
my %designhash = &Apache::loncommon::get_domainconf($dom);
my %defaultdesign = %Apache::loncommon::defaultdesign;
@@ -1950,10 +2030,6 @@ sub print_rolecolors {
my %defaults = &role_defaults($role,\@bgs,\@links,\@images);
if (ref($settings) eq 'HASH') {
if (ref($settings->{$role}) eq 'HASH') {
- if ($settings->{$role}->{'img'} ne '') {
- $designs{'img'} = $settings->{$role}->{'img'};
- $is_custom{'img'} = 1;
- }
if ($settings->{$role}->{'font'} ne '') {
$designs{'font'} = $settings->{$role}->{'font'};
$is_custom{'font'} = 1;
@@ -1976,10 +2052,6 @@ sub print_rolecolors {
}
}
} else {
- if ($designhash{$dom.'.'.$role.'.img'} ne '') {
- $designs{img} = $designhash{$dom.'.'.$role.'.img'};
- $is_custom{'img'} = 1;
- }
if ($designhash{$dom.'.'.$role.'.fontmenu'} ne '') {
$designs{fontmenu} = $designhash{$dom.'.'.$role.'.fontmenu'};
$is_custom{'fontmenu'} = 1;
@@ -2029,7 +2101,6 @@ sub role_defaults {
}
} else {
%defaults = (
- img => $defaultdesign{$role.'.img'},
font => $defaultdesign{$role.'.font'},
fontmenu => $defaultdesign{$role.'.fontmenu'},
);
@@ -2354,7 +2425,7 @@ sub print_quotas {
} else {
$context = $action;
}
- my ($datatable,$defaultquota,$authorquota,@usertools,@options,%validations);
+ my ($datatable,$defaultquota,@usertools,@options,%validations);
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
my $typecount = 0;
my ($css_class,%titles);
@@ -2368,12 +2439,12 @@ sub print_quotas {
@options = ('norequest','approval','automatic');
%titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','webdav','portfolio');
+ @usertools = ('aboutme','blog','portfolio','portaccess','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') {
@@ -2382,9 +2453,6 @@ sub print_quotas {
} else {
$currdefquota = $settings->{$type};
}
- if (ref($settings->{authorquota}) eq 'HASH') {
- $currauthorquota = $settings->{authorquota}->{$type};
- }
}
}
if (defined($usertypes->{$type})) {
@@ -2472,9 +2540,12 @@ sub print_quotas {
}
} else {
my $checked = 'checked="checked" ';
+ if ($item eq 'timezone') {
+ $checked = '';
+ }
if (ref($settings) eq 'HASH') {
if (ref($settings->{$item}) eq 'HASH') {
- if ($settings->{$item}->{$type} == 0) {
+ if (!$settings->{$item}->{$type}) {
$checked = '';
} elsif ($settings->{$item}->{$type} == 1) {
$checked = 'checked="checked" ';
@@ -2499,13 +2570,9 @@ sub print_quotas {
($context eq 'requestauthor')) {
$datatable .=
''.
- ''.&mt('Portfolio').': '.
+ ''.
' '.(' ' x 2).
- ''.&mt('Authoring').': '.
- ' ';
}
$datatable .= '';
@@ -2514,16 +2581,12 @@ sub print_quotas {
}
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 ++;
@@ -2635,12 +2698,9 @@ sub print_quotas {
$datatable .= '';
unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
$datatable .= ''.
- ''.&mt('Portfolio').': '.
+ ''.
' '.(' ' x2).
- ''.&mt('Authoring').': '.
- ' ';
+ $defaultquota.'" size="5" />';
}
$datatable .= '';
$typecount ++;
@@ -3413,8 +3473,17 @@ ENDSCRIPT
sub lti_javascript {
my ($dom,$settings) = @_;
my $togglejs = <i_toggle_js($dom);
+ my $linkprot_js = &Apache::courseprefs::linkprot_javascript();
unless (ref($settings) eq 'HASH') {
- return $togglejs;
+ return $togglejs.'
+
+';
}
my (%ordered,$total,%jstext);
$total = scalar(keys(%{$settings}));
@@ -3432,7 +3501,6 @@ sub lti_javascript {
push(@jsarray,$ordered{$item});
}
my $jstext = ' var lti = Array('."'".join("','",@jsarray)."'".');'."\n";
- my $linkprot_js = &Apache::courseprefs::linkprot_javascript();
return <<"ENDSCRIPT";
@@ -3901,16 +3850,16 @@ sub saml_javascript {
return <<"ENDSCRIPT";
+
+ENDSCRIPT
+}
+
sub print_autoenroll {
my ($dom,$settings,$rowtotal) = @_;
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
@@ -4678,7 +4660,7 @@ sub print_contacts {
map {$excluded{$_} = 1; } @{$lonstatus{'excluded'}};
}
}
- foreach my $item ('errorthreshold','errorsysmail') {
+ foreach my $item ('errorthreshold','errorsysmail') {
$css_class = $rownum%2?' class="LC_odd_row"':'';
$datatable .= ''.
''.
@@ -4760,7 +4742,7 @@ sub print_contacts {
$includeloc{'override_'.$key} = '';
$includestr{'override_'.$key} = '';
if ($settings->{'overrides'}{$key}{'include'} ne '') {
- ($includeloc{'override_'.$key},$includestr{'override_'.$key}) =
+ ($includeloc{'override_'.$key},$includestr{'override_'.$key}) =
split(/:/,$settings->{'overrides'}{$key}{'include'},2);
$includestr{'override_'.$key} = &unescape($includestr{'override_'.$key});
}
@@ -4772,7 +4754,6 @@ sub print_contacts {
my $optionsprefix = 'LC_options_helpdesk_';
my $onclicktypes = "toggleHelpdeskRow(this.form,'overrides','$customclass','$optionsprefix');";
-
$datatable .= &insttypes_row($settings,$types,$usertypes,$dom,
$numinrow,$othertitle,'overrides',
\$rownum,$onclicktypes,$customclass);
@@ -4839,7 +4820,7 @@ sub overridden_helpdesk {
}
my $title;
if (ref($short_titles) eq 'HASH') {
- $title = $short_titles->{$item};
+ $title = $short_titles->{$item};
}
$output .= ''.
'
@@ -5372,421 +5352,50 @@ sub radiobutton_prefs {
}
sub print_ltitools {
- my ($dom,$settings,$rowtotal) = @_;
- my $rownum = 0;
- my $css_class;
- my $itemcount = 1;
- my $maxnum = 0;
- my %ordered;
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my (%rules,%encrypt,%privkeys,%linkprot);
if (ref($settings) eq 'HASH') {
- foreach my $item (keys(%{$settings})) {
- if (ref($settings->{$item}) eq 'HASH') {
- my $num = $settings->{$item}{'order'};
- $ordered{$num} = $item;
- }
- }
- }
- my $confname = $dom.'-domainconfig';
- my $switchserver = &check_switchserver($dom,$confname);
- my $maxnum = scalar(keys(%ordered));
- my $datatable;
- my %lt = <itools_names();
- my @courseroles = ('cc','in','ta','ep','st');
- my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
- my @fields = ('fullname','firstname','lastname','email','roles','user');
- if (keys(%ordered)) {
- my @items = sort { $a <=> $b } keys(%ordered);
- for (my $i=0; $i<@items; $i++) {
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $item = $ordered{$items[$i]};
- my ($title,$key,$secret,$url,$lifetime,$imgsrc,%sigsel);
- if (ref($settings->{$item}) eq 'HASH') {
- $title = $settings->{$item}->{'title'};
- $url = $settings->{$item}->{'url'};
- $key = $settings->{$item}->{'key'};
- $secret = $settings->{$item}->{'secret'};
- $lifetime = $settings->{$item}->{'lifetime'};
- my $image = $settings->{$item}->{'image'};
- if ($image ne '') {
- $imgsrc = ' ';
- }
- if ($settings->{$item}->{'sigmethod'} eq 'HMAC-256') {
- $sigsel{'HMAC-256'} = ' selected="selected"';
- } else {
- $sigsel{'HMAC-SHA1'} = ' selected="selected"';
- }
- }
- my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_".$item."'".');"';
- $datatable .= ''
- .'';
- for (my $k=0; $k<=$maxnum; $k++) {
- my $vpos = $k+1;
- my $selstr;
- if ($k == $i) {
- $selstr = ' selected="selected" ';
- }
- $datatable .= ''.$vpos.' ';
- }
- $datatable .= ' '.(' 'x2).
- ' '.
- &mt('Delete?').' '.
- ''.
- ''.&mt('Required settings').' '.
- ''.$lt{'title'}.': '.
- (' 'x2).
- ''.$lt{'version'}.':'.
- '1.1 '.
- (' 'x2).
- ''.$lt{'msgtype'}.':'.
- 'Launch '.
- (' 'x2).
- ''.$lt{'sigmethod'}.':'.
- 'HMAC-SHA1 '.
- 'HMAC-SHA256 '.
- ' '.
- ''.$lt{'url'}.': '.
- (' 'x2).
- ''.$lt{'key'}.':'.
- ' '.
- (' 'x2).
- ''.$lt{'lifetime'}.':'.
- ' '.
- (' 'x2).
- ''.$lt{'secret'}.':'.
- ' '.
- ' '.&mt('Visible input').' '.
- ' '.
- ' '.
- ''.&mt('Optional settings').' '.
- ''.&mt('Display target:');
- my %currdisp;
- if (ref($settings->{$item}->{'display'}) eq 'HASH') {
- if ($settings->{$item}->{'display'}->{'target'} eq 'window') {
- $currdisp{'window'} = ' checked="checked"';
- } elsif ($settings->{$item}->{'display'}->{'target'} eq 'tab') {
- $currdisp{'tab'} = ' checked="checked"';
- } else {
- $currdisp{'iframe'} = ' checked="checked"';
- }
- if ($settings->{$item}->{'display'}->{'width'} =~ /^(\d+)$/) {
- $currdisp{'width'} = $1;
- }
- if ($settings->{$item}->{'display'}->{'height'} =~ /^(\d+)$/) {
- $currdisp{'height'} = $1;
- }
- $currdisp{'linktext'} = $settings->{$item}->{'display'}->{'linktext'};
- $currdisp{'explanation'} = $settings->{$item}->{'display'}->{'explanation'};
- } else {
- $currdisp{'iframe'} = ' checked="checked"';
- }
- foreach my $disp ('iframe','tab','window') {
- $datatable .= ' '.
- $lt{$disp}.' '.(' 'x2);
- }
- $datatable .= (' 'x4);
- foreach my $dimen ('width','height') {
- $datatable .= ''.$lt{$dimen}.' '.
- ' '.
- (' 'x2);
- }
- $datatable .= ' '.
- ''.$lt{'linktext'}.' '.
- '
'.
- ''.$lt{'explanation'}.' '.
- ''.$currdisp{'explanation'}.
- '
';
- my %units = (
- 'passback' => 'days',
- 'roster' => 'seconds',
- );
- foreach my $extra ('passback','roster') {
- my $validsty = 'none';
- my $currvalid;
- my $checkedon = '';
- my $checkedoff = ' checked="checked"';
- if ($settings->{$item}->{$extra}) {
- $checkedon = $checkedoff;
- $checkedoff = '';
- $validsty = 'inline-block';
- if ($settings->{$item}->{$extra.'valid'} =~ /^\d+\.?\d*$/) {
- $currvalid = $settings->{$item}->{$extra.'valid'};
- }
- }
- my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','$i'".');"';
- $datatable .= ''.$lt{$extra}.' '.
- ' '.
- &mt('No').' '.(' 'x2).
- ' '.
- &mt('Yes').'
'.
- '
';
- }
- $datatable .= ''.$lt{'icon'}.': ';
- if ($imgsrc) {
- $datatable .= $imgsrc.
- ' '.&mt('Delete?').' '.
- ' '.&mt('Replace:').' ';
- } else {
- $datatable .= '('.&mt('if larger than 21x21 pixels, image will be scaled').') ';
- }
- if ($switchserver) {
- $datatable .= &mt('Upload to library server: [_1]',$switchserver);
- } else {
- $datatable .= ' ';
- }
- $datatable .= ' ';
- my (%checkedfields,%rolemaps,$userincdom);
- if (ref($settings->{$item}) eq 'HASH') {
- if (ref($settings->{$item}->{'fields'}) eq 'HASH') {
- %checkedfields = %{$settings->{$item}->{'fields'}};
- }
- $userincdom = $settings->{$item}->{'incdom'};
- if (ref($settings->{$item}->{'roles'}) eq 'HASH') {
- %rolemaps = %{$settings->{$item}->{'roles'}};
- $checkedfields{'roles'} = 1;
- }
- }
- $datatable .= ''.&mt('User data sent on launch').' '.
- '';
- my $userfieldstyle = 'display:none;';
- my $seluserdom = '';
- my $unseluserdom = ' selected="selected"';
- foreach my $field (@fields) {
- my ($checked,$onclick,$id,$spacer);
- if ($checkedfields{$field}) {
- $checked = ' checked="checked"';
- }
- if ($field eq 'user') {
- $id = ' id="ltitools_user_field_'.$i.'"';
- $onclick = ' onclick="toggleLTITools(this.form,'."'$field','$i'".')"';
- if ($checked) {
- $userfieldstyle = 'display:inline-block';
- if ($userincdom) {
- $seluserdom = $unseluserdom;
- $unseluserdom = '';
- }
+ if ($position eq 'top') {
+ if (exists($settings->{'encrypt'})) {
+ if (ref($settings->{'encrypt'}) eq 'HASH') {
+ foreach my $key (keys(%{$settings->{'encrypt'}})) {
+ $encrypt{'toolsec_'.$key} = $settings->{'encrypt'}{$key};
}
- } else {
- $spacer = (' ' x2);
}
- $datatable .= ''.
- ' '.
- $lt{$field}.' '.$spacer;
}
- $datatable .= ' ';
- $datatable .= ''.
- ' : '.
- ''.
- ''.&mt('Select').' '.
- ''.&mt('username').' '.
- ''.&mt('username:domain').' '.
- '
';
- $datatable .= ' '.
- ''.&mt('Role mapping').' ';
- foreach my $role (@courseroles) {
- my ($selected,$selectnone);
- if (!$rolemaps{$role}) {
- $selectnone = ' selected="selected"';
- }
- $datatable .= ''.
- &Apache::lonnet::plaintext($role,'Course').' '.
- ''.
- ''.&mt('Select').' ';
- foreach my $ltirole (@ltiroles) {
- unless ($selectnone) {
- if ($rolemaps{$role} eq $ltirole) {
- $selected = ' selected="selected"';
- } else {
- $selected = '';
+ if (exists($settings->{'private'})) {
+ if (ref($settings->{'private'}) eq 'HASH') {
+ if (ref($settings->{'private'}) eq 'HASH') {
+ if (ref($settings->{'private'}{'keys'}) eq 'ARRAY') {
+ map { $privkeys{$_} = 1; } (@{$settings->{'private'}{'keys'}});
}
}
- $datatable .= ''.$ltirole.' ';
}
- $datatable .= ' ';
}
- $datatable .= '
';
- my %courseconfig;
- if (ref($settings->{$item}) eq 'HASH') {
- if (ref($settings->{$item}->{'crsconf'}) eq 'HASH') {
- %courseconfig = %{$settings->{$item}->{'crsconf'}};
- }
- }
- $datatable .= ''.&mt('Configurable in course').' ';
- foreach my $item ('label','title','target','linktext','explanation','append') {
- my $checked;
- if ($courseconfig{$item}) {
- $checked = ' checked="checked"';
+ } elsif ($position eq 'middle') {
+ if (exists($settings->{'rules'})) {
+ if (ref($settings->{'rules'}) eq 'HASH') {
+ %rules = %{$settings->{'rules'}};
}
- $datatable .= ''.
- ' '.
- $lt{'crs'.$item}.' '."\n";
}
- $datatable .= ' '.
- ''.&mt('Custom items sent on launch').' '.
- ' '."\n";
- $itemcount ++;
}
}
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_add_pos'".');"';
- $datatable .= ''."\n".
- ' '."\n".
- '';
- for (my $k=0; $k<$maxnum+1; $k++) {
- my $vpos = $k+1;
- my $selstr;
- if ($k == $maxnum) {
- $selstr = ' selected="selected" ';
- }
- $datatable .= ''.$vpos.' ';
+ my $datatable;
+ my $itemcount = 1;
+ if ($position eq 'top') {
+ $datatable = &secrets_form($dom,'toolsec',\%encrypt,\%privkeys,$rowtotal);
+ } elsif ($position eq 'middle') {
+ $datatable = &password_rules('toolsecrets',\$itemcount,\%rules);
+ $$rowtotal += $itemcount;
+ } else {
+ $datatable = &Apache::courseprefs::print_ltitools($dom,'',$settings,\$rowtotal,'','','domain');
}
- $datatable .= ' '."\n".
- ' '.&mt('Add').' '."\n".
- ''.
- ''.&mt('Required settings').' '.
- ''.$lt{'title'}.': '."\n".
- (' 'x2).
- ''.$lt{'version'}.':'.
- '1.1 '."\n".
- (' 'x2).
- ''.$lt{'msgtype'}.':'.
- 'Launch '.
- ''.$lt{'sigmethod'}.':'.
- 'HMAC-SHA1 '.
- 'HMAC-SHA256 '.
- ' '.
- ''.$lt{'url'}.': '."\n".
- (' 'x2).
- ''.$lt{'key'}.': '."\n".
- (' 'x2).
- ''.$lt{'lifetime'}.': '."\n".
- (' 'x2).
- ''.$lt{'secret'}.': '.
- ' '.&mt('Visible input').' '."\n".
- ' '.
- ''.&mt('Optional settings').' '.
- ''.&mt('Display target:');
- my %defaultdisp;
- $defaultdisp{'iframe'} = ' checked="checked"';
- foreach my $disp ('iframe','tab','window') {
- $datatable .= ' '.
- $lt{$disp}.' '.(' 'x2);
- }
- $datatable .= (' 'x4);
- foreach my $dimen ('width','height') {
- $datatable .= ''.$lt{$dimen}.' '.
- ' '.
- (' 'x2);
- }
- $datatable .= ' '.
- ''.$lt{'linktext'}.' '.
- '
'.
- ''.$lt{'explanation'}.' '.
- ' '.
- '
';
- my %units = (
- 'passback' => 'days',
- 'roster' => 'seconds',
- );
- my %defaulttimes = (
- 'passback' => '7',
- 'roster' => '300',
- );
- foreach my $extra ('passback','roster') {
- my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','add'".');"';
- $datatable .= ''.$lt{$extra}.' '.
- ' '.
- &mt('No').' '.(' 'x2).''.
- ' '.
- &mt('Yes').'
'.
- '
';
- }
- $datatable .= ''.$lt{'icon'}.': '.
- '('.&mt('if larger than 21x21 pixels, image will be scaled').') ';
- if ($switchserver) {
- $datatable .= &mt('Upload to library server: [_1]',$switchserver);
- } else {
- $datatable .= ' ';
- }
- $datatable .= ' '.
- ''.&mt('User data sent on launch').' '.
- '';
- foreach my $field (@fields) {
- my ($id,$onclick,$spacer);
- if ($field eq 'user') {
- $id = ' id="ltitools_user_field_add"';
- $onclick = ' onclick="toggleLTITools(this.form,'."'$field','add'".')"';
- } else {
- $spacer = (' ' x2);
- }
- $datatable .= ''.
- ' '.
- $lt{$field}.' '.$spacer;
- }
- $datatable .= ' '.
- ''.
- ' : '.
- ''.
- ''.&mt('Select').' '.
- ''.&mt('username').' '.
- ''.&mt('username:domain').' '.
- '
';
- $datatable .= ''.&mt('Role mapping').' ';
- foreach my $role (@courseroles) {
- my ($checked,$checkednone);
- $datatable .= ''.
- &Apache::lonnet::plaintext($role,'Course').' '.
- ''.
- ''.&mt('Select').' ';
- foreach my $ltirole (@ltiroles) {
- $datatable .= ''.$ltirole.' ';
- }
- $datatable .= ' ';
- }
- $datatable .= '
'.
- ''.&mt('Configurable in course').' ';
- foreach my $item ('label','title','target','linktext','explanation','append') {
- $datatable .= ''.
- ' '.
- $lt{'crs'.$item}.' '.(' ' x2)."\n";
- }
- $datatable .= ' '.
- ''.&mt('Custom items sent on launch').' '.
- ' '."\n".
- ' '."\n".
- ' '."\n";
- $itemcount ++;
return $datatable;
}
@@ -5800,7 +5409,7 @@ sub ltitools_names {
'key' => 'Key',
'lifetime' => 'Nonce lifetime (s)',
'secret' => 'Secret',
- 'icon' => 'Icon',
+ 'icon' => 'Icon',
'user' => 'User',
'fullname' => 'Full Name',
'firstname' => 'First Name',
@@ -5818,7 +5427,7 @@ sub ltitools_names {
'roster' => 'Tool can retrieve roster:',
'crstarget' => 'Display target',
'crslabel' => 'Course label',
- 'crstitle' => 'Course title',
+ 'crstitle' => 'Course title',
'crslinktext' => 'Link Text',
'crsexplanation' => 'Explanation',
'crsappend' => 'Provider URL',
@@ -5826,6 +5435,123 @@ sub ltitools_names {
return %lt;
}
+sub secrets_form {
+ my ($dom,$context,$encrypt,$privkeys,$rowtotal) = @_;
+ my @ids=&Apache::lonnet::current_machine_ids();
+ my %servers = &Apache::lonnet::get_servers($dom,'library');
+ my $primary = &Apache::lonnet::domain($dom,'primary');
+ my ($css_class,$extra,$numshown,$itemcount,$output);
+ $itemcount = 0;
+ foreach my $hostid (sort(keys(%servers))) {
+ my ($showextra,$divsty,$switch);
+ if ($hostid eq $primary) {
+ if ($context eq 'ltisec') {
+ if (($encrypt->{'ltisec_consumers'}) || ($encrypt->{'ltisec_domlinkprot'})) {
+ $showextra = 1;
+ }
+ if ($encrypt->{'ltisec_crslinkprot'}) {
+ $showextra = 1;
+ }
+ } else {
+ if (($encrypt->{'toolsec_crs'}) || ($encrypt->{'toolsec_dom'})) {
+ $showextra = 1;
+ }
+ }
+ unless (grep(/^\Q$hostid\E$/,@ids)) {
+ $switch = 1;
+ }
+ if ($showextra) {
+ $numshown ++;
+ $divsty = 'display:inline-block';
+ } else {
+ $divsty = 'display:none';
+ }
+ $extra .= ''.
+ ''.$hostid.' ';
+ if ($switch) {
+ my $switchserver = ''.&mt('Switch Server').' ';
+ if (exists($privkeys->{$hostid})) {
+ $extra .= '
'.
+ ''.
+ &mt('Encryption Key').': ['.&mt('not shown').'] '.(' 'x2).' '.
+ ''.&mt('Change?').
+ ' '.&mt('No').' '.
+ (' 'x2).
+ ' '.&mt('Yes').
+ '
'.
+ ' - '.&mt('submit from server ([_1]): [_2].',$hostid,$switchserver).
+ ' ';
+ } else {
+ $extra .= ''.
+ &mt('Key required').' - '.&mt('submit from server ([_1]): [_2].',$hostid,$switchserver).
+ ' '."\n";
+ }
+ } elsif (exists($privkeys->{$hostid})) {
+ $extra .= '
'.
+ &mt('Encryption Key').': ['.&mt('not shown').'] '.(' 'x2).' '.
+ ''.&mt('Change?').
+ ' '.&mt('No').' '.
+ (' 'x2).
+ ' '.&mt('Yes').
+ '
'.
+ ''.&mt('New Key').':'.
+ ' '.
+ ' '.&mt('Visible input').' '.
+ ' ';
+ } else {
+ $extra .= ''.&mt('Encryption Key').':'.
+ ' '.
+ ' '.&mt('Visible input').' ';
+ }
+ $extra .= ' ';
+ }
+ }
+ my (%choices,@toggles,%defaultchecked);
+ if ($context eq 'ltisec') {
+ %choices = &Apache::lonlocal::texthash (
+ ltisec_crslinkprot => 'Encrypt stored link protection secrets defined in courses',
+ ltisec_domlinkprot => 'Encrypt stored link protection secrets defined in domain',
+ ltisec_consumers => 'Encrypt stored consumer secrets defined in domain',
+ );
+ @toggles = qw(ltisec_crslinkprot ltisec_domlinkprot ltisec_consumers);
+ %defaultchecked = (
+ 'ltisec_crslinkprot' => 'off',
+ 'ltisec_domlinkprot' => 'off',
+ 'ltisec_consumers' => 'off',
+ );
+ } else {
+ %choices = &Apache::lonlocal::texthash (
+ toolsec_crs => 'Encrypt stored external tool secrets defined in courses',
+ toolsec_dom => 'Encrypt stored external tool secrets defined in domain',
+ );
+ @toggles = qw(toolsec_crs toolsec_dom);
+ %defaultchecked = (
+ 'toolsec_crs' => 'off',
+ 'toolsec_dom' => 'off',
+ );
+ }
+ my ($onclick,$itemcount);
+ $onclick = 'javascript:toggleLTIEncKey(this.form,'."'$context'".');';
+ ($output,$itemcount) = &radiobutton_prefs($encrypt,\@toggles,\%defaultchecked,
+ \%choices,$itemcount,$onclick,'','left','no');
+
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $noprivkeysty = 'display:inline-block';
+ if ($numshown) {
+ $noprivkeysty = 'display:none';
+ }
+ $output .= ''.&mt('Encryption Key(s)').' '.
+ ''.
+ ''.&mt('Not in use').'
'.
+ $extra.
+ ' ';
+ $itemcount ++;
+ $$rowtotal += $itemcount;
+ return $output;
+}
+
sub print_proctoring {
my ($dom,$settings,$rowtotal) = @_;
my $itemcount = 1;
@@ -6464,7 +6190,7 @@ sub print_lti {
my ($position,$dom,$settings,$rowtotal) = @_;
my $itemcount = 1;
my ($datatable,$css_class);
- my (%rules,%encrypt,%privkeys,%linkprot);
+ my (%rules,%encrypt,%privkeys,%linkprot,%suggestions);
if (ref($settings) eq 'HASH') {
if ($position eq 'top') {
if (exists($settings->{'encrypt'})) {
@@ -6487,12 +6213,18 @@ sub print_lti {
}
}
}
- } elsif ($position eq 'middle') {
+ } elsif ($position eq 'upper') {
if (exists($settings->{'rules'})) {
if (ref($settings->{'rules'}) eq 'HASH') {
%rules = %{$settings->{'rules'}};
}
}
+ } elsif ($position eq 'middle') {
+ if (exists($settings->{'suggested'})) {
+ if (ref($settings->{'suggested'}) eq 'HASH') {
+ %suggestions = %{$settings->{'suggested'}};
+ }
+ }
} elsif ($position eq 'lower') {
if (exists($settings->{'linkprot'})) {
if (ref($settings->{'linkprot'}) eq 'HASH') {
@@ -6503,7 +6235,7 @@ sub print_lti {
}
}
} else {
- foreach my $key ('encrypt','private','rules','linkprot') {
+ foreach my $key ('encrypt','private','rules','linkprot','suggestions') {
if (exists($settings->{$key})) {
delete($settings->{$key});
}
@@ -6511,104 +6243,19 @@ sub print_lti {
}
}
if ($position eq 'top') {
- my @ids=&Apache::lonnet::current_machine_ids();
- my %servers = &Apache::lonnet::get_servers($dom,'library');
- my $primary = &Apache::lonnet::domain($dom,'primary');
- my ($extra,$numshown);
- foreach my $hostid (sort(keys(%servers))) {
- my ($showextra,$divsty,$switch);
- if ($hostid eq $primary) {
- if (($encrypt{'ltisec_consumers'}) || ($encrypt{'ltisec_domlinkprot'})) {
- $showextra = 1;
- }
- }
- if ($encrypt{'ltisec_crslinkprot'}) {
- $showextra = 1;
- }
- unless (grep(/^\Q$hostid\E$/,@ids)) {
- $switch = 1;
- }
- if ($showextra) {
- $numshown ++;
- $divsty = 'display:inline-block';
- } else {
- $divsty = 'display:none';
- }
- $extra .= ''.
- ''.$hostid.' ';
- if ($switch) {
- my $switchserver = ''.&mt('Switch Server').' ';
- if (exists($privkeys{$hostid})) {
- $extra .= '
'.
- ''.
- &mt('Encryption Key').': ['.&mt('not shown').'] '.(' 'x2).' '.
- ''.&mt('Change?').
- ' '.&mt('No').' '.
- (' 'x2).
- ' '.&mt('Yes').
- '
'.
- ' - '.&mt('submit from server ([_1]): [_2].',$hostid,$switchserver).
- ' ';
- } else {
- $extra .= ''.
- &mt('Key required').' - '.&mt('submit from server ([_1]): [_2].',$hostid,$switchserver).
- ' '."\n";
- }
- } elsif (exists($privkeys{$hostid})) {
- $extra .= '
'.
- &mt('Encryption Key').': ['.&mt('not shown').'] '.(' 'x2).' '.
- ''.&mt('Change?').
- ' '.&mt('No').' '.
- (' 'x2).
- ' '.&mt('Yes').
- '
'.
- ''.&mt('New Key').':'.
- ' '.
- ' '.&mt('Visible input').' '.
- ' ';
- } else {
- $extra .= ''.&mt('Encryption Key').':'.
- ' '.
- ' '.&mt('Visible input').' ';
- }
- $extra .= ' ';
- }
- my %choices = &Apache::lonlocal::texthash (
- ltisec_crslinkprot => 'Encrypt stored link protection secrets defined in courses',
- ltisec_domlinkprot => 'Encrypt stored link protection secrets defined in domain',
- ltisec_consumers => 'Encrypt stored consumer secrets defined in domain',
- );
- my @toggles = qw(ltisec_crslinkprot ltisec_domlinkprot ltisec_consumers);
- my %defaultchecked = (
- 'ltisec_crslinkprot' => 'off',
- 'ltisec_domlinkprot' => 'off',
- 'ltisec_consumers' => 'off',
- );
- my ($onclick,$itemcount);
- $onclick = 'javascript:toggleLTIEncKey(this.form);';
- ($datatable,$itemcount) = &radiobutton_prefs(\%encrypt,\@toggles,\%defaultchecked,
- \%choices,$itemcount,$onclick,'','left','no');
-
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $noprivkeysty = 'display:inline-block';
- if ($numshown) {
- $noprivkeysty = 'display:none';
- }
- $datatable .= ''.&mt('Encryption Key(s)').' '.
- ''.
- ''.&mt('Not in use').'
'.
- $extra.
- ' ';
- $itemcount ++;
+ $datatable = &secrets_form($dom,'ltisec',\%encrypt,\%privkeys,$rowtotal);
+ } elsif ($position eq 'upper') {
+ $datatable = &password_rules('ltisecrets',\$itemcount,\%rules);
$$rowtotal += $itemcount;
} elsif ($position eq 'middle') {
- $datatable = &password_rules('secrets',\$itemcount,\%rules);
+ $datatable = &linkprot_suggestions(\%suggestions,\$itemcount);
$$rowtotal += $itemcount;
} elsif ($position eq 'lower') {
- $datatable .= &Apache::courseprefs::print_linkprotection($dom,'',$settings,$rowtotal,'','','domain');
+ $datatable .= &Apache::courseprefs::print_linkprotection($dom,'',$settings,$rowtotal,'','','domain');
} else {
+ my ($switchserver,$switchmessage);
+ $switchserver = &check_switchserver($dom);
+ $switchmessage = &mt("submit from domain's primary library server: [_1].",$switchserver);
my $maxnum = 0;
my %ordered;
if (ref($settings) eq 'HASH') {
@@ -6629,10 +6276,10 @@ sub print_lti {
for (my $i=0; $i<@items; $i++) {
$css_class = $itemcount%2?' class="LC_odd_row"':'';
my $item = $ordered{$items[$i]};
- my ($key,$secret,$lifetime,$consumer,$requser,$crsinc,$current);
+ my ($key,$secret,$usable,$lifetime,$consumer,$requser,$crsinc,$current);
if (ref($settings->{$item}) eq 'HASH') {
$key = $settings->{$item}->{'key'};
- $secret = $settings->{$item}->{'secret'};
+ $usable = $settings->{$item}->{'usable'};
$lifetime = $settings->{$item}->{'lifetime'};
$consumer = $settings->{$item}->{'consumer'};
$requser = $settings->{$item}->{'requser'};
@@ -6680,8 +6327,56 @@ sub print_lti {
'1.1 '.
(' 'x2).
''.$lt{'lifetime'}.': '.
- (' 'x2).
+ 'value="'.$lifetime.'" size="3" /> ';
+ if ($key ne '') {
+ $datatable .= ''.$lt{'key'};
+ if ($switchserver) {
+ $datatable .= ': ['.&mt('[_1] to view/edit',$switchserver).']';
+ } else {
+ $datatable .= ': ';
+ }
+ $datatable .= ' '.(' 'x2);
+ } elsif (!$switchserver) {
+ $datatable .= ''.$lt{'key'}.':'.
+ ' '.
+ ' '.(' 'x2);
+ }
+ if ($switchserver) {
+ if ($usable ne '') {
+ $datatable .= '
'.
+ $lt{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).' '.
+ ''.&mt('Change secret?').
+ ' '.&mt('No').' '.
+ (' 'x2).
+ ' '.&mt('Yes').' '.(' 'x2).
+ '
'.
+ ' - '.$switchmessage.' '.
+ '';
+ } elsif ($key eq '') {
+ $datatable .= ''.&mt('Key and Secret are required').' - '.$switchmessage.' '."\n";
+ } else {
+ $datatable .= ''.&mt('Secret required').' - '.$switchmessage.' '."\n";
+ }
+ } else {
+ if ($usable ne '') {
+ $datatable .= '
'.
+ $lt{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).' '.
+ ''.&mt('Change?').
+ ' '.&mt('No').' '.
+ (' 'x2).
+ ' '.&mt('Yes').
+ '
'.
+ ''.&mt('New Secret').':'.
+ ' '.
+ ' '.&mt('Visible input').' ';
+ } else {
+ $datatable .=
+ ''.$lt{'secret'}.':'.
+ ' '.
+ ' '.&mt('Visible input').' ';
+ }
+ }
+ $datatable .= ' '.
''.$lt{'requser'}.':'.
' '.&mt('Yes').' '."\n".
' '.&mt('No').' '."\n".
@@ -6690,12 +6385,6 @@ sub print_lti {
' '.&mt('Yes').' '."\n".
' '.&mt('No').' '."\n".
(' 'x4).
- ''.$lt{'key'}.
- ': '.
- (' 'x2).
- ''.$lt{'secret'}.':'.
- ' '.
- ' '.&mt('Visible input').' '.
' '.
''.<i_options($i,$current,$itemcount,%lt).' ';
$itemcount ++;
@@ -6724,8 +6413,16 @@ sub print_lti {
''.$lt{'version'}.':'.
'1.1 '."\n".
(' 'x2).
- ''.$lt{'lifetime'}.': '."\n".
- (' 'x2).
+ ''.$lt{'lifetime'}.': '."\n";
+ if ($switchserver) {
+ $datatable .= ''.&mt('Key and Secret are required').' - '.$switchmessage.' '."\n";
+ } else {
+ $datatable .= ''.$lt{'key'}.': '."\n".
+ (' 'x2).
+ ''.$lt{'secret'}.': '.
+ ' '.&mt('Visible input').' '."\n";
+ }
+ $datatable .= ' '.
''.$lt{'requser'}.':'.
' '.&mt('Yes').' '."\n".
' '.&mt('No').' '."\n".
@@ -6733,11 +6430,6 @@ sub print_lti {
''.$lt{'crsinc'}.':'.
' '.&mt('Yes').' '."\n".
' '.&mt('No').' '."\n".
- (' 'x4).
- ''.$lt{'key'}.': '."\n".
- (' 'x2).
- ''.$lt{'secret'}.': '.
- ' '.&mt('Visible input').' '."\n".
''.<i_options('add',undef,$itemcount,%lt).
''."\n".
''."\n";
@@ -6810,7 +6502,7 @@ sub lti_options {
if (($current->{'mapuser'} ne '') && ($current->{'mapuser'} ne 'lis_person_sourcedid')) {
$checked{'mapuser'}{'sourcedid'} = '';
if ($current->{'mapuser'} eq 'lis_person_contact_email_primary') {
- $checked{'mapuser'}{'email'} = ' checked="checked"';
+ $checked{'mapuser'}{'email'} = ' checked="checked"';
} else {
$checked{'mapuser'}{'other'} = ' checked="checked"';
$userfield = $current->{'mapuser'};
@@ -6820,7 +6512,7 @@ sub lti_options {
if (($current->{'mapcrs'} ne '') && ($current->{'mapcrs'} ne 'course_offering_sourcedid')) {
$checked{'mapcrs'}{'course_offering_sourcedid'} = '';
if ($current->{'mapcrs'} eq 'context_id') {
- $checked{'mapcrs'}{'context_id'} = ' checked="checked"';
+ $checked{'mapcrs'}{'context_id'} = ' checked="checked"';
} else {
$checked{'mapcrs'}{'other'} = ' checked="checked"';
$cidfield = $current->{'mapcrs'};
@@ -6848,7 +6540,7 @@ sub lti_options {
$checked{'lcauth'}{$1} = ' checked="checked"';
unless (($current->{'lcauth'} eq 'lti') || ($current->{'lcauth'} eq 'internal')) {
$lcauthparm = $current->{'lcauthparm'};
- $lcauthparmstyle = 'display:table-row';
+ $lcauthparmstyle = 'display:table-row';
if ($current->{'lcauth'} eq 'localauth') {
$lcauthparmtext = &mt('Local auth argument');
} else {
@@ -6865,7 +6557,7 @@ sub lti_options {
%rolemaps = %{$current->{'maproles'}};
}
if ($current->{'section'} ne '') {
- $checked{'crssec'}{'Y'} = ' checked="checked"';
+ $checked{'crssec'}{'Y'} = ' checked="checked"';
$crssecfieldsty = 'inline-block';
if ($current->{'section'} eq 'course_section_sourcedid') {
$checked{'crssecsrc'}{'sourcedid'} = ' checked="checked"';
@@ -6911,9 +6603,9 @@ sub lti_options {
$checked{'crssec'}{'N'} = ' checked="checked"';
$checked{'callback'}{'N'} = ' checked="checked"';
$checked{'topmenu'}{'N'} = ' checked="checked"';
- $checked{'inlinemenu'}{'Y'} = ' checked="checked"';
+ $checked{'inlinemenu'}{'Y'} = ' checked="checked"';
$checked{'menuitem'}{'grades'} = ' checked="checked"';
- $menusty = 'inline-block';
+ $menusty = 'inline-block';
}
my @coursetypes = ('official','unofficial','community','textbook','placement','lti');
my %coursetypetitles = &Apache::lonlocal::texthash (
@@ -6966,7 +6658,7 @@ sub lti_options {
''.&mt('Roles which may create user accounts').' ';
foreach my $ltirole (@ltiroles) {
$output .= ' '.$ltirole.' ';
+ $checked{'makeuser'}{$ltirole}.' />'.$ltirole.' ';
}
$output .= ' '.
''.&mt('New user accounts created for LTI users').' '.
@@ -7098,9 +6790,9 @@ sub lti_options {
if ($extra eq 'passback') {
$pb1p1chk = ' checked="checked"';
$pb1p0chk = '';
- $onclickpb = ' onclick="toggleLTI(this.form,'."'passback','$num'".');"';
+ $onclickpb = ' onclick="toggleLTI(this.form,'."'passback','$num'".');"';
} else {
- $onclickpb = '';
+ $onclickpb = '';
}
if (ref($current) eq 'HASH') {
if (($current->{$extra})) {
@@ -7146,20 +6838,56 @@ sub ltimenu_titles {
);
}
-sub check_switchserver {
- my ($home) = @_;
- my $switchserver;
- if ($home ne '') {
- my $allowed;
- my @ids=&Apache::lonnet::current_machine_ids();
- foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
- if (!$allowed) {
- $switchserver=''.&mt('Switch Server').' ';
+sub linkprot_suggestions {
+ my ($suggested,$itemcount) = @_;
+ my $count = 0;
+ my $next = 1;
+ my %lt = &Apache::lonlocal::texthash(
+ 'name' => 'Suggested Launcher',
+ 'info' => 'Recommendations',
+ );
+ my ($datatable,$css_class,$dest);
+ if (ref($suggested) eq 'HASH') {
+ my @current = sort { $a <=> $b } keys(%{$suggested});
+ $next += $current[-1];
+ for (my $i=0; $i<@current; $i++) {
+ my $num = $current[$i];
+ my %values;
+ if (ref($suggested->{$num}) eq 'HASH') {
+ %values = %{$suggested->{$num}};
+ } else {
+ next;
+ }
+ $css_class = $$itemcount%2?' class="LC_odd_row"':'';
+ $datatable .=
+ ''."\n".
+ ' '."\n".
+ &mt('Delete?').' '."\n".
+ '
'.$lt{'name'}.' '."\n".
+ ' '."\n".
+ ' '.
+ '
'.$lt{'info'}.' '."\n".
+ ''.$values{'info'}.' '.
+ ' '.
+ '
'."\n".
+ ' '."\n";
+ $$itemcount ++;
}
}
- return $switchserver;
+ $css_class = $$itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= ''."\n".
+ ' '."\n".
+ ' '.&mt('Add').' '."\n".
+ ''."\n".
+ '
'.$lt{'name'}.' '."\n".
+ ' '."\n".
+ ' '.
+ '
'.$lt{'info'}.' '."\n".
+ ' '.
+ ' '.
+ '
'."\n".
+ ' '."\n";
+ return $datatable;
}
sub print_coursedefaults {
@@ -7169,6 +6897,7 @@ sub print_coursedefaults {
my %choices = &Apache::lonlocal::texthash (
canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
uploadquota => 'Default quota for files uploaded directly to course/community using Course Editor (MB)',
+ coursequota => 'Default cumulative quota for all group portfolio spaces in course (MB)',
anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
coursecredits => 'Credits can be specified for courses',
uselcmath => 'Math preview uses LON-CAPA previewer (javascript) in place of DragMath (Java)',
@@ -7179,12 +6908,21 @@ sub print_coursedefaults {
canclone => "People who may clone a course (besides course's owner and coordinators)",
mysqltables => 'Lifetime (s) of "Temporary" MySQL tables (student performance data) on homeserver',
ltiauth => 'Student username in LTI launch of deep-linked URL can be accepted without re-authentication',
+ domexttool => 'External Tools defined in the domain may be used in courses/communities (by type)',
+ exttool => 'External Tools can be defined and configured in courses/communities (by type)',
+ crsauthor => 'Standard LON-CAPA problems can be created within a course/community (by type)',
+ crseditors => 'Available editors for web pages and/or problems created in a course/community',
);
my %staticdefaults = (
anonsurvey_threshold => 10,
uploadquota => 500,
+ coursequota => 20,
postsubmit => 60,
mysqltables => 172800,
+ domexttool => 1,
+ exttool => 0,
+ crsauthor => 1,
+ crseditors => ['edit','xml'],
);
if ($position eq 'top') {
%defaultchecked = (
@@ -7298,21 +7036,73 @@ sub print_coursedefaults {
$itemcount ++;
} else {
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
- my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout,%currmysql);
+ my ($currdefresponder,%defcredits,%curruploadquota,%currcoursequota,
+ %deftimeout,%currmysql);
my $currusecredits = 0;
my $postsubmitclient = 1;
my $ltiauth = 0;
+ my %domexttool;
+ my %exttool;
+ my %crsauthor;
+ my %crseditors;
my @types = ('official','unofficial','community','textbook','placement');
if (ref($settings) eq 'HASH') {
if ($settings->{'ltiauth'}) {
$ltiauth = 1;
}
+ if (ref($settings->{'domexttool'}) eq 'HASH') {
+ foreach my $type (@types) {
+ if ($settings->{'domexttool'}->{$type}) {
+ $domexttool{$type} = ' checked="checked"';
+ }
+ }
+ } else {
+ foreach my $type (@types) {
+ if ($staticdefaults{'domexttool'}) {
+ $domexttool{$type} = ' checked="checked"';
+ }
+ }
+ }
+ if (ref($settings->{'exttool'}) eq 'HASH') {
+ foreach my $type (@types) {
+ if ($settings->{'exttool'}->{$type}) {
+ $exttool{$type} = ' checked="checked"';
+ }
+ }
+ }
+ if (ref($settings->{'crsauthor'}) eq 'HASH') {
+ foreach my $type (@types) {
+ if ($settings->{'crsauthor'}->{$type}) {
+ $crsauthor{$type} = ' checked="checked"';
+ }
+ }
+ } else {
+ foreach my $type (@types) {
+ if ($staticdefaults{'crsauthor'}) {
+ $crsauthor{$type} = ' checked="checked"';
+ }
+ }
+ }
+ if (ref($settings->{'crseditors'}) eq 'ARRAY') {
+ foreach my $editor (@{$settings->{'crseditors'}}) {
+ $crseditors{$editor} = ' checked="checked"';
+ }
+ } else {
+ foreach my $editor (@{$staticdefaults{'crseditors'}}) {
+ $crseditors{$editor} = ' checked="checked"';
+ }
+ }
$currdefresponder = $settings->{'anonsurvey_threshold'};
if (ref($settings->{'uploadquota'}) eq 'HASH') {
foreach my $type (keys(%{$settings->{'uploadquota'}})) {
$curruploadquota{$type} = $settings->{'uploadquota'}{$type};
}
}
+ if (ref($settings->{'coursequota'}) eq 'HASH') {
+ foreach my $type (keys(%{$settings->{'coursequota'}})) {
+ $currcoursequota{$type} = $settings->{'coursequota'}{$type};
+ }
+ }
if (ref($settings->{'coursecredits'}) eq 'HASH') {
foreach my $type (@types) {
next if ($type eq 'community');
@@ -7358,6 +7148,15 @@ sub print_coursedefaults {
} else {
foreach my $type (@types) {
$deftimeout{$type} = $staticdefaults{'postsubmit'};
+ if ($staticdefaults{'domexttool'}) {
+ $domexttool{$type} = ' checked="checked"';
+ }
+ if ($staticdefaults{'crsauthor'}) {
+ $crsauthor{$type} = ' checked="checked"';
+ }
+ }
+ foreach my $editor (@{$staticdefaults{'crseditors'}}) {
+ $crseditors{$editor} = ' checked="checked"';
}
}
if (!$currdefresponder) {
@@ -7369,6 +7168,9 @@ sub print_coursedefaults {
if ($curruploadquota{$type} eq '') {
$curruploadquota{$type} = $staticdefaults{'uploadquota'};
}
+ if ($currcoursequota{$type} eq '') {
+ $currcoursequota{$type} = $staticdefaults{'coursequota'};
+ }
}
$datatable .=
''.
@@ -7392,6 +7194,19 @@ sub print_coursedefaults {
}
$datatable .= '
'."\n";
$itemcount ++;
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ $choices{'coursequota'}.
+ ' '.
+ ''.
+ ' '."\n";
+ $itemcount ++;
my $onclick = "toggleDisplay(this.form,'credits');";
my $display = 'none';
if ($currusecredits) {
@@ -7461,12 +7276,300 @@ sub print_coursedefaults {
&radiobutton_prefs($current,\@toggles,\%defaultchecked,
\%choices,$itemcount,undef,undef,'left');
$datatable .= $table;
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ $choices{'domexttool'}.
+ ' '.
+ ''.
+ ' '."\n";
+ $itemcount ++;
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ $choices{'exttool'}.
+ ' '.
+ ''.
+ ' '."\n";
+ $itemcount ++;
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ $choices{'crsauthor'}.
+ ' '.
+ ''.
+ ' '."\n";
+ $itemcount ++;
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ $choices{'crseditors'}.
+ ' '.
+ ''.
+ ' '."\n";
+ }
+ $$rowtotal += $itemcount;
+ return $datatable;
+}
+
+sub crseditor_titles {
+ return &Apache::lonlocal::texthash(
+ edit => 'Standard editor (Edit)',
+ xml => 'Text editor (EditXML)',
+ daxe => 'Daxe editor (Daxe)',
+ );
+}
+
+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',
+ 'daxecollapse' => 'off',
+ 'domcoordacc' => 'on',
+ );
+ my @toggles = ('nocodemirror','daxecollapse','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 .= ''.
+ ''.$titles{'copyright'}.
+ ' '.
+ &selectbox('copyright',$currrights{'copyright'},'',
+ \&Apache::loncommon::copyrightdescription,
+ (grep !/^priv|custom$/,(&Apache::loncommon::copyrightids))).
+ ' '."\n";
+ $itemcount ++;
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= ''.
+ ''.$titles{'sourceavail'}.
+ ' '.
+ &selectbox('sourceavail',$currrights{'sourceavail'},'',
+ \&Apache::loncommon::source_copyrightdescription,
+ (&Apache::loncommon::source_copyrightids)).
+ ' '."\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 = ''."\n".
+ ''.$titles{'editors'}.' '."\n".
+ ''."\n".
+ '';
+ foreach my $editor (@editors) {
+ my $checked;
+ if (grep(/^\Q$editor\E$/,@{$curreditors})) {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= ''.
+ ' '.
+ $titles{$editor}.' ';
+ }
+ $datatable .= ' '."\n".' '."\n".' '."\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 .= ''.
+ ''.$titles{'webdav_LC_adv'}.' '.
+ $titles{'webdav_LC_adv_over'}.
+ ' '.
+ '';
+ 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 .= ''.
+ ' '.
+ $text.' ';
+ }
+ $datatable .= ' ';
+ $itemcount ++;
+ my %defchecked = (
+ 'archive' => 'off',
+ );
+ my @toggles = ('archive');
+ (my $archive,$itemcount) = &radiobutton_prefs($settings,['archive'],
+ {'archive' => 'off'},
+ \%titles,$itemcount);
+ $datatable .= $archive."\n";
$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',
+ daxecollapse => 'Daxe editor: LON-CAPA standard menus start collapsed',
+ 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',
+ archive => 'Authors can download tar.gz file of Authoring Space',
+ );
+}
+
+sub selectbox {
+ my ($name,$value,$readonly,$functionref,@idlist)=@_;
+ my $selout = '';
+ foreach my $id (@idlist) {
+ $selout.=''.&{$functionref}($id).' ';
+ }
+ $selout.=' ';
+ return $selout;
+}
+
sub print_selfenrollment {
my ($position,$dom,$settings,$rowtotal) = @_;
my ($css_class,$datatable);
@@ -7696,13 +7799,15 @@ sub print_privacy {
my ($position,$dom,$settings,$rowtotal) = @_;
my ($datatable,$css_class,$numinrow,@items,%names,$othertitle,$usertypes,$types);
my $itemcount = 0;
- unless ($position eq 'top') {
+ if ($position eq 'top') {
+ $numinrow = 2;
+ } else {
@items = ('domain','author','course','community');
%names = &Apache::lonlocal::texthash (
domain => 'Assigned domain role(s)',
author => 'Assigned co-author role(s)',
course => 'Assigned course role(s)',
- community => 'Assigned community role',
+ community => 'Assigned community role(s)',
);
$numinrow = 4;
($othertitle,$usertypes,$types) =
@@ -7721,6 +7826,7 @@ sub print_privacy {
auto => 'Unrestricted',
instdom => 'Other domain shares institution/provider',
extdom => 'Other domain has different institution/provider',
+ notify => 'Notify when role needs authorization',
);
my %names = &Apache::lonlocal::texthash (
domain => 'Domain role',
@@ -7772,6 +7878,28 @@ sub print_privacy {
$datatable .= '';
$itemcount ++;
}
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= ''.$titles{'notify'}.' '.
+ '';
+ if ((@instdoms > 1) || (keys(%by_location) > 0)) {
+ my %curr;
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'notify'} ne '') {
+ map {$curr{$_}=1;} split(/,/,$settings->{'notify'});
+ }
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my ($numdc,$table,$rows) = &active_dc_picker($dom,$numinrow,'checkbox',
+ 'privacy_notify',%curr);
+ if ($numdc > 0) {
+ $datatable .= $table;
+ } else {
+ $datatable .= &mt('There are no active Domain Coordinators');
+ }
+ } else {
+ $datatable .= &mt('Nothing to set here, as there are no other domains');
+ }
+ $datatable .=' ';
} elsif ($position eq 'middle') {
if ((@instdoms > 1) || (keys(%by_location) > 0)) {
if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) {
@@ -8185,7 +8313,7 @@ sub password_rules {
max => 'Maximum password length',
chars => 'Required characters',
);
- } elsif ($prefix eq 'secrets') {
+ } elsif (($prefix eq 'ltisecrets') || ($prefix eq 'toolsecrets')) {
%titles = &Apache::lonlocal::texthash (
min => 'Minimum secret length',
max => 'Maximum secret length',
@@ -8208,7 +8336,7 @@ sub password_rules {
if (ref($settings->{chars}) eq 'ARRAY') {
map { $chars{$_} = 1; } (@{$settings->{chars}});
}
- if ($prefix eq 'passwords') {
+ if ($prefix eq 'passwords') {
if ($settings->{expire}) {
$expire = $settings->{expire};
}
@@ -8351,7 +8479,7 @@ sub print_wafproxy {
my %config = &Apache::lonnet::get_dom('configuration',['wafproxy'],$domain);
if (ref($config{'wafproxy'}) eq 'HASH') {
$aliases{$domain} = $config{'wafproxy'}{'alias'};
- if (exists($config{'wafproxy'}{'saml'})) {
+ if (exists($config{'wafproxy'}{'saml'})) {
$saml{$domain} = $config{'wafproxy'}{'saml'};
}
foreach my $item ('remoteip','ipheader','trusted','vpnint','vpnext') {
@@ -8368,8 +8496,10 @@ sub print_wafproxy {
my $dom_in_effect;
my $aliasrows = ''.
''.
- &mt('Hostname').': '.
- ''.&Apache::lonnet::hostname($server).' ';
+ &mt('Hostname').': '.
+ ''.
+ &Apache::lonnet::hostname($server).
+ ' ';
if ($othercontrol{$server}) {
$dom_in_effect = $othercontrol{$server};
my ($current,$forsaml);
@@ -8416,10 +8546,10 @@ sub print_wafproxy {
(' 'x2).''.
&mt('Alias used for SSO Auth').': '.
' '.
- &mt('No').' '.
+ &mt('No').' '.
' '.
&mt('Yes').' '.
- '';
+ '';
}
$aliasrows .= ' ';
$aliasinfo{$dom_in_effect} .= $aliasrows;
@@ -9329,7 +9459,7 @@ sub print_loadbalancing {
no => ' checked="checked"',
);
my %balcookiechecked = (
- no => ' checked="checked"',
+ no => ' checked="checked"',
);
foreach my $sparetype (@sparestypes) {
my $targettable;
@@ -9684,8 +9814,9 @@ sub tool_titles {
my %titles = &Apache::lonlocal::texthash (
aboutme => 'Personal web page',
blog => 'Blog',
- webdav => 'WebDAV',
portfolio => 'Portfolio',
+ portaccess => 'Share portfolio files',
+ timezone => 'Can set time zone',
official => 'Official courses (with institutional codes)',
unofficial => 'Unofficial courses',
community => 'Communities',
@@ -9915,7 +10046,7 @@ sub print_selfcreation {
($datatable,$itemcount) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked,
\%choices,$itemcount,$onclick);
$$rowtotal += $itemcount;
-
+
if (ref($usertypes) eq 'HASH') {
if (keys(%{$usertypes}) > 0) {
$datatable .= &insttypes_row($createsettings,$types,$usertypes,
@@ -10052,7 +10183,7 @@ sub print_selfcreation {
my $currstyle = 'display:none';
if (grep(/^\Q$status\E$/,@ordered)) {
$currstyle = $rowstyle;
- $hidden = 0;
+ $hidden = 0;
}
$datatable .= &noninst_users($processing,$emailverified,$emailoptions,$emaildomain,
$emailrules,$emailruleorder,$settings,$status,$rowid,
@@ -10079,8 +10210,8 @@ sub print_selfcreation {
foreach my $status (@posstypes) {
my $rowid = $classprefix.$status;
my $datarowstyle = 'display:none';
- if (grep(/^\Q$status\E$/,@ordered)) {
- $datarowstyle = $rowstyle;
+ if (grep(/^\Q$status\E$/,@ordered)) {
+ $datarowstyle = $rowstyle;
}
$datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings,
$numinrow,$$rowtotal,\%usertypeshash,$infofields,
@@ -10182,7 +10313,7 @@ function toggleEmailOptions(form,radio,p
document.getElementById(altprefix+'_inst_'+status).style.display = 'none';
document.getElementById(altprefix+'_noninst_'+status).style.display = 'none';
if (curr == 'custom') {
- if (prefix) {
+ if (prefix) {
document.getElementById(prefix+'_'+status).style.display = 'inline';
}
} else if (curr == 'inst') {
@@ -10205,10 +10336,10 @@ ENDSCRIPT
sub noninst_users {
my ($processing,$emailverified,$emailoptions,$emaildomain,$emailrules,
- $emailruleorder,$settings,$type,$rowid,$typetitle,$css_class,$rowstyle,$intdom) = @_;
+ $emailruleorder,$settings,$type,$rowid,$typetitle,$css_class,$rowstyle,$intdom) = @_;
my $class = 'LC_left_item';
if ($css_class) {
- $css_class = ' class="'.$css_class.'"';
+ $css_class = ' class="'.$css_class.'"';
}
if ($rowid) {
$rowid = ' id="'.$rowid.'"';
@@ -10223,10 +10354,10 @@ sub noninst_users {
$description = &mt('Requests for: [_1] (status self-reported)',$typetitle);
}
$output = ''.
- "$description \n".
+ "$description \n".
''.
'';
- my %headers = &Apache::lonlocal::texthash(
+ my %headers = &Apache::lonlocal::texthash(
approve => 'Processing',
email => 'E-mail',
username => 'Username',
@@ -10351,7 +10482,7 @@ sub noninst_users {
my $value;
if (ref($emaildomain) eq 'HASH') {
if (ref($emaildomain->{$type}) eq 'HASH') {
- $value = $emaildomain->{$type}->{$option};
+ $value = $emaildomain->{$type}->{$option};
}
}
if ($value eq '') {
@@ -10467,7 +10598,7 @@ sub user_formats_row {
'username' => 'new usernames',
'id' => 'IDs',
);
- unless ($type eq 'email') {
+ unless (($type eq 'email') || ($type eq 'unamemap')) {
my $css_class = $rowcount%2?' class="LC_odd_row"':'';
$output = ' '.
''.
@@ -10522,9 +10653,9 @@ sub user_formats_row {
} elsif ($colsleft == 1) {
$output .= ' ';
}
- $output .= '
';
- unless ($type eq 'email') {
- $output .= ' ';
+ $output .= '';
+ unless (($type eq 'email') || ($type eq 'unamemap')) {
+ $output .= '
';
}
return $output;
}
@@ -10587,6 +10718,15 @@ sub print_usermodification {
$$rowtotal ++;
$rowcount ++;
}
+ } elsif ($position eq 'middle') {
+ $rowcount = 0;
+ $context = 'coauthor';
+ foreach my $role ('ca','aa') {
+ $datatable .= &modifiable_userdata_row($context,$role,$settings,
+ $numinrow,$rowcount);
+ $$rowtotal ++;
+ $rowcount ++;
+ }
} elsif ($position eq 'bottom') {
$context = 'course';
$rowcount = 0;
@@ -10656,18 +10796,34 @@ sub print_defaults {
} elsif ($item eq 'lang_def') {
my $includeempty = 1;
$datatable .= &Apache::loncommon::select_language($item,$defaults{$item},$includeempty);
- } else {
- my $size;
- if ($item eq 'portal_def') {
- $size = ' size="25"';
- }
+ } elsif ($item eq 'portal_def') {
$datatable .= ' ';
+ $defaults{$item}.'" size="25" onkeyup="portalExtras(this);" />';
+ my $portalsty = 'none';
+ if ($defaults{$item}) {
+ $portalsty = 'block';
+ }
+ foreach my $field ('email','web') {
+ my $checkedoff = ' checked="checked"';
+ my $checkedon;
+ if ($defaults{$item.'_'.$field}) {
+ $checkedon = $checkedoff;
+ $checkedoff = '';
+ }
+ $datatable .= ''.
+ ''.$titles->{$field}.' '.
+ ' '.&mt('Yes').' '.
+ (' 'x2).
+ ' '.&mt('No').' '.
+ '
';
+ }
+ } else {
+ $datatable .= ' ';
}
$datatable .= '';
$rownum ++;
}
- } else {
+ } elsif ($position eq 'middle') {
my %defaults;
if (ref($settings) eq 'HASH') {
if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) {
@@ -10717,6 +10873,22 @@ sub print_defaults {
$rownum ++;
}
}
+ } else {
+ my ($unamemaprules,$ruleorder) =
+ &Apache::lonnet::inst_userrules($dom,'unamemap');
+ $css_class = $rownum%2?' class="LC_odd_row"':'';
+ if ((ref($unamemaprules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) {
+ my $numinrow = 2;
+ $datatable .= ''.&mt('Available conversions').' '.
+ &user_formats_row('unamemap',$settings,$unamemaprules,
+ $ruleorder,$numinrow).
+ '
';
+ }
+ if ($datatable eq '') {
+ $datatable .= ''.
+ &mt('No rules set for domain in customized localenroll.pm').
+ ' ';
+ }
}
$$rowtotal += $rownum;
return $datatable;
@@ -10742,6 +10914,8 @@ sub defaults_titles {
'timezone_def' => 'Default timezone',
'datelocale_def' => 'Default locale for dates',
'portal_def' => 'Portal/Default URL',
+ 'email' => 'Email links use portal URL',
+ 'web' => 'Public web links use portal URL',
'intauth_cost' => 'Encryption cost for bcrypt (positive integer)',
'intauth_check' => 'Check bcrypt cost if authenticated',
'intauth_switch' => 'Existing crypt-based switched to bcrypt on authentication',
@@ -10974,10 +11148,13 @@ sub legacy_scantronformat {
my ($url,$error);
my @statinfo = &Apache::lonnet::stat_file($newurl);
if ((!@statinfo) || ($statinfo[0] eq 'no_such_dir')) {
+ my $modified = [];
(my $result,$url) =
- &publishlogo($r,'copy',$legacyfile,$dom,$confname,'scantron',
- '','',$newfile);
- if ($result ne 'ok') {
+ &Apache::lonconfigsettings::publishlogo($r,'copy',$legacyfile,$dom,$confname,
+ 'scantron','','',$newfile,$modified);
+ if ($result eq 'ok') {
+ &update_modify_urls($r,$modified);
+ } else {
$error = &mt("An error occurred publishing the [_1] bubblesheet format file in RES space. Error was: [_2].",$newfile,$result);
}
}
@@ -11456,6 +11633,23 @@ sub serverstatus_pages {
sub defaults_javascript {
my ($settings) = @_;
return unless (ref($settings) eq 'HASH');
+ my $portal_js = <<"ENDPORTAL";
+
+function portalExtras(caller) {
+ var x = caller.value;
+ var y = new Array('email','web');
+ for (var i=0; i 0) {
+ z.style.display = 'block';
+ } else {
+ z.style.display = 'none';
+ }
+ }
+ }
+}
+ENDPORTAL
if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) {
my $maxnum = scalar(@{$settings->{'inststatusorder'}});
if ($maxnum eq '') {
@@ -11509,6 +11703,17 @@ $jstext
return;
}
+$portal_js
+
+// ]]>
+
+
+ENDSCRIPT
+ } else {
+return <<"ENDSCRIPT";
+
@@ -11529,7 +11734,7 @@ sub passwords_javascript {
passexp => 'Warning: days before password expiration must be a positive integer (or blank).',
passnum => 'Warning: number of previous passwords to save must be a positive integer (or blank).',
);
- } elsif ($prefix eq 'secrets') {
+ } elsif (($prefix eq 'ltisecrets') || ($prefix eq 'toolsecrets')) {
%intalert = &Apache::lonlocal::texthash (
passmin => 'Warning: minimum secret length must be a positive integer greater than 6.',
passmax => 'Warning: maximum secret length must be a positive integer (or blank).',
@@ -11537,7 +11742,7 @@ sub passwords_javascript {
}
&js_escape(\%intalert);
my $defmin = $Apache::lonnet::passwdmin;
- my $intauthjs;
+ my $intauthjs;
if ($prefix eq 'passwords') { $intauthjs = <<"ENDSCRIPT";
function warnIntAuth(field) {
@@ -11568,7 +11773,7 @@ function warnInt$prefix(field) {
field.value.replace(/^\s+/,'');
field.value.replace(/\s+\$/,'');
var regexdigit=/^\\d+\$/;
- if (field.name == '$prefix\_min') {
+ if (field.name == '${prefix}_min') {
if (field.value == '') {
alert('$intalert{passmin}');
field.value = '$defmin';
@@ -11588,7 +11793,7 @@ function warnInt$prefix(field) {
field.value = '';
}
if (field.value != '') {
- if (field.name == '$prefix\_expire') {
+ if (field.name == '${prefix}_expire') {
var regexpposnum=/^\\d+(|\\.\\d*)\$/;
if (!regexpposnum.test(field.value)) {
alert('$intalert{passexp}');
@@ -11602,10 +11807,10 @@ function warnInt$prefix(field) {
}
} else {
if (!regexdigit.test(field.value)) {
- if (field.name == '$prefix\_max') {
+ if (field.name == '${prefix}_max') {
alert('$intalert{passmax}');
} else {
- if (field.name == '$prefix\_numsaved') {
+ if (field.name == '${prefix}_numsaved') {
alert('$intalert{passnum}');
}
}
@@ -11931,7 +12136,6 @@ sub modifiable_userdata_row {
'';
my $rem;
my %checks;
- my %current;
if (ref($settings) eq 'HASH') {
my $hashref;
if ($context eq 'lti') {
@@ -11957,7 +12161,7 @@ sub modifiable_userdata_row {
}
}
}
- if (ref($hashref) eq 'HASH') {
+ if (ref($hashref) eq 'HASH') {
foreach my $field (@fields) {
if ($hashref->{$field}) {
if ($role eq 'emailusername') {
@@ -11969,7 +12173,6 @@ sub modifiable_userdata_row {
}
}
}
-
my $total = scalar(@fields);
for (my $i=0; $i<$total; $i++) {
$rem = $i%($numinrow);
@@ -12029,6 +12232,8 @@ sub modifiable_userdata_row {
} else {
if ($context eq 'lti') {
$prefix = 'lti';
+ } elsif ($context eq 'coauthor') {
+ $prefix = 'cacanmodify';
} elsif ($context eq 'privacy') {
$prefix = 'privacy';
}
@@ -12058,15 +12263,19 @@ sub insttypes_row {
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') {
@@ -12103,25 +12312,44 @@ sub insttypes_row {
}
$output .= '';
}
- 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 .= ''."\n".
+ ''."\n".
+ $usertypes->{$types->[$i]}.' '."\n".
+ ' '."\n".
+ ' ';
+ } 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 .= ''.
+ ''.
+ ' [$i].'"'.$check.$onclick.'/>'.
+ $usertypes->{$types->[$i]}.' ';
}
- $output .= ''.
- ''.
- ' [$i].'"'.$check.$onclick.' />'.
- $usertypes->{$types->[$i]}.' ';
}
}
$rem = @{$types}%($numinrow);
@@ -12133,7 +12361,7 @@ sub insttypes_row {
} else {
$output .= '';
}
- $output .= ' ';
+ $output .= ' ';
} else {
if ($rem == 0) {
$output .= ' ';
@@ -12143,20 +12371,41 @@ sub insttypes_row {
} else {
$output .= '';
}
- 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 .= ''.$othertitle.' '."\n".
+ ' '."\n".
+ ' ';
+ } 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 .= ''.
+ ' '.
+ $othertitle.' ';
}
- $output .= ''.
- ' '.
- $othertitle.' ';
}
$output .= '
';
return $output;
@@ -12236,7 +12485,7 @@ sub modify_login {
my ($r,$dom,$confname,$lastactref,%domconfig) = @_;
my ($resulttext,$errors,$colchgtext,%changes,%colchanges,%newfile,%newurl,
%curr_loginvia,%loginhash,@currlangs,@newlangs,$addedfile,%title,@offon,
- %currsaml,%saml,%samltext,%samlimg,%samlalt,%samlurl,%samltitle,%samlnotsso);
+ %currsaml,%saml,%samltext,%samlimg,%samlalt,%samlurl,%samltitle,%samlwindow,%samlnotsso);
%title = ( coursecatalog => 'Display course catalog',
adminmail => 'Display administrator E-mail address',
helpdesk => 'Display "Contact Helpdesk" link',
@@ -12260,6 +12509,7 @@ sub modify_login {
$samlalt{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'alt'};
$samlimg{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'img'};
$samltitle{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'title'};
+ $samlwindow{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'window'};
$samlnotsso{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'notsso'};
}
}
@@ -12402,13 +12652,16 @@ sub modify_login {
if ($addedfile ne '') {
push(@allnew,$addedfile);
}
+ my $modified = [];
foreach my $lang (@allnew) {
my $formelem = 'loginhelpurl_'.$lang;
if ($lang eq $env{'form.loginhelpurl_add_lang'}) {
$formelem = 'loginhelpurl_add_file';
}
- (my $result,$newurl{$lang}) = &publishlogo($r,'upload',$formelem,$dom,$confname,
- "help/$lang",'','',$newfile{$lang});
+ (my $result,$newurl{$lang}) =
+ &Apache::lonconfigsettings::publishlogo($r,'upload',$formelem,$dom,$confname,
+ "help/$lang",'','',$newfile{$lang},
+ $modified);
if ($result eq 'ok') {
$loginhash{'login'}{'helpurl'}{$lang} = $newurl{$lang};
$changes{'helpurl'}{$lang} = 1;
@@ -12421,6 +12674,7 @@ sub modify_login {
}
}
}
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of custom log-in help file(s) failed because an author role could not be assigned to a Domain Configuration user ([_1]) in domain: [_2]. Error was: [_3].",$confname,$dom,$author_ok);
}
@@ -12478,11 +12732,14 @@ sub modify_login {
if ($switchserver) {
$error = &mt("Upload of custom markup is not permitted to this server: [_1]",$switchserver);
} elsif ($author_ok eq 'ok') {
+ my $modified = [];
foreach my $lonhost (@newhosts) {
my $formelem = 'loginheadtag_'.$lonhost;
- (my $result,$newheadtagurls{$lonhost}) = &publishlogo($r,'upload',$formelem,$dom,$confname,
- "login/headtag/$lonhost",'','',
- $env{'form.loginheadtag_'.$lonhost.'.filename'});
+ (my $result,$newheadtagurls{$lonhost}) =
+ &Apache::lonconfigsettings::publishlogo($r,'upload',$formelem,$dom,$confname,
+ "login/headtag/$lonhost",'','',
+ $env{'form.loginheadtag_'.$lonhost.'.filename'},
+ $modified);
if ($result eq 'ok') {
$loginhash{'login'}{'headtag'}{$lonhost}{'url'} = $newheadtagurls{$lonhost};
$changes{'headtag'}{$lonhost} = 1;
@@ -12499,6 +12756,7 @@ sub modify_login {
}
}
}
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of custom markup file(s) failed because an author role could not be assigned to a Domain Configuration user ([_1]) in domain: [_2]. Error was: [_3].",$confname,$dom,$author_ok);
}
@@ -12517,10 +12775,13 @@ sub modify_login {
if ($env{'form.saml_img_'.$lonhost.'.filename'}) {
push(@newsamlimgs,$lonhost);
}
- foreach my $item ('text','alt','url','title','notsso') {
+ foreach my $item ('text','alt','url','title','window','notsso') {
$env{'form.saml_'.$item.'_'.$lonhost} =~ s/^\s+|\s+$//g;
}
if ($saml{$lonhost}) {
+ if ($env{'form.saml_window_'.$lonhost} ne '1') {
+ $env{'form.saml_window_'.$lonhost} = '';
+ }
if (grep(/^\Q$lonhost\E$/,@delsamlimg)) {
#FIXME Need to obsolete published image
delete($currsaml{$lonhost}{'img'});
@@ -12538,25 +12799,28 @@ sub modify_login {
if ($env{'form.saml_title_'.$lonhost} ne $samltitle{$lonhost}) {
$changes{'saml'}{$lonhost} = 1;
}
+ if ($env{'form.saml_window_'.$lonhost} ne $samlwindow{$lonhost}) {
+ $changes{'saml'}{$lonhost} = 1;
+ }
if ($env{'form.saml_notsso_'.$lonhost} ne $samlnotsso{$lonhost}) {
$changes{'saml'}{$lonhost} = 1;
}
} else {
$changes{'saml'}{$lonhost} = 1;
}
- foreach my $item ('text','alt','url','title','notsso') {
+ foreach my $item ('text','alt','url','title','window','notsso') {
$currsaml{$lonhost}{$item} = $env{'form.saml_'.$item.'_'.$lonhost};
}
} else {
- if ($saml{$lonhost}) {
+ if ($saml{$lonhost}) {
$changes{'saml'}{$lonhost} = 1;
delete($currsaml{$lonhost});
}
}
}
foreach my $posshost (keys(%currsaml)) {
- unless (exists($domservers{$posshost})) {
- delete($currsaml{$posshost});
+ unless (exists($domservers{$posshost})) {
+ delete($currsaml{$posshost});
}
}
%{$loginhash{'login'}{'saml'}} = %currsaml;
@@ -12567,11 +12831,14 @@ sub modify_login {
if ($switchserver) {
$error = &mt("Upload of SSO Button Image is not permitted to this server: [_1].",$switchserver);
} elsif ($author_ok eq 'ok') {
+ my $modified = [];
foreach my $lonhost (@newsamlimgs) {
my $formelem = 'saml_img_'.$lonhost;
- my ($result,$imgurl) = &publishlogo($r,'upload',$formelem,$dom,$confname,
- "login/saml/$lonhost",'','',
- $env{'form.saml_img_'.$lonhost.'.filename'});
+ my ($result,$imgurl) =
+ &Apache::lonconfigsettings::publishlogo($r,'upload',$formelem,$dom,$confname,
+ "login/saml/$lonhost",'','',
+ $env{'form.saml_img_'.$lonhost.'.filename'},
+ $modified);
if ($result eq 'ok') {
$currsaml{$lonhost}{'img'} = $imgurl;
$loginhash{'login'}{'saml'}{$lonhost}{'img'} = $imgurl;
@@ -12582,6 +12849,7 @@ sub modify_login {
$errors .= ''.$puberror.' ';
}
}
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of SSO button image file(s) failed because an author role could not be assigned to a Domain Configuration user ([_1]) in domain: [_2]. Error was: [_3].",$confname,$dom,$author_ok);
}
@@ -12745,19 +13013,22 @@ sub modify_login {
alt => 'Alt text for button image',
url => 'SSO URL',
title => 'Tooltip for SSO link',
+ window => 'Pop-up window if iframe',
notsso => 'Text for non-SSO log-in',
);
foreach my $lonhost (sort(keys(%{$changes{$item}}))) {
if (ref($currsaml{$lonhost}) eq 'HASH') {
$resulttext .= ''.&mt("$title{$item} in use for [_1]","$lonhost ").
'';
- foreach my $key ('text','img','alt','url','title','notsso') {
+ foreach my $key ('text','img','alt','url','title','window','notsso') {
if ($currsaml{$lonhost}{$key} eq '') {
$resulttext .= ''.&mt("$notlt{$key} not in use").' ';
} else {
my $value = "'$currsaml{$lonhost}{$key}'";
if ($key eq 'img') {
$value = ' ';
+ } elsif ($key eq 'window') {
+ $value = 'On';
}
$resulttext .= ''.&mt("$notlt{$key} set to: [_1]",
$value).' ';
@@ -12855,7 +13126,6 @@ sub check_exempt_addresses {
sub color_font_choices {
my %choices =
&Apache::lonlocal::texthash (
- img => "Header",
bgs => "Background colors",
links => "Link colors",
images => "Images",
@@ -12910,13 +13180,15 @@ sub modify_ipaccess {
foreach my $idx (@items) {
my $itemid = $itemids{$idx};
next unless ($itemid);
- my %current;
- unless ($idx eq 'add') {
+ my ($position,%current);
+ if ($idx eq 'add') {
+ $position = $env{'form.ipaccess_pos_add'};
+ } else {
+ $position = $env{'form.ipaccess_pos_'.$itemid};
if (ref($domconfig{'ipaccess'}{$itemid}) eq 'HASH') {
%current = %{$domconfig{'ipaccess'}{$itemid}};
}
}
- my $position = $env{'form.ipaccess_pos_'.$itemid};
$position =~ s/\D+//g;
if ($position ne '') {
$allpos[$position] = $itemid;
@@ -12933,7 +13205,7 @@ sub modify_ipaccess {
$possrange =~ s/,+/,/g;
if ($possrange ne '') {
my (@ok,$count);
- $count = 0;
+ $count = 0;
foreach my $poss (split(/\,/,$possrange)) {
$count ++;
$poss = &validate_ip_pattern($poss);
@@ -12966,9 +13238,9 @@ sub modify_ipaccess {
}
}
$confhash{$itemid}{'commblocks'} = {};
-
+
my %commblocks;
- map { $commblocks{$_} = 1; } &Apache::loncommon::get_env_multiple('form.ipaccess_block_'.$idx);
+ map { $commblocks{$_} = 1; } &Apache::loncommon::get_env_multiple('form.ipaccess_block_'.$idx);
foreach my $type (@{$typeorder}) {
if ($commblocks{$type}) {
$confhash{$itemid}{'commblocks'}{$type} = 'on';
@@ -13000,7 +13272,7 @@ sub modify_ipaccess {
}
$env{'form.ipaccess_cnum_'.$idx} =~ s/^\s+|\s+$//g;
$env{'form.ipaccess_cdom_'.$idx} =~ s/^\s+|\s+$//g;
- if (($env{'form.ipaccess_cnum_'.$idx} =~ /^$match_courseid$/) &&
+ if (($env{'form.ipaccess_cnum_'.$idx} =~ /^$match_courseid$/) &&
($env{'form.ipaccess_cdom_'.$idx} =~ /^$match_domain$/)) {
if (&Apache::lonnet::homeserver($env{'form.ipaccess_cnum_'.$idx},
$env{'form.ipaccess_cdom_'.$idx}) eq 'no_host') {
@@ -13080,7 +13352,7 @@ sub modify_ipaccess {
if (keys(%{$confhash{$itemid}{'courses'}})) {
my @courses;
foreach my $cid (sort(keys(%{$confhash{$itemid}{'courses'}}))) {
- my %courseinfo = &Apache::lonnet::coursedescription($cid,{'one_time' => 1});
+ my %courseinfo = &Apache::lonnet::coursedescription($cid,{'one_time' => 1});
push(@courses,$courseinfo{'description'}.' ('.$cid.')');
}
$resulttext .= ''.&mt('Courses/Communities allowed').':'.
@@ -13148,6 +13420,251 @@ sub get_ipaccess_id {
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',
+ 'daxecollapse' => 'off',
+ 'domcoordacc' => 'on',
+ 'editors' => ['edit','xml'],
+ 'authorquota' => 500,
+ 'webdav' => 0,
+ 'archive' => 'off',
+ );
+ my %titles = &authordefaults_titles();
+ foreach my $item ('nocodemirror','daxecollapse','domcoordacc','archive') {
+ 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$/,@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','daxecollapse','domcoordacc','copyright','sourceavail','archive') {
+ 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','daxecollapse','domcoordacc','archive') {
+ if ($offon[$confhash{$item}] ne $staticdefaults{$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ foreach my $item ('copyright','sourceavail') {
+ if ($confhash{$item} ne $staticdefaults{$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ my @diffs =
+ &Apache::loncommon::compare_arrays($confhash{'editors'},
+ $staticdefaults{'editors'});
+ unless (@diffs == 0) {
+ $changes{'editors'} = 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)) {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ if ((exists($changes{'authorquota'})) || (exists($changes{'webdav'})) ||
+ ($changes{'webdav_LC_adv'})) {
+ 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'};
+ }
+ }
+ $resulttext = &mt('Changes made:').'';
+ my $authoroverride;
+ foreach my $key ('nocodemirror','daxecollapse','domcoordacc','copyright','sourceavail') {
+ if (exists($changes{$key})) {
+ $domdefaults{$key} = $confhash{$key};
+ my $shown;
+ unless ($authoroverride) {
+ $resulttext .= ''.&mt('Defaults which can be overridden by Author').'';
+ $authoroverride = 1;
+ }
+ if (($key eq 'nocodemirror') || ($key eq 'daxecollapse') || ($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 .= ''.&mt('[_1] set to: [_2]',$titles{$key},$shown).' ';
+ }
+ }
+ if ($authoroverride) {
+ $resulttext .= ' ';
+ }
+ my $domcoordoverride;
+ foreach my $key ('editors','authorquota','webdav','webdav_LC_adv','archive') {
+ if (exists($changes{$key})) {
+ my $shown;
+ unless ($domcoordoverride) {
+ $resulttext .= ''.&mt('Defaults which can be overridden by a Domain Coodinator').'';
+ $domcoordoverride = 1;
+ }
+ if ($key eq 'editors') {
+ if (ref($confhash{'editors'}) eq 'ARRAY') {
+ $domdefaults{'editors'} = join(',',@{$confhash{'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'};
+ }
+ } elsif ($key eq 'archive') {
+ $domdefaults{$key} = $confhash{$key};
+ $shown = ($confhash{$key} ? &mt('Yes') : &mt('No'));
+ }
+ $resulttext .= ''.&mt('[_1] set to: [_2]',$titles{$key},$shown).' ';
+ }
+ }
+ if ($domcoordoverride) {
+ $resulttext .= ' ';
+ }
+ $resulttext .= ' ';
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
+ } 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);
@@ -13204,11 +13721,15 @@ sub modify_colors {
@images = ('img','logo','domlogo','login');
@bgs = ('pgbg','mainbg','sidebg');
} else {
- @images = ('img');
+ @images = ();
@bgs = ('pgbg','tabbg','sidebg');
}
my %defaults = &role_defaults($role,\@bgs,\@links,\@images,\@logintext);
- unless ($env{'form.'.$role.'_font'} eq $defaults{'font'}) {
+ $env{'form.'.$role.'_font'} = lc($env{'form.'.$role.'_font'});
+ if ($env{'form.'.$role.'_font'} =~ /^\w+/) {
+ $env{'form.'.$role.'_font'} = '#'.$env{'form.'.$role.'_font'};
+ }
+ unless ($env{'form.'.$role.'_font'} eq lc($defaults{'font'})) {
$confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
}
if ($role eq 'login') {
@@ -13226,7 +13747,7 @@ sub modify_colors {
if ($env{'form.'.$role.'_fontmenu'} =~ /^\w+/) {
$env{'form.'.$role.'_fontmenu'} = '#'.$env{'form.'.$role.'_fontmenu'};
}
- unless($env{'form.'.$role.'_fontmenu'} eq lc($defaults{'fontmenu'})) {
+ unless ($env{'form.'.$role.'_fontmenu'} eq lc($defaults{'fontmenu'})) {
$confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
}
}
@@ -13283,12 +13804,15 @@ sub modify_colors {
$error = &mt("Upload of [_1] image for $role page(s) is not permitted to this server: [_2]",$choices{$img},$switchserver);
} else {
if ($author_ok eq 'ok') {
+ my $modified = [];
my ($result,$logourl) =
- &publishlogo($r,'upload',$role.'_'.$img,
- $dom,$confname,$img,$width,$height);
+ &Apache::lonconfigsettings::publishlogo($r,'upload',$role.'_'.$img,
+ $dom,$confname,$img,$width,$height,
+ '',$modified);
if ($result eq 'ok') {
$confhash->{$role}{$img} = $logourl;
$changes{$role}{'images'}{$img} = 1;
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of [_1] image for $role page(s) failed because an error occurred publishing the file in RES space. Error was: [_2].",$choices{img},$result);
}
@@ -13310,12 +13834,15 @@ sub modify_colors {
# is confname an author?
if ($switchserver eq '') {
if ($author_ok eq 'ok') {
+ my $modified = [];
my ($result,$logourl) =
- &publishlogo($r,'copy',$domconfig->{$role}{$img},
- $dom,$confname,$img,$width,$height);
+ &Apache::lonconfigsettings::publishlogo($r,'copy',$domconfig->{$role}{$img},
+ $dom,$confname,$img,$width,$height,
+ '',$modified);
if ($result eq 'ok') {
$confhash->{$role}{$img} = $logourl;
$changes{$role}{'images'}{$img} = 1;
+ &update_modify_urls($r,$modified);
}
}
}
@@ -13609,229 +14136,16 @@ sub check_authorstatus {
return $author_ok;
}
-sub publishlogo {
- my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight,$savefileas) = @_;
- my ($output,$fname,$logourl,$madethumb);
- if ($action eq 'upload') {
- $fname=$env{'form.'.$formname.'.filename'};
- chop($env{'form.'.$formname});
- } else {
- ($fname) = ($formname =~ /([^\/]+)$/);
- }
- if ($savefileas ne '') {
- $fname = $savefileas;
- }
- $fname=&Apache::lonnet::clean_filename($fname);
-# See if there is anything left
- unless ($fname) { return ('error: no uploaded file'); }
- $fname="$subdir/$fname";
- my $docroot=$r->dir_config('lonDocRoot');
- my $filepath="$docroot/priv";
- my $relpath = "$dom/$confname";
- my ($fnamepath,$file,$fetchthumb);
- $file=$fname;
- if ($fname=~m|/|) {
- ($fnamepath,$file) = ($fname =~ m|^(.*)/([^/]+)$|);
- }
- my @parts=split(/\//,"$filepath/$relpath/$fnamepath");
- my $count;
- for ($count=5;$count<=$#parts;$count++) {
- $filepath.="/$parts[$count]";
- if ((-e $filepath)!=1) {
- mkdir($filepath,02770);
- }
- }
- # Check for bad extension and disallow upload
- if ($file=~/\.(\w+)$/ &&
- (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
- $output =
- &mt('Invalid file extension ([_1]) - reserved for internal use.',$1);
- } elsif ($file=~/\.(\w+)$/ &&
- !defined(&Apache::loncommon::fileembstyle($1))) {
- $output = &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1);
- } elsif ($file=~/\.(\d+)\.(\w+)$/) {
- $output = &mt('Filename not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2);
- } elsif (-d "$filepath/$file") {
- $output = &mt('Filename is a directory name - rename the file and re-upload');
- } else {
- my $source = $filepath.'/'.$file;
- my $logfile;
- if (!open($logfile,">>",$source.'.log')) {
- return (&mt('No write permission to Authoring Space'));
- }
- print $logfile
-"\n================= Publish ".localtime()." ================\n".
-$env{'user.name'}.':'.$env{'user.domain'}."\n";
-# Save the file
- if (!open(FH,">",$source)) {
- &Apache::lonnet::logthis('Failed to create '.$source);
- return (&mt('Failed to create file'));
- }
- if ($action eq 'upload') {
- if (!print FH ($env{'form.'.$formname})) {
- &Apache::lonnet::logthis('Failed to write to '.$source);
- return (&mt('Failed to write file'));
- }
- } else {
- my $original = &Apache::lonnet::filelocation('',$formname);
- if(!copy($original,$source)) {
- &Apache::lonnet::logthis('Failed to copy '.$original.' to '.$source);
- return (&mt('Failed to write file'));
- }
- }
- close(FH);
- chmod(0660, $source); # Permissions to rw-rw---.
-
- my $targetdir=$docroot.'/res/'.$dom.'/'.$confname .'/'.$fnamepath;
- my $copyfile=$targetdir.'/'.$file;
-
- my @parts=split(/\//,$targetdir);
- my $path="/$parts[1]/$parts[2]/$parts[3]/$parts[4]";
- for (my $count=5;$count<=$#parts;$count++) {
- $path.="/$parts[$count]";
- if (!-e $path) {
- print $logfile "\nCreating directory ".$path;
- mkdir($path,02770);
- }
- }
- my $versionresult;
- if (-e $copyfile) {
- $versionresult = &logo_versioning($targetdir,$file,$logfile);
- } else {
- $versionresult = 'ok';
- }
- if ($versionresult eq 'ok') {
- if (copy($source,$copyfile)) {
- print $logfile "\nCopied original source to ".$copyfile."\n";
- $output = 'ok';
- $logourl = '/res/'.$dom.'/'.$confname.'/'.$fname;
- push(@{$modified_urls},[$copyfile,$source]);
- my $metaoutput =
- &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);
- unless ($registered_cleanup) {
- my $handlers = $r->get_handlers('PerlCleanupHandler');
- $r->set_handlers('PerlCleanupHandler' => [\¬ifysubscribed,@{$handlers}]);
- $registered_cleanup=1;
- }
- } else {
- print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
- $output = &mt('Failed to copy file to RES space').", $!";
- }
- if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) {
- my $inputfile = $filepath.'/'.$file;
- my $outfile = $filepath.'/'.'tn-'.$file;
- my ($fullwidth,$fullheight) = &check_dimensions($inputfile);
- if ($fullwidth ne '' && $fullheight ne '') {
- if ($fullwidth > $thumbwidth && $fullheight > $thumbheight) {
- my $thumbsize = $thumbwidth.'x'.$thumbheight;
- my @args = ('convert','-sample',$thumbsize,$inputfile,$outfile);
- system({$args[0]} @args);
- chmod(0660, $filepath.'/tn-'.$file);
- if (-e $outfile) {
- my $copyfile=$targetdir.'/tn-'.$file;
- if (copy($outfile,$copyfile)) {
- print $logfile "\nCopied source to ".$copyfile."\n";
- my $thumb_metaoutput =
- &write_metadata($dom,$confname,$formname,
- $targetdir,'tn-'.$file,$logfile);
- push(@{$modified_urls},[$copyfile,$outfile]);
- unless ($registered_cleanup) {
- my $handlers = $r->get_handlers('PerlCleanupHandler');
- $r->set_handlers('PerlCleanupHandler' => [\¬ifysubscribed,@{$handlers}]);
- $registered_cleanup=1;
- }
- $madethumb = 1;
- } else {
- print $logfile "\nUnable to write ".$copyfile.
- ':'.$!."\n";
- }
- }
- }
- }
- }
- } else {
- $output = $versionresult;
- }
- }
- return ($output,$logourl,$madethumb);
-}
-
-sub logo_versioning {
- my ($targetdir,$file,$logfile) = @_;
- my $target = $targetdir.'/'.$file;
- my ($maxversion,$fn,$extn,$output);
- $maxversion = 0;
- if ($file =~ /^(.+)\.(\w+)$/) {
- $fn=$1;
- $extn=$2;
- }
- opendir(DIR,$targetdir);
- while (my $filename=readdir(DIR)) {
- if ($filename=~/\Q$fn\E\.(\d+)\.\Q$extn\E$/) {
- $maxversion=($1>$maxversion)?$1:$maxversion;
- }
- }
- $maxversion++;
- print $logfile "\nCreating old version ".$maxversion."\n";
- my $copyfile=$targetdir.'/'.$fn.'.'.$maxversion.'.'.$extn;
- if (copy($target,$copyfile)) {
- print $logfile "Copied old target to ".$copyfile."\n";
- $copyfile=$copyfile.'.meta';
- if (copy($target.'.meta',$copyfile)) {
- print $logfile "Copied old target metadata to ".$copyfile."\n";
- $output = 'ok';
- } else {
- print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n";
- $output = &mt('Failed to copy old meta').", $!, ";
+sub update_modify_urls {
+ my ($r,$modified) = @_;
+ if ((ref($modified) eq 'ARRAY') && (@{$modified})) {
+ push(@{$modified_urls},$modified);
+ unless ($registered_cleanup) {
+ my $handlers = $r->get_handlers('PerlCleanupHandler');
+ $r->set_handlers('PerlCleanupHandler' => [\¬ifysubscribed,@{$handlers}]);
+ $registered_cleanup=1;
}
- } else {
- print $logfile "Unable to write ".$copyfile.':'.$!."\n";
- $output = &mt('Failed to copy old target').", $!, ";
}
- return $output;
-}
-
-sub write_metadata {
- my ($dom,$confname,$formname,$targetdir,$file,$logfile) = @_;
- my (%metadatafields,%metadatakeys,$output);
- $metadatafields{'title'}=$formname;
- $metadatafields{'creationdate'}=time;
- $metadatafields{'lastrevisiondate'}=time;
- $metadatafields{'copyright'}='public';
- $metadatafields{'modifyinguser'}=$env{'user.name'}.':'.
- $env{'user.domain'};
- $metadatafields{'authorspace'}=$confname.':'.$dom;
- $metadatafields{'domain'}=$dom;
- {
- print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
- my $mfh;
- if (open($mfh,">",$targetdir.'/'.$file.'.meta')) {
- foreach (sort(keys(%metadatafields))) {
- unless ($_=~/\./) {
- my $unikey=$_;
- $unikey=~/^([A-Za-z]+)/;
- my $tag=$1;
- $tag=~tr/A-Z/a-z/;
- print $mfh "\n\<$tag";
- foreach (split(/\,/,$metadatakeys{$unikey})) {
- my $value=$metadatafields{$unikey.'.'.$_};
- $value=~s/\"/\'\'/g;
- print $mfh ' '.$_.'="'.$value.'"';
- }
- print $mfh '>'.
- &HTML::Entities::encode($metadatafields{$unikey},'<>&"')
- .''.$tag.'>';
- }
- }
- $output = 'ok';
- print $logfile "\nWrote metadata";
- close($mfh);
- } else {
- print $logfile "\nFailed to open metadata file";
- $output = &mt('Could not write metadata');
- }
- }
- return $output;
}
sub notifysubscribed {
@@ -13882,15 +14196,21 @@ sub subscribed_hosts {
sub check_switchserver {
my ($dom,$confname) = @_;
- my ($allowed,$switchserver);
- my $home = &Apache::lonnet::homeserver($confname,$dom);
- if ($home eq 'no_host') {
+ my ($allowed,$switchserver,$home);
+ if ($confname eq '') {
$home = &Apache::lonnet::domain($dom,'primary');
+ } else {
+ $home = &Apache::lonnet::homeserver($confname,$dom);
+ if ($home eq 'no_host') {
+ $home = &Apache::lonnet::domain($dom,'primary');
+ }
}
my @ids=&Apache::lonnet::current_machine_ids();
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
- $switchserver=''.&mt('Switch Server').' ';
+ $switchserver=''.&mt('Switch Server').' ';
}
return $switchserver;
}
@@ -13902,7 +14222,7 @@ sub modify_quotas {
$author_ok,$switchserver,$errors,$validationitemsref,$validationnamesref,
$validationfieldsref);
if ($action eq 'quotas') {
- $context = 'tools';
+ $context = 'tools';
} else {
$context = $action;
}
@@ -13922,7 +14242,7 @@ sub modify_quotas {
@usertools = ('author');
%titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','webdav','portfolio');
+ @usertools = ('aboutme','blog','portfolio','portaccess','timezone');
%titles = &tool_titles();
}
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
@@ -13945,8 +14265,6 @@ sub modify_quotas {
} 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);
}
@@ -14240,7 +14558,6 @@ sub modify_quotas {
}
} else {
$confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
- $confhash{'authorquota'}{'default'} = $env{'form.authorquota'};
}
foreach my $item (@usertools) {
foreach my $type (@{$types},'default','_LC_adv') {
@@ -14329,15 +14646,10 @@ sub modify_quotas {
}
}
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') {
@@ -14357,21 +14669,6 @@ sub modify_quotas {
}
}
}
- 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') {
@@ -14412,19 +14709,6 @@ sub modify_quotas {
}
$resulttext .= ' ';
}
- if (ref($changes{'authorquota'}) eq 'HASH') {
- $resulttext .= ''.&mt('Authoring Space default quotas').'';
- foreach my $type (@{$types},'default') {
- if (defined($changes{'authorquota'}{$type})) {
- my $typetitle = $usertypes->{$type};
- if ($type eq 'default') {
- $typetitle = $othertitle;
- }
- $resulttext .= ''.&mt('[_1] set to [_2] MB',$typetitle,$confhash{'authorquota'}{$type}).' ';
- }
- }
- $resulttext .= ' ';
- }
}
my %newenv;
foreach my $item (@usertools) {
@@ -14576,6 +14860,7 @@ sub modify_quotas {
$resulttext .= ''.&mt('Validated course requests identified as processed by: [_1]',
''.$changes{'validation'}{'dc'}.' ').' ';
}
+ $resulttext .= ' ';
}
}
}
@@ -14613,11 +14898,14 @@ sub process_textbook_image {
$error = &mt('Upload of textbook image is not permitted to this server: [_1]',
$switchserver);
} elsif ($author_ok eq 'ok') {
+ my $modified = [];
my ($result,$imageurl) =
- &publishlogo($r,'upload',$caller,$dom,$confname,
- "$type/$cdom/$cnum/cover",$width,$height);
+ &Apache::lonconfigsettings::publishlogo($r,'upload',$caller,$dom,$confname,
+ "$type/$cdom/$cnum/cover",$width,$height,
+ '',$modified);
if ($result eq 'ok') {
$url = $imageurl;
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$filename,$result);
}
@@ -14632,656 +14920,382 @@ sub process_textbook_image {
sub modify_ltitools {
my ($r,$dom,$action,$lastactref,%domconfig) = @_;
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
- my ($newid,@allpos,%changes,%confhash,%encconfig,$errors,$resulttext);
+ my (%currtoolsec,%secchanges,%newtoolsec,%newkeyset);
+ &fetch_secrets($dom,'toolsec',\%domconfig,\%currtoolsec,\%secchanges,\%newtoolsec,\%newkeyset);
+
my $confname = $dom.'-domainconfig';
my $servadm = $r->dir_config('lonAdmEMail');
my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);
- my (%posslti,%possfield);
- my @courseroles = ('cc','in','ta','ep','st');
- my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
- map { $posslti{$_} = 1; } @ltiroles;
- my @allfields = ('fullname','firstname','lastname','email','user','roles');
- map { $possfield{$_} = 1; } @allfields;
- my %lt = <itools_names();
- if ($env{'form.ltitools_add'}) {
- my $title = $env{'form.ltitools_add_title'};
- $title =~ s/(`)/'/g;
- ($newid,my $error) = &get_ltitools_id($dom,$title);
- if ($newid) {
- my $position = $env{'form.ltitools_add_pos'};
- $position =~ s/\D+//g;
- if ($position ne '') {
- $allpos[$position] = $newid;
- }
- $changes{$newid} = 1;
- foreach my $item ('title','url','key','secret','lifetime') {
- $env{'form.ltitools_add_'.$item} =~ s/(`)/'/g;
- if ($item eq 'lifetime') {
- $env{'form.ltitools_add_'.$item} =~ s/[^\d.]//g;
- }
- if ($env{'form.ltitools_add_'.$item}) {
- if (($item eq 'key') || ($item eq 'secret')) {
- $encconfig{$newid}{$item} = $env{'form.ltitools_add_'.$item};
- } else {
- $confhash{$newid}{$item} = $env{'form.ltitools_add_'.$item};
- }
- }
- }
- if ($env{'form.ltitools_add_version'} eq 'LTI-1p0') {
- $confhash{$newid}{'version'} = $env{'form.ltitools_add_version'};
- }
- if ($env{'form.ltitools_add_msgtype'} eq 'basic-lti-launch-request') {
- $confhash{$newid}{'msgtype'} = $env{'form.ltitools_add_msgtype'};
- }
- if ($env{'form.ltitools_add_sigmethod'} eq 'HMAC-SHA256') {
- $confhash{$newid}{'sigmethod'} = $env{'form.ltitools_add_sigmethod'};
- } else {
- $confhash{$newid}{'sigmethod'} = 'HMAC-SHA1';
- }
- foreach my $item ('width','height','linktext','explanation') {
- $env{'form.ltitools_add_'.$item} =~ s/^\s+//;
- $env{'form.ltitools_add_'.$item} =~ s/\s+$//;
- if (($item eq 'width') || ($item eq 'height')) {
- if ($env{'form.ltitools_add_'.$item} =~ /^\d+$/) {
- $confhash{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
- }
- } else {
- if ($env{'form.ltitools_add_'.$item} ne '') {
- $confhash{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
- }
- }
- }
- if ($env{'form.ltitools_add_target'} eq 'window') {
- $confhash{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
- } elsif ($env{'form.ltitools_add_target'} eq 'tab') {
- $confhash{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
- } else {
- $confhash{$newid}{'display'}{'target'} = 'iframe';
- }
- foreach my $item ('passback','roster') {
- if ($env{'form.ltitools_'.$item.'_add'}) {
- $confhash{$newid}{$item} = 1;
- if ($env{'form.ltitools_'.$item.'valid_add'} ne '') {
- my $lifetime = $env{'form.ltitools_'.$item.'valid_add'};
- $lifetime =~ s/^\s+|\s+$//g;
- if ($lifetime =~ /^\d+\.?\d*$/) {
- $confhash{$newid}{$item.'valid'} = $lifetime;
- }
- }
- }
- }
- if ($env{'form.ltitools_add_image.filename'} ne '') {
- my ($imageurl,$error) =
- &process_ltitools_image($r,$dom,$confname,'ltitools_add_image',$newid,
- $configuserok,$switchserver,$author_ok);
- if ($imageurl) {
- $confhash{$newid}{'image'} = $imageurl;
- }
- if ($error) {
- &Apache::lonnet::logthis($error);
- $errors .= ''.$error.' ';
- }
- }
- my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_add_fields');
- foreach my $field (@fields) {
- if ($possfield{$field}) {
- if ($field eq 'roles') {
- foreach my $role (@courseroles) {
- my $choice = $env{'form.ltitools_add_roles_'.$role};
- if (($choice ne '') && ($posslti{$choice})) {
- $confhash{$newid}{'roles'}{$role} = $choice;
- if ($role eq 'cc') {
- $confhash{$newid}{'roles'}{'co'} = $choice;
- }
- }
+
+ my ($resulttext,$ltitoolsoutput,$is_home,$errors,%ltitoolschg,%newtoolsenc,%newltitools);
+ my $toolserror =
+ &Apache::courseprefs::process_ltitools($r,$dom,$confname,$domconfig{'ltitools'},\%ltitoolschg,'domain',
+ $lastactref,$configuserok,$switchserver,$author_ok);
+
+ my $home = &Apache::lonnet::domain($dom,'primary');
+ unless (($home eq 'no_host') || ($home eq '')) {
+ my @ids=&Apache::lonnet::current_machine_ids();
+ foreach my $id (@ids) { if ($id eq $home) { $is_home=1; last; } }
+ }
+
+ if (keys(%ltitoolschg)) {
+ foreach my $id (keys(%ltitoolschg)) {
+ if (ref($ltitoolschg{$id}) eq 'HASH') {
+ foreach my $inner (keys(%{$ltitoolschg{$id}})) {
+ if (($inner eq 'secret') || ($inner eq 'key')) {
+ if ($is_home) {
+ $newtoolsenc{$id}{$inner} = $ltitoolschg{$id}{$inner};
}
- } else {
- $confhash{$newid}{'fields'}{$field} = 1;
- }
- }
- }
- if (ref($confhash{$newid}{'fields'}) eq 'HASH') {
- if ($confhash{$newid}{'fields'}{'user'}) {
- if ($env{'form.ltitools_userincdom_add'}) {
- $confhash{$newid}{'incdom'} = 1;
}
}
}
- my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig');
- foreach my $item (@courseconfig) {
- $confhash{$newid}{'crsconf'}{$item} = 1;
- }
- if ($env{'form.ltitools_add_custom'}) {
- my $name = $env{'form.ltitools_add_custom_name'};
- my $value = $env{'form.ltitools_add_custom_value'};
- $value =~ s/(`)/'/g;
- $name =~ s/(`)/'/g;
- $confhash{$newid}{'custom'}{$name} = $value;
- }
- } else {
- my $error = &mt('Failed to acquire unique ID for new external tool');
- $errors .= ''.$error.' ';
}
- }
- if (ref($domconfig{$action}) eq 'HASH') {
- my %deletions;
- my @todelete = &Apache::loncommon::get_env_multiple('form.ltitools_del');
- if (@todelete) {
- map { $deletions{$_} = 1; } @todelete;
+ $ltitoolsoutput = &Apache::courseprefs::store_ltitools($dom,'','domain',\%ltitoolschg,$domconfig{'ltitools'});
+ if (keys(%ltitoolschg)) {
+ %newltitools = %ltitoolschg;
}
- my %customadds;
- my @newcustom = &Apache::loncommon::get_env_multiple('form.ltitools_customadd');
- if (@newcustom) {
- map { $customadds{$_} = 1; } @newcustom;
- }
- my %imgdeletions;
- my @todeleteimages = &Apache::loncommon::get_env_multiple('form.ltitools_image_del');
- if (@todeleteimages) {
- map { $imgdeletions{$_} = 1; } @todeleteimages;
- }
- my $maxnum = $env{'form.ltitools_maxnum'};
- for (my $i=0; $i<=$maxnum; $i++) {
- my $itemid = $env{'form.ltitools_id_'.$i};
- $itemid =~ s/\D+//g;
- if (ref($domconfig{$action}{$itemid}) eq 'HASH') {
- if ($deletions{$itemid}) {
- if ($domconfig{$action}{$itemid}{'image'}) {
- #FIXME need to obsolete item in RES space
- }
- $changes{$itemid} = $domconfig{$action}{$itemid}{'title'};
- next;
- } else {
- my $newpos = $env{'form.ltitools_'.$itemid};
- $newpos =~ s/\D+//g;
- foreach my $item ('title','url','lifetime') {
- $confhash{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
- if ($domconfig{$action}{$itemid}{$item} ne $confhash{$itemid}{$item}) {
- $changes{$itemid} = 1;
- }
- }
- foreach my $item ('key','secret') {
- $encconfig{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
- if ($domconfig{$action}{$itemid}{$item} ne $encconfig{$itemid}{$item}) {
- $changes{$itemid} = 1;
- }
- }
- if ($env{'form.ltitools_version_'.$i} eq 'LTI-1p0') {
- $confhash{$itemid}{'version'} = $env{'form.ltitools_version_'.$i};
- }
- if ($env{'form.ltitools_msgtype_'.$i} eq 'basic-lti-launch-request') {
- $confhash{$itemid}{'msgtype'} = $env{'form.ltitools_msgtype_'.$i};
- }
- if ($env{'form.ltitools_sigmethod_'.$i} eq 'HMAC-SHA256') {
- $confhash{$itemid}{'sigmethod'} = $env{'form.ltitools_sigmethod_'.$i};
- } else {
- $confhash{$itemid}{'sigmethod'} = 'HMAC-SHA1';
- }
- if ($domconfig{$action}{$itemid}{'sigmethod'} eq '') {
- if ($confhash{$itemid}{'sigmethod'} ne 'HMAC-SHA1') {
- $changes{$itemid} = 1;
- }
- } elsif ($domconfig{$action}{$itemid}{'sigmethod'} ne $confhash{$itemid}{'sigmethod'}) {
- $changes{$itemid} = 1;
- }
- foreach my $size ('width','height') {
- $env{'form.ltitools_'.$size.'_'.$i} =~ s/^\s+//;
- $env{'form.ltitools_'.$size.'_'.$i} =~ s/\s+$//;
- if ($env{'form.ltitools_'.$size.'_'.$i} =~ /^\d+$/) {
- $confhash{$itemid}{'display'}{$size} = $env{'form.ltitools_'.$size.'_'.$i};
- if (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{$size} ne $confhash{$itemid}{'display'}{$size}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- } elsif (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{$size} ne '') {
- $changes{$itemid} = 1;
- }
- }
- }
- foreach my $item ('linktext','explanation') {
- $env{'form.ltitools_'.$item.'_'.$i} =~ s/^\s+//;
- $env{'form.ltitools_'.$item.'_'.$i} =~ s/\s+$//;
- if ($env{'form.ltitools_'.$item.'_'.$i} ne '') {
- $confhash{$itemid}{'display'}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
- if (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{$item} ne $confhash{$itemid}{'display'}{$item}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- } elsif (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{$item} ne '') {
- $changes{$itemid} = 1;
- }
- }
- }
- if ($env{'form.ltitools_target_'.$i} eq 'window') {
- $confhash{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
- } elsif ($env{'form.ltitools_target_'.$i} eq 'tab') {
- $confhash{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
- } else {
- $confhash{$itemid}{'display'}{'target'} = 'iframe';
- }
- if (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{'target'} ne $confhash{$itemid}{'display'}{'target'}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- foreach my $extra ('passback','roster') {
- if ($env{'form.ltitools_'.$extra.'_'.$i}) {
- $confhash{$itemid}{$extra} = 1;
- if ($env{'form.ltitools_'.$extra.'valid_'.$i} ne '') {
- my $lifetime = $env{'form.ltitools_'.$extra.'valid_'.$i};
- $lifetime =~ s/^\s+|\s+$//g;
- if ($lifetime =~ /^\d+\.?\d*$/) {
- $confhash{$itemid}{$extra.'valid'} = $lifetime;
- }
- }
- }
- if ($domconfig{$action}{$itemid}{$extra} ne $confhash{$itemid}{$extra}) {
- $changes{$itemid} = 1;
- }
- if ($domconfig{$action}{$itemid}{$extra.'valid'} ne $confhash{$itemid}{$extra.'valid'}) {
- $changes{$itemid} = 1;
- }
- }
- my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig_'.$i);
- foreach my $item ('label','title','target','linktext','explanation','append') {
- if (grep(/^\Q$item\E$/,@courseconfig)) {
- $confhash{$itemid}{'crsconf'}{$item} = 1;
- if (ref($domconfig{$action}{$itemid}{'crsconf'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'crsconf'}{$item} ne $confhash{$itemid}{'crsconf'}{$item}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- }
- }
- my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_fields_'.$i);
- foreach my $field (@fields) {
- if ($possfield{$field}) {
- if ($field eq 'roles') {
- foreach my $role (@courseroles) {
- my $choice = $env{'form.ltitools_roles_'.$role.'_'.$i};
- if (($choice ne '') && ($posslti{$choice})) {
- $confhash{$itemid}{'roles'}{$role} = $choice;
- if ($role eq 'cc') {
- $confhash{$itemid}{'roles'}{'co'} = $choice;
- }
- }
- if (ref($domconfig{$action}{$itemid}{'roles'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'roles'}{$role} ne $confhash{$itemid}{'roles'}{$role}) {
- $changes{$itemid} = 1;
- }
- } elsif ($confhash{$itemid}{'roles'}{$role}) {
- $changes{$itemid} = 1;
- }
- }
- } else {
- $confhash{$itemid}{'fields'}{$field} = 1;
- if (ref($domconfig{$action}{$itemid}{'fields'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'fields'}{$field} ne $confhash{$itemid}{'fields'}{$field}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- }
- }
- }
- if (ref($confhash{$itemid}{'fields'}) eq 'HASH') {
- if ($confhash{$itemid}{'fields'}{'user'}) {
- if ($env{'form.ltitools_userincdom_'.$i}) {
- $confhash{$itemid}{'incdom'} = 1;
- }
- if ($domconfig{$action}{$itemid}{'incdom'} ne $confhash{$itemid}{'incdom'}) {
- $changes{$itemid} = 1;
- }
- }
- }
- $allpos[$newpos] = $itemid;
- }
- if ($imgdeletions{$itemid}) {
- $changes{$itemid} = 1;
- #FIXME need to obsolete item in RES space
- } elsif ($env{'form.ltitools_image_'.$i.'.filename'}) {
- my ($imgurl,$error) = &process_ltitools_image($r,$dom,$confname,'ltitools_image_'.$i,
- $itemid,$configuserok,$switchserver,
- $author_ok);
- if ($imgurl) {
- $confhash{$itemid}{'image'} = $imgurl;
- $changes{$itemid} = 1;
- }
- if ($error) {
- &Apache::lonnet::logthis($error);
- $errors .= ''.$error.' ';
- }
- } elsif ($domconfig{$action}{$itemid}{'image'}) {
- $confhash{$itemid}{'image'} =
- $domconfig{$action}{$itemid}{'image'};
- }
- if ($customadds{$i}) {
- my $name = $env{'form.ltitools_custom_name_'.$i};
- $name =~ s/(`)/'/g;
- $name =~ s/^\s+//;
- $name =~ s/\s+$//;
- my $value = $env{'form.ltitools_custom_value_'.$i};
- $value =~ s/(`)/'/g;
- $value =~ s/^\s+//;
- $value =~ s/\s+$//;
- if ($name ne '') {
- $confhash{$itemid}{'custom'}{$name} = $value;
- $changes{$itemid} = 1;
- }
- }
- my %customdels;
- my @customdeletions = &Apache::loncommon::get_env_multiple('form.ltitools_customdel_'.$i);
- if (@customdeletions) {
- $changes{$itemid} = 1;
- }
- map { $customdels{$_} = 1; } @customdeletions;
- if (ref($domconfig{$action}{$itemid}{'custom'}) eq 'HASH') {
- foreach my $key (keys(%{$domconfig{$action}{$itemid}{'custom'}})) {
- unless ($customdels{$key}) {
- if ($env{'form.ltitools_customval_'.$key.'_'.$i} ne '') {
- $confhash{$itemid}{'custom'}{$key} = $env{'form.ltitools_customval_'.$key.'_'.$i};
- }
- if ($domconfig{$action}{$itemid}{'custom'}{$key} ne $env{'form.ltitools_customval_'.$key.'_'.$i}) {
- $changes{$itemid} = 1;
- }
- }
- }
- }
- unless ($changes{$itemid}) {
- foreach my $key (keys(%{$domconfig{$action}{$itemid}})) {
- if (ref($domconfig{$action}{$itemid}{$key}) eq 'HASH') {
- if (ref($confhash{$itemid}{$key}) eq 'HASH') {
- foreach my $innerkey (keys(%{$domconfig{$action}{$itemid}{$key}})) {
- unless (exists($confhash{$itemid}{$key}{$innerkey})) {
- $changes{$itemid} = 1;
- last;
- }
- }
- } elsif (keys(%{$domconfig{$action}{$itemid}{$key}}) > 0) {
- $changes{$itemid} = 1;
+ }
+ if (ref($domconfig{'ltitools'}) eq 'HASH') {
+ foreach my $id (%{$domconfig{'ltitools'}}) {
+ next if ($id !~ /^\d+$/);
+ unless (exists($ltitoolschg{$id})) {
+ if (ref($domconfig{'ltitools'}{$id}) eq 'HASH') {
+ foreach my $inner (keys(%{$domconfig{'ltitools'}{$id}})) {
+ if (($inner eq 'secret') || ($inner eq 'key')) {
+ if ($is_home) {
+ $newtoolsenc{$id}{$inner} = $domconfig{'ltitools'}{$id}{$inner};
}
+ } else {
+ $newltitools{$id}{$inner} = $domconfig{'ltitools'}{$id}{$inner};
}
- last if ($changes{$itemid});
}
+ } else {
+ $newltitools{$id} = $domconfig{'ltitools'}{$id};
}
}
}
}
- if (@allpos > 0) {
- my $idx = 0;
- foreach my $itemid (@allpos) {
- if ($itemid ne '') {
- $confhash{$itemid}{'order'} = $idx;
- if (ref($domconfig{$action}) eq 'HASH') {
- if (ref($domconfig{$action}{$itemid}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'order'} ne $idx) {
- $changes{$itemid} = 1;
- }
- }
- }
- $idx ++;
- }
+ if ($toolserror) {
+ $errors = ''.$toolserror.' ';
+ }
+ if ((keys(%ltitoolschg) == 0) && (keys(%secchanges) == 0)) {
+ $resulttext = &mt('No changes made.');
+ if ($errors) {
+ $resulttext .= ' '.&mt('The following errors occurred: ').'';
}
+ return $resulttext;
}
my %ltitoolshash = (
- $action => { %confhash }
+ $action => { %newltitools }
);
- my $putresult = &Apache::lonnet::put_dom('configuration',\%ltitoolshash,
- $dom);
+ if (keys(%secchanges)) {
+ $ltitoolshash{'toolsec'} = \%newtoolsec;
+ }
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%ltitoolshash,$dom);
if ($putresult eq 'ok') {
- my %ltienchash = (
- $action => { %encconfig }
- );
- &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1);
- if (keys(%changes) > 0) {
+ my %keystore;
+ if ($is_home) {
+ my %toolsenchash = (
+ $action => { %newtoolsenc }
+ );
+ &Apache::lonnet::put_dom('encconfig',\%toolsenchash,$dom,undef,1);
my $cachetime = 24*60*60;
- my %ltiall = %confhash;
- foreach my $id (keys(%ltiall)) {
- if (ref($encconfig{$id}) eq 'HASH') {
- foreach my $item ('key','secret') {
- $ltiall{$id}{$item} = $encconfig{$id}{$item};
+ &Apache::lonnet::do_cache_new('ltitoolsenc',$dom,\%newtoolsenc,$cachetime);
+ &store_security($dom,'ltitools',\%secchanges,\%newkeyset,\%keystore,$lastactref);
+ }
+ $resulttext = &mt('Changes made:').'';
+ if ($changes{'approval'}) {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ delete($domdefaults{'userapprovals'});
+ if (ref($privacyhash{'approval'}) eq 'HASH') {
+ foreach my $domtype ('instdom','extdom') {
+ if (ref($privacyhash{'approval'}{$domtype}) eq 'HASH') {
+ foreach my $roletype ('domain','author','course','community') {
+ if ($privacyhash{'approval'}{$domtype}{$roletype} eq 'user') {
+ $domdefaults{'userapprovals'} = 1;
+ last;
+ }
+ }
+ }
+ last if ($domdefaults{'userapprovals'});
+ }
+ }
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
+ }
} else {
$resulttext = &mt('No changes made to user information settings');
}
@@ -18247,12 +18321,15 @@ sub modify_passwords {
$error = &mt("Upload of file containing domain-specific text is not permitted to this server: [_1]",$switchserver);
} else {
if ($author_ok eq 'ok') {
+ my $modified = [];
my ($result,$customurl) =
- &publishlogo($r,'upload','passwords_customfile',$dom,
- $confname,'customtext/resetpw','','',$customfn);
+ &Apache::lonconfigsettings::publishlogo($r,'upload','passwords_customfile',$dom,
+ $confname,'customtext/resetpw','','',$customfn,
+ $modified);
if ($result eq 'ok') {
$newvalues{'resetcustom'} = $customurl;
$changes{'reset'} = 1;
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$customfn,$result);
}
@@ -18500,7 +18577,7 @@ sub modify_passwords {
);
my $needed = ''.
join(' ',map {$rulenames{$_} } @{$confighash{'passwords'}{'chars'}}).
- ' ';
+ '';
$resulttext .= ''.&mt('[_1] set to: [_2]',$titles{'chars'},$needed).' ';
} else {
$resulttext .= ''.&mt('[_1] set to none',$titles{'chars'}).' ';
@@ -18573,7 +18650,7 @@ sub password_rule_changes {
my (@rules,%staticdefaults);
if ($prefix eq 'passwords') {
@rules = ('min','max','expire','numsaved');
- } elsif ($prefix eq 'secrets') {
+ } elsif (($prefix eq 'ltisecrets') || ($prefix eq 'toolsecrets')) {
@rules = ('min','max');
}
$staticdefaults{'min'} = $Apache::lonnet::passwdmin;
@@ -18983,7 +19060,7 @@ sub modify_selfcreation {
if (($chosen eq 'inst') || ($chosen eq 'noninst')) {
my $emaildom;
if ($env{'form.cancreate_emaildomain_'.$chosen.'_'.$type} =~ /^\@[^\@]+$/) {
- $emaildom = $env{'form.cancreate_emaildomain_'.$chosen.'_'.$type};
+ $emaildom = $env{'form.cancreate_emaildomain_'.$chosen.'_'.$type};
$cancreate{'emaildomain'}{$type}{$chosen} = $emaildom;
if (ref($curremaildom{$type}) eq 'HASH') {
if (exists($curremaildom{$type}{$chosen})) {
@@ -18995,7 +19072,7 @@ sub modify_selfcreation {
}
} elsif ($emaildom ne '') {
push(@{$changes{'cancreate'}},'emaildomain');
- }
+ }
}
$cancreate{'emailoptions'}{$type} = $env{'form.cancreate_emailoptions_'.$type};
} elsif ($chosen eq 'custom') {
@@ -19422,7 +19499,7 @@ sub modify_selfcreation {
);
if (@types) {
if (@statuses) {
- $chgtext .= &mt('Processing of requests to create account with e-mail verification set as follows:').
+ $chgtext .= &mt('Processing of requests to create account with e-mail verification set as follows:').
'';
foreach my $status (@statuses) {
if ($status eq 'default') {
@@ -19508,7 +19585,7 @@ sub modify_selfcreation {
$output = ''.$usertypes{$type}.' -- '.&mt('No restriction on e-mail domain').' ';
} else {
$output = ''.$usertypes{$type}.' -- '.&mt("User's e-mail address needs to end: [_1]",
- $cancreate{'emaildomain'}{$type}{'inst'}).' ';
+ $cancreate{'emaildomain'}{$type}{'inst'}).'';
}
}
} elsif ($cancreate{'emailoptions'}{$type} eq 'noninst') {
@@ -19526,7 +19603,7 @@ sub modify_selfcreation {
$output = ''.$usertypes{$type}.' -- '.&mt('No restriction on e-mail domain').' ';
} else {
$output = ''.$usertypes{$type}.' -- '.&mt("User's e-mail address must not end: [_1]",
- $cancreate{'emaildomain'}{$type}{'noninst'}).' ';
+ $cancreate{'emaildomain'}{$type}{'noninst'}).'';
}
}
}
@@ -19630,7 +19707,7 @@ sub modify_selfcreation {
$typename = $othertitle;
} else {
$typename = $usertypes{$type};
- }
+ }
$chgtext .= &mt('(Affiliation: [_1])',$typename);
}
if (@{$email_rule{$type}} > 0) {
@@ -19814,21 +19891,27 @@ sub modify_usermodification {
}
}
}
- my @contexts = ('author','course');
+ my @contexts = ('author','coauthor','course');
my %context_title = (
author => 'In author context',
+ coauthor => 'As co-author manager',
course => 'In course context',
);
my @fields = ('lastname','firstname','middlename','generation',
'permanentemail','id');
my %roles = (
author => ['ca','aa'],
+ coauthor => ['ca','aa'],
course => ['st','ep','ta','in','cr'],
);
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
foreach my $context (@contexts) {
+ my $prefix = 'canmodify';
+ if ($context eq 'coauthor') {
+ $prefix = 'cacanmodify';
+ }
foreach my $role (@{$roles{$context}}) {
- my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$role);
+ my @modifiable = &Apache::loncommon::get_env_multiple('form.'.$prefix.'_'.$role);
foreach my $item (@fields) {
if (grep(/^\Q$item\E$/,@modifiable)) {
$modifyhash{$context}{$role}{$item} = 1;
@@ -19948,16 +20031,58 @@ sub modify_defaults {
}
} elsif ($item eq 'portal_def') {
if ($newvalues{$item} ne '') {
- unless ($newvalues{$item} =~ /^https?\:\/\/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/?$/) {
+ if ($newvalues{$item} =~ /^https?\:\/\/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/?$/) {
+ foreach my $field ('email','web') {
+ if ($env{'form.'.$item.'_'.$field}) {
+ $newvalues{$item.'_'.$field} = $env{'form.'.$item.'_'.$field};
+ }
+ }
+ } else {
push(@errors,$item);
}
}
}
if (grep(/^\Q$item\E$/,@errors)) {
$newvalues{$item} = $domdefaults{$item};
+ if ($item eq 'portal_def') {
+ if ($domdefaults{$item}) {
+ foreach my $field ('email','web') {
+ if (exists($domdefaults{$item.'_'.$field})) {
+ $newvalues{$item.'_'.$field} = $domdefaults{$item.'_'.$field};
+ }
+ }
+ }
+ }
} elsif ($domdefaults{$item} ne $newvalues{$item}) {
$changes{$item} = 1;
}
+ if ($item eq 'portal_def') {
+ unless (grep(/^\Q$item\E$/,@errors)) {
+ if ($newvalues{$item} eq '') {
+ foreach my $field ('email','web') {
+ if (exists($domdefaults{$item.'_'.$field})) {
+ delete($domdefaults{$item.'_'.$field});
+ }
+ }
+ } else {
+ unless ($changes{$item}) {
+ foreach my $field ('email','web') {
+ if ($domdefaults{$item.'_'.$field} ne $newvalues{$item.'_'.$field}) {
+ $changes{$item} = 1;
+ last;
+ }
+ }
+ }
+ foreach my $field ('email','web') {
+ if ($newvalues{$item.'_'.$field}) {
+ $domdefaults{$item.'_'.$field} = $newvalues{$item.'_'.$field};
+ } elsif (exists($domdefaults{$item.'_'.$field})) {
+ delete($domdefaults{$item.'_'.$field});
+ }
+ }
+ }
+ }
+ }
$domdefaults{$item} = $newvalues{$item};
}
my %staticdefaults = (
@@ -19972,6 +20097,41 @@ sub modify_defaults {
$newvalues{$item} = $staticdefaults{$item};
}
}
+ my ($unamemaprules,$ruleorder);
+ my @possunamemaprules = &Apache::loncommon::get_env_multiple('form.unamemap_rule');
+ if (@possunamemaprules) {
+ ($unamemaprules,$ruleorder) =
+ &Apache::lonnet::inst_userrules($dom,'unamemap');
+ if ((ref($unamemaprules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) {
+ if (@{$ruleorder} > 0) {
+ my %possrules;
+ map { $possrules{$_} = 1; } @possunamemaprules;
+ foreach my $rule (@{$ruleorder}) {
+ if ($possrules{$rule}) {
+ push(@{$newvalues{'unamemap_rule'}},$rule);
+ }
+ }
+ }
+ }
+ }
+ if (ref($domdefaults{'unamemap_rule'}) eq 'ARRAY') {
+ if (ref($newvalues{'unamemap_rule'}) eq 'ARRAY') {
+ my @rulediffs = &Apache::loncommon::compare_arrays($domdefaults{'unamemap_rule'},
+ $newvalues{'unamemap_rule'});
+ if (@rulediffs) {
+ $changes{'unamemap_rule'} = 1;
+ $domdefaults{'unamemap_rule'} = $newvalues{'unamemap_rule'};
+ }
+ } elsif (@{$domdefaults{'unamemap_rule'}} > 0) {
+ $changes{'unamemap_rule'} = 1;
+ delete($domdefaults{'unamemap_rule'});
+ }
+ } elsif (ref($newvalues{'unamemap_rule'}) eq 'ARRAY') {
+ if (@{$newvalues{'unamemap_rule'}} > 0) {
+ $changes{'unamemap_rule'} = 1;
+ $domdefaults{'unamemap_rule'} = $newvalues{'unamemap_rule'};
+ }
+ }
my %defaults_hash = (
defaults => \%newvalues,
);
@@ -20083,9 +20243,29 @@ sub modify_defaults {
$resulttext =~ s/, $//;
$resulttext .= '';
} else {
- $resulttext .= ''.&mt('Institutional user status types deleted').' ';
+ $resulttext .= ''.&mt('Institutional user status types deleted').' ';
}
}
+ } elsif ($item eq 'unamemap_rule') {
+ if (ref($newvalues{'unamemap_rule'}) eq 'ARRAY') {
+ my @rulenames;
+ if (ref($unamemaprules) eq 'HASH') {
+ foreach my $rule (@{$newvalues{'unamemap_rule'}}) {
+ if (ref($unamemaprules->{$rule}) eq 'HASH') {
+ push(@rulenames,$unamemaprules->{$rule}->{'name'});
+ }
+ }
+ }
+ if (@rulenames) {
+ $resulttext .= ''.&mt('Mapping for missing usernames includes: [_1]',
+ '').
+ ' ';
+ } else {
+ $resulttext .= ''.&mt('No mapping for missing usernames via standard log-in').' ';
+ }
+ } else {
+ $resulttext .= ''.&mt('Mapping for missing usernames via standard log-in deleted').' ';
+ }
} else {
my $value = $env{'form.'.$item};
if ($value eq '') {
@@ -20102,7 +20282,20 @@ sub modify_defaults {
$value = $authnames{$shortauth{$value}};
}
$resulttext .= ''.&mt('[_1] set to "[_2]"',$title->{$item},$value).' ';
- $mailmsgtext .= "$title->{$item} set to $value\n";
+ $mailmsgtext .= "$title->{$item} set to $value\n";
+ if ($item eq 'portal_def') {
+ if ($env{'form.'.$item} ne '') {
+ foreach my $field ('email','web') {
+ $value = $env{'form.'.$item.'_'.$field};
+ if ($value) {
+ $value = &mt('Yes');
+ } else {
+ $value = &mt('No');
+ }
+ $resulttext .= ''.&mt('[_1] set to "[_2]"',$title->{$field},$value).' ';
+ }
+ }
+ }
}
}
$resulttext .= ' ';
@@ -20157,12 +20350,15 @@ sub modify_scantron {
$error = &mt("Upload of bubblesheet format file is not permitted to this server: [_1]",$switchserver);
} else {
if ($author_ok eq 'ok') {
+ my $modified = [];
my ($result,$scantronurl) =
- &publishlogo($r,'upload','scantronformat',$dom,
- $confname,'scantron','','',$custom);
+ &Apache::lonconfigsettings::publishlogo($r,'upload','scantronformat',$dom,
+ $confname,'scantron','','',$custom,
+ $modified);
if ($result eq 'ok') {
$confhash{'scantron'}{'scantronformat'} = $scantronurl;
$changes{'scantronformat'} = 1;
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$custom,$result);
}
@@ -21082,20 +21278,30 @@ sub modify_coursedefaults {
my @toggles = ('canuse_pdfforms','uselcmath','usejsme','inline_chem','ltiauth');
my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial',
'uploadquota_community','uploadquota_textbook','uploadquota_placement',
- 'mysqltables_official','mysqltables_unofficial','mysqltables_community',
- 'mysqltables_textbook','mysqltables_placement');
+ 'coursequota_official','coursequota_unofficial','coursequota_community',
+ 'coursequota_textbook','coursequota_placement','mysqltables_official',
+ 'mysqltables_unofficial','mysqltables_community','mysqltables_textbook',
+ 'mysqltables_placement');
my @types = ('official','unofficial','community','textbook','placement');
my %staticdefaults = (
anonsurvey_threshold => 10,
uploadquota => 500,
+ coursequota => 20,
postsubmit => 60,
mysqltables => 172800,
+ domexttool => 1,
+ crsauthor => 1,
+ crseditors => ['edit','xml'],
);
my %texoptions = (
MathJax => 'MathJax',
mimetex => &mt('Convert to Images'),
tth => &mt('TeX to HTML'),
);
+
+ my @editors = ('edit','xml','daxe');
+ my %editornames = &crseditor_titles();
+
$defaultshash{'coursedefaults'} = {};
if (ref($domconfig{'coursedefaults'}) ne 'HASH') {
@@ -21134,7 +21340,7 @@ sub modify_coursedefaults {
}
$defaultshash{'coursedefaults'}{$item} = $newdef;
} else {
- my ($setting,$type) = ($item =~ /^(uploadquota|mysqltables)_(\w+)$/);
+ my ($setting,$type) = ($item =~ /^(uploadquota|coursequota|mysqltables)_(\w+)$/);
if (ref($domconfig{'coursedefaults'}{$setting}) eq 'HASH') {
$currdef = $domconfig{'coursedefaults'}{$setting}{$type};
}
@@ -21146,7 +21352,7 @@ sub modify_coursedefaults {
unless (($currdef eq '') && ($newdef == $staticdefaults{$item})) {
$changes{$item} = 1;
}
- } elsif ($item =~ /^(uploadquota|mysqltables)_/) {
+ } elsif ($item =~ /^(uploadquota|coursequota|mysqltables)_/) {
my $setting = $1;
unless (($currdef eq '') && ($newdef == $staticdefaults{$setting})) {
$changes{$setting} = 1;
@@ -21281,6 +21487,90 @@ sub modify_coursedefaults {
$changes{'postsubmit'} = 1;
}
}
+ my (%newdomexttool,%newexttool,%newcrsauthor,%olddomexttool,%oldexttool,%oldcrsauthor,
+ %posscrseditors);
+ map { $newdomexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.domexttool');
+ map { $newexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.exttool');
+ map { $newcrsauthor{$_} = 1; } &Apache::loncommon::get_env_multiple('form.crsauthor');
+ map { $posscrseditors{$_} = 1; } &Apache::loncommon::get_env_multiple('form.crseditors');
+ if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') {
+ %olddomexttool = %{$domconfig{'coursedefaults'}{'domexttool'}};
+ } else {
+ foreach my $type (@types) {
+ if ($staticdefaults{'domexttool'}) {
+ $olddomexttool{$type} = 1;
+ } else {
+ $olddomexttool{$type} = 0;
+ }
+ }
+ }
+ if (ref($domconfig{'coursedefaults'}{'exttool'}) eq 'HASH') {
+ %oldexttool = %{$domconfig{'coursedefaults'}{'exttool'}};
+ } else {
+ foreach my $type (@types) {
+ if ($staticdefaults{'exttool'}) {
+ $oldexttool{$type} = 1;
+ } else {
+ $oldexttool{$type} = 0;
+ }
+ }
+ }
+ if (ref($domconfig{'coursedefaults'}{'crsauthor'}) eq 'HASH') {
+ %oldcrsauthor = %{$domconfig{'coursedefaults'}{'crsauthor'}};
+ } else {
+ foreach my $type (@types) {
+ if ($staticdefaults{'crsauthor'}) {
+ $oldcrsauthor{$type} = 1;
+ } else {
+ $oldcrsauthor{$type} = 0;
+ }
+ }
+ }
+ my @newcrseditors = ();
+ foreach my $editor (@editors) {
+ if ($posscrseditors{$editor}) {
+ push(@newcrseditors,$editor);
+ }
+ }
+ if (ref($domconfig{'coursedefaults'}{'crseditors'}) eq 'ARRAY') {
+ my @diffs =
+ &Apache::loncommon::compare_arrays($domconfig{'coursedefaults'}{'crseditors'},
+ \@newcrseditors);
+ if (@diffs) {
+ $changes{'crseditors'} = 1;
+ }
+ } else {
+ my @diffs =
+ &Apache::loncommon::compare_arrays($staticdefaults{'crseditors'},
+ \@newcrseditors);
+ unless (@diffs == 0) {
+ $changes{'crseditors'} = 1;
+ }
+ }
+ foreach my $type (@types) {
+ unless ($newdomexttool{$type}) {
+ $newdomexttool{$type} = 0;
+ }
+ unless ($newexttool{$type}) {
+ $newexttool{$type} = 0;
+ }
+ unless ($newcrsauthor{$type}) {
+ $newcrsauthor{$type} = 0;
+ }
+ if ($newdomexttool{$type} != $olddomexttool{$type}) {
+ $changes{'domexttool'} = 1;
+ }
+ if ($newexttool{$type} != $oldexttool{$type}) {
+ $changes{'exttool'} = 1;
+ }
+ if ($newcrsauthor{$type} != $oldcrsauthor{$type}) {
+ $changes{'crsauthor'} = 1;
+ }
+ }
+ $defaultshash{'coursedefaults'}{'domexttool'} = \%newdomexttool;
+ $defaultshash{'coursedefaults'}{'exttool'} = \%newexttool;
+ $defaultshash{'coursedefaults'}{'crsauthor'} = \%newcrsauthor;
+ $defaultshash{'coursedefaults'}{'crseditors'} = \@newcrseditors;
}
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
$dom);
@@ -21290,8 +21580,10 @@ sub modify_coursedefaults {
if (($changes{'canuse_pdfforms'}) || ($changes{'uploadquota'}) || ($changes{'postsubmit'}) ||
($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) ||
($changes{'canclone'}) || ($changes{'mysqltables'}) || ($changes{'texengine'}) ||
- ($changes{'inline_chem'}) || ($changes{'ltiauth'})) {
- foreach my $item ('canuse_pdfforms','uselcmath','usejsme','inline_chem','texengine','ltiauth') {
+ ($changes{'inline_chem'}) || ($changes{'ltiauth'}) || ($changes{'domexttool'}) ||
+ ($changes{'exttool'}) || ($changes{'coursequota'}) || ($changes{'crsauthor'})) {
+ foreach my $item ('canuse_pdfforms','uselcmath','usejsme','inline_chem','texengine',
+ 'ltiauth') {
if ($changes{$item}) {
$domdefaults{$item}=$defaultshash{'coursedefaults'}{$item};
}
@@ -21322,6 +21614,13 @@ sub modify_coursedefaults {
}
}
}
+ if ($changes{'coursequota'}) {
+ if (ref($defaultshash{'coursedefaults'}{'coursequota'}) eq 'HASH') {
+ foreach my $type (@types) {
+ $domdefaults{$type.'coursequota'}=$defaultshash{'coursedefaults'}{'coursequota'}{$type};
+ }
+ }
+ }
if ($changes{'canclone'}) {
if (ref($defaultshash{'coursedefaults'}{'canclone'}) eq 'HASH') {
if (ref($defaultshash{'coursedefaults'}{'canclone'}{'instcode'}) eq 'ARRAY') {
@@ -21334,6 +21633,32 @@ sub modify_coursedefaults {
$domdefaults{'canclone'}=$defaultshash{'coursedefaults'}{'canclone'};
}
}
+ if ($changes{'domexttool'}) {
+ if (ref($defaultshash{'coursedefaults'}{'domexttool'}) eq 'HASH') {
+ foreach my $type (@types) {
+ $domdefaults{$type.'domexttool'}=$defaultshash{'coursedefaults'}{'domexttool'}{$type};
+ }
+ }
+ }
+ if ($changes{'exttool'}) {
+ if (ref($defaultshash{'coursedefaults'}{'exttool'}) eq 'HASH') {
+ foreach my $type (@types) {
+ $domdefaults{$type.'exttool'}=$defaultshash{'coursedefaults'}{'exttool'}{$type};
+ }
+ }
+ }
+ if ($changes{'crsauthor'}) {
+ if (ref($defaultshash{'coursedefaults'}{'crsauthor'}) eq 'HASH') {
+ foreach my $type (@types) {
+ $domdefaults{$type.'crsauthor'}=$defaultshash{'coursedefaults'}{'crsauthor'}{$type};
+ }
+ }
+ }
+ if ($changes{'crseditors'}) {
+ if (ref($defaultshash{'coursedefaults'}{'crseditors'}) eq 'ARRAY') {
+ $domdefaults{'crseditors'}=join(',',@{$defaultshash{'coursedefaults'}{'crseditors'}});
+ }
+ }
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
if (ref($lastactref) eq 'HASH') {
@@ -21386,6 +21711,19 @@ sub modify_coursedefaults {
} else {
$resulttext .= ''.&mt('Default quota for content uploaded via Course Editor remains default: [_1] MB',$staticdefaults{'uploadquota'}).' ';
}
+ } elsif ($item eq 'coursequota') {
+ if (ref($defaultshash{'coursedefaults'}{'coursequota'}) eq 'HASH') {
+ $resulttext .= ''.&mt('Default cumulative quota for all group portfolio spaces in course set as follows:').''.
+ ''.&mt('Official courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'coursequota'}{'official'}.' ').' '.
+ ''.&mt('Unofficial courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'coursequota'}{'unofficial'}.' ').' '.
+ ''.&mt('Textbook courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'coursequota'}{'textbook'}.' ').' '.
+ ''.&mt('Placement tests: [_1] MB',''.$defaultshash{'coursedefaults'}{'coursequota'}{'placement'}.' ').' '.
+ ''.&mt('Communities: [_1] MB',''.$defaultshash{'coursedefaults'}{'coursequota'}{'community'}.' ').' '.
+ ' '.
+ ' ';
+ } else {
+ $resulttext .= ''.&mt('Default cumulative quota for all group portfolio spaces in course remains default: [_1] MB',$staticdefaults{'coursequota'}).' ';
+ }
} elsif ($item eq 'mysqltables') {
if (ref($defaultshash{'coursedefaults'}{'mysqltables'}) eq 'HASH') {
$resulttext .= ''.&mt('Lifetime of "Temporary" MySQL tables (student performance data) on homeserver').''.
@@ -21471,6 +21809,45 @@ sub modify_coursedefaults {
} else {
$resulttext .= ''.&mt('LTI launch of deep-linked URL will require re-authentication').' ';
}
+ } elsif (($item eq 'domexttool') || ($item eq 'exttool') || ($item eq 'crsauthor')) {
+ my @noyes = (&mt('no'),&mt('yes'));
+ my %status = (
+ domexttool => {
+ ishash => &mt('External Tools defined in the domain may be used as follows:'),
+ default => &mt('External Tools defined in the domain may be used in all course types, by default'),
+ },
+ exttool => {
+ ishash => &mt('External Tools can be defined and configured in course containers as follows:'),
+ default => &mt('External Tools can not be defined in any course types, by default'),
+ },
+ crsauthor => {
+ ishash => &mt('Standard Problems can be created within course containers as follows:'),
+ default => &mt('Standard Problems can be created within any course type, by default'),
+ },
+ );
+
+ if (ref($defaultshash{'coursedefaults'}{$item}) eq 'HASH') {
+ $resulttext .= ''.$status{$item}{'ishash'}.''.
+ ''.&mt('Official courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{$item}{'official'}].' ').' '.
+ ''.&mt('Unofficial courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{$item}{'unofficial'}].' ').' '.
+ ''.&mt('Textbook courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{$item}{'textbook'}].' ').' '.
+ ''.&mt('Placement tests: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{$item}{'placement'}].' ').' '.
+ ''.&mt('Communities: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{$item}{'community'}].' ').' '.
+ ' '.
+ ' ';
+ } else {
+ $resulttext .= ''.$status{$item}{'default'}.' ';
+ }
+ } elsif ($item eq 'crseditors') {
+ if (ref($defaultshash{'coursedefaults'}{$item}) eq 'ARRAY') {
+ my $shown;
+ if (@{$defaultshash{'coursedefaults'}{$item}}) {
+ $shown = join(', ', map { $editornames{$_} } @{$defaultshash{'coursedefaults'}{$item}});
+ } else {
+ $shown = &mt('None');
+ }
+ $resulttext .= ''.&mt('Available editors for course/community resources: [_1]',$shown).' ';
+ }
}
}
$resulttext .= ' ';
@@ -21864,7 +22241,7 @@ sub modify_wafproxy {
}
} elsif ($currvalue{$item}) {
$changes{$item} = 1;
- }
+ }
}
} else {
if (keys(%curralias)) {
@@ -21872,7 +22249,7 @@ sub modify_wafproxy {
}
if (keys(%currsaml)) {
$changes{'saml'} = 1;
- }
+ }
if (keys(%currvalue)) {
foreach my $key (keys(%currvalue)) {
$changes{$key} = 1;
@@ -21882,7 +22259,7 @@ sub modify_wafproxy {
if (keys(%changes)) {
my %defaultshash = (
wafproxy => \%wafproxy,
- );
+ );
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
$dom);
if ($putresult eq 'ok') {
@@ -21898,7 +22275,7 @@ sub modify_wafproxy {
$domdefaults{'waf_'.$item} = $wafproxy{$item};
} elsif (exists($domdefaults{'waf_'.$item})) {
delete($domdefaults{'waf_'.$item});
- }
+ }
}
}
if ($updatedomdefs) {
@@ -21965,7 +22342,7 @@ sub modify_wafproxy {
$output .= ' '.&mt('Aliases deleted for hostnames').' ';
}
} elsif ($item eq 'saml') {
- my $shown;
+ my $shown;
if (ref($wafproxy{'saml'}) eq 'HASH') {
if (keys(%{$wafproxy{'saml'}})) {
$shown = join(', ',sort(keys(%{$wafproxy{'saml'}})));
@@ -22029,6 +22406,7 @@ sub modify_wafproxy {
}
}
}
+ $output .= '';
} else {
$output = ''.
&mt('An error occurred: [_1]',$putresult).' ';
@@ -22294,7 +22672,7 @@ sub modify_usersessions {
if (($offload eq 'offloadoth') && (@okoffloadoth)) {
$changes{'offloadoth'} = 1;
}
- }
+ }
}
} else {
if (@okoffload) {
@@ -22711,8 +23089,10 @@ sub modify_trust {
}
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ &Apache::lonnet::do_cache_new('trust',$dom,$defaultshash{'trust'},3600);
if (ref($lastactref) eq 'HASH') {
$lastactref->{'domdefaults'} = 1;
+ $lastactref->{'trust'} = 1;
}
if (keys(%changes) > 0) {
my %lt = &trust_titles();
@@ -22830,7 +23210,7 @@ sub modify_loadbalancing {
}
if ($env{'form.loadbalancing_cookie_'.$i}) {
$defaultshash{'loadbalancing'}{$balancer}{'cookie'} = 1;
- if (exists($currbalancer{$balancer})) {
+ if (exists($currbalancer{$balancer})) {
unless ($currcookies{$balancer}) {
$changes{'curr'}{$balancer}{'cookie'} = 1;
}
@@ -23516,7 +23896,6 @@ function balancerChange(balnum,baltotal,
END
}
-
sub new_spares_js {
my @sparestypes = ('primary','default');
my $types = join("','",@sparestypes);
@@ -23781,7 +24160,7 @@ sub devalidate_remote_domconfs {
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
my @posscached = ('domainconfig','domdefaults','ltitools','usersessions',
'directorysrch','passwdconf','cats','proxyalias','proxysaml',
- 'ipaccess');
+ 'ipaccess','trust');
my %cache_by_lonhost;
if (exists($cachekeys->{'samllanding'})) {
if (ref($cachekeys->{'samllanding'}) eq 'HASH') {