'.$domservers{$lonhost}.' '.
' '.
&mt('Yes').' '.
''.
- ''.&mt('SSO').' '.
+ ' '.
- ''.
' ';
@@ -1800,7 +1727,7 @@ sub print_rolecolors {
my %choices = &color_font_choices();
my @bgs = ('pgbg','tabbg','sidebg');
my @links = ('link','alink','vlink');
- my @images = ('img');
+ my @images = ();
my %alt_text = &Apache::lonlocal::texthash(img => "Banner for $role role");
my %designhash = &Apache::loncommon::get_domainconf($dom);
my %defaultdesign = %Apache::loncommon::defaultdesign;
@@ -1808,10 +1735,6 @@ sub print_rolecolors {
my %defaults = &role_defaults($role,\@bgs,\@links,\@images);
if (ref($settings) eq 'HASH') {
if (ref($settings->{$role}) eq 'HASH') {
- if ($settings->{$role}->{'img'} ne '') {
- $designs{'img'} = $settings->{$role}->{'img'};
- $is_custom{'img'} = 1;
- }
if ($settings->{$role}->{'font'} ne '') {
$designs{'font'} = $settings->{$role}->{'font'};
$is_custom{'font'} = 1;
@@ -1834,10 +1757,6 @@ sub print_rolecolors {
}
}
} else {
- if ($designhash{$dom.'.'.$role.'.img'} ne '') {
- $designs{img} = $designhash{$dom.'.'.$role.'.img'};
- $is_custom{'img'} = 1;
- }
if ($designhash{$dom.'.'.$role.'.fontmenu'} ne '') {
$designs{fontmenu} = $designhash{$dom.'.'.$role.'.fontmenu'};
$is_custom{'fontmenu'} = 1;
@@ -1887,7 +1806,6 @@ sub role_defaults {
}
} else {
%defaults = (
- img => $defaultdesign{$role.'.img'},
font => $defaultdesign{$role.'.font'},
fontmenu => $defaultdesign{$role.'.fontmenu'},
);
@@ -1952,7 +1870,7 @@ sub display_color_options {
$logincolors =
&login_text_colors($img,$role,$logintext,$phase,$choices,
$designs,$defaults);
- } else {
+ } else {
if ($img ne 'domlogo') {
$datatable.= &logo_display_options($img,$defaults,$designs);
}
@@ -2226,7 +2144,7 @@ sub print_quotas {
@options = ('norequest','approval','automatic');
%titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','webdav','portfolio','timezone');
+ @usertools = ('aboutme','blog','webdav','portfolio');
%titles = &tool_titles();
}
if (ref($types) eq 'ARRAY') {
@@ -2330,12 +2248,9 @@ sub print_quotas {
}
} else {
my $checked = 'checked="checked" ';
- if ($item eq 'timezone') {
- $checked = '';
- }
if (ref($settings) eq 'HASH') {
if (ref($settings->{$item}) eq 'HASH') {
- if (!$settings->{$item}->{$type}) {
+ if ($settings->{$item}->{$type} == 0) {
$checked = '';
} elsif ($settings->{$item}->{$type} == 1) {
$checked = 'checked="checked" ';
@@ -2934,108 +2849,6 @@ $jstext{'templates'};
ENDSCRIPT
}
-sub ltitools_javascript {
- my ($settings) = @_;
- my $togglejs = <itools_toggle_js();
- unless (ref($settings) eq 'HASH') {
- return $togglejs;
- }
- my (%ordered,$total,%jstext);
- $total = 0;
- foreach my $item (keys(%{$settings})) {
- if (ref($settings->{$item}) eq 'HASH') {
- my $num = $settings->{$item}{'order'};
- $ordered{$num} = $item;
- }
- }
- $total = scalar(keys(%{$settings}));
- my @jsarray = ();
- foreach my $item (sort {$a <=> $b } (keys(%ordered))) {
- push(@jsarray,$ordered{$item});
- }
- my $jstext = ' var ltitools = Array('."'".join("','",@jsarray)."'".');'."\n";
- return <<"ENDSCRIPT";
-
-
-$togglejs
-
-ENDSCRIPT
-}
-
-sub ltitools_toggle_js {
- return <<"ENDSCRIPT";
-
-
-ENDSCRIPT
-}
-
sub wafproxy_javascript {
my ($dom) = @_;
return <<"ENDSCRIPT";
@@ -3151,140 +2964,6 @@ function toggleWAF() {
ENDSCRIPT
}
-sub lti_javascript {
- my ($dom,$settings) = @_;
- my $togglejs = <i_toggle_js($dom);
- my $linkprot_js = &Apache::courseprefs::linkprot_javascript();
- return <<"ENDSCRIPT";
-
-
-$togglejs
-
-ENDSCRIPT
-}
-
-sub lti_toggle_js {
- my ($dom) = @_;
- my %servers = &Apache::lonnet::get_servers($dom,'library');
- my $primary = &Apache::lonnet::domain($dom,'primary');
- my $course_servers = "'".join("','",keys(%servers))."'";
- return <<"ENDSCRIPT";
-
-
-ENDSCRIPT
-}
-
sub autoupdate_javascript {
return <<"ENDSCRIPT";
-
-ENDSCRIPT
- } else {
-return <<"ENDSCRIPT";
-
@@ -9411,26 +8451,17 @@ ENDSCRIPT
}
sub passwords_javascript {
- my ($prefix) = @_;
- my %intalert;
- if ($prefix eq 'passwords') {
- %intalert = &Apache::lonlocal::texthash (
- authcheck => 'Warning: disallowing login for an authenticated user if the stored cost is less than the default will require a password reset by/for the user.',
- authcost => 'Warning: bcrypt encryption cost for internal authentication must be an integer.',
- passmin => 'Warning: minimum password length must be a positive integer greater than 6.',
- 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') {
- %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).',
- );
- }
+ my %intalert = &Apache::lonlocal::texthash (
+ authcheck => 'Warning: disallowing login for an authenticated user if the stored cost is less than the default will require a password reset by/for the user.',
+ authcost => 'Warning: bcrypt encryption cost for internal authentication must be an integer.',
+ passmin => 'Warning: minimum password length must be a positive integer greater than 6.',
+ passmax => 'Warning: maximum password length must be a positive integer (or blank).',
+ passexp => 'Warning: days before password expiration must be a positive integer (or blank).',
+ passnum => 'Warning: number of previous passwords to save must be a positive integer (or blank).',
+ );
&js_escape(\%intalert);
my $defmin = $Apache::lonnet::passwdmin;
- my $intauthjs;
- if ($prefix eq 'passwords') { $intauthjs = <<"ENDSCRIPT";
+ my $intauthjs = <<"ENDSCRIPT";
function warnIntAuth(field) {
if (field.name == 'intauth_check') {
@@ -9450,17 +8481,11 @@ function warnIntAuth(field) {
return;
}
-ENDSCRIPT
-
- }
-
- $intauthjs .= <<"ENDSCRIPT";
-
-function warnInt$prefix(field) {
+function warnIntPass(field) {
field.value.replace(/^\s+/,'');
field.value.replace(/\s+\$/,'');
var regexdigit=/^\\d+\$/;
- if (field.name == '${prefix}_min') {
+ if (field.name == 'passwords_min') {
if (field.value == '') {
alert('$intalert{passmin}');
field.value = '$defmin';
@@ -9480,15 +8505,29 @@ function warnInt$prefix(field) {
field.value = '';
}
if (field.value != '') {
- if (!regexdigit.test(field.value)) {
- if (field.name == '${prefix}_max') {
- alert('$intalert{passmax}');
+ if (field.name == 'passwords_expire') {
+ var regexpposnum=/^\\d+(|\\.\\d*)\$/;
+ if (!regexpposnum.test(field.value)) {
+ alert('$intalert{passexp}');
+ field.value = '';
} else {
- if (field.name == '${prefix}_numsaved') {
- alert('$intalert{passnum}');
+ var expval = parseFloat(field.value);
+ if (expval == 0) {
+ alert('$intalert{passexp}');
+ field.value = '';
+ }
+ }
+ } else {
+ if (!regexdigit.test(field.value)) {
+ if (field.name == 'passwords_max') {
+ alert('$intalert{passmax}');
+ } else {
+ if (field.name == 'passwords_numsaved') {
+ alert('$intalert{passnum}');
+ }
}
+ field.value = '';
}
- field.value = '';
}
}
}
@@ -10067,7 +9106,7 @@ sub modify_login {
my ($r,$dom,$confname,$lastactref,%domconfig) = @_;
my ($resulttext,$errors,$colchgtext,%changes,%colchanges,%newfile,%newurl,
%curr_loginvia,%loginhash,@currlangs,@newlangs,$addedfile,%title,@offon,
- %currsaml,%saml,%samltext,%samlimg,%samlalt,%samlurl,%samltitle,%samlwindow,%samlnotsso);
+ %currsaml,%saml,%samltext,%samlimg,%samlalt,%samlurl,%samltitle,%samlnotsso);
%title = ( coursecatalog => 'Display course catalog',
adminmail => 'Display administrator E-mail address',
helpdesk => 'Display "Contact Helpdesk" link',
@@ -10091,7 +9130,6 @@ sub modify_login {
$samlalt{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'alt'};
$samlimg{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'img'};
$samltitle{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'title'};
- $samlwindow{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'window'};
$samlnotsso{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'notsso'};
}
}
@@ -10349,13 +9387,10 @@ sub modify_login {
if ($env{'form.saml_img_'.$lonhost.'.filename'}) {
push(@newsamlimgs,$lonhost);
}
- foreach my $item ('text','alt','url','title','window','notsso') {
+ foreach my $item ('text','alt','url','title','notsso') {
$env{'form.saml_'.$item.'_'.$lonhost} =~ s/^\s+|\s+$//g;
}
if ($saml{$lonhost}) {
- if ($env{'form.saml_window_'.$lonhost} ne '1') {
- $env{'form.saml_window_'.$lonhost} = '';
- }
if (grep(/^\Q$lonhost\E$/,@delsamlimg)) {
#FIXME Need to obsolete published image
delete($currsaml{$lonhost}{'img'});
@@ -10373,16 +9408,13 @@ sub modify_login {
if ($env{'form.saml_title_'.$lonhost} ne $samltitle{$lonhost}) {
$changes{'saml'}{$lonhost} = 1;
}
- if ($env{'form.saml_window_'.$lonhost} ne $samlwindow{$lonhost}) {
- $changes{'saml'}{$lonhost} = 1;
- }
if ($env{'form.saml_notsso_'.$lonhost} ne $samlnotsso{$lonhost}) {
$changes{'saml'}{$lonhost} = 1;
}
} else {
$changes{'saml'}{$lonhost} = 1;
}
- foreach my $item ('text','alt','url','title','window','notsso') {
+ foreach my $item ('text','alt','url','title','notsso') {
$currsaml{$lonhost}{$item} = $env{'form.saml_'.$item.'_'.$lonhost};
}
} else {
@@ -10583,22 +9615,19 @@ sub modify_login {
alt => 'Alt text for button image',
url => 'SSO URL',
title => 'Tooltip for SSO link',
- window => 'Pop-up window if iframe',
notsso => 'Text for non-SSO log-in',
);
foreach my $lonhost (sort(keys(%{$changes{$item}}))) {
if (ref($currsaml{$lonhost}) eq 'HASH') {
$resulttext .= ''.&mt("$title{$item} in use for [_1]","$lonhost ").
'';
- foreach my $key ('text','img','alt','url','title','window','notsso') {
+ foreach my $key ('text','img','alt','url','title','notsso') {
if ($currsaml{$lonhost}{$key} eq '') {
$resulttext .= ''.&mt("$notlt{$key} not in use").' ';
} else {
my $value = "'$currsaml{$lonhost}{$key}'";
if ($key eq 'img') {
$value = ' ';
- } elsif ($key eq 'window') {
- $value = 'On';
}
$resulttext .= ''.&mt("$notlt{$key} set to: [_1]",
$value).' ';
@@ -10696,7 +9725,6 @@ sub check_exempt_addresses {
sub color_font_choices {
my %choices =
&Apache::lonlocal::texthash (
- img => "Header",
bgs => "Background colors",
links => "Link colors",
images => "Images",
@@ -11045,11 +10073,15 @@ sub modify_colors {
@images = ('img','logo','domlogo','login');
@bgs = ('pgbg','mainbg','sidebg');
} else {
- @images = ('img');
+ @images = ();
@bgs = ('pgbg','tabbg','sidebg');
}
my %defaults = &role_defaults($role,\@bgs,\@links,\@images,\@logintext);
- unless ($env{'form.'.$role.'_font'} eq $defaults{'font'}) {
+ $env{'form.'.$role.'_font'} = lc($env{'form.'.$role.'_font'});
+ if ($env{'form.'.$role.'_font'} =~ /^\w+/) {
+ $env{'form.'.$role.'_font'} = '#'.$env{'form.'.$role.'_font'};
+ }
+ unless ($env{'form.'.$role.'_font'} eq lc($defaults{'font'})) {
$confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
}
if ($role eq 'login') {
@@ -11067,7 +10099,7 @@ sub modify_colors {
if ($env{'form.'.$role.'_fontmenu'} =~ /^\w+/) {
$env{'form.'.$role.'_fontmenu'} = '#'.$env{'form.'.$role.'_fontmenu'};
}
- unless($env{'form.'.$role.'_fontmenu'} eq lc($defaults{'fontmenu'})) {
+ unless ($env{'form.'.$role.'_fontmenu'} eq lc($defaults{'fontmenu'})) {
$confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
}
}
@@ -11096,7 +10128,7 @@ sub modify_colors {
$domconfig->{$role} = {};
}
foreach my $img (@images) {
- if ($role eq 'login') {
+ if ($role eq 'login') {
if (($img eq 'img') || ($img eq 'logo')) {
if (defined($env{'form.login_showlogo_'.$img})) {
$confhash->{$role}{'showlogo'}{$img} = 1;
@@ -11762,7 +10794,7 @@ sub modify_quotas {
@usertools = ('author');
%titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','webdav','portfolio','timezone');
+ @usertools = ('aboutme','blog','webdav','portfolio');
%titles = &tool_titles();
}
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
@@ -12416,6 +11448,7 @@ sub modify_quotas {
$resulttext .= ''.&mt('Validated course requests identified as processed by: [_1]',
''.$changes{'validation'}{'dc'}.' ').' ';
}
+ $resulttext .= ' ';
}
}
}
@@ -12470,861 +11503,6 @@ sub process_textbook_image {
return ($url,$error);
}
-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 $confname = $dom.'-domainconfig';
- my $servadm = $r->dir_config('lonAdmEMail');
- my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);
- my (%posslti,%possfield);
- my @courseroles = ('cc','in','ta','ep','st');
- my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
- map { $posslti{$_} = 1; } @ltiroles;
- my @allfields = ('fullname','firstname','lastname','email','user','roles');
- map { $possfield{$_} = 1; } @allfields;
- my %lt = <itools_names();
- if ($env{'form.ltitools_add'}) {
- my $title = $env{'form.ltitools_add_title'};
- $title =~ s/(`)/'/g;
- ($newid,my $error) = &get_ltitools_id($dom,$title);
- if ($newid) {
- my $position = $env{'form.ltitools_add_pos'};
- $position =~ s/\D+//g;
- if ($position ne '') {
- $allpos[$position] = $newid;
- }
- $changes{$newid} = 1;
- foreach my $item ('title','url','key','secret','lifetime') {
- $env{'form.ltitools_add_'.$item} =~ s/(`)/'/g;
- if ($item eq 'lifetime') {
- $env{'form.ltitools_add_'.$item} =~ s/[^\d.]//g;
- }
- if ($env{'form.ltitools_add_'.$item}) {
- if (($item eq 'key') || ($item eq 'secret')) {
- $encconfig{$newid}{$item} = $env{'form.ltitools_add_'.$item};
- } else {
- $confhash{$newid}{$item} = $env{'form.ltitools_add_'.$item};
- }
- }
- }
- if ($env{'form.ltitools_add_version'} eq 'LTI-1p0') {
- $confhash{$newid}{'version'} = $env{'form.ltitools_add_version'};
- }
- if ($env{'form.ltitools_add_msgtype'} eq 'basic-lti-launch-request') {
- $confhash{$newid}{'msgtype'} = $env{'form.ltitools_add_msgtype'};
- }
- if ($env{'form.ltitools_add_sigmethod'} eq 'HMAC-SHA256') {
- $confhash{$newid}{'sigmethod'} = $env{'form.ltitools_add_sigmethod'};
- } else {
- $confhash{$newid}{'sigmethod'} = 'HMAC-SHA1';
- }
- foreach my $item ('width','height','linktext','explanation') {
- $env{'form.ltitools_add_'.$item} =~ s/^\s+//;
- $env{'form.ltitools_add_'.$item} =~ s/\s+$//;
- if (($item eq 'width') || ($item eq 'height')) {
- if ($env{'form.ltitools_add_'.$item} =~ /^\d+$/) {
- $confhash{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
- }
- } else {
- if ($env{'form.ltitools_add_'.$item} ne '') {
- $confhash{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
- }
- }
- }
- if ($env{'form.ltitools_add_target'} eq 'window') {
- $confhash{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
- } elsif ($env{'form.ltitools_add_target'} eq 'tab') {
- $confhash{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
- } else {
- $confhash{$newid}{'display'}{'target'} = 'iframe';
- }
- if ($env{'form.ltitools_add_image.filename'} ne '') {
- my ($imageurl,$error) =
- &process_ltitools_image($r,$dom,$confname,'ltitools_add_image',$newid,
- $configuserok,$switchserver,$author_ok);
- if ($imageurl) {
- $confhash{$newid}{'image'} = $imageurl;
- }
- if ($error) {
- &Apache::lonnet::logthis($error);
- $errors .= ''.$error.' ';
- }
- }
- my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_add_fields');
- foreach my $field (@fields) {
- if ($possfield{$field}) {
- if ($field eq 'roles') {
- foreach my $role (@courseroles) {
- my $choice = $env{'form.ltitools_add_roles_'.$role};
- if (($choice ne '') && ($posslti{$choice})) {
- $confhash{$newid}{'roles'}{$role} = $choice;
- if ($role eq 'cc') {
- $confhash{$newid}{'roles'}{'co'} = $choice;
- }
- }
- }
- } else {
- $confhash{$newid}{'fields'}{$field} = 1;
- }
- }
- }
- if (ref($confhash{$newid}{'fields'}) eq 'HASH') {
- if ($confhash{$newid}{'fields'}{'user'}) {
- if ($env{'form.ltitools_userincdom_add'}) {
- $confhash{$newid}{'incdom'} = 1;
- }
- }
- }
- my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig');
- foreach my $item (@courseconfig) {
- $confhash{$newid}{'crsconf'}{$item} = 1;
- }
- if ($env{'form.ltitools_add_custom'}) {
- my $name = $env{'form.ltitools_add_custom_name'};
- my $value = $env{'form.ltitools_add_custom_value'};
- $value =~ s/(`)/'/g;
- $name =~ s/(`)/'/g;
- $confhash{$newid}{'custom'}{$name} = $value;
- }
- } else {
- my $error = &mt('Failed to acquire unique ID for new external tool');
- $errors .= ''.$error.' ';
- }
- }
- if (ref($domconfig{$action}) eq 'HASH') {
- my %deletions;
- my @todelete = &Apache::loncommon::get_env_multiple('form.ltitools_del');
- if (@todelete) {
- map { $deletions{$_} = 1; } @todelete;
- }
- my %customadds;
- my @newcustom = &Apache::loncommon::get_env_multiple('form.ltitools_customadd');
- if (@newcustom) {
- map { $customadds{$_} = 1; } @newcustom;
- }
- my %imgdeletions;
- my @todeleteimages = &Apache::loncommon::get_env_multiple('form.ltitools_image_del');
- if (@todeleteimages) {
- map { $imgdeletions{$_} = 1; } @todeleteimages;
- }
- my $maxnum = $env{'form.ltitools_maxnum'};
- for (my $i=0; $i<=$maxnum; $i++) {
- my $itemid = $env{'form.ltitools_id_'.$i};
- $itemid =~ s/\D+//g;
- if (ref($domconfig{$action}{$itemid}) eq 'HASH') {
- if ($deletions{$itemid}) {
- if ($domconfig{$action}{$itemid}{'image'}) {
- #FIXME need to obsolete item in RES space
- }
- $changes{$itemid} = $domconfig{$action}{$itemid}{'title'};
- next;
- } else {
- my $newpos = $env{'form.ltitools_'.$itemid};
- $newpos =~ s/\D+//g;
- foreach my $item ('title','url','lifetime') {
- $confhash{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
- if ($domconfig{$action}{$itemid}{$item} ne $confhash{$itemid}{$item}) {
- $changes{$itemid} = 1;
- }
- }
- foreach my $item ('key','secret') {
- $encconfig{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
- if ($domconfig{$action}{$itemid}{$item} ne $encconfig{$itemid}{$item}) {
- $changes{$itemid} = 1;
- }
- }
- if ($env{'form.ltitools_version_'.$i} eq 'LTI-1p0') {
- $confhash{$itemid}{'version'} = $env{'form.ltitools_version_'.$i};
- }
- if ($env{'form.ltitools_msgtype_'.$i} eq 'basic-lti-launch-request') {
- $confhash{$itemid}{'msgtype'} = $env{'form.ltitools_msgtype_'.$i};
- }
- if ($env{'form.ltitools_sigmethod_'.$i} eq 'HMAC-SHA256') {
- $confhash{$itemid}{'sigmethod'} = $env{'form.ltitools_sigmethod_'.$i};
- } else {
- $confhash{$itemid}{'sigmethod'} = 'HMAC-SHA1';
- }
- if ($domconfig{$action}{$itemid}{'sigmethod'} eq '') {
- if ($confhash{$itemid}{'sigmethod'} ne 'HMAC-SHA1') {
- $changes{$itemid} = 1;
- }
- } elsif ($domconfig{$action}{$itemid}{'sigmethod'} ne $confhash{$itemid}{'sigmethod'}) {
- $changes{$itemid} = 1;
- }
- foreach my $size ('width','height') {
- $env{'form.ltitools_'.$size.'_'.$i} =~ s/^\s+//;
- $env{'form.ltitools_'.$size.'_'.$i} =~ s/\s+$//;
- if ($env{'form.ltitools_'.$size.'_'.$i} =~ /^\d+$/) {
- $confhash{$itemid}{'display'}{$size} = $env{'form.ltitools_'.$size.'_'.$i};
- if (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{$size} ne $confhash{$itemid}{'display'}{$size}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- } elsif (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{$size} ne '') {
- $changes{$itemid} = 1;
- }
- }
- }
- foreach my $item ('linktext','explanation') {
- $env{'form.ltitools_'.$item.'_'.$i} =~ s/^\s+//;
- $env{'form.ltitools_'.$item.'_'.$i} =~ s/\s+$//;
- if ($env{'form.ltitools_'.$item.'_'.$i} ne '') {
- $confhash{$itemid}{'display'}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
- if (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{$item} ne $confhash{$itemid}{'display'}{$item}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- } elsif (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{$item} ne '') {
- $changes{$itemid} = 1;
- }
- }
- }
- if ($env{'form.ltitools_target_'.$i} eq 'window') {
- $confhash{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
- } elsif ($env{'form.ltitools_target_'.$i} eq 'tab') {
- $confhash{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
- } else {
- $confhash{$itemid}{'display'}{'target'} = 'iframe';
- }
- if (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{'target'} ne $confhash{$itemid}{'display'}{'target'}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig_'.$i);
- foreach my $item ('label','title','target','linktext','explanation','append') {
- if (grep(/^\Q$item\E$/,@courseconfig)) {
- $confhash{$itemid}{'crsconf'}{$item} = 1;
- if (ref($domconfig{$action}{$itemid}{'crsconf'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'crsconf'}{$item} ne $confhash{$itemid}{'crsconf'}{$item}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- }
- }
- my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_fields_'.$i);
- foreach my $field (@fields) {
- if ($possfield{$field}) {
- if ($field eq 'roles') {
- foreach my $role (@courseroles) {
- my $choice = $env{'form.ltitools_roles_'.$role.'_'.$i};
- if (($choice ne '') && ($posslti{$choice})) {
- $confhash{$itemid}{'roles'}{$role} = $choice;
- if ($role eq 'cc') {
- $confhash{$itemid}{'roles'}{'co'} = $choice;
- }
- }
- if (ref($domconfig{$action}{$itemid}{'roles'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'roles'}{$role} ne $confhash{$itemid}{'roles'}{$role}) {
- $changes{$itemid} = 1;
- }
- } elsif ($confhash{$itemid}{'roles'}{$role}) {
- $changes{$itemid} = 1;
- }
- }
- } else {
- $confhash{$itemid}{'fields'}{$field} = 1;
- if (ref($domconfig{$action}{$itemid}{'fields'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'fields'}{$field} ne $confhash{$itemid}{'fields'}{$field}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- }
- }
- }
- if (ref($confhash{$itemid}{'fields'}) eq 'HASH') {
- if ($confhash{$itemid}{'fields'}{'user'}) {
- if ($env{'form.ltitools_userincdom_'.$i}) {
- $confhash{$itemid}{'incdom'} = 1;
- }
- if ($domconfig{$action}{$itemid}{'incdom'} ne $confhash{$itemid}{'incdom'}) {
- $changes{$itemid} = 1;
- }
- }
- }
- $allpos[$newpos] = $itemid;
- }
- if ($imgdeletions{$itemid}) {
- $changes{$itemid} = 1;
- #FIXME need to obsolete item in RES space
- } elsif ($env{'form.ltitools_image_'.$i.'.filename'}) {
- my ($imgurl,$error) = &process_ltitools_image($r,$dom,$confname,'ltitools_image_'.$i,
- $itemid,$configuserok,$switchserver,
- $author_ok);
- if ($imgurl) {
- $confhash{$itemid}{'image'} = $imgurl;
- $changes{$itemid} = 1;
- }
- if ($error) {
- &Apache::lonnet::logthis($error);
- $errors .= ''.$error.' ';
- }
- } elsif ($domconfig{$action}{$itemid}{'image'}) {
- $confhash{$itemid}{'image'} =
- $domconfig{$action}{$itemid}{'image'};
- }
- if ($customadds{$i}) {
- my $name = $env{'form.ltitools_custom_name_'.$i};
- $name =~ s/(`)/'/g;
- $name =~ s/^\s+//;
- $name =~ s/\s+$//;
- my $value = $env{'form.ltitools_custom_value_'.$i};
- $value =~ s/(`)/'/g;
- $value =~ s/^\s+//;
- $value =~ s/\s+$//;
- if ($name ne '') {
- $confhash{$itemid}{'custom'}{$name} = $value;
- $changes{$itemid} = 1;
- }
- }
- my %customdels;
- my @customdeletions = &Apache::loncommon::get_env_multiple('form.ltitools_customdel_'.$i);
- if (@customdeletions) {
- $changes{$itemid} = 1;
- }
- map { $customdels{$_} = 1; } @customdeletions;
- if (ref($domconfig{$action}{$itemid}{'custom'}) eq 'HASH') {
- foreach my $key (keys(%{$domconfig{$action}{$itemid}{'custom'}})) {
- unless ($customdels{$key}) {
- if ($env{'form.ltitools_customval_'.$key.'_'.$i} ne '') {
- $confhash{$itemid}{'custom'}{$key} = $env{'form.ltitools_customval_'.$key.'_'.$i};
- }
- if ($domconfig{$action}{$itemid}{'custom'}{$key} ne $env{'form.ltitools_customval_'.$key.'_'.$i}) {
- $changes{$itemid} = 1;
- }
- }
- }
- }
- unless ($changes{$itemid}) {
- foreach my $key (keys(%{$domconfig{$action}{$itemid}})) {
- if (ref($domconfig{$action}{$itemid}{$key}) eq 'HASH') {
- if (ref($confhash{$itemid}{$key}) eq 'HASH') {
- foreach my $innerkey (keys(%{$domconfig{$action}{$itemid}{$key}})) {
- unless (exists($confhash{$itemid}{$key}{$innerkey})) {
- $changes{$itemid} = 1;
- last;
- }
- }
- } elsif (keys(%{$domconfig{$action}{$itemid}{$key}}) > 0) {
- $changes{$itemid} = 1;
- }
- }
- last if ($changes{$itemid});
- }
- }
- }
- }
- }
- if (@allpos > 0) {
- my $idx = 0;
- foreach my $itemid (@allpos) {
- if ($itemid ne '') {
- $confhash{$itemid}{'order'} = $idx;
- if (ref($domconfig{$action}) eq 'HASH') {
- if (ref($domconfig{$action}{$itemid}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'order'} ne $idx) {
- $changes{$itemid} = 1;
- }
- }
- }
- $idx ++;
- }
- }
- }
- my %ltitoolshash = (
- $action => { %confhash }
- );
- my $putresult = &Apache::lonnet::put_dom('configuration',\%ltitoolshash,
- $dom);
- if ($putresult eq 'ok') {
- my %ltienchash = (
- $action => { %encconfig }
- );
- &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1);
- if (keys(%changes) > 0) {
- my $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);
- if (ref($lastactref) eq 'HASH') {
- $lastactref->{'ltitools'} = 1;
- }
- $resulttext = &mt('Changes made:').'';
- my %bynum;
- foreach my $itemid (sort(keys(%changes))) {
- 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 .= '';
- my $position = $pos + 1;
- $resulttext .= ''.&mt('Order: [_1]',$position).' ';
- foreach my $item ('version','msgtype','sigmethod','url','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 (!$numconfig) {
- $resulttext .= &mt('None');
- }
- $resulttext .= ' ';
- if (ref($confhash{$itemid}{'display'}) eq 'HASH') {
- my $displaylist;
- if ($confhash{$itemid}{'display'}{'target'}) {
- $displaylist = &mt('Display target').': '.
- $confhash{$itemid}{'display'}{'target'}.',';
- }
- foreach my $size ('width','height') {
- if ($confhash{$itemid}{'display'}{$size}) {
- $displaylist .= (' 'x2).$lt{$size}.': '.
- $confhash{$itemid}{'display'}{$size}.',';
- }
- }
- if ($displaylist) {
- $displaylist =~ s/,$//;
- $resulttext .= ''.$displaylist.' ';
- }
- foreach my $item ('linktext','explanation') {
- if ($confhash{$itemid}{'display'}{$item}) {
- $resulttext .= ''.$lt{$item}.': '.$confhash{$itemid}{'display'}{$item}.' ';
- }
- }
- }
- if (ref($confhash{$itemid}{'fields'}) eq 'HASH') {
- my $fieldlist;
- foreach my $field (@allfields) {
- if ($confhash{$itemid}{'fields'}{$field}) {
- $fieldlist .= (' 'x2).$lt{$field}.',';
- }
- }
- if ($fieldlist) {
- $fieldlist =~ s/,$//;
- if ($confhash{$itemid}{'fields'}{'user'}) {
- if ($confhash{$itemid}{'incdom'}) {
- $fieldlist .= ' ('.&mt('username:domain').')';
- } else {
- $fieldlist .= ' ('.&mt('username').')';
- }
- }
- $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 ($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 ($customlist) {
- $resulttext .= ''.&mt('Custom items').': '.$customlist.' ';
- }
- }
- $resulttext .= ' ';
- }
- }
- $resulttext .= ' ';
- } else {
- $resulttext = &mt('No changes made.');
- }
- } else {
- $errors .= ''.&mt('Failed to save changes').' ';
- }
- if ($errors) {
- $resulttext .= &mt('The following errors occurred: ').'';
- }
- 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);
- }
- } 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);
-}
-
-sub get_ltitools_id {
- my ($cdom,$title) = @_;
- # get lock on ltitools db
- my $lockhash = {
- lock => $env{'user.name'}.
- ':'.$env{'user.domain'},
- };
- my $tries = 0;
- my $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom);
- my ($id,$error);
-
- while (($gotlock ne 'ok') && ($tries<10)) {
- $tries ++;
- sleep (0.1);
- $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom);
- }
- if ($gotlock eq 'ok') {
- my %currids = &Apache::lonnet::dump_dom('ltitools',$cdom);
- if ($currids{'lock'}) {
- delete($currids{'lock'});
- if (keys(%currids)) {
- my @curr = sort { $a <=> $b } keys(%currids);
- if ($curr[-1] =~ /^\d+$/) {
- $id = 1 + $curr[-1];
- }
- } else {
- $id = 1;
- }
- if ($id) {
- unless (&Apache::lonnet::newput_dom('ltitools',{ $id => $title },$cdom) eq 'ok') {
- $error = 'nostore';
- }
- } else {
- $error = 'nonumber';
- }
- }
- my $dellockoutcome = &Apache::lonnet::del_dom('ltitools',['lock'],$cdom);
- } 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);
@@ -14773,7 +12951,56 @@ sub modify_passwords {
$updatedefaults = 1;
}
}
- &password_rule_changes('passwords',\%newvalues,\%current,\%changes);
+ foreach my $rule ('min','max','numsaved') {
+ $env{'form.passwords_'.$rule} =~ s/^\s+|\s+$//g;
+ my $ruleok;
+ if ($rule eq 'min') {
+ if ($env{'form.passwords_'.$rule} =~ /^\d+$/) {
+ if ($env{'form.passwords_'.$rule} >= $Apache::lonnet::passwdmin) {
+ $ruleok = 1;
+ }
+ }
+ } elsif (($env{'form.passwords_'.$rule} =~ /^\d+$/) &&
+ ($env{'form.passwords_'.$rule} ne '0')) {
+ $ruleok = 1;
+ }
+ if ($ruleok) {
+ $newvalues{$rule} = $env{'form.passwords_'.$rule};
+ if (exists($current{$rule})) {
+ if ($newvalues{$rule} ne $current{$rule}) {
+ $changes{'rules'} = 1;
+ }
+ } elsif ($rule eq 'min') {
+ if ($staticdefaults{$rule} ne $newvalues{$rule}) {
+ $changes{'rules'} = 1;
+ }
+ } else {
+ $changes{'rules'} = 1;
+ }
+ } elsif (exists($current{$rule})) {
+ $changes{'rules'} = 1;
+ }
+ }
+ my @posschars = &Apache::loncommon::get_env_multiple('form.passwords_chars');
+ my @chars;
+ foreach my $item (sort(@posschars)) {
+ if ($item =~ /^(uc|lc|num|spec)$/) {
+ push(@chars,$item);
+ }
+ }
+ $newvalues{'chars'} = \@chars;
+ unless ($changes{'rules'}) {
+ if (ref($current{'chars'}) eq 'ARRAY') {
+ my @diffs = &Apache::loncommon::compare_arrays($current{'chars'},\@chars);
+ if (@diffs > 0) {
+ $changes{'rules'} = 1;
+ }
+ } else {
+ if (@chars > 0) {
+ $changes{'rules'} = 1;
+ }
+ }
+ }
my %crsownerchg = (
by => [],
for => [],
@@ -15033,71 +13260,6 @@ sub modify_passwords {
return $resulttext;
}
-sub password_rule_changes {
- my ($prefix,$newvalues,$current,$changes) = @_;
- return unless ((ref($newvalues) eq 'HASH') &&
- (ref($current) eq 'HASH') &&
- (ref($changes) eq 'HASH'));
- my (@rules,%staticdefaults);
- if ($prefix eq 'passwords') {
- @rules = ('min','max','numsaved');
- } elsif ($prefix eq 'secrets') {
- @rules = ('min','max');
- }
- $staticdefaults{'min'} = $Apache::lonnet::passwdmin;
- foreach my $rule (@rules) {
- $env{'form.'.$prefix.'_'.$rule} =~ s/^\s+|\s+$//g;
- my $ruleok;
- if ($rule eq 'min') {
- if ($env{'form.'.$prefix.'_'.$rule} =~ /^\d+$/) {
- if ($env{'form.'.$prefix.'_'.$rule} >= $staticdefaults{$rule}) {
- $ruleok = 1;
- }
- }
- } elsif (($env{'form.'.$prefix.'_'.$rule} =~ /^\d+$/) &&
- ($env{'form.'.$prefix.'_'.$rule} ne '0')) {
- $ruleok = 1;
- }
- if ($ruleok) {
- $newvalues->{$rule} = $env{'form.'.$prefix.'_'.$rule};
- if (exists($current->{$rule})) {
- if ($newvalues->{$rule} ne $current->{$rule}) {
- $changes->{'rules'} = 1;
- }
- } elsif ($rule eq 'min') {
- if ($staticdefaults{$rule} ne $newvalues->{$rule}) {
- $changes->{'rules'} = 1;
- }
- } else {
- $changes->{'rules'} = 1;
- }
- } elsif (exists($current->{$rule})) {
- $changes->{'rules'} = 1;
- }
- }
- my @posschars = &Apache::loncommon::get_env_multiple('form.'.$prefix.'_chars');
- my @chars;
- foreach my $item (sort(@posschars)) {
- if ($item =~ /^(uc|lc|num|spec)$/) {
- push(@chars,$item);
- }
- }
- $newvalues->{'chars'} = \@chars;
- unless ($changes->{'rules'}) {
- if (ref($current->{'chars'}) eq 'ARRAY') {
- my @diffs = &Apache::loncommon::compare_arrays($current->{'chars'},\@chars);
- if (@diffs > 0) {
- $changes->{'rules'} = 1;
- }
- } else {
- if (@chars > 0) {
- $changes->{'rules'} = 1;
- }
- }
- }
- return;
-}
-
sub modify_usercreation {
my ($dom,%domconfig) = @_;
my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate,%save_usercreate);
@@ -16412,58 +14574,16 @@ sub modify_defaults {
}
} elsif ($item eq 'portal_def') {
if ($newvalues{$item} ne '') {
- if ($newvalues{$item} =~ /^https?\:\/\/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/?$/) {
- foreach my $field ('email','web') {
- if ($env{'form.'.$item.'_'.$field}) {
- $newvalues{$item.'_'.$field} = $env{'form.'.$item.'_'.$field};
- }
- }
- } else {
+ unless ($newvalues{$item} =~ /^https?\:\/\/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/?$/) {
push(@errors,$item);
}
}
}
if (grep(/^\Q$item\E$/,@errors)) {
$newvalues{$item} = $domdefaults{$item};
- if ($item eq 'portal_def') {
- if ($domdefaults{$item}) {
- foreach my $field ('email','web') {
- if (exists($domdefaults{$item.'_'.$field})) {
- $newvalues{$item.'_'.$field} = $domdefaults{$item.'_'.$field};
- }
- }
- }
- }
} elsif ($domdefaults{$item} ne $newvalues{$item}) {
$changes{$item} = 1;
}
- if ($item eq 'portal_def') {
- unless (grep(/^\Q$item\E$/,@errors)) {
- if ($newvalues{$item} eq '') {
- foreach my $field ('email','web') {
- if (exists($domdefaults{$item.'_'.$field})) {
- delete($domdefaults{$item.'_'.$field});
- }
- }
- } else {
- unless ($changes{$item}) {
- foreach my $field ('email','web') {
- if ($domdefaults{$item.'_'.$field} ne $newvalues{$item.'_'.$field}) {
- $changes{$item} = 1;
- last;
- }
- }
- }
- foreach my $field ('email','web') {
- if ($newvalues{$item.'_'.$field}) {
- $domdefaults{$item.'_'.$field} = $newvalues{$item.'_'.$field};
- } elsif (exists($domdefaults{$item.'_'.$field})) {
- delete($domdefaults{$item.'_'.$field});
- }
- }
- }
- }
- }
$domdefaults{$item} = $newvalues{$item};
}
my %staticdefaults = (
@@ -16644,8 +14764,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').' ';
}
@@ -16664,20 +14784,7 @@ sub modify_defaults {
$value = $authnames{$shortauth{$value}};
}
$resulttext .= ''.&mt('[_1] set to "[_2]"',$title->{$item},$value).' ';
- $mailmsgtext .= "$title->{$item} set to $value\n";
- if ($item eq 'portal_def') {
- if ($env{'form.'.$item} ne '') {
- foreach my $field ('email','web') {
- $value = $env{'form.'.$item.'_'.$field};
- if ($value) {
- $value = &mt('Yes');
- } else {
- $value = &mt('No');
- }
- $resulttext .= ''.&mt('[_1] set to "[_2]"',$title->{$field},$value).' ';
- }
- }
- }
+ $mailmsgtext .= "$title->{$item} set to $value\n";
}
}
$resulttext .= '';
@@ -17621,9 +15728,8 @@ sub modify_coursedefaults {
'uselcmath' => 'on',
'usejsme' => 'on',
'inline_chem' => 'on',
- 'ltiauth' => 'off',
);
- my @toggles = ('uselcmath','usejsme','inline_chem','ltiauth');
+ my @toggles = ('uselcmath','usejsme','inline_chem');
my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial',
'uploadquota_community','uploadquota_textbook','mysqltables_official',
'mysqltables_unofficial','mysqltables_community','mysqltables_textbook');
@@ -17833,8 +15939,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'})) {
- foreach my $item ('uselcmath','usejsme','inline_chem','texengine','ltiauth') {
+ ($changes{'inline_chem'})) {
+ foreach my $item ('uselcmath','usejsme','inline_chem','texengine') {
if ($changes{$item}) {
$domdefaults{$item}=$defaultshash{'coursedefaults'}{$item};
}
@@ -17999,12 +16105,6 @@ sub modify_coursedefaults {
} else {
$resulttext .= ''.&mt('By default, only course owner and coordinators may clone a course.').' ';
}
- } elsif ($item eq 'ltiauth') {
- if ($env{'form.'.$item} eq '1') {
- $resulttext .= ''.&mt('LTI launch of deep-linked URL need not require re-authentication').' ';
- } else {
- $resulttext .= ''.&mt('LTI launch of deep-linked URL will require re-authentication').' ';
- }
}
}
$resulttext .= '';
@@ -18563,6 +16663,7 @@ sub modify_wafproxy {
}
}
}
+ $output .= '';
} else {
$output = ''.
&mt('An error occurred: [_1]',$putresult).' ';
@@ -19988,7 +18089,7 @@ sub devalidate_remote_domconfs {
my %servers = &Apache::lonnet::internet_dom_servers($dom);
my %thismachine;
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
- my @posscached = ('domainconfig','domdefaults','ltitools','usersessions',
+ my @posscached = ('domainconfig','domdefaults','usersessions',
'directorysrch','passwdconf','cats','proxyalias','proxysaml',
'ipaccess');
my %cache_by_lonhost;