--- loncom/interface/domainprefs.pm 2023/01/23 19:36:25 1.160.6.118.2.13
+++ loncom/interface/domainprefs.pm 2024/03/03 02:21:32 1.160.6.118.2.21
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.118.2.13 2023/01/23 19:36:25 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.118.2.21 2024/03/03 02:21:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,7 +27,7 @@
#
#
###############################################################
-##############################################################
+###############################################################
=pod
@@ -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
@@ -104,8 +103,8 @@ $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, and textbook). In each case the radio buttons
-allow the selection of one of four values:
+(official, unofficial, community, textbook, and lti).
+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();
@@ -174,7 +174,9 @@ use File::Copy;
use Locale::Language;
use DateTime::TimeZone;
use DateTime::Locale;
+use Time::HiRes qw( sleep );
use Net::CIDR;
+use Crypt::CBC;
my $registered_cleanup;
my $modified_urls;
@@ -218,15 +220,50 @@ sub handler {
'serverstatuses','requestcourses','helpsettings',
'coursedefaults','usersessions','loadbalancing',
'requestauthor','selfenrollment','inststatus',
- 'passwords','ltitools','ltisec','wafproxy','ipaccess'],$dom);
+ 'passwords','ltitools','toolsec','lti','ltisec',
+ 'wafproxy','ipaccess','authordefaults'],$dom);
my %encconfig =
- &Apache::lonnet::get_dom('encconfig',['ltitools','linkprot'],$dom,undef,1);
+ &Apache::lonnet::get_dom('encconfig',['ltitools','lti','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') {
- foreach my $item ('key','secret') {
- $domconfig{'ltitools'}{$id}{$item} = $encconfig{'ltitools'}{$id}{$item};
+ if ((ref($domconfig{'ltitools'}{$id}) eq 'HASH') &&
+ (ref($encconfig{'ltitools'}{$id}) eq 'HASH')) {
+ $domconfig{'ltitools'}{$id}{'key'} = $encconfig{'ltitools'}{$id}{'key'};
+ if (($is_home) && ($phase eq 'process')) {
+ $domconfig{'ltitools'}{$id}{'secret'} = $encconfig{'ltitools'}{$id}{'secret'};
+ }
+ }
+ }
+ }
+ }
+ 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')) {
+ $domconfig{'lti'}{$id}{'key'} = $encconfig{'lti'}{$id}{'key'};
+ if (($is_home) && ($phase eq 'process')) {
+ $domconfig{'lti'}{$id}{'secret'} = $encconfig{'lti'}{$id}{'secret'};
}
}
}
@@ -254,7 +291,7 @@ sub handler {
'contacts','usercreation','selfcreation','usermodification',
'scantron','requestcourses','requestauthor','coursecategories',
'serverstatuses','helpsettings','coursedefaults',
- 'ltitools','selfenrollment','usersessions','lti');
+ 'authordefaults','ltitools','selfenrollment','usersessions','lti');
my %existing;
if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
%existing = %{$domconfig{'loadbalancing'}};
@@ -330,11 +367,11 @@ sub handler {
modify => \&modify_passwords,
},
'quotas' =>
- { text => 'Blogs, personal pages/timezones, webDAV/quotas, portfolio',
+ { text => 'Blogs, personal pages/timezones, portfolio/quotas',
help => 'Domain_Configuration_Quotas',
header => [{col1 => 'User affiliation',
col2 => 'Available tools',
- col3 => 'Quotas, MB; (Authoring requires role)',}],
+ col3 => 'Portfolio quota (MB)',}],
print => \&print_quotas,
modify => \&modify_quotas,
},
@@ -541,24 +578,32 @@ sub handler {
'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,
},
- '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',
col2 => 'Settings'},
+ {col1 => 'Link Protectors in Courses',
+ col2 => 'Values'},
{col1 => 'Link Protectors',
+ col2 => 'Settings'},
+ {col1 => 'Consumers',
col2 => 'Settings'},],
print => \&print_lti,
modify => \&modify_lti,
},
- 'ipaccess' =>
+ 'ipaccess' =>
{text => 'IP-based access control',
help => 'Domain_Configuration_IP_Access',
header => [{col1 => 'Setting',
@@ -566,6 +611,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',
@@ -753,16 +808,18 @@ sub process_changes {
$output = &modify_usersessions($dom,$lastactref,%domconfig);
} elsif ($action eq 'loadbalancing') {
$output = &modify_loadbalancing($dom,%domconfig);
+ } elsif ($action eq 'ltitools') {
+ $output = &modify_ltitools($r,$dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'lti') {
$output = &modify_lti($r,$dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'passwords') {
$output = &modify_passwords($r,$dom,$confname,$lastactref,%domconfig);
- } elsif ($action eq 'ltitools') {
- $output = &modify_ltitools($r,$dom,$action,$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;
}
@@ -794,9 +851,9 @@ sub print_config_box {
&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 'wafproxy') {
$output .= &wafproxy_javascript($dom);
@@ -808,6 +865,8 @@ sub print_config_box {
$output .= &saml_javascript();
} elsif ($action eq 'ipaccess') {
$output .= &ipaccess_javascript($settings);
+ } elsif ($action eq 'authordefaults') {
+ $output .= &authordefaults_javascript();
}
$output .=
'
@@ -824,7 +883,7 @@ sub print_config_box {
if ($numheaders > 1) {
my $colspan = '';
my $rightcolspan = '';
- my $leftnobr = '';
+ my $leftnobr = '';
if (($action eq 'rolecolors') || ($action eq 'defaults') ||
($action eq 'directorysrch') ||
(($action eq 'login') && ($numheaders < 5))) {
@@ -848,7 +907,8 @@ sub print_config_box {
if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'directorysrch') ||
- ($action eq 'helpsettings') || ($action eq 'contacts') || ($action eq 'wafproxy') || ($action eq 'lti')) {
+ ($action eq 'helpsettings') || ($action eq 'contacts') || ($action eq 'wafproxy') ||
+ ($action eq 'lti') || ($action eq 'ltitools') || ($action eq 'authordefaults')) {
$output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'passwords') {
$output .= $item->{'print'}->('top',$dom,$confname,$settings,\$rowtotal);
@@ -884,15 +944,33 @@ sub print_config_box {
($action eq 'selfcreation') || ($action eq 'selfenrollment') ||
($action eq 'usersessions') || ($action eq 'coursecategories') ||
($action eq 'contacts') || ($action eq 'passwords') ||
- ($action eq 'defaults') || ($action eq 'lti')) {
+ ($action eq 'defaults') || ($action eq 'lti') ||
+ ($action eq 'ltitools')) {
if ($action eq 'coursecategories') {
$output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal);
$colspan = ' colspan="2"';
} elsif ($action eq 'passwords') {
$output .= $item->{'print'}->('middle',$dom,$confname,$settings,\$rowtotal);
+ } elsif ($action eq 'lti') {
+ $output .= $item->{'print'}->('upper',$dom,$settings,\$rowtotal).'
+
+
+
+
+
+
+
+ '.&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);
}
+ my $hdridx = 2;
+ if ($action eq 'lti') {
+ $hdridx = 3;
+ }
$output .= '
@@ -901,8 +979,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);
@@ -912,6 +990,7 @@ sub print_config_box {
} else {
$output .= $item->{'print'}->('lower',$dom,$settings,\$rowtotal);
}
+ $hdridx ++;
$output .= '
@@ -921,8 +1000,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 {
@@ -939,7 +1018,7 @@ sub print_config_box {
$rowtotal ++;
} elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
($action eq 'directorysrch') || ($action eq 'helpsettings') ||
- ($action eq 'wafproxy')) {
+ ($action eq 'wafproxy') || ($action eq 'authordefaults')) {
$output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= $item->{'print'}->($r,'bottom',$dom,$confname,$settings,\$rowtotal);
@@ -1120,7 +1199,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 'ipaccess')) {
+ ($action eq 'ipaccess')) {
$output .= $item->{'print'}->($dom,$settings,\$rowtotal);
}
}
@@ -1140,7 +1219,6 @@ sub print_login {
%lt = &login_file_options();
$switchserver = &check_switchserver($dom,$confname);
}
-
if ($caller eq 'service') {
my %servers = &Apache::lonnet::internet_dom_servers($dom);
my $choice = $choices{'disallowlogin'};
@@ -2212,12 +2290,12 @@ 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);
if ($context eq 'requestcourses') {
- @usertools = ('official','unofficial','community','textbook');
+ @usertools = ('official','unofficial','community','textbook','lti');
@options =('norequest','approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($dom);
%titles = &courserequest_titles();
@@ -2226,12 +2304,12 @@ sub print_quotas {
@options = ('norequest','approval','automatic');
%titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','webdav','portfolio','timezone');
+ @usertools = ('aboutme','blog','portfolio','timezone');
%titles = &tool_titles();
}
if (ref($types) eq 'ARRAY') {
foreach my $type (@{$types}) {
- my ($currdefquota,$currauthorquota);
+ my $currdefquota;
unless (($context eq 'requestcourses') ||
($context eq 'requestauthor')) {
if (ref($settings) eq 'HASH') {
@@ -2240,9 +2318,6 @@ sub print_quotas {
} else {
$currdefquota = $settings->{$type};
}
- if (ref($settings->{authorquota}) eq 'HASH') {
- $currauthorquota = $settings->{authorquota}->{$type};
- }
}
}
if (defined($usertypes->{$type})) {
@@ -2360,13 +2435,9 @@ sub print_quotas {
($context eq 'requestauthor')) {
$datatable .=
''.
- ''.&mt('Portfolio').': '.
+ ''.
' '.(' ' x 2).
- ''.&mt('Authoring').': '.
- ' ';
}
$datatable .= '';
@@ -2375,16 +2446,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 ++;
@@ -2496,12 +2563,9 @@ sub print_quotas {
$datatable .= '';
unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
$datatable .= ''.
- ''.&mt('Portfolio').': '.
+ ''.
' '.(' ' x2).
- ''.&mt('Authoring').': '.
- ' ';
+ $defaultquota.'" size="5" />';
}
$datatable .= '';
$typecount ++;
@@ -2684,7 +2748,7 @@ sub print_studentcode {
my ($settings,$rowtotal) = @_;
my $rownum = 0;
my ($output,%current);
- my @crstypes = ('official','unofficial','community','textbook');
+ my @crstypes = ('official','unofficial','community','textbook','lti');
if (ref($settings) eq 'HASH') {
if (ref($settings->{'uniquecode'}) eq 'HASH') {
foreach my $type (@crstypes) {
@@ -3015,6 +3079,30 @@ sub ltitools_toggle_js {
function toggleLTITools(form,setting,item) {
var radioname = '';
var divid = '';
+ if ((setting == 'passback') || (setting == 'roster')) {
+ radioname = 'ltitools_'+setting+'_'+item;
+ divid = 'ltitools_'+setting+'time_'+item;
+ var num = form.elements[radioname].length;
+ if (num) {
+ var setvis = '';
+ for (var i=0; i
+//
+
+';
+ }
+ my (%ordered,$total,%jstext);
+ $total = scalar(keys(%{$settings}));
+ foreach my $item (keys(%{$settings})) {
+ if (ref($settings->{$item}) eq 'HASH') {
+ my $num = $settings->{$item}{'order'};
+ if ($num eq '') {
+ $num = $total - 1;
+ }
+ $ordered{$num} = $item;
+ }
+ }
+ my @jsarray = ();
+ foreach my $item (sort {$a <=> $b } (keys(%ordered))) {
+ push(@jsarray,$ordered{$item});
+ }
+ my $jstext = ' var lti = Array('."'".join("','",@jsarray)."'".');'."\n";
return <<"ENDSCRIPT";
+
+ENDSCRIPT
+}
+
sub print_autoenroll {
my ($dom,$settings,$rowtotal) = @_;
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
@@ -3595,8 +3888,8 @@ sub print_autoupdate {
$updateoff = ' ';
}
}
- $enable = ''.
- ''.&mt($choices{'run'}).' '.
+ $enable = ' '.
+ ''.$choices{'run'}.' '.
''.
' '.&mt('No').' '.
@@ -4230,7 +4523,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);
@@ -4447,7 +4739,6 @@ sub print_helpsettings {
push(@jsarray,('notinc','notexc'));
}
my $hiddenstr = join("','",@jsarray);
- $datatable .= &helpsettings_javascript(\@roles_by_num,$maxnum,$hiddenstr,$formname);
my $context = 'domprefs';
my $crstype = 'Course';
my $prefix = 'helproles_';
@@ -4818,10 +5109,10 @@ sub radiobutton_prefs {
$checkedon{$item}.' value="1"'.$onclick.' />'.&mt('Yes').'';
} else {
$datatable .=
- ' '.&mt('Yes').
- ' '.&mt('No').' ';
+ ' '.&mt('Yes').
+ ' '.&mt('No').' ';
}
$datatable .= ' '.$additional.' ';
$itemcount ++;
@@ -4830,373 +5121,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'}.' '.
- '
'.
- '
';
- $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}.' '.(' ' x2)."\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'}.' '.
- ''.
- '
'.
- '
';
- $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;
}
@@ -5224,6 +5192,8 @@ sub ltitools_names {
'width' => 'Width',
'linktext' => 'Default Link Text',
'explanation' => 'Default Explanation',
+ 'passback' => 'Tool can return grades:',
+ 'roster' => 'Tool can retrieve roster:',
'crstarget' => 'Display target',
'crslabel' => 'Course label',
'crstitle' => 'Course title',
@@ -5231,21 +5201,141 @@ sub ltitools_names {
'crsexplanation' => 'Explanation',
'crsappend' => 'Provider URL',
);
-
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_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'})) {
if (ref($settings->{'encrypt'}) eq 'HASH') {
foreach my $key (keys(%{$settings->{'encrypt'}})) {
- $encrypt{'ltisec_'.$key.'linkprot'} = $settings->{'encrypt'}{$key};
+ if ($key eq 'consumers') {
+ $encrypt{'ltisec_'.$key} = $settings->{'encrypt'}{$key};
+ } else {
+ $encrypt{'ltisec_'.$key.'linkprot'} = $settings->{'encrypt'}{$key};
+ }
}
}
}
@@ -5258,13 +5348,19 @@ 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 'bottom') {
+ } 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') {
%linkprot = %{$settings->{'linkprot'}};
@@ -5273,105 +5369,658 @@ sub print_lti {
}
}
}
+ } else {
+ foreach my $key ('encrypt','private','rules','linkprot','suggestions') {
+ if (exists($settings->{$key})) {
+ delete($settings->{$key});
+ }
+ }
}
}
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_domlinkprot'}) {
- $showextra = 1;
+ $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 = &linkprot_suggestions(\%suggestions,\$itemcount);
+ $$rowtotal += $itemcount;
+ } elsif ($position eq 'lower') {
+ $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') {
+ foreach my $item (keys(%{$settings})) {
+ if (ref($settings->{$item}) eq 'HASH') {
+ my $num = $settings->{$item}{'order'};
+ if ($num eq '') {
+ $num = scalar(keys(%{$settings}));
+ }
+ $ordered{$num} = $item;
}
}
- if ($encrypt{'ltisec_crslinkprot'}) {
- $showextra = 1;
+ }
+ $maxnum = scalar(keys(%ordered));
+ my %lt = <i_names();
+ 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 ($key,$secret,$usable,$lifetime,$consumer,$requser,$crsinc,$current);
+ if (ref($settings->{$item}) eq 'HASH') {
+ $key = $settings->{$item}->{'key'};
+ $usable = $settings->{$item}->{'usable'};
+ $lifetime = $settings->{$item}->{'lifetime'};
+ $consumer = $settings->{$item}->{'consumer'};
+ $requser = $settings->{$item}->{'requser'};
+ $crsinc = $settings->{$item}->{'crsinc'};
+ $current = $settings->{$item};
+ }
+ my $onclickrequser = ' onclick="toggleLTI(this.form,'."'requser','$i'".');"';
+ my %checkedrequser = (
+ yes => ' checked="checked"',
+ no => '',
+ );
+ if (!$requser) {
+ $checkedrequser{'no'} = $checkedrequser{'yes'};
+ $checkedrequser{'yes'} = '';
+ }
+ my $onclickcrsinc = ' onclick="toggleLTI(this.form,'."'crsinc','$i'".');"';
+ my %checkedcrsinc = (
+ yes => ' checked="checked"',
+ no => '',
+ );
+ if (!$crsinc) {
+ $checkedcrsinc{'no'} = $checkedcrsinc{'yes'};
+ $checkedcrsinc{'yes'} = '';
+ }
+ my $chgstr = ' onchange="javascript:reorderLTI(this.form,'."'lti_pos_".$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{'consumer'}.
+ ': '.
+ (' 'x2).
+ ''.$lt{'version'}.':'.
+ '1.1 '.
+ (' 'x2).
+ ''.$lt{'lifetime'}.': ';
+ 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".
+ ' '.
+ ''.$lt{'crsinc'}.':'.
+ ' '.&mt('Yes').' '."\n".
+ ' '.&mt('No').' '."\n".
+ (' 'x4).
+ ' '.
+ ' '.<i_options($i,$current,$itemcount,%lt).' ';
+ $itemcount ++;
}
- unless (grep(/^\Q$hostid\E$/,@ids)) {
- $switch = 1;
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderLTI(this.form,'."'lti_pos_add'".');"';
+ $datatable .= ''."\n".
+ ' '."\n".
+ '';
+ for (my $k=0; $k<$maxnum+1; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $maxnum) {
+ $selstr = ' selected="selected" ';
}
- if ($showextra) {
- $numshown ++;
- $divsty = 'display:inline-block';
+ $datatable .= ''.$vpos.' ';
+ }
+ $datatable .= ' '."\n".
+ ' '.&mt('Add').' '."\n".
+ ''.
+ ''.&mt('Required settings').' '.
+ ''.$lt{'consumer'}.
+ ': '."\n".
+ (' 'x2).
+ ''.$lt{'version'}.':'.
+ '1.1 '."\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".
+ ' '.
+ ''.$lt{'crsinc'}.':'.
+ ' '.&mt('Yes').' '."\n".
+ ' '.&mt('No').' '."\n".
+ ' '.<i_options('add',undef,$itemcount,%lt).
+ ' '."\n".
+ ' '."\n";
+ $itemcount ++;
+ }
+ $$rowtotal += $itemcount;
+ return $datatable;
+}
+
+sub lti_names {
+ my %lt = &Apache::lonlocal::texthash(
+ 'version' => 'LTI Version',
+ 'url' => 'URL',
+ 'key' => 'Key',
+ 'lifetime' => 'Nonce lifetime (s)',
+ 'consumer' => 'Consumer',
+ 'secret' => 'Secret',
+ 'requser' => "User's identity sent",
+ 'crsinc' => "Course's identity sent",
+ 'email' => 'Email address',
+ 'sourcedid' => 'User ID',
+ 'other' => 'Other',
+ 'passback' => 'Can return grades to Consumer:',
+ 'roster' => 'Can retrieve roster from Consumer:',
+ 'topmenu' => 'Display LON-CAPA page header',
+ 'inlinemenu'=> 'Display LON-CAPA inline menu',
+ );
+ return %lt;
+}
+
+sub lti_options {
+ my ($num,$current,$itemcount,%lt) = @_;
+ my (%checked,%rolemaps,$crssecsrc,$userfield,$cidfield,$callback);
+ $checked{'mapuser'}{'sourcedid'} = ' checked="checked"';
+ $checked{'mapcrs'}{'course_offering_sourcedid'} = ' checked="checked"';
+ $checked{'storecrs'}{'Y'} = ' checked="checked"';
+ $checked{'makecrs'}{'N'} = ' checked="checked"';
+ $checked{'mapcrstype'} = {};
+ $checked{'makeuser'} = {};
+ $checked{'selfenroll'} = {};
+ $checked{'crssec'} = {};
+ $checked{'crssecsrc'} = {};
+ $checked{'lcauth'} = {};
+ $checked{'menuitem'} = {};
+ if ($num eq 'add') {
+ $checked{'lcauth'}{'lti'} = ' checked="checked"';
+ }
+ my $userfieldsty = 'none';
+ my $crsfieldsty = 'none';
+ my $crssecfieldsty = 'none';
+ my $secsrcfieldsty = 'none';
+ my $callbacksty = 'none';
+ my $passbacksty = 'none';
+ my $optionsty = 'block';
+ my $crssty = 'block';
+ my $lcauthparm;
+ my $lcauthparmstyle = 'display:none';
+ my $lcauthparmtext;
+ my $menusty;
+ my $numinrow = 4;
+ my %menutitles = <imenu_titles();
+
+ if (ref($current) eq 'HASH') {
+ if (!$current->{'requser'}) {
+ $optionsty = 'none';
+ $crssty = 'none';
+ } elsif (!$current->{'crsinc'}) {
+ $crssty = 'none';
+ }
+ 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"';
} else {
- $divsty = 'display:none';
+ $checked{'mapuser'}{'other'} = ' checked="checked"';
+ $userfield = $current->{'mapuser'};
+ $userfieldsty = 'inline-block';
}
- $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).
- ' ';
+ }
+ 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"';
+ } else {
+ $checked{'mapcrs'}{'other'} = ' checked="checked"';
+ $cidfield = $current->{'mapcrs'};
+ $crsfieldsty = 'inline-block';
+ }
+ }
+ if (ref($current->{'mapcrstype'}) eq 'ARRAY') {
+ foreach my $type (@{$current->{'mapcrstype'}}) {
+ $checked{'mapcrstype'}{$type} = ' checked="checked"';
+ }
+ }
+ if (!$current->{'storecrs'}) {
+ $checked{'storecrs'}{'N'} = $checked{'storecrs'}{'Y'};
+ $checked{'storecrs'}{'Y'} = '';
+ }
+ if ($current->{'makecrs'}) {
+ $checked{'makecrs'}{'Y'} = ' checked="checked"';
+ }
+ if (ref($current->{'makeuser'}) eq 'ARRAY') {
+ foreach my $role (@{$current->{'makeuser'}}) {
+ $checked{'makeuser'}{$role} = ' checked="checked"';
+ }
+ }
+ if ($current->{'lcauth'} =~ /^(internal|localauth|krb4|krb5|lti)$/) {
+ $checked{'lcauth'}{$1} = ' checked="checked"';
+ unless (($current->{'lcauth'} eq 'lti') || ($current->{'lcauth'} eq 'internal')) {
+ $lcauthparm = $current->{'lcauthparm'};
+ $lcauthparmstyle = 'display:table-row';
+ if ($current->{'lcauth'} eq 'localauth') {
+ $lcauthparmtext = &mt('Local auth argument');
} else {
- $extra .= ''.
- &mt('Key required').' - '.&mt('submit from server ([_1]): [_2].',$hostid,$switchserver).
- ' '."\n";
+ $lcauthparmtext = &mt('Kerberos domain');
}
- } 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').' '.
- ' ';
+ }
+ }
+ if (ref($current->{'selfenroll'}) eq 'ARRAY') {
+ foreach my $role (@{$current->{'selfenroll'}}) {
+ $checked{'selfenroll'}{$role} = ' checked="checked"';
+ }
+ }
+ if (ref($current->{'maproles'}) eq 'HASH') {
+ %rolemaps = %{$current->{'maproles'}};
+ }
+ if ($current->{'section'} ne '') {
+ $checked{'crssec'}{'Y'} = ' checked="checked"';
+ $crssecfieldsty = 'inline-block';
+ if ($current->{'section'} eq 'course_section_sourcedid') {
+ $checked{'crssecsrc'}{'sourcedid'} = ' checked="checked"';
} else {
- $extra .= ''.&mt('Encryption Key').':'.
- ' '.
- ' '.&mt('Visible input').' ';
+ $checked{'crssecsrc'}{'other'} = ' checked="checked"';
+ $crssecsrc = $current->{'section'};
+ $secsrcfieldsty = 'inline-block';
}
- $extra .= ' ';
+ } else {
+ $checked{'crssec'}{'N'} = ' checked="checked"';
}
- 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',
- );
- my @toggles = qw(ltisec_crslinkprot ltisec_domlinkprot);
- my %defaultchecked = (
- 'ltisec_crslinkprot' => 'off',
- 'ltisec_domlinkprot' => 'off',
- );
- my ($onclick,$itemcount);
- $onclick = 'javascript:toggleLTIEncKey(this.form);';
- ($datatable,$itemcount) = &radiobutton_prefs(\%encrypt,\@toggles,\%defaultchecked,
- \%choices,$itemcount,$onclick,'','left','no');
+ if ($current->{'callback'} ne '') {
+ $callback = $current->{'callback'};
+ $checked{'callback'}{'Y'} = ' checked="checked"';
+ $callbacksty = 'inline-block';
+ } else {
+ $checked{'callback'}{'N'} = ' checked="checked"';
+ }
+ if ($current->{'topmenu'}) {
+ $checked{'topmenu'}{'Y'} = ' checked="checked"';
+ } else {
+ $checked{'topmenu'}{'N'} = ' checked="checked"';
+ }
+ if ($current->{'inlinemenu'}) {
+ $checked{'inlinemenu'}{'Y'} = ' checked="checked"';
+ } else {
+ $checked{'inlinemenu'}{'N'} = ' checked="checked"';
+ }
+ if (($current->{'topmenu'}) || ($current->{'inlinemenu'})) {
+ $menusty = 'inline-block';
+ if (ref($current->{'lcmenu'}) eq 'ARRAY') {
+ foreach my $item (@{$current->{'lcmenu'}}) {
+ if (exists($menutitles{$item})) {
+ $checked{'menuitem'}{$item} = ' checked="checked"';
+ }
+ }
+ }
+ } else {
+ $menusty = 'none';
+ }
+ } else {
+ $checked{'makecrs'}{'N'} = ' checked="checked"';
+ $checked{'crssec'}{'N'} = ' checked="checked"';
+ $checked{'callback'}{'N'} = ' checked="checked"';
+ $checked{'topmenu'}{'N'} = ' checked="checked"';
+ $checked{'inlinemenu'}{'Y'} = ' checked="checked"';
+ $checked{'menuitem'}{'grades'} = ' checked="checked"';
+ $menusty = 'inline-block';
+ }
+ my @coursetypes = ('official','unofficial','community','textbook','lti');
+ my %coursetypetitles = &Apache::lonlocal::texthash (
+ official => 'Official',
+ unofficial => 'Unofficial',
+ community => 'Community',
+ textbook => 'Textbook',
+ lti => 'LTI Provider',
+ );
+ my @authtypes = ('internal','krb4','krb5','localauth');
+ my %shortauth = (
+ internal => 'int',
+ krb4 => 'krb4',
+ krb5 => 'krb5',
+ localauth => 'loc'
+ );
+ my %authnames = &authtype_names();
+ my @ltiroles = qw(Learner Instructor ContentDeveloper TeachingAssistant Mentor Member Manager Administrator);
+ my @lticourseroles = qw(Learner Instructor TeachingAssistant Mentor);
+ my @courseroles = ('cc','in','ta','ep','st');
+ my $onclickuser = ' onclick="toggleLTI(this.form,'."'user','$num'".');"';
+ my $onclickcrs = ' onclick="toggleLTI(this.form,'."'crs','$num'".');"';
+ my $onclicksec = ' onclick="toggleLTI(this.form,'."'sec','$num'".');"';
+ my $onclickcallback = ' onclick="toggleLTI(this.form,'."'callback','$num'".');"';
+ my $onclicksecsrc = ' onclick="toggleLTI(this.form,'."'secsrc','$num'".')"';
+ my $onclicklcauth = ' onclick="toggleLTI(this.form,'."'lcauth','$num'".')"';
+ my $onclickmenu = ' onclick="toggleLTI(this.form,'."'lcmenu','$num'".');"';
+ my $output = ''.&mt('Logout options').' '.
+ ''.&mt('Callback to logout LON-CAPA on log out from Consumer').': '.
+ ' '.&mt('No').' '.(' 'x2).
+ ' '.&mt('Yes').'
'.
+ ''.
+ ''.&mt('Parameter').': '.
+ ' '.
+ '
'.
+ ''.&mt('Mapping users').' '.
+ ''.&mt('LON-CAPA username').': ';
+ foreach my $option ('sourcedid','email','other') {
+ $output .= ' '.$lt{$option}.' '.
+ ($option eq 'other' ? '' : (' 'x2) );
+ }
+ $output .= '
'.
+ ''.
+ '
'.
+ ''.&mt('Roles which may create user accounts').' ';
+ foreach my $ltirole (@ltiroles) {
+ $output .= ' '.$ltirole.' ';
+ }
+ $output .= ' '.
+ ''.&mt('New user accounts created for LTI users').' '.
+ ''.
+ &modifiable_userdata_row('lti','instdata_'.$num,$current,$numinrow,$itemcount).
+ '
'.
+ ' '.
+ ''.
+ &mt('LON-CAPA menu items (Course Coordinator can override)').' '.
+ ''.$lt{'topmenu'}.': '.
+ ' '.&mt('No').' '.(' 'x2).
+ ' '.&mt('Yes').'
'.
+ '
'.
+ ''.$lt{'inlinemenu'}.': '.
+ ' '.&mt('No').' '.(' 'x2).
+ ' '.&mt('Yes').'
';
+ $output .='
'.
+ ' '.
+ ''.&mt('Mapping courses').' '.
+ ''.
+ &mt('Unique course identifier').': ';
+ foreach my $option ('course_offering_sourcedid','context_id','other') {
+ $output .= ' '.$option.' '.
+ ($option eq 'other' ? '' : (' 'x2) );
+ }
+ $output .= '
'.
+ ' '.
+ '
'.
+ ''.&mt('LON-CAPA course type(s)').': ';
+ foreach my $type (@coursetypes) {
+ $output .= ' '.$coursetypetitles{$type}.' '.
+ (' 'x2);
+ }
+ $output .= ' '.
+ ''.&mt('Store mapping of course identifier to LON-CAPA CourseID').': '.
+ ' '.&mt('No').' '.(' 'x2).
+ ' '.&mt('Yes').' '.
+ ' '.
+ ''.&mt('Mapping course roles').' ';
+ foreach my $ltirole (@lticourseroles) {
+ my ($selected,$selectnone);
+ if ($rolemaps{$ltirole} eq '') {
+ $selectnone = ' selected="selected"';
+ }
+ $output .= ''.$ltirole.' '.
+ ''.
+ ''.&mt('Select').' ';
+ foreach my $role (@courseroles) {
+ unless ($selectnone) {
+ if ($rolemaps{$ltirole} eq $role) {
+ $selected = ' selected="selected"';
+ } else {
+ $selected = '';
+ }
+ }
+ $output .= ''.
+ &Apache::lonnet::plaintext($role,'Course').
+ ' ';
+ }
+ $output .= ' ';
+ }
+ $output .= '
'.
+ ''.&mt('Creating courses').' '.
+ ''.&mt('Course created (if absent) on Instructor access').': '.
+ ' '.&mt('No').' '.(' 'x2).
+ ' '.&mt('Yes').' '.
+ ' '.
+ ''.&mt('Roles which may self-enroll').' ';
+ foreach my $lticrsrole (@lticourseroles) {
+ $output .= ' '.$lticrsrole.' ';
+ }
+ $output .= ' '.
+ ''.&mt('Course options').' '.
+ ''.&mt('Assign users to sections').': '.
+ ' '.&mt('No').' '.(' 'x2).
+ ' '.&mt('Yes').'
'.
+ ''.
+ ' '.
+ '
';
+ my ($pb1p1chk,$pb1p0chk,$onclickpb);
+ foreach my $extra ('roster','passback') {
+ my $checkedon = '';
+ my $checkedoff = ' checked="checked"';
+ if ($extra eq 'passback') {
+ $pb1p1chk = ' checked="checked"';
+ $pb1p0chk = '';
+ $onclickpb = ' onclick="toggleLTI(this.form,'."'passback','$num'".');"';
+ } else {
+ $onclickpb = '';
+ }
+ if (ref($current) eq 'HASH') {
+ if (($current->{$extra})) {
+ $checkedon = $checkedoff;
+ $checkedoff = '';
+ if ($extra eq 'passback') {
+ $passbacksty = 'inline-block';
+ }
+ if ($current->{'passbackformat'} eq '1.0') {
+ $pb1p0chk = ' checked="checked"';
+ $pb1p1chk = '';
+ }
+ }
+ }
+ $output .= $lt{$extra}.' '.
+ ' '.
+ &mt('No').' '.(' 'x2).
+ ' '.
+ &mt('Yes').' ';
+ }
+ $output .= ''.
+ ''.&mt('Grade format').
+ ' '.
+ &mt('Outcomes Service (1.1)').' '.(' 'x2).
+ ' '.
+ &mt('Outcomes Extension (1.0)').'
'.
+ '
';
+ $output .= '';
+# ''.&mt('Assigning author roles').' ';
+#
+# $output .= ' '.
+# ''.&mt('Assigning domain roles').' ';
+ return $output;
+}
- $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 ++;
- $$rowtotal += $itemcount;
- } elsif ($position eq 'middle') {
- $datatable = &password_rules('secrets',\$itemcount,\%rules);
- $$rowtotal += $itemcount;
- } elsif ($position eq 'bottom') {
- $datatable .= &Apache::courseprefs::print_linkprotection($dom,'',$settings,$rowtotal,'','','domain');
+sub ltimenu_titles {
+ return &Apache::lonlocal::texthash(
+ fullname => 'Full name',
+ coursetitle => 'Course title',
+ role => 'Role',
+ logout => 'Logout',
+ grades => 'Grades',
+ );
+}
+
+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".
+ ''.
+ ' '.
+ '
'."\n".
+ ' '."\n";
+ $$itemcount ++;
+ }
}
+ $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;
}
@@ -5381,6 +6030,7 @@ sub print_coursedefaults {
my $itemcount = 1;
my %choices = &Apache::lonlocal::texthash (
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)',
@@ -5391,12 +6041,17 @@ 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)',
);
my %staticdefaults = (
anonsurvey_threshold => 10,
uploadquota => 500,
+ coursequota => 20,
postsubmit => 60,
mysqltables => 172800,
+ domexttool => 1,
+ exttool => 0,
);
if ($position eq 'top') {
%defaultchecked = (
@@ -5482,7 +6137,7 @@ sub print_coursedefaults {
if ($checked) {
$show = 'block';
}
- $additional = '
'.
+ $additional = '
'.
&mt('Institutional codes for new and cloned course have identical:').
' ';
foreach my $item (@code_order) {
@@ -5509,21 +6164,49 @@ 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 @types = ('official','unofficial','community','textbook');
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"';
+ }
+ }
+ }
$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');
@@ -5569,6 +6252,9 @@ sub print_coursedefaults {
} else {
foreach my $type (@types) {
$deftimeout{$type} = $staticdefaults{'postsubmit'};
+ if ($staticdefaults{'domexttool'}) {
+ $domexttool{$type} = ' checked="checked"';
+ }
}
}
if (!$currdefresponder) {
@@ -5580,6 +6266,9 @@ sub print_coursedefaults {
if ($curruploadquota{$type} eq '') {
$curruploadquota{$type} = $staticdefaults{'uploadquota'};
}
+ if ($currcoursequota{$type} eq '') {
+ $currcoursequota{$type} = $staticdefaults{'coursequota'};
+ }
}
$datatable .=
''.
@@ -5603,6 +6292,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) {
@@ -5672,12 +6374,250 @@ 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";
+ }
+ $$rowtotal += $itemcount;
+ return $datatable;
+}
+
+sub print_authordefaults {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable,%checkedon,%checkedoff);
+ my $itemcount = 1;
+ my %titles = &authordefaults_titles();
+ if ($position eq 'top') {
+ my %defaultchecked = (
+ 'nocodemirror' => 'off',
+ '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 ++;
}
$$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',
+ );
+}
+
+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);
@@ -6258,7 +7198,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',
@@ -6429,8 +7369,9 @@ 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);
@@ -6694,12 +7635,14 @@ sub print_usersessions {
$other_insts,$curroffloadnow,$curroffloadoth,$rowtotal);
} else {
$datatable .= ' '.
- &mt('Nothing to set here, as the cluster to which this domain belongs only contains one server.');
+ &mt('Nothing to set here, as the cluster to which this domain belongs only contains one server.').
+ ' ';
}
} else {
if (keys(%by_location) == 0) {
$datatable .= ''.
- &mt('Nothing to set here, as the cluster to which this domain belongs only contains one institution.');
+ &mt('Nothing to set here, as the cluster to which this domain belongs only contains one institution.').
+ ' ';
} else {
my %lt = &usersession_titles();
my $numinrow = 5;
@@ -7415,7 +8358,7 @@ sub loadbalance_rule_row {
}
my $space;
if ($islast && $num == 1) {
- $space = '
';
+ $space = '
';
}
my $output =
''.$space.
@@ -7552,7 +8495,6 @@ sub tool_titles {
my %titles = &Apache::lonlocal::texthash (
aboutme => 'Personal web page',
blog => 'Blog',
- webdav => 'WebDAV',
portfolio => 'Portfolio',
timezone => 'Can set time zone',
official => 'Official courses (with institutional codes)',
@@ -7569,6 +8511,7 @@ sub courserequest_titles {
unofficial => 'Unofficial',
community => 'Communities',
textbook => 'Textbook',
+ lti => 'LTI Provider',
norequest => 'Not allowed',
approval => 'Approval by Dom. Coord.',
validate => 'With validation',
@@ -7682,7 +8625,7 @@ sub print_usercreation {
}
} else {
my @contexts = ('author','course','domain');
- my @authtypes = ('int','krb4','krb5','loc');
+ my @authtypes = ('int','krb4','krb5','loc','lti');
my %checked;
if (ref($settings) eq 'HASH') {
if (ref($settings->{'authtypes'}) eq 'HASH') {
@@ -8244,7 +9187,7 @@ sub noninst_users {
sub captcha_choice {
my ($context,$settings,$itemcount,$customcss,$rowstyle) = @_;
my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext,
- $vertext,$currver);
+ $vertext,$currver);
my %lt = &captcha_phrases();
$keyentry = 'hidden';
my $colspan=2;
@@ -8426,6 +9369,7 @@ sub authtype_names {
krb4 => 'Kerberos 4',
krb5 => 'Kerberos 5',
loc => 'Local',
+ lti => 'LTI',
);
return %lt;
}
@@ -8494,12 +9438,13 @@ sub print_defaults {
' '.$titles->{$item}.
' ';
if ($item eq 'auth_def') {
- my @authtypes = ('internal','krb4','krb5','localauth');
+ my @authtypes = ('internal','krb4','krb5','localauth','lti');
my %shortauth = (
internal => 'int',
krb4 => 'krb4',
krb5 => 'krb5',
- localauth => 'loc'
+ localauth => 'loc',
+ lti => 'lti',
);
my %authnames = &authtype_names();
foreach my $auth (@authtypes) {
@@ -8872,10 +9817,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);
}
}
@@ -9408,6 +10356,7 @@ $portal_js
ENDSCRIPT
}
+ return;
}
sub passwords_javascript {
@@ -9421,7 +10370,7 @@ sub passwords_javascript {
passmax => 'Warning: maximum password length 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).',
@@ -9731,7 +10680,7 @@ sub build_category_rows {
sub modifiable_userdata_row {
my ($context,$item,$settings,$numinrow,$rowcount,$usertypes,$fieldsref,$titlesref,
- $rowid,$customcss,$rowstyle) = @_;
+ $rowid,$customcss,$rowstyle,$itemdesc) = @_;
my ($role,$rolename,$statustype);
$role = $item;
if ($context eq 'cancreate') {
@@ -9752,6 +10701,8 @@ sub modifiable_userdata_row {
} else {
$rolename = $role;
}
+ } elsif ($context eq 'lti') {
+ $rolename = &mt('Institutional data used (if available)');
} else {
if ($role eq 'cr') {
$rolename = &mt('Custom role');
@@ -9789,42 +10740,41 @@ sub modifiable_userdata_row {
if ($rowid) {
$rowid = ' id="'.$rowid.'"';
}
-
$output = ' '.
''.$rolename.' '.
'';
my $rem;
my %checks;
if (ref($settings) eq 'HASH') {
- if (ref($settings->{$context}) eq 'HASH') {
+ my $hashref;
+ if ($context eq 'lti') {
+ if (ref($settings) eq 'HASH') {
+ $hashref = $settings->{'instdata'};
+ }
+ } elsif (ref($settings->{$context}) eq 'HASH') {
if (ref($settings->{$context}->{$role}) eq 'HASH') {
- my $hashref = $settings->{$context}->{$role};
- if ($role eq 'emailusername') {
- if ($statustype) {
- if (ref($settings->{$context}->{$role}->{$statustype}) eq 'HASH') {
- $hashref = $settings->{$context}->{$role}->{$statustype};
- if (ref($hashref) eq 'HASH') {
- foreach my $field (@fields) {
- if ($hashref->{$field}) {
- $checks{$field} = $hashref->{$field};
- }
- }
- }
- }
+ $hashref = $settings->{'lti_instdata'};
+ }
+ if ($role eq 'emailusername') {
+ if ($statustype) {
+ if (ref($settings->{$context}->{$role}->{$statustype}) eq 'HASH') {
+ $hashref = $settings->{$context}->{$role}->{$statustype};
}
- } else {
- if (ref($hashref) eq 'HASH') {
- foreach my $field (@fields) {
- if ($hashref->{$field}) {
- $checks{$field} = ' checked="checked" ';
- }
- }
+ }
+ }
+ }
+ if (ref($hashref) eq 'HASH') {
+ foreach my $field (@fields) {
+ if ($hashref->{$field}) {
+ if ($role eq 'emailusername') {
+ $checks{$field} = $hashref->{$field};
+ } else {
+ $checks{$field} = ' checked="checked" ';
}
}
}
}
}
-
my $total = scalar(@fields);
for (my $i=0; $i<$total; $i++) {
$rem = $i%($numinrow);
@@ -9838,7 +10788,7 @@ sub modifiable_userdata_row {
unless ($role eq 'emailusername') {
if (exists($checks{$fields[$i]})) {
$check = $checks{$fields[$i]};
- } else {
+ } elsif ($context ne 'lti') {
if ($role eq 'st') {
if (ref($settings) ne 'HASH') {
$check = ' checked="checked" ';
@@ -9848,6 +10798,7 @@ sub modifiable_userdata_row {
}
$output .= ''.
'';
+ my $prefix = 'canmodify';
if ($role eq 'emailusername') {
unless ($checks{$fields[$i]} =~ /^(required|optional)$/) {
$checks{$fields[$i]} = 'omit';
@@ -9858,13 +10809,16 @@ sub modifiable_userdata_row {
$checked='checked="checked" ';
}
$output .= ''.
- ' '.
+ ' '.
&mt($option).' '.(' ' x2);
}
$output .= ''.$fieldtitles{$fields[$i]}.' ';
} else {
+ if ($context eq 'lti') {
+ $prefix = 'lti';
+ }
$output .= ''.
- ' '.$fieldtitles{$fields[$i]}.
' ';
}
@@ -9889,15 +10843,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') {
@@ -9934,25 +10892,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);
@@ -9974,20 +10951,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;
@@ -10234,13 +11232,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;
@@ -10253,6 +11254,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);
}
@@ -10310,11 +11312,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;
@@ -10331,6 +11336,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);
}
@@ -10405,11 +11411,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;
@@ -10420,6 +11429,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);
}
@@ -10989,6 +11999,240 @@ 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,
+ );
+ my %titles = &authordefaults_titles();
+ foreach my $item ('nocodemirror','daxecollapse','domcoordacc') {
+ if ($env{'form.'.$item} =~ /^(0|1)$/) {
+ $confhash{$item} = $env{'form.'.$item};
+ }
+ }
+ if ($env{'form.copyright'} =~ /^(default|domain|public)$/) {
+ $confhash{'copyright'} = $1;
+ }
+ if ($env{'form.sourceavail'} =~ /^(closed|open)$/) {
+ $confhash{'sourceavail'} = $1;
+ }
+ my @posseditors = &Apache::loncommon::get_env_multiple('form.author_editors');
+ my @okeditors = ('edit','xml','daxe');
+ my @editors;
+ foreach my $item (@posseditors) {
+ if (grep(/^\Q$item\E$/,@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') {
+ 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') {
+ if ($offon[$confhash{$item}] ne $staticdefaults{$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ foreach my $item ('copyright','sourceavail') {
+ if ($confhash{$item} ne $staticdefaults{$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ }
+ foreach my $key ('authorquota','webdav') {
+ if (ref($curr_quotas{$key}) eq 'HASH') {
+ foreach my $type (@insttypes,'default') {
+ if (exists($save_quotas{$key}{$type})) {
+ if ($save_quotas{$key}{$type} ne $curr_quotas{$key}{$type}) {
+ $changes{$key}{$type} = 1;
+ }
+ } elsif (exists($curr_quotas{$key}{$type})) {
+ $save_quotas{$key}{$type} = $curr_quotas{$key}{$type};
+ } else {
+ $save_quotas{$key}{$type} = $staticdefaults{$key};
+ }
+ }
+ } else {
+ foreach my $type (@insttypes,'default') {
+ if (exists($save_quotas{$key}{$type})) {
+ unless ($save_quotas{$key}{$type} eq $staticdefaults{$key}) {
+ $changes{$key}{$type} = 1;
+ }
+ } else {
+ $save_quotas{$key}{$type} = $staticdefaults{$key};
+ }
+ }
+ }
+ }
+ if (ref($curr_quotas{'webdav'}) eq 'HASH') {
+ if (exists($save_quotas{'webdav'}{'_LC_adv'})) {
+ if ($save_quotas{'webdav'}{'_LC_adv'} ne $curr_quotas{'webdav'}{'_LC_adv'}) {
+ $changes{'webdav_LC_adv'} = 1;
+ }
+ } elsif (exists($curr_quotas{'webdav'}{'_LC_adv'})) {
+ $changes{'webdav_LC_adv'} = 1;
+ }
+ } elsif (exists($save_quotas{'webdav'}{'_LC_adv'})) {
+ $changes{'webdav_LC_adv'} = 1;
+ }
+ my %confighash = (
+ quotas => \%save_quotas,
+ authordefaults => \%confhash,
+ );
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%confighash,
+ $dom);
+ my $resulttext;
+ if ($putresult eq 'ok') {
+ if (keys(%changes)) {
+ 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') {
+ 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'};
+ }
+ }
+ $resulttext .= ''.&mt('[_1] set to: [_2]',$titles{$key},$shown).' ';
+ }
+ }
+ if ($domcoordoverride) {
+ $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);
@@ -11124,12 +12368,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);
}
@@ -11151,12 +12398,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);
}
}
}
@@ -11450,228 +12700,16 @@ sub check_authorstatus {
return $author_ok;
}
-sub publishlogo {
- my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight,$savefileas) = @_;
- my ($output,$fname,$logourl);
- 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;
- }
- } else {
- print $logfile "\nUnable to write ".$copyfile.
- ':'.$!."\n";
- }
- }
- }
- }
- }
- } else {
- $output = $versionresult;
+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;
}
}
- return ($output,$logourl);
-}
-
-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').", $!, ";
- }
- } 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 {
@@ -11722,15 +12760,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;
}
@@ -11742,12 +12786,12 @@ sub modify_quotas {
$author_ok,$switchserver,$errors,$validationitemsref,$validationnamesref,
$validationfieldsref);
if ($action eq 'quotas') {
- $context = 'tools';
+ $context = 'tools';
} else {
$context = $action;
}
if ($context eq 'requestcourses') {
- @usertools = ('official','unofficial','community','textbook');
+ @usertools = ('official','unofficial','community','textbook','lti');
@options =('norequest','approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($dom);
%titles = &courserequest_titles();
@@ -11762,7 +12806,7 @@ sub modify_quotas {
@usertools = ('author');
%titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','webdav','portfolio','timezone');
+ @usertools = ('aboutme','blog','portfolio','timezone');
%titles = &tool_titles();
}
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
@@ -11785,8 +12829,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);
}
@@ -11796,7 +12838,7 @@ sub modify_quotas {
my @approvalnotify = &Apache::loncommon::get_env_multiple('form.'.$context.'notifyapproval');
@approvalnotify = sort(@approvalnotify);
$confhash{'notify'}{'approval'} = join(',',@approvalnotify);
- my @crstypes = ('official','unofficial','community','textbook');
+ my @crstypes = ('official','unofficial','community','textbook','lti');
my @hasuniquecode = &Apache::loncommon::get_env_multiple('form.uniquecode');
foreach my $type (@hasuniquecode) {
if (grep(/^\Q$type\E$/,@crstypes)) {
@@ -11918,7 +12960,7 @@ sub modify_quotas {
&Apache::lonnet::logthis($error);
$errors .= ''.$error.' ';
}
- }
+ }
} elsif ($domconfig{$action}{$type}{$key}{'image'}) {
$confhash{$type}{$key}{'image'} =
$domconfig{$action}{$type}{$key}{'image'};
@@ -12080,7 +13122,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') {
@@ -12169,15 +13210,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') {
@@ -12197,21 +13233,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') {
@@ -12252,19 +13273,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) {
@@ -12453,11 +13461,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);
}
@@ -12472,361 +13483,888 @@ 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;
+
+ 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};
+ }
+ }
}
- 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};
+ }
+ }
+ $ltitoolsoutput = &Apache::courseprefs::store_ltitools($dom,'','domain',\%ltitoolschg,$domconfig{'ltitools'});
+ if (keys(%ltitoolschg)) {
+ %newltitools = %ltitoolschg;
+ }
+ }
+ 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};
+ }
}
+ } else {
+ $newltitools{$id} = $domconfig{'ltitools'}{$id};
}
}
- if ($env{'form.ltitools_add_version'} eq 'LTI-1p0') {
- $confhash{$newid}{'version'} = $env{'form.ltitools_add_version'};
+ }
+ }
+ 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 => { %newltitools }
+ );
+ if (keys(%secchanges)) {
+ $ltitoolshash{'toolsec'} = \%newtoolsec;
+ }
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%ltitoolshash,$dom);
+ if ($putresult eq 'ok') {
+ my %keystore;
+ if ($is_home) {
+ my %toolsenchash = (
+ $action => { %newtoolsenc }
+ );
+ &Apache::lonnet::put_dom('encconfig',\%toolsenchash,$dom,undef,1);
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('ltitoolsenc',$dom,\%newtoolsenc,$cachetime);
+ &store_security($dom,'ltitools',\%secchanges,\%newkeyset,\%keystore,$lastactref);
+ }
+ $resulttext = &mt('Changes made:').'';
+ if (keys(%secchanges) > 0) {
+ $resulttext .= <i_security_results($dom,'ltitools',\%secchanges,\%newtoolsec,\%newkeyset,\%keystore);
+ }
+ if (keys(%ltitoolschg) > 0) {
+ $resulttext .= $ltitoolsoutput;
+ }
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('ltitools',$dom,\%newltitools,$cachetime);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'ltitools'} = 1;
+ }
+ } else {
+ $errors .= ''.&mt('Failed to save changes').' ';
+ }
+ if ($errors) {
+ $resulttext .= ''.&mt('The following errors occurred: ').'
';
+ }
+ return $resulttext;
+}
+
+sub fetch_secrets {
+ my ($dom,$context,$domconfig,$currsec,$secchanges,$newsec,$newkeyset) = @_;
+ my %keyset;
+ %{$currsec} = ();
+ $newsec->{'private'}{'keys'} = [];
+ $newsec->{'encrypt'} = {};
+ $newsec->{'rules'} = {};
+ if ($context eq 'ltisec') {
+ $newsec->{'linkprot'} = {};
+ }
+ if (ref($domconfig->{$context}) eq 'HASH') {
+ %{$currsec} = %{$domconfig->{$context}};
+ if ($context eq 'ltisec') {
+ if (ref($currsec->{'linkprot'}) eq 'HASH') {
+ foreach my $id (keys(%{$currsec->{'linkprot'}})) {
+ unless ($id =~ /^\d+$/) {
+ delete($currsec->{'linkprot'}{$id});
+ }
+ }
}
- if ($env{'form.ltitools_add_msgtype'} eq 'basic-lti-launch-request') {
- $confhash{$newid}{'msgtype'} = $env{'form.ltitools_add_msgtype'};
+ }
+ if (ref($currsec->{'private'}) eq 'HASH') {
+ if (ref($currsec->{'private'}{'keys'}) eq 'ARRAY') {
+ $newsec->{'private'}{'keys'} = $currsec->{'private'}{'keys'};
+ map { $keyset{$_} = 1; } @{$currsec->{'private'}{'keys'}};
}
- if ($env{'form.ltitools_add_sigmethod'} eq 'HMAC-SHA256') {
- $confhash{$newid}{'sigmethod'} = $env{'form.ltitools_add_sigmethod'};
+ }
+ }
+ my @items= ('crs','dom');
+ if ($context eq 'ltisec') {
+ push(@items,'consumers');
+ }
+ foreach my $item (@items) {
+ my $formelement;
+ if (($context eq 'toolsec') || ($item eq 'consumers')) {
+ $formelement = 'form.'.$context.'_'.$item;
+ } else {
+ $formelement = 'form.'.$context.'_'.$item.'linkprot';
+ }
+ if ($env{$formelement}) {
+ $newsec->{'encrypt'}{$item} = 1;
+ if (ref($currsec->{'encrypt'}) eq 'HASH') {
+ unless ($currsec->{'encrypt'}{$item}) {
+ $secchanges->{'encrypt'} = 1;
+ }
} else {
- $confhash{$newid}{'sigmethod'} = 'HMAC-SHA1';
+ $secchanges->{'encrypt'} = 1;
}
- 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};
+ } elsif (ref($currsec->{'encrypt'}) eq 'HASH') {
+ if ($currsec->{'encrypt'}{$item}) {
+ $secchanges->{'encrypt'} = 1;
+ }
+ }
+ }
+ my $secrets;
+ if ($context eq 'ltisec') {
+ $secrets = 'ltisecrets';
+ } else {
+ $secrets = 'toolsecrets';
+ }
+ unless (exists($currsec->{'rules'})) {
+ $currsec->{'rules'} = {};
+ }
+ &password_rule_changes($secrets,$newsec->{'rules'},$currsec->{'rules'},$secchanges);
+
+ my @ids=&Apache::lonnet::current_machine_ids();
+ my %servers = &Apache::lonnet::get_servers($dom,'library');
+
+ foreach my $hostid (keys(%servers)) {
+ if (($hostid ne '') && (grep(/^\Q$hostid\E$/,@ids))) {
+ my $keyitem = 'form.'.$context.'_privkey_'.$hostid;
+ if (exists($env{$keyitem})) {
+ $env{$keyitem} =~ s/(`)/'/g;
+ if ($keyset{$hostid}) {
+ if ($env{'form.'.$context.'_changeprivkey_'.$hostid}) {
+ if ($env{$keyitem} ne '') {
+ $secchanges->{'private'} = 1;
+ $newkeyset->{$hostid} = $env{$keyitem};
+ }
}
- } else {
- if ($env{'form.ltitools_add_'.$item} ne '') {
- $confhash{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
+ } elsif ($env{$keyitem} ne '') {
+ unless (grep(/^\Q$hostid\E$/,@{$newsec->{'private'}{'keys'}})) {
+ push(@{$newsec->{'private'}{'keys'}},$hostid);
}
+ $secchanges->{'private'} = 1;
+ $newkeyset->{$hostid} = $env{$keyitem};
}
}
- 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'};
+ }
+ }
+}
+
+sub store_security {
+ my ($dom,$context,$secchanges,$newkeyset,$keystore) = @_;
+ return unless ((ref($secchanges) eq 'HASH') && (ref($newkeyset) eq 'HASH') &&
+ (ref($keystore) eq 'HASH'));
+ if (keys(%{$secchanges})) {
+ if ($secchanges->{'private'}) {
+ my $who = &escape($env{'user.name'}.':'.$env{'user.domain'});
+ foreach my $hostid (keys(%{$newkeyset})) {
+ my $storehash = {
+ key => $newkeyset->{$hostid},
+ who => $env{'user.name'}.':'.$env{'user.domain'},
+ };
+ $keystore->{$hostid} = &Apache::lonnet::store_dom($storehash,$context,'private',
+ $dom,$hostid);
+ }
+ }
+ }
+}
+
+sub lti_security_results {
+ my ($dom,$context,$secchanges,$newsec,$newkeyset,$keystore) = @_;
+ my $output;
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ my $needs_update;
+ foreach my $item (keys(%{$secchanges})) {
+ if ($item eq 'encrypt') {
+ $needs_update = 1;
+ my %encrypted;
+ if ($context eq 'lti') {
+ %encrypted = (
+ crs => {
+ on => &mt('Encryption of stored link protection secrets defined in courses enabled'),
+ off => &mt('Encryption of stored link protection secrets defined in courses disabled'),
+ },
+ dom => {
+ on => &mt('Encryption of stored link protection secrets defined in domain enabled'),
+ off => &mt('Encryption of stored link protection secrets defined in domain disabled'),
+ },
+ consumers => {
+ on => &mt('Encryption of stored consumer secrets defined in domain enabled'),
+ off => &mt('Encryption of stored consumer secrets defined in domain disabled'),
+ },
+ );
} else {
- $confhash{$newid}{'display'}{'target'} = 'iframe';
+ %encrypted = (
+ crs => {
+ on => &mt('Encryption of stored external tool secrets defined in courses enabled'),
+ off => &mt('Encryption of stored external tool secrets defined in courses disabled'),
+ },
+ dom => {
+ on => &mt('Encryption of stored external tool secrets defined in domain enabled'),
+ off => &mt('Encryption of stored external tool secrets defined in domain disabled'),
+ },
+ );
}
- 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;
+ my @types= ('crs','dom');
+ if ($context eq 'lti') {
+ foreach my $type (@types) {
+ undef($domdefaults{'linkprotenc_'.$type});
}
- if ($error) {
- &Apache::lonnet::logthis($error);
- $errors .= ''.$error.' ';
+ push(@types,'consumers');
+ undef($domdefaults{'ltienc_consumers'});
+ } elsif ($context eq 'ltitools') {
+ foreach my $type (@types) {
+ undef($domdefaults{'toolenc_'.$type});
}
}
- 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;
- }
+ foreach my $type (@types) {
+ my $shown = $encrypted{$type}{'off'};
+ if (ref($newsec->{$item}) eq 'HASH') {
+ if ($newsec->{$item}{$type}) {
+ if ($context eq 'lti') {
+ if ($type eq 'consumers') {
+ $domdefaults{'ltienc_consumers'} = 1;
+ } else {
+ $domdefaults{'linkprotenc_'.$type} = 1;
}
+ } elsif ($context eq 'ltitools') {
+ $domdefaults{'toolenc_'.$type} = 1;
}
- } else {
- $confhash{$newid}{'fields'}{$field} = 1;
+ $shown = $encrypted{$type}{'on'};
}
}
+ $output .= ''.$shown.' ';
+ }
+ } elsif ($item eq 'rules') {
+ my %titles = &Apache::lonlocal::texthash(
+ min => 'Minimum password length',
+ max => 'Maximum password length',
+ chars => 'Required characters',
+ );
+ foreach my $rule ('min','max') {
+ if ($newsec->{rules}{$rule} eq '') {
+ if ($rule eq 'min') {
+ $output .= ''.&mt('[_1] not set.',$titles{$rule});
+ ' '.&mt('Default of [_1] will be used',
+ $Apache::lonnet::passwdmin).' ';
+ } else {
+ $output .= ''.&mt('[_1] set to none',$titles{$rule}).' ';
+ }
+ } else {
+ $output .= ''.&mt('[_1] set to [_2]',$titles{$rule},$newsec->{rules}{$rule}).' ';
+ }
+ }
+ if (ref($newsec->{'rules'}{'chars'}) eq 'ARRAY') {
+ if (@{$newsec->{'rules'}{'chars'}} > 0) {
+ my %rulenames = &Apache::lonlocal::texthash(
+ uc => 'At least one upper case letter',
+ lc => 'At least one lower case letter',
+ num => 'At least one number',
+ spec => 'At least one non-alphanumeric',
+ );
+ my $needed = ''.
+ join(' ',map {$rulenames{$_} } @{$newsec->{'rules'}{'chars'}}).
+ ' ';
+ $output .= ''.&mt('[_1] set to: [_2]',$titles{'chars'},$needed).' ';
+ } else {
+ $output .= ''.&mt('[_1] set to none',$titles{'chars'}).' ';
+ }
+ } else {
+ $output .= ''.&mt('[_1] set to none',$titles{'chars'}).' ';
+ }
+ } elsif ($item eq 'private') {
+ $needs_update = 1;
+ if ($context eq 'lti') {
+ undef($domdefaults{'ltiprivhosts'});
+ } elsif ($context eq 'ltitools') {
+ undef($domdefaults{'toolprivhosts'});
}
- if (ref($confhash{$newid}{'fields'}) eq 'HASH') {
- if ($confhash{$newid}{'fields'}{'user'}) {
- if ($env{'form.ltitools_userincdom_add'}) {
- $confhash{$newid}{'incdom'} = 1;
+ if (keys(%{$newkeyset})) {
+ my @privhosts;
+ foreach my $hostid (sort(keys(%{$newkeyset}))) {
+ if ($keystore->{$hostid} eq 'ok') {
+ $output .= ''.&mt('Encryption key for storage of shared secrets saved for [_1]',$hostid).' ';
+ unless (grep(/^\Q$hostid\E$/,@privhosts)) {
+ push(@privhosts,$hostid);
+ }
}
}
+ if (@privhosts) {
+ if ($context eq 'lti') {
+ $domdefaults{'ltiprivhosts'} = \@privhosts;
+ } elsif ($context eq 'ltitools') {
+ $domdefaults{'toolprivhosts'} = \@privhosts;
+ }
+ }
+ }
+ } elsif ($item eq 'linkprot') {
+ next;
+ } elsif ($item eq 'suggested') {
+ if ((ref($secchanges->{'suggested'}) eq 'HASH') &&
+ (ref($newsec->{'suggested'}) eq 'HASH')) {
+ my $suggestions;
+ foreach my $id (sort { $a <=> $b } keys(%{$secchanges->{'suggested'}})) {
+ if (ref($newsec->{'suggested'}->{$id}) eq 'HASH') {
+ my $name = $newsec->{'suggested'}->{$id}->{'name'};
+ my $info = $newsec->{'suggested'}->{$id}->{'info'};
+ $suggestions .= ''.&mt('Launcher: [_1]',$name).' '.
+ &mt('Recommend: [_1]',''.$info.' ').
+ ' ';
+ } else {
+ $suggestions .= ''.&mt('Recommendations deleted for Launcher: [_1]',
+ $newsec->{'suggested'}->{$id}).' ';
+ }
+ }
+ if ($suggestions) {
+ $output .= ''.&mt('Hints in Courses for Link Protector Configuration').
+ ''.
+ ' ';
+ }
}
- my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig');
- foreach my $item (@courseconfig) {
- $confhash{$newid}{'crsconf'}{$item} = 1;
+ }
+ }
+ if ($needs_update) {
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ }
+ return $output;
+}
+
+sub modify_lti {
+ my ($r,$dom,$action,$lastactref,%domconfig) = @_;
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
+ my ($newid,@allpos,%changes,%confhash,%ltienc,$errors,$resulttext);
+ my (%posslti,%posslticrs,%posscrstype);
+ my @courseroles = ('cc','in','ta','ep','st');
+ my @ltiroles = qw(Learner Instructor ContentDeveloper TeachingAssistant Mentor Member Manager Administrator);
+ my @lticourseroles = qw(Instructor TeachingAssistant Mentor Learner);
+ my @coursetypes = ('official','unofficial','community','textbook','placement','lti');
+ my %coursetypetitles = &Apache::lonlocal::texthash (
+ official => 'Official',
+ unofficial => 'Unofficial',
+ community => 'Community',
+ textbook => 'Textbook',
+ placement => 'Placement Test',
+ lti => 'LTI Provider',
+ );
+ my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
+ my %lt = <i_names();
+ map { $posslti{$_} = 1; } @ltiroles;
+ map { $posslticrs{$_} = 1; } @lticourseroles;
+ map { $posscrstype{$_} = 1; } @coursetypes;
+
+ my %menutitles = <imenu_titles();
+ my (%currltisec,%secchanges,%newltisec,%newltienc,%newkeyset);
+
+ &fetch_secrets($dom,'ltisec',\%domconfig,\%currltisec,\%secchanges,\%newltisec,\%newkeyset);
+
+ my (%linkprotchg,$linkprotoutput,$is_home);
+ my $proterror = &Apache::courseprefs::process_linkprot($dom,'',$currltisec{'linkprot'},
+ \%linkprotchg,'domain');
+ 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; } }
+ }
+
+ if (keys(%linkprotchg)) {
+ $secchanges{'linkprot'} = 1;
+ my %oldlinkprot;
+ if (ref($currltisec{'linkprot'}) eq 'HASH') {
+ %oldlinkprot = %{$currltisec{'linkprot'}};
+ }
+ foreach my $id (keys(%linkprotchg)) {
+ if (ref($linkprotchg{$id}) eq 'HASH') {
+ foreach my $inner (keys(%{$linkprotchg{$id}})) {
+ if (($inner eq 'secret') || ($inner eq 'key')) {
+ if ($is_home) {
+ $newltienc{$id}{$inner} = $linkprotchg{$id}{$inner};
+ }
+ }
+ }
+ } else {
+ $newltisec{'linkprot'}{$id} = $linkprotchg{$id};
+ }
+ }
+ $linkprotoutput = &Apache::courseprefs::store_linkprot($dom,'','domain',\%linkprotchg,\%oldlinkprot);
+ if (keys(%linkprotchg)) {
+ %{$newltisec{'linkprot'}} = %linkprotchg;
+ }
+ }
+ if (ref($currltisec{'linkprot'}) eq 'HASH') {
+ foreach my $id (keys(%{$currltisec{'linkprot'}})) {
+ next if ($id !~ /^\d+$/);
+ unless (exists($linkprotchg{$id})) {
+ if (ref($currltisec{'linkprot'}{$id}) eq 'HASH') {
+ foreach my $inner (keys(%{$currltisec{'linkprot'}{$id}})) {
+ if (($inner eq 'secret') || ($inner eq 'key')) {
+ if ($is_home) {
+ $newltienc{$id}{$inner} = $currltisec{'linkprot'}{$id}{$inner};
+ }
+ } else {
+ $newltisec{'linkprot'}{$id}{$inner} = $currltisec{'linkprot'}{$id}{$inner};
+ }
+ }
+ } else {
+ $newltisec{'linkprot'}{$id} = $currltisec{'linkprot'}{$id};
+ }
+ }
+ }
+ }
+ if ($proterror) {
+ $errors .= ''.$proterror.' ';
+ }
+
+ my (%delsuggested,%suggids,@suggested);;
+ if (ref($currltisec{'suggested'}) eq 'HASH') {
+ my $maxnum = $env{'form.linkprot_suggested_maxnum'};
+ my @todelete = &Apache::loncommon::get_env_multiple('form.linkprot_suggested_del');
+ for (my $i=0; $i<$maxnum; $i++) {
+ my $itemid = $env{'form.linkprot_suggested_id_'.$i};
+ $itemid =~ s/\D+//g;
+ if ($itemid) {
+ if (ref($currltisec{'suggested'}->{$itemid}) eq 'HASH') {
+ push(@suggested,$i);
+ $suggids{$i} = $itemid;
+ if ((@todelete > 0) && (grep(/^$i$/,@todelete))) {
+ if (ref($currltisec{'suggested'}{$itemid}) eq 'HASH') {
+ $delsuggested{$itemid} = $currltisec{'suggested'}{$itemid}{'name'};
+ }
+ } else {
+ if ($env{'form.linkprot_suggested_name_'.$i} eq '') {
+ $delsuggested{$itemid} = $currltisec{'suggested'}{$itemid}{'name'};
+ } else {
+ $env{'form.linkprot_suggested_name_'.$i} =~ s/(`)/'/g;
+ $env{'form.linkprot_suggested_info_'.$i} =~ s/(`)/'/g;
+ $newltisec{'suggested'}{$itemid}{'name'} = $env{'form.linkprot_suggested_name_'.$i};
+ $newltisec{'suggested'}{$itemid}{'info'} = $env{'form.linkprot_suggested_info_'.$i};
+ if (($currltisec{'suggested'}{$itemid}{'name'} ne $newltisec{'suggested'}{$itemid}{'name'}) ||
+ ($currltisec{'suggested'}{$itemid}{'info'} ne $newltisec{'suggested'}{$itemid}{'info'})) {
+ $secchanges{'suggested'}{$itemid} = 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;
+ }
+ }
+ foreach my $key (keys(%delsuggested)) {
+ $newltisec{'suggested'}{$key} = $delsuggested{$key};
+ $secchanges{'suggested'}{$key} = 1;
+ }
+ if (($env{'form.linkprot_suggested_add'}) &&
+ ($env{'form.linkprot_suggested_name_add'} ne '')) {
+ $env{'form.linkprot_suggested_name_add'} =~ s/(`)/'/g;
+ $env{'form.linkprot_suggested_info_add'} =~ s/(`)/'/g;
+ my ($newsuggid,$errormsg) = &get_lti_id($dom,$env{'form.linkprot_suggested_name_add'},'suggested');
+ if ($newsuggid) {
+ $newltisec{'suggested'}{$newsuggid}{'name'} = $env{'form.linkprot_suggested_name_add'};
+ $newltisec{'suggested'}{$newsuggid}{'info'} = $env{'form.linkprot_suggested_info_add'};
+ $secchanges{'suggested'}{$newsuggid} = 1;
+ } else {
+ my $error = &mt('Failed to acquire unique ID for new Link Protectors in Courses Suggestion');
+ if ($errormsg) {
+ $error .= ' ('.$errormsg.')';
}
+ $errors .= ''.$error.' ';
+ }
+ }
+ my (@items,%deletions,%itemids);
+ if ($env{'form.lti_add'}) {
+ my $consumer = $env{'form.lti_consumer_add'};
+ $consumer =~ s/(`)/'/g;
+ ($newid,my $errormsg) = &get_lti_id($dom,$consumer,'lti');
+ if ($newid) {
+ $itemids{'add'} = $newid;
+ push(@items,'add');
+ $changes{$newid} = 1;
} else {
- my $error = &mt('Failed to acquire unique ID for new external tool');
+ my $error = &mt('Failed to acquire unique ID for new LTI configuration');
+ if ($errormsg) {
+ $error .= ' ('.$errormsg.')';
+ }
$errors .= ''.$error.' ';
}
}
if (ref($domconfig{$action}) eq 'HASH') {
- my %deletions;
- my @todelete = &Apache::loncommon::get_env_multiple('form.ltitools_del');
+ my @todelete = &Apache::loncommon::get_env_multiple('form.lti_del');
if (@todelete) {
map { $deletions{$_} = 1; } @todelete;
}
- 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};
+ my $maxnum = $env{'form.lti_maxnum'};
+ for (my $i=0; $i<$maxnum; $i++) {
+ my $itemid = $env{'form.lti_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;
+ $changes{$itemid} = $domconfig{$action}{$itemid}{'consumer'};
} 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;
+ push(@items,$i);
+ $itemids{$i} = $itemid;
+ }
+ }
+ }
+ }
+ my (%keystore,$secstored);
+ if ($is_home) {
+ &store_security($dom,'lti',\%secchanges,\%newkeyset,\%keystore);
+ }
+
+ my ($cipher,$privnum);
+ if ((@items > 0) && ($is_home)) {
+ ($cipher,$privnum) = &get_priv_creds($dom,$home,$secchanges{'encrypt'},
+ $newltisec{'encrypt'},$keystore{$home});
+ }
+ foreach my $idx (@items) {
+ my $itemid = $itemids{$idx};
+ next unless ($itemid);
+ my %currlti;
+ unless ($idx eq 'add') {
+ if (ref($domconfig{$action}) eq 'HASH') {
+ if (ref($domconfig{$action}{$itemid}) eq 'HASH') {
+ %currlti = %{$domconfig{$action}{$itemid}};
+ }
+ }
+ }
+ my $position = $env{'form.lti_pos_'.$itemid};
+ $position =~ s/\D+//g;
+ if ($position ne '') {
+ $allpos[$position] = $itemid;
+ }
+ foreach my $item ('consumer','lifetime','requser','crsinc') {
+ my $formitem = 'form.lti_'.$item.'_'.$idx;
+ $env{$formitem} =~ s/(`)/'/g;
+ if ($item eq 'lifetime') {
+ $env{$formitem} =~ s/[^\d.]//g;
+ }
+ if ($env{$formitem} ne '') {
+ $confhash{$itemid}{$item} = $env{$formitem};
+ unless (($idx eq 'add') || ($changes{$itemid})) {
+ if ($currlti{$item} ne $confhash{$itemid}{$item}) {
+ $changes{$itemid} = 1;
+ }
+ }
+ }
+ }
+ if ($env{'form.lti_version_'.$idx} eq 'LTI-1p0') {
+ $confhash{$itemid}{'version'} = $env{'form.lti_version_'.$idx};
+ }
+ if ($confhash{$itemid}{'requser'}) {
+ if ($env{'form.lti_mapuser_'.$idx} eq 'sourcedid') {
+ $confhash{$itemid}{'mapuser'} = 'lis_person_sourcedid';
+ } elsif ($env{'form.lti_mapuser_'.$idx} eq 'email') {
+ $confhash{$itemid}{'mapuser'} = 'lis_person_contact_email_primary';
+ } elsif ($env{'form.lti_mapuser_'.$idx} eq 'other') {
+ my $mapuser = $env{'form.lti_customuser_'.$idx};
+ $mapuser =~ s/(`)/'/g;
+ $mapuser =~ s/^\s+|\s+$//g;
+ $confhash{$itemid}{'mapuser'} = $mapuser;
+ }
+ my @possmakeuser = &Apache::loncommon::get_env_multiple('form.lti_makeuser_'.$idx);
+ my @makeuser;
+ foreach my $ltirole (sort(@possmakeuser)) {
+ if ($posslti{$ltirole}) {
+ push(@makeuser,$ltirole);
+ }
+ }
+ $confhash{$itemid}{'makeuser'} = \@makeuser;
+ if (@makeuser) {
+ my $lcauth = $env{'form.lti_lcauth_'.$idx};
+ if ($lcauth =~ /^(internal|krb4|krb5|localauth)$/) {
+ $confhash{$itemid}{'lcauth'} = $lcauth;
+ if ($lcauth ne 'internal') {
+ my $lcauthparm = $env{'form.lti_lcauthparm_'.$idx};
+ $lcauthparm =~ s/^(\s+|\s+)$//g;
+ $lcauthparm =~ s/`//g;
+ if ($lcauthparm ne '') {
+ $confhash{$itemid}{'lcauthparm'} = $lcauthparm;
}
}
- 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;
+ } else {
+ $confhash{$itemid}{'lcauth'} = 'lti';
+ }
+ }
+ my @possinstdata = &Apache::loncommon::get_env_multiple('form.lti_instdata_'.$idx);
+ if (@possinstdata) {
+ foreach my $field (@possinstdata) {
+ if (exists($fieldtitles{$field})) {
+ push(@{$confhash{$itemid}{'instdata'}});
+ }
+ }
+ }
+ if ($env{'form.lti_callback_'.$idx}) {
+ if ($env{'form.lti_callbackparam_'.$idx}) {
+ my $callback = $env{'form.lti_callbackparam_'.$idx};
+ $callback =~ s/^\s+|\s+$//g;
+ $confhash{$itemid}{'callback'} = $callback;
+ }
+ }
+ foreach my $field ('topmenu','inlinemenu') {
+ if ($env{'form.lti_'.$field.'_'.$idx}) {
+ $confhash{$itemid}{$field} = 1;
+ }
+ }
+ if ($env{'form.lti_topmenu_'.$idx} || $env{'form.lti_inlinemenu_'.$idx}) {
+ $confhash{$itemid}{lcmenu} = [];
+ my @possmenu = &Apache::loncommon::get_env_multiple('form.lti_menuitem_'.$idx);
+ foreach my $field (@possmenu) {
+ if (exists($menutitles{$field})) {
+ if ($field eq 'grades') {
+ next unless ($env{'form.lti_inlinemenu_'.$idx});
}
+ push(@{$confhash{$itemid}{lcmenu}},$field);
+ }
+ }
+ }
+ if ($confhash{$itemid}{'crsinc'}) {
+ if (($env{'form.lti_mapcrs_'.$idx} eq 'course_offering_sourcedid') ||
+ ($env{'form.lti_mapcrs_'.$idx} eq 'context_id')) {
+ $confhash{$itemid}{'mapcrs'} = $env{'form.lti_mapcrs_'.$idx};
+ } elsif ($env{'form.lti_mapcrs_'.$idx} eq 'other') {
+ my $mapcrs = $env{'form.lti_mapcrsfield_'.$idx};
+ $mapcrs =~ s/(`)/'/g;
+ $mapcrs =~ s/^\s+|\s+$//g;
+ $confhash{$itemid}{'mapcrs'} = $mapcrs;
+ }
+ my @posstypes = &Apache::loncommon::get_env_multiple('form.lti_mapcrstype_'.$idx);
+ my @crstypes;
+ foreach my $type (sort(@posstypes)) {
+ if ($posscrstype{$type}) {
+ push(@crstypes,$type);
+ }
+ }
+ $confhash{$itemid}{'mapcrstype'} = \@crstypes;
+ if ($env{'form.lti_storecrs_'.$idx}) {
+ $confhash{$itemid}{'storecrs'} = 1;
+ }
+ if ($env{'form.lti_makecrs_'.$idx}) {
+ $confhash{$itemid}{'makecrs'} = 1;
+ }
+ foreach my $ltirole (@lticourseroles) {
+ my $possrole = $env{'form.lti_maprole_'.$ltirole.'_'.$idx};
+ if (grep(/^\Q$possrole\E$/,@courseroles)) {
+ $confhash{$itemid}{'maproles'}{$ltirole} = $possrole;
+ }
+ }
+ my @possenroll = &Apache::loncommon::get_env_multiple('form.lti_selfenroll_'.$idx);
+ my @selfenroll;
+ foreach my $type (sort(@possenroll)) {
+ if ($posslticrs{$type}) {
+ push(@selfenroll,$type);
}
- if ($env{'form.ltitools_version_'.$i} eq 'LTI-1p0') {
- $confhash{$itemid}{'version'} = $env{'form.ltitools_version_'.$i};
+ }
+ $confhash{$itemid}{'selfenroll'} = \@selfenroll;
+ if ($env{'form.lti_crssec_'.$idx}) {
+ if ($env{'form.lti_crssecsrc_'.$idx} eq 'course_section_sourcedid') {
+ $confhash{$itemid}{'section'} = $env{'form.lti_crssecsrc_'.$idx};
+ } elsif ($env{'form.lti_crssecsrc_'.$idx} eq 'other') {
+ my $section = $env{'form.lti_customsection_'.$idx};
+ $section =~ s/(`)/'/g;
+ $section =~ s/^\s+|\s+$//g;
+ if ($section ne '') {
+ $confhash{$itemid}{'section'} = $section;
+ }
}
- if ($env{'form.ltitools_msgtype_'.$i} eq 'basic-lti-launch-request') {
- $confhash{$itemid}{'msgtype'} = $env{'form.ltitools_msgtype_'.$i};
+ }
+ foreach my $field ('passback','roster') {
+ if ($env{'form.lti_'.$field.'_'.$idx}) {
+ $confhash{$itemid}{$field} = 1;
}
- if ($env{'form.ltitools_sigmethod_'.$i} eq 'HMAC-SHA256') {
- $confhash{$itemid}{'sigmethod'} = $env{'form.ltitools_sigmethod_'.$i};
+ }
+ if ($env{'form.lti_passback_'.$idx}) {
+ if ($env{'form.lti_passbackformat_'.$idx} eq '1.0') {
+ $confhash{$itemid}{'passbackformat'} = '1.0';
} else {
- $confhash{$itemid}{'sigmethod'} = 'HMAC-SHA1';
+ $confhash{$itemid}{'passbackformat'} = '1.1';
}
- if ($domconfig{$action}{$itemid}{'sigmethod'} eq '') {
- if ($confhash{$itemid}{'sigmethod'} ne 'HMAC-SHA1') {
+ }
+ }
+ unless (($idx eq 'add') || ($changes{$itemid})) {
+ if ($confhash{$itemid}{'crsinc'}) {
+ foreach my $field ('mapcrs','storecrs','makecrs','section','passback','roster') {
+ if ($currlti{$field} ne $confhash{$itemid}{$field}) {
$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 '') {
+ unless ($changes{$itemid}) {
+ if ($currlti{'passback'} eq $confhash{$itemid}{'passback'}) {
+ if ($currlti{'passbackformat'} ne $confhash{$itemid}{'passbackformat'}) {
$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}) {
+ foreach my $field ('mapcrstype','selfenroll') {
+ unless ($changes{$itemid}) {
+ if (ref($currlti{$field}) eq 'ARRAY') {
+ if (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
+ my @diffs = &Apache::loncommon::compare_arrays($currlti{$field},
+ $confhash{$itemid}{$field});
+ if (@diffs) {
+ $changes{$itemid} = 1;
+ }
+ } elsif (@{$currlti{$field}} > 0) {
$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;
- }
- 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}) {
+ } elsif (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
+ if (@{$confhash{$itemid}{$field}} > 0) {
$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;
- }
+ unless ($changes{$itemid}) {
+ if (ref($currlti{'maproles'}) eq 'HASH') {
+ if (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {
+ foreach my $ltirole (keys(%{$currlti{'maproles'}})) {
+ if ($currlti{'maproles'}{$ltirole} ne
+ $confhash{$itemid}{'maproles'}{$ltirole}) {
+ $changes{$itemid} = 1;
+ last;
}
- if (ref($domconfig{$action}{$itemid}{'roles'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'roles'}{$role} ne $confhash{$itemid}{'roles'}{$role}) {
+ }
+ unless ($changes{$itemid}) {
+ foreach my $ltirole (keys(%{$confhash{$itemid}{'maproles'}})) {
+ if ($confhash{$itemid}{'maproles'}{$ltirole} ne
+ $currlti{'maproles'}{$ltirole}) {
$changes{$itemid} = 1;
+ last;
}
- } 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 {
+ } elsif (keys(%{$currlti{'maproles'}}) > 0) {
+ $changes{$itemid} = 1;
+ }
+ } elsif (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {
+ unless ($changes{$itemid}) {
+ if (keys(%{$confhash{$itemid}{'maproles'}}) > 0) {
$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;
+ }
+ unless ($changes{$itemid}) {
+ foreach my $field ('mapuser','lcauth','lcauthparm','topmenu','inlinemenu','callback') {
+ if ($currlti{$field} ne $confhash{$itemid}{$field}) {
+ $changes{$itemid} = 1;
+ }
+ }
+ unless ($changes{$itemid}) {
+ foreach my $field ('makeuser','lcmenu') {
+ if (ref($currlti{$field}) eq 'ARRAY') {
+ if (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
+ my @diffs = &Apache::loncommon::compare_arrays($currlti{$field},
+ $confhash{$itemid}{$field});
+ if (@diffs) {
+ $changes{$itemid} = 1;
+ }
+ } elsif (@{$currlti{$field}} > 0) {
+ $changes{$itemid} = 1;
+ }
+ } elsif (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
+ if (@{$confhash{$itemid}{$field}} > 0) {
+ $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;
+ }
+ }
+ if ($is_home) {
+ my $keyitem = 'form.lti_key_'.$idx;
+ $env{$keyitem} =~ s/(`)/'/g;
+ if ($env{$keyitem} ne '') {
+ $ltienc{$itemid}{'key'} = $env{$keyitem};
+ unless ($changes{$itemid}) {
+ if ($currlti{'key'} ne $env{$keyitem}) {
$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;
+ }
+ }
+ my $secretitem = 'form.lti_secret_'.$idx;
+ $env{$secretitem} =~ s/(`)/'/g;
+ if ($currlti{'usable'}) {
+ if ($env{'form.lti_changesecret_'.$idx}) {
+ if ($env{$secretitem} ne '') {
+ if ($privnum && $cipher) {
+ $ltienc{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
+ $confhash{$itemid}{'cipher'} = $privnum;
+ } else {
+ $ltienc{$itemid}{'secret'} = $env{$secretitem};
+ }
$changes{$itemid} = 1;
}
+ } else {
+ $ltienc{$itemid}{'secret'} = $currlti{'secret'};
+ $confhash{$itemid}{'cipher'} = $currlti{'cipher'};
}
- my %customdels;
- my @customdeletions = &Apache::loncommon::get_env_multiple('form.ltitools_customdel_'.$i);
- if (@customdeletions) {
- $changes{$itemid} = 1;
+ if (ref($ltienc{$itemid}) eq 'HASH') {
+ if (($ltienc{$itemid}{'key'} ne '') && ($ltienc{$itemid}{'secret'} ne '')) {
+ $confhash{$itemid}{'usable'} = 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;
- }
- }
+ } elsif ($env{$secretitem} ne '') {
+ if ($privnum && $cipher) {
+ $ltienc{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
+ $confhash{$itemid}{'cipher'} = $privnum;
+ } else {
+ $ltienc{$itemid}{'secret'} = $env{$secretitem};
+ }
+ if (ref($ltienc{$itemid}) eq 'HASH') {
+ if (($ltienc{$itemid}{'key'} ne '') && ($ltienc{$itemid}{'key'} ne '')) {
+ $confhash{$itemid}{'usable'} = 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;
+ }
+ }
+ unless ($changes{$itemid}) {
+ foreach my $key (keys(%currlti)) {
+ if (ref($currlti{$key}) eq 'HASH') {
+ if (ref($confhash{$itemid}{$key}) eq 'HASH') {
+ foreach my $innerkey (keys(%{$currlti{$key}})) {
+ unless (exists($confhash{$itemid}{$key}{$innerkey})) {
$changes{$itemid} = 1;
+ last;
}
}
- last if ($changes{$itemid});
+ } elsif (keys(%{$currlti{$key}}) > 0) {
+ $changes{$itemid} = 1;
}
}
+ last if ($changes{$itemid});
}
}
}
@@ -12846,149 +14384,233 @@ sub modify_ltitools {
}
}
}
- my %ltitoolshash = (
- $action => { %confhash }
- );
- my $putresult = &Apache::lonnet::put_dom('configuration',\%ltitoolshash,
- $dom);
+
+ if ((keys(%changes) == 0) && (keys(%secchanges) == 0)) {
+ return &mt('No changes made.');
+ }
+
+ my %ltihash = (
+ $action => { %confhash }
+ );
+ my %ltienchash;
+
+ if ($is_home) {
+ %ltienchash = (
+ $action => { %ltienc }
+ );
+ }
+ if (keys(%secchanges)) {
+ $ltihash{'ltisec'} = \%newltisec;
+ if ($secchanges{'linkprot'}) {
+ if ($is_home) {
+ $ltienchash{'linkprot'} = \%newltienc;
+ }
+ }
+ }
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%ltihash,$dom);
if ($putresult eq 'ok') {
- my %ltienchash = (
- $action => { %encconfig }
- );
- &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1);
+ if (keys(%ltienchash)) {
+ &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1);
+ }
+ $resulttext = &mt('Changes made:').'';
+ if (keys(%secchanges) > 0) {
+ $resulttext .= <i_security_results($dom,'lti',\%secchanges,\%newltisec,\%newkeyset,\%keystore);
+ if (exists($secchanges{'linkprot'})) {
+ $resulttext .= $linkprotoutput;
+ }
+ }
if (keys(%changes) > 0) {
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('ltitools',$dom,\%ltiall,$cachetime);
+ &Apache::lonnet::do_cache_new('lti',$dom,\%confhash,$cachetime);
if (ref($lastactref) eq 'HASH') {
- $lastactref->{'ltitools'} = 1;
+ $lastactref->{'lti'} = 1;
}
- $resulttext = &mt('Changes made:').'';
my %bynum;
foreach my $itemid (sort(keys(%changes))) {
- my $position = $confhash{$itemid}{'order'};
- $bynum{$position} = $itemid;
+ if (ref($confhash{$itemid}) eq 'HASH') {
+ my $position = $confhash{$itemid}{'order'};
+ $bynum{$position} = $itemid;
+ }
}
foreach my $pos (sort { $a <=> $b } keys(%bynum)) {
my $itemid = $bynum{$pos};
- if (ref($confhash{$itemid}) ne 'HASH') {
- $resulttext .= ''.&mt('Deleted: [_1]',$changes{$itemid}).' ';
- } else {
- $resulttext .= ''.$confhash{$itemid}{'title'}.' ';
- if ($confhash{$itemid}{'image'}) {
- $resulttext .= ' '.
- ' ';
- }
- $resulttext .= '';
+ if (ref($confhash{$itemid}) eq 'HASH') {
+ $resulttext .= ''.$confhash{$itemid}{'consumer'}.' ';
my $position = $pos + 1;
$resulttext .= ''.&mt('Order: [_1]',$position).' ';
- foreach my $item ('version','msgtype','sigmethod','url','lifetime') {
+ foreach my $item ('version','lifetime') {
if ($confhash{$itemid}{$item} ne '') {
$resulttext .= ''.$lt{$item}.': '.$confhash{$itemid}{$item}.' ';
}
}
- if ($encconfig{$itemid}{'key'} ne '') {
- $resulttext .= ''.$lt{'key'}.': '.$encconfig{$itemid}{'key'}.' ';
- }
- if ($encconfig{$itemid}{'secret'} ne '') {
- $resulttext .= ''.$lt{'secret'}.': ';
- my $num = length($encconfig{$itemid}{'secret'});
- $resulttext .= ('*'x$num).' ';
- }
- $resulttext .= ''.&mt('Configurable in course:');
- my @possconfig = ('label','title','target','linktext','explanation','append');
- my $numconfig = 0;
- if (ref($confhash{$itemid}{'crsconf'}) eq 'HASH') {
- foreach my $item (@possconfig) {
- if ($confhash{$itemid}{'crsconf'}{$item}) {
- $numconfig ++;
- $resulttext .= ' "'.$lt{'crs'.$item}.'"';
- }
- }
+ if ($ltienc{$itemid}{'key'} ne '') {
+ $resulttext .= ' '.$lt{'key'}.': '.$ltienc{$itemid}{'key'}.' ';
}
- if (!$numconfig) {
- $resulttext .= &mt('None');
+ if ($ltienc{$itemid}{'secret'} ne '') {
+ $resulttext .= ''.$lt{'secret'}.': ['.&mt('not shown').'] ';
}
- $resulttext .= ' ';
- if (ref($confhash{$itemid}{'display'}) eq 'HASH') {
- my $displaylist;
- if ($confhash{$itemid}{'display'}{'target'}) {
- $displaylist = &mt('Display target').': '.
- $confhash{$itemid}{'display'}{'target'}.',';
+ if ($confhash{$itemid}{'requser'}) {
+ if ($confhash{$itemid}{'callback'}) {
+ $resulttext .= ''.&mt('Callback setting').': '.$confhash{$itemid}{'callback'}.' ';
+ } else {
+ $resulttext .= ''.&mt('Callback to logout LON-CAPA on log out from Consumer').' ';
}
- foreach my $size ('width','height') {
- if ($confhash{$itemid}{'display'}{$size}) {
- $displaylist .= (' 'x2).$lt{$size}.': '.
- $confhash{$itemid}{'display'}{$size}.',';
+ if ($confhash{$itemid}{'mapuser'}) {
+ my $shownmapuser;
+ if ($confhash{$itemid}{'mapuser'} eq 'lis_person_sourcedid') {
+ $shownmapuser = $lt{'sourcedid'}.' (lis_person_sourcedid)';
+ } elsif ($confhash{$itemid}{'mapuser'} eq 'lis_person_contact_email_primary') {
+ $shownmapuser = $lt{'email'}.' (lis_person_contact_email_primary)';
+ } else {
+ $shownmapuser = &mt('Other').' ('.$confhash{$itemid}{'mapuser'}.')';
}
+ $resulttext .= ''.&mt('LON-CAPA username').': '.$shownmapuser.' ';
}
- if ($displaylist) {
- $displaylist =~ s/,$//;
- $resulttext .= ''.$displaylist.' ';
+ if (ref($confhash{$itemid}{'makeuser'}) eq 'ARRAY') {
+ if (@{$confhash{$itemid}{'makeuser'}} > 0) {
+ $resulttext .= ''.&mt('Following roles may create user accounts: [_1]',
+ join(', ',@{$confhash{$itemid}{'makeuser'}})).' ';
+ if ($confhash{$itemid}{'lcauth'} eq 'lti') {
+ $resulttext .= &mt('New users will only be able to authenticate via LTI').' ';
+ } else {
+ $resulttext .= &mt('New users will be assigned LON-CAPA authentication: [_1]',
+ $confhash{$itemid}{'lcauth'});
+ if ($confhash{$itemid}{'lcauth'} eq 'internal') {
+ $resulttext .= '; '.&mt('a randomly generated password will be created');
+ } elsif ($confhash{$itemid}{'lcauth'} eq 'localauth') {
+ if ($confhash{$itemid}{'lcauthparm'} ne '') {
+ $resulttext .= ' '.&mt('with argument: [_1]',$confhash{$itemid}{'lcauthparm'});
+ }
+ } else {
+ $resulttext .= '; '.&mt('Kerberos domain: [_1]',$confhash{$itemid}{'lcauthparm'});
+ }
+ }
+ $resulttext .= '';
+ } else {
+ $resulttext .= ''.&mt('User account creation not permitted.').' ';
+ }
}
- foreach my $item ('linktext','explanation') {
- if ($confhash{$itemid}{'display'}{$item}) {
- $resulttext .= ''.$lt{$item}.': '.$confhash{$itemid}{'display'}{$item}.' ';
+ if (ref($confhash{$itemid}{'instdata'}) eq 'ARRAY') {
+ if (@{$confhash{$itemid}{'instdata'}} > 0) {
+ $resulttext .= ''.&mt('Institutional data will be used when creating a new user for: [_1]',
+ join(', ',map { $fieldtitles{$_}; } @{$confhash{$itemid}{'instdata'}})).' ';
+ } else {
+ $resulttext .= ''.&mt('No institutional data used when creating a new user.').' ';
}
}
- }
- if (ref($confhash{$itemid}{'fields'}) eq 'HASH') {
- my $fieldlist;
- foreach my $field (@allfields) {
- if ($confhash{$itemid}{'fields'}{$field}) {
- $fieldlist .= (' 'x2).$lt{$field}.',';
+ foreach my $item ('topmenu','inlinemenu') {
+ $resulttext .= ''.$lt{$item}.': ';
+ if ($confhash{$itemid}{$item}) {
+ $resulttext .= &mt('Yes');
+ } else {
+ $resulttext .= &mt('No');
}
+ $resulttext .= ' ';
}
- if ($fieldlist) {
- $fieldlist =~ s/,$//;
- if ($confhash{$itemid}{'fields'}{'user'}) {
- if ($confhash{$itemid}{'incdom'}) {
- $fieldlist .= ' ('.&mt('username:domain').')';
+ if (ref($confhash{$itemid}{'lcmenu'}) eq 'ARRAY') {
+ if (@{$confhash{$itemid}{'lcmenu'}} > 0) {
+ $resulttext .= ''.&mt('Menu items:').' '.
+ join(', ', map { $menutitles{$_}; } (@{$confhash{$itemid}{'lcmenu'}})).' ';
+ } else {
+ $resulttext .= ''.&mt('No menu items displayed in header or online menu').' ';
+ }
+ }
+ if ($confhash{$itemid}{'crsinc'}) {
+ if (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {
+ my $rolemaps;
+ foreach my $role (@ltiroles) {
+ if ($confhash{$itemid}{'maproles'}{$role}) {
+ $rolemaps .= (' 'x2).$role.'='.
+ &Apache::lonnet::plaintext($confhash{$itemid}{'maproles'}{$role},
+ 'Course').',';
+ }
+ }
+ if ($rolemaps) {
+ $rolemaps =~ s/,$//;
+ $resulttext .= ''.&mt('Role mapping:').$rolemaps.' ';
+ }
+ }
+ if ($confhash{$itemid}{'mapcrs'}) {
+ $resulttext .= ''.&mt('Unique course identifier').': '.$confhash{$itemid}{'mapcrs'}.' ';
+ }
+ if (ref($confhash{$itemid}{'mapcrstype'}) eq 'ARRAY') {
+ if (@{$confhash{$itemid}{'mapcrstype'}} > 0) {
+ $resulttext .= ''.&mt('Mapping for the following LON-CAPA course types: [_1]',
+ join(', ',map { $coursetypetitles{$_}; } @coursetypes)).
+ ' ';
} else {
- $fieldlist .= ' ('.&mt('username').')';
+ $resulttext .= ''.&mt('No mapping to LON-CAPA courses').' ';
}
}
- $resulttext .= ''.&mt('Data sent').':'.$fieldlist.' ';
- }
- }
- if (ref($confhash{$itemid}{'roles'}) eq 'HASH') {
- my $rolemaps;
- foreach my $role (@courseroles) {
- if ($confhash{$itemid}{'roles'}{$role}) {
- $rolemaps .= (' 'x2).&Apache::lonnet::plaintext($role,'Course').'='.
- $confhash{$itemid}{'roles'}{$role}.',';
+ if ($confhash{$itemid}{'storecrs'}) {
+ $resulttext .= ''.&mt('Store mapping of course identifier to LON-CAPA CourseID').': '.$confhash{$itemid}{'storecrs'}.' ';
}
- }
- if ($rolemaps) {
- $rolemaps =~ s/,$//;
- $resulttext .= ''.&mt('Role mapping:').$rolemaps.' ';
- }
- }
- if (ref($confhash{$itemid}{'custom'}) eq 'HASH') {
- my $customlist;
- if (keys(%{$confhash{$itemid}{'custom'}})) {
- foreach my $key (sort(keys(%{$confhash{$itemid}{'custom'}}))) {
- $customlist .= $key.':'.$confhash{$itemid}{'custom'}{$key}.(' 'x2);
+ if ($confhash{$itemid}{'makecrs'}) {
+ $resulttext .= ''.&mt('Instructor may create course (if absent).').' ';
+ } else {
+ $resulttext .= ''.&mt('Instructor may not create course (if absent).').' ';
+ }
+ if (ref($confhash{$itemid}{'selfenroll'}) eq 'ARRAY') {
+ if (@{$confhash{$itemid}{'selfenroll'}} > 0) {
+ $resulttext .= ''.&mt('Self-enrollment for following roles: [_1]',
+ join(', ',@{$confhash{$itemid}{'selfenroll'}})).
+ ' ';
+ } else {
+ $resulttext .= ''.&mt('Self-enrollment not permitted').' ';
+ }
+ }
+ if ($confhash{$itemid}{'section'}) {
+ if ($confhash{$itemid}{'section'} eq 'course_section_sourcedid') {
+ $resulttext .= ''.&mt('User section from standard field:').
+ ' (course_section_sourcedid)'.' ';
+ } else {
+ $resulttext .= ''.&mt('User section from:').' '.
+ $confhash{$itemid}{'section'}.' ';
+ }
+ } else {
+ $resulttext .= ''.&mt('No section assignment').' ';
+ }
+ foreach my $item ('passback','roster','topmenu','inlinemenu') {
+ $resulttext .= ''.$lt{$item}.': ';
+ if ($confhash{$itemid}{$item}) {
+ $resulttext .= &mt('Yes');
+ if ($item eq 'passback') {
+ if ($confhash{$itemid}{'passbackformat'} eq '1.0') {
+ $resulttext .= ' ('.&mt('Outcomes Extension (1.0)').')';
+ } elsif ($confhash{$itemid}{'passbackformat'} eq '1.1') {
+ $resulttext .= ' ('.&mt('Outcomes Service (1.1)').')';
+ }
+ }
+ } else {
+ $resulttext .= &mt('No');
+ }
+ $resulttext .= ' ';
+ }
+ if (ref($confhash{$itemid}{'lcmenu'}) eq 'ARRAY') {
+ if (@{$confhash{$itemid}{'lcmenu'}} > 0) {
+ $resulttext .= ''.&mt('Menu items:').' '.
+ join(', ', map { $menutitles{$_}; } (@{$confhash{$itemid}{'lcmenu'}})).' ';
+ } else {
+ $resulttext .= ''.&mt('No menu items displayed in header or online menu').' ';
+ }
}
- }
- if ($customlist) {
- $resulttext .= ''.&mt('Custom items').': '.$customlist.' ';
}
}
$resulttext .= ' ';
}
}
- $resulttext .= ' ';
- } else {
- $resulttext = &mt('No changes made.');
+ if (keys(%deletions)) {
+ foreach my $itemid (sort { $a <=> $b } keys(%deletions)) {
+ $resulttext .= ''.&mt('Deleted: [_1]',$changes{$itemid}).' ';
+ }
+ }
+ }
+ $resulttext .= ' ';
+ if (ref($lastactref) eq 'HASH') {
+ if (($secchanges{'encrypt'}) || ($secchanges{'private'}) || (exists($secchanges{'suggested'}))) {
+ &Apache::lonnet::get_domain_defaults($dom,1);
+ $lastactref->{'domdefaults'} = 1;
+ }
}
} else {
$errors .= ''.&mt('Failed to save changes').' ';
@@ -13000,57 +14622,51 @@ sub modify_ltitools {
return $resulttext;
}
-sub process_ltitools_image {
- my ($r,$dom,$confname,$caller,$itemid,$configuserok,$switchserver,$author_ok) = @_;
- my $filename = $env{'form.'.$caller.'.filename'};
- my ($error,$url);
- my ($width,$height) = (21,21);
- if ($configuserok eq 'ok') {
- if ($switchserver) {
- $error = &mt('Upload of Tool Provider (LTI) icon is not permitted to this server: [_1]',
- $switchserver);
- } elsif ($author_ok eq 'ok') {
- my ($result,$imageurl,$madethumb) =
- &publishlogo($r,'upload',$caller,$dom,$confname,
- "ltitools/$itemid/icon",$width,$height);
- if ($result eq 'ok') {
- if ($madethumb) {
- my ($path,$imagefile) = ($imageurl =~ m{^(.+)/([^/]+)$});
- my $imagethumb = "$path/tn-".$imagefile;
- $url = $imagethumb;
- } else {
- $url = $imageurl;
- }
- } else {
- $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$filename,$result);
+sub get_priv_creds {
+ my ($dom,$home,$encchg,$encrypt,$storedsec) = @_;
+ my ($needenc,$cipher,$privnum);
+ my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
+ if (($encchg) && (ref($encrypt) eq 'HASH')) {
+ $needenc = $encrypt->{'consumers'}
+ } else {
+ $needenc = $domdefs{'ltienc_consumers'};
+ }
+ if ($needenc) {
+ if (($storedsec eq 'ok') || ((ref($domdefs{'ltiprivhosts'}) eq 'ARRAY') &&
+ (grep(/^\Q$home\E$/,@{$domdefs{'ltiprivhosts'}})))) {
+ my %privhash = &Apache::lonnet::restore_dom('lti','private',$dom,$home,1);
+ my $privkey = $privhash{'key'};
+ $privnum = $privhash{'version'};
+ if (($privnum) && ($privkey ne '')) {
+ $cipher = Crypt::CBC->new({'key' => $privkey,
+ 'cipher' => 'DES'});
}
- } else {
- $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$author_ok);
}
- } else {
- $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$configuserok);
}
- return ($url,$error);
+ return ($cipher,$privnum);
}
-sub get_ltitools_id {
- my ($cdom,$title) = @_;
- # get lock on ltitools db
+sub get_lti_id {
+ my ($domain,$consumer,$dbname) = @_;
+ unless (($dbname eq 'lti') || ($dbname eq 'suggested')) {
+ return ('','invalid db');
+ }
+ # get lock on db
my $lockhash = {
lock => $env{'user.name'}.
':'.$env{'user.domain'},
};
my $tries = 0;
- my $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom);
+ my $gotlock = &Apache::lonnet::newput_dom($dbname,$lockhash,$domain);
my ($id,$error);
while (($gotlock ne 'ok') && ($tries<10)) {
$tries ++;
sleep (0.1);
- $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom);
+ $gotlock = &Apache::lonnet::newput_dom($dbname,$lockhash,$domain);
}
if ($gotlock eq 'ok') {
- my %currids = &Apache::lonnet::dump_dom('ltitools',$cdom);
+ my %currids = &Apache::lonnet::dump_dom($dbname,$domain);
if ($currids{'lock'}) {
delete($currids{'lock'});
if (keys(%currids)) {
@@ -13062,269 +14678,20 @@ sub get_ltitools_id {
$id = 1;
}
if ($id) {
- unless (&Apache::lonnet::newput_dom('ltitools',{ $id => $title },$cdom) eq 'ok') {
+ unless (&Apache::lonnet::newput_dom($dbname,{ $id => $consumer },$domain) eq 'ok') {
$error = 'nostore';
}
} else {
$error = 'nonumber';
}
}
- my $dellockoutcome = &Apache::lonnet::del_dom('ltitools',['lock'],$cdom);
+ my $dellockoutcome = &Apache::lonnet::del_dom($dbname,['lock'],$domain);
} else {
$error = 'nolock';
}
return ($id,$error);
}
-sub modify_lti {
- my ($r,$dom,$action,$lastactref,%domconfig) = @_;
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
- my (%encconfig,$errors,$resulttext);
-
- my (%currltisec,%secchanges,%newltisec,%newltienc,%keyset,%newkeyset);
- $newltisec{'private'}{'keys'} = [];
- $newltisec{'encrypt'} = {};
- $newltisec{'rules'} = {};
- $newltisec{'linkprot'} = {};
- if (ref($domconfig{'ltisec'}) eq 'HASH') {
- %currltisec = %{$domconfig{'ltisec'}};
- if (ref($currltisec{'linkprot'}) eq 'HASH') {
- foreach my $id (keys(%{$currltisec{'linkprot'}})) {
- unless ($id =~ /^\d+$/) {
- delete($currltisec{'linkprot'}{$id});
- }
- }
- }
- if (ref($currltisec{'private'}) eq 'HASH') {
- if (ref($currltisec{'private'}{'keys'}) eq 'ARRAY') {
- $newltisec{'private'}{'keys'} = $currltisec{'private'}{'keys'};
- map { $keyset{$_} = 1; } @{$currltisec{'private'}{'keys'}};
- }
- }
- }
- foreach my $item ('crs','dom') {
- my $formelement = 'form.ltisec_'.$item.'linkprot';
- if ($env{$formelement}) {
- $newltisec{'encrypt'}{$item} = 1;
- if (ref($currltisec{'encrypt'}) eq 'HASH') {
- unless ($currltisec{'encrypt'}{$item}) {
- $secchanges{'encrypt'} = 1;
- }
- } else {
- $secchanges{'encrypt'} = 1;
- }
- } elsif (ref($currltisec{'encrypt'}) eq 'HASH') {
- if ($currltisec{'encrypt'}{$item}) {
- $secchanges{'encrypt'} = 1;
- }
- }
- }
- unless (exists($currltisec{'rules'})) {
- $currltisec{'rules'} = {};
- }
- &password_rule_changes('secrets',$newltisec{'rules'},$currltisec{'rules'},\%secchanges);
-
- my @ids=&Apache::lonnet::current_machine_ids();
- my %servers = &Apache::lonnet::get_servers($dom,'library');
-
- foreach my $hostid (keys(%servers)) {
- if (($hostid ne '') && (grep(/^\Q$hostid\E$/,@ids))) {
- my $newkey;
- my $keyitem = 'form.ltisec_privkey_'.$hostid;
- if (exists($env{$keyitem})) {
- $env{$keyitem} =~ s/(`)/'/g;
- if ($keyset{$hostid}) {
- if ($env{'form.ltisec_changeprivkey_'.$hostid}) {
- if ($env{$keyitem} ne '') {
- $secchanges{'private'} = 1;
- $newkeyset{$hostid} = $env{$keyitem};
- }
- }
- } elsif ($env{$keyitem} ne '') {
- unless (grep(/^\Q$hostid\E$/,@{$newltisec{'private'}{'keys'}})) {
- push(@{$newltisec{'private'}{'keys'}},$hostid);
- }
- $secchanges{'private'} = 1;
- $newkeyset{$hostid} = $env{$keyitem};
- }
- }
- }
- }
-
- my (%linkprotchg,$linkprotoutput,$is_home);
- my $proterror = &Apache::courseprefs::process_linkprot($dom,'',$currltisec{'linkprot'},
- \%linkprotchg,'domain');
- 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; } }
- }
-
- if (keys(%linkprotchg)) {
- $secchanges{'linkprot'} = 1;
- my %oldlinkprot;
- if (ref($currltisec{'linkprot'}) eq 'HASH') {
- %oldlinkprot = %{$currltisec{'linkprot'}};
- }
- foreach my $id (keys(%linkprotchg)) {
- if (ref($linkprotchg{$id}) eq 'HASH') {
- foreach my $inner (keys(%{$linkprotchg{$id}})) {
- if (($inner eq 'secret') || ($inner eq 'key')) {
- if ($is_home) {
- $newltienc{$id}{$inner} = $linkprotchg{$id}{$inner};
- }
- }
- }
- } else {
- $newltisec{'linkprot'}{$id} = $linkprotchg{$id};
- }
- }
- $linkprotoutput = &Apache::courseprefs::store_linkprot($dom,'','domain',\%linkprotchg,\%oldlinkprot);
- if (keys(%linkprotchg)) {
- %{$newltisec{'linkprot'}} = %linkprotchg;
- }
- }
- if (ref($currltisec{'linkprot'}) eq 'HASH') {
- foreach my $id (%{$currltisec{'linkprot'}}) {
- next if ($id !~ /^\d+$/);
- unless (exists($linkprotchg{$id})) {
- if (ref($currltisec{'linkprot'}{$id}) eq 'HASH') {
- foreach my $inner (keys(%{$currltisec{'linkprot'}{$id}})) {
- if (($inner eq 'secret') || ($inner eq 'key')) {
- if ($is_home) {
- $newltienc{$id}{$inner} = $currltisec{'linkprot'}{$id}{$inner};
- }
- } else {
- $newltisec{'linkprot'}{$id}{$inner} = $currltisec{'linkprot'}{$id}{$inner};
- }
- }
- } else {
- $newltisec{'linkprot'}{$id} = $currltisec{'linkprot'}{$id};
- }
- }
- }
- }
- if ($proterror) {
- $errors .= ''.$proterror.' ';
- }
-
- my ($putresult,%keystore);
- if (keys(%secchanges)) {
- my %ltienchash;
- my %ltihash = (
- 'ltisec' => { %newltisec }
- );
- $putresult = &Apache::lonnet::put_dom('configuration',\%ltihash,$dom);
- if ($putresult eq 'ok') {
- if ($secchanges{'private'}) {
- my $who = &escape($env{'user.name'}.':'.$env{'user.domain'});
- foreach my $hostid (keys(%newkeyset)) {
- my $storehash = {
- key => $newkeyset{$hostid},
- who => $env{'user.name'}.':'.$env{'user.domain'},
- };
- $keystore{$hostid} = &Apache::lonnet::store_dom($storehash,'lti','private',
- $dom,$hostid);
- }
- }
- if (ref($lastactref) eq 'HASH') {
- if (($secchanges{'encrypt'}) || ($secchanges{'private'})) {
- $lastactref->{'domdefaults'} = 1;
- }
- }
- if (($secchanges{'linkprot'}) && ($is_home)) {
- my %ltienchash = (
- 'linkprot' => { %newltienc }
- );
- &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1);
- }
- }
- } else {
- return &mt('No changes made.');
- }
- if ($putresult eq 'ok') {
- $resulttext = &mt('Changes made:').'';
- foreach my $item (keys(%secchanges)) {
- if ($item eq 'encrypt') {
- my %encrypted = (
- crs => {
- on => &mt('Encryption of stored link protection secrets defined in courses enabled'),
- off => &mt('Encryption of stored link protection secrets defined in courses disabled'),
- },
- dom => {
- on => &mt('Encryption of stored link protection secrets defined in domain enabled'),
- off => &mt('Encryption of stored link protection secrets defined in domain disabled'),
- },
- );
- foreach my $type ('crs','dom') {
- my $shown = $encrypted{$type}{'off'};
- if (ref($newltisec{$item}) eq 'HASH') {
- if ($newltisec{$item}{$type}) {
- $shown = $encrypted{$type}{'on'};
- }
- }
- $resulttext .= ''.$shown.' ';
- }
- } elsif ($item eq 'rules') {
- my %titles = &Apache::lonlocal::texthash(
- min => 'Minimum password length',
- max => 'Maximum password length',
- chars => 'Required characters',
- );
- foreach my $rule ('min','max') {
- if ($newltisec{rules}{$rule} eq '') {
- if ($rule eq 'min') {
- $resulttext .= ''.&mt('[_1] not set.',$titles{$rule});
- ' '.&mt('Default of [_1] will be used',
- $Apache::lonnet::passwdmin).' ';
- } else {
- $resulttext .= ''.&mt('[_1] set to none',$titles{$rule}).' ';
- }
- } else {
- $resulttext .= ''.&mt('[_1] set to [_2]',$titles{$rule},$newltisec{rules}{$rule}).' ';
- }
- }
- if (ref($newltisec{'rules'}{'chars'}) eq 'ARRAY') {
- if (@{$newltisec{'rules'}{'chars'}} > 0) {
- my %rulenames = &Apache::lonlocal::texthash(
- uc => 'At least one upper case letter',
- lc => 'At least one lower case letter',
- num => 'At least one number',
- spec => 'At least one non-alphanumeric',
- );
- my $needed = ''.
- join(' ',map {$rulenames{$_} } @{$newltisec{'rules'}{'chars'}}).
- ' ';
- $resulttext .= ''.&mt('[_1] set to: [_2]',$titles{'chars'},$needed).' ';
- } else {
- $resulttext .= ''.&mt('[_1] set to none',$titles{'chars'}).' ';
- }
- } else {
- $resulttext .= ''.&mt('[_1] set to none',$titles{'chars'}).' ';
- }
- } elsif ($item eq 'private') {
- if (keys(%newkeyset)) {
- foreach my $hostid (sort(keys(%newkeyset))) {
- if ($keystore{$hostid} eq 'ok') {
- $resulttext .= ''.&mt('Encryption key for storage of shared secrets saved for [_1]',$hostid).' ';
- }
- }
- }
- } elsif ($item eq 'linkprot') {
- $resulttext .= $linkprotoutput;
- }
- }
- $resulttext .= ' ';
- } else {
- $errors .= ''.&mt('Failed to save changes').' ';
- }
- if ($errors) {
- $resulttext .= &mt('The following errors occurred: ').'';
- }
- return $resulttext;
-}
-
sub modify_autoenroll {
my ($dom,$lastactref,%domconfig) = @_;
my ($resulttext,%changes);
@@ -14084,7 +15451,7 @@ sub modify_contacts {
$contacts_hash{'contacts'}{'overrides'}{$type}{'include'} = $includeloc{$type}.':'.&escape($includestr{$type});
$newsetting{'override_'.$type}{'include'} = $contacts_hash{'contacts'}{'overrides'}{$type}{'include'};
}
- }
+ }
}
}
if (keys(%currsetting) > 0) {
@@ -14534,7 +15901,7 @@ sub modify_contacts {
}
} else {
$resulttext = ''.
- &mt('An error occurred: [_1].',$putresult).' ';
+ &mt('An error occurred: [_1]',$putresult).'';
}
return $resulttext;
}
@@ -14706,7 +16073,6 @@ sub modify_passwords {
}
if ($env{'form.passwords_customfile.filename'} ne '') {
my $servadm = $r->dir_config('lonAdmEMail');
- my $servadm = $r->dir_config('lonAdmEMail');
my ($configuserok,$author_ok,$switchserver) =
&config_check($dom,$confname,$servadm);
my $error;
@@ -14715,12 +16081,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);
}
@@ -15041,7 +16410,7 @@ sub password_rule_changes {
my (@rules,%staticdefaults);
if ($prefix eq 'passwords') {
@rules = ('min','max','numsaved');
- } elsif ($prefix eq 'secrets') {
+ } elsif (($prefix eq 'ltisecrets') || ($prefix eq 'toolsecrets')) {
@rules = ('min','max');
}
$staticdefaults{'min'} = $Apache::lonnet::passwdmin;
@@ -15182,7 +16551,7 @@ sub modify_usercreation {
}
my @authen_contexts = ('author','course','domain');
- my @authtypes = ('int','krb4','krb5','loc');
+ my @authtypes = ('int','krb4','krb5','loc','lti');
my %authhash;
foreach my $item (@authen_contexts) {
my @authallowed = &Apache::loncommon::get_env_multiple('form.'.$item.'_auth');
@@ -15397,7 +16766,6 @@ sub modify_selfcreation {
# Populate $cancreate{'selfcreate'} array reference with types of user, for which self-creation of user accounts
# is permitted.
#
-
my ($emailrules,$emailruleorder) = &Apache::lonnet::inst_userrules($dom,'email');
my (@statuses,%email_rule);
@@ -16375,7 +17743,7 @@ sub modify_defaults {
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def',
'portal_def');
- my @authtypes = ('internal','krb4','krb5','localauth');
+ my @authtypes = ('internal','krb4','krb5','localauth','lti');
foreach my $item (@items) {
$newvalues{$item} = $env{'form.'.$item};
if ($item eq 'auth_def') {
@@ -16644,8 +18012,8 @@ sub modify_defaults {
'').
'';
} else {
- $resulttext .= ''.&mt('No mapping for missing usernames via standard log-in').' ';
- }
+ $resulttext .= ''.&mt('No mapping for missing usernames via standard log-in').' ';
+ }
} else {
$resulttext .= ''.&mt('Mapping for missing usernames via standard log-in deleted').' ';
}
@@ -16660,6 +18028,7 @@ sub modify_defaults {
krb4 => 'krb4',
krb5 => 'krb5',
localauth => 'loc',
+ lti => 'lti',
);
$value = $authnames{$shortauth{$value}};
}
@@ -16732,12 +18101,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);
}
@@ -16889,8 +18261,8 @@ sub modify_scantron {
$resulttext = &mt('No changes made to bubblesheet format settings');
}
if ($errors) {
- $resulttext .= &mt('The following errors occurred: ').'';
+ $resulttext .= ''.&mt('The following errors occurred: ').'
';
}
return $resulttext;
}
@@ -17625,14 +18997,18 @@ sub modify_coursedefaults {
);
my @toggles = ('uselcmath','usejsme','inline_chem','ltiauth');
my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial',
- 'uploadquota_community','uploadquota_textbook','mysqltables_official',
- 'mysqltables_unofficial','mysqltables_community','mysqltables_textbook');
+ 'uploadquota_community','uploadquota_textbook','coursequota_official',
+ 'coursequota_unofficial','coursequota_community','coursequota_textbook',
+ 'mysqltables_official','mysqltables_unofficial','mysqltables_community',
+ 'mysqltables_textbook');
my @types = ('official','unofficial','community','textbook');
my %staticdefaults = (
anonsurvey_threshold => 10,
uploadquota => 500,
+ coursequota => 20,
postsubmit => 60,
mysqltables => 172800,
+ domexttool => 1,
);
my %texoptions = (
MathJax => 'MathJax',
@@ -17677,7 +19053,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};
}
@@ -17689,7 +19065,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;
@@ -17824,6 +19200,47 @@ sub modify_coursedefaults {
$changes{'postsubmit'} = 1;
}
}
+ my (%newdomexttool,%newexttool,%olddomexttool,%oldexttool);
+ map { $newdomexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.domexttool');
+ map { $newexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.exttool');
+ 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;
+ }
+ }
+ }
+ foreach my $type (@types) {
+ unless ($newdomexttool{$type}) {
+ $newdomexttool{$type} = 0;
+ }
+ unless ($newexttool{$type}) {
+ $newexttool{$type} = 0;
+ }
+ if ($newdomexttool{$type} != $olddomexttool{$type}) {
+ $changes{'domexttool'} = 1;
+ }
+ if ($newexttool{$type} != $oldexttool{$type}) {
+ $changes{'exttool'} = 1;
+ }
+ }
+ $defaultshash{'coursedefaults'}{'domexttool'} = \%newdomexttool;
+ $defaultshash{'coursedefaults'}{'exttool'} = \%newexttool;
}
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
$dom);
@@ -17833,7 +19250,8 @@ sub modify_coursedefaults {
if (($changes{'uploadquota'}) || ($changes{'postsubmit'}) ||
($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) ||
($changes{'canclone'}) || ($changes{'mysqltables'}) || ($changes{'texengine'}) ||
- ($changes{'inline_chem'}) || ($changes{'ltiauth'})) {
+ ($changes{'inline_chem'}) || ($changes{'ltiauth'}) || ($changes{'domexttool'}) ||
+ ($changes{'exttool'}) || ($changes{'coursequota'})) {
foreach my $item ('uselcmath','usejsme','inline_chem','texengine','ltiauth') {
if ($changes{$item}) {
$domdefaults{$item}=$defaultshash{'coursedefaults'}{$item};
@@ -17865,6 +19283,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') {
@@ -17877,6 +19302,20 @@ 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};
+ }
+ }
+ }
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
if (ref($lastactref) eq 'HASH') {
@@ -17916,13 +19355,24 @@ sub modify_coursedefaults {
''.&mt('Official courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'official'}.' ').' '.
''.&mt('Unofficial courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'unofficial'}.' ').' '.
''.&mt('Textbook courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'textbook'}.' ').' '.
-
''.&mt('Communities: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'community'}.' ').' '.
' '.
'';
} 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('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').''.
@@ -18005,6 +19455,34 @@ sub modify_coursedefaults {
} else {
$resulttext .= ''.&mt('LTI launch of deep-linked URL will require re-authentication').' ';
}
+ } elsif ($item eq 'domexttool') {
+ my @noyes = (&mt('no'),&mt('yes'));
+ if (ref($defaultshash{'coursedefaults'}{'domexttool'}) eq 'HASH') {
+ $resulttext .= ''.&mt('External Tools defined in the domain may be used as follows:').''.
+ ''.&mt('Official courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'official'}].' ').' '.
+ ''.&mt('Unofficial courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'unofficial'}].' ').' '.
+ ''.&mt('Textbook courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'textbook'}].' ').' '.
+ ''.&mt('Placement tests: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'placement'}].' ').' '.
+ ''.&mt('Communities: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'community'}].' ').' '.
+ ' '.
+ ' ';
+ } else {
+ $resulttext .= ''.&mt('External Tools defined in the domain may be used in all course types, by default').' ';
+ }
+ } elsif ($item eq 'exttool') {
+ my @noyes = (&mt('no'),&mt('yes'));
+ if (ref($defaultshash{'coursedefaults'}{'exttool'}) eq 'HASH') {
+ $resulttext .= ''.&mt('External Tools can be defined and configured in course containers as follows:').''.
+ ''.&mt('Official courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'official'}].' ').' '.
+ ''.&mt('Unofficial courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'unofficial'}].' ').' '.
+ ''.&mt('Textbook courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'textbook'}].' ').' '.
+ ''.&mt('Placement tests: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'placement'}].' ').' '.
+ ''.&mt('Communities: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'community'}].' ').' '.
+ ' '.
+ ' ';
+ } else {
+ $resulttext .= ''.&mt('External Tools can not be defined in any course types, by default').' ';
+ }
}
}
$resulttext .= ' ';
@@ -18563,6 +20041,7 @@ sub modify_wafproxy {
}
}
}
+ $output .= '';
} else {
$output = ''.
&mt('An error occurred: [_1]',$putresult).' ';
@@ -18916,7 +20395,7 @@ sub modify_usersessions {
}
} else {
if ($type eq 'version') {
- $newvalue .= ' '.&mt('(or later)');
+ $newvalue .= ' '.&mt('(or later)');
}
$resulttext .= ' '.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).' ';
}
@@ -19799,7 +21278,7 @@ function updateNewSpares(formname,lonhos
function checkNewSpares(lonhost,type) {
var newSpare = document.getElementById('newspare_'+type+'_'+lonhost);
var chosen = newSpare.options[newSpare.selectedIndex].value;
- if (chosen != '') {
+ if (chosen != '') {
var othertype;
var othernewSpare;
if (type == 'primary') {
@@ -19933,7 +21412,7 @@ function toggleDisplay(domForm,caller) {
var dispval = 'block';
var selfcreateRegExp = /^cancreate_emailverified/;
if (caller == 'emailoptions') {
- optionsElement = domForm.cancreate_email;
+ optionsElement = domForm.cancreate_email;
}
if (caller == 'studentsubmission') {
optionsElement = domForm.postsubmit;