'.$domservers{$lonhost}.' '.
' '.
&mt('Yes').' '.
''.
- ''.&mt('SSO').' '.
+ ' '.
- ''.
' ';
@@ -1845,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;
@@ -1853,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;
@@ -1879,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;
@@ -1932,7 +1806,6 @@ sub role_defaults {
}
} else {
%defaults = (
- img => $defaultdesign{$role.'.img'},
font => $defaultdesign{$role.'.font'},
fontmenu => $defaultdesign{$role.'.fontmenu'},
);
@@ -1997,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);
}
@@ -2262,7 +2135,7 @@ sub print_quotas {
my $typecount = 0;
my ($css_class,%titles);
if ($context eq 'requestcourses') {
- @usertools = ('official','unofficial','community','textbook','lti');
+ @usertools = ('official','unofficial','community','textbook');
@options =('norequest','approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($dom);
%titles = &courserequest_titles();
@@ -2271,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') {
@@ -2375,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" ';
@@ -2729,7 +2599,7 @@ sub print_studentcode {
my ($settings,$rowtotal) = @_;
my $rownum = 0;
my ($output,%current);
- my @crstypes = ('official','unofficial','community','textbook','lti');
+ my @crstypes = ('official','unofficial','community','textbook');
if (ref($settings) eq 'HASH') {
if (ref($settings->{'uniquecode'}) eq 'HASH') {
foreach my $type (@crstypes) {
@@ -2979,132 +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";
@@ -3220,312 +2964,6 @@ function toggleWAF() {
ENDSCRIPT
}
-sub lti_javascript {
- my ($dom,$settings) = @_;
- my $togglejs = <i_toggle_js($dom);
- my $linkprot_js = &Apache::courseprefs::linkprot_javascript();
- unless (ref($settings) eq 'HASH') {
- return $togglejs.'
-
-';
- }
- 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";
-
-
-$togglejs
-
-ENDSCRIPT
-}
-
-sub lti_toggle_js {
- my ($dom) = @_;
- my %lcauthparmtext = &Apache::lonlocal::texthash (
- localauth => 'Local auth argument',
- krb => 'Kerberos domain',
- );
- my $crsincalert = &mt('"User\'s identity sent" needs to be set to "Yes" first,[_1] before setting "Course\'s identity sent" to "Yes"',"\n");
- &js_escape(\$crsincalert);
- 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";
-
ENDSCRIPT
}
- return;
}
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 '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).',
- );
- }
+ 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') {
@@ -10054,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';
@@ -10084,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 = '';
}
}
}
@@ -10335,7 +8770,7 @@ sub build_category_rows {
sub modifiable_userdata_row {
my ($context,$item,$settings,$numinrow,$rowcount,$usertypes,$fieldsref,$titlesref,
- $rowid,$customcss,$rowstyle,$itemdesc) = @_;
+ $rowid,$customcss,$rowstyle) = @_;
my ($role,$rolename,$statustype);
$role = $item;
if ($context eq 'cancreate') {
@@ -10356,8 +8791,6 @@ 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');
@@ -10395,41 +8828,42 @@ sub modifiable_userdata_row {
if ($rowid) {
$rowid = ' id="'.$rowid.'"';
}
+
$output = ''.
''.$rolename.' '.
'';
my $rem;
my %checks;
if (ref($settings) 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}) eq 'HASH') {
if (ref($settings->{$context}->{$role}) eq 'HASH') {
- $hashref = $settings->{'lti_instdata'};
- }
- if ($role eq 'emailusername') {
- if ($statustype) {
- if (ref($settings->{$context}->{$role}->{$statustype}) eq 'HASH') {
- $hashref = $settings->{$context}->{$role}->{$statustype};
+ 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};
+ }
+ }
+ }
+ }
}
- }
- }
- }
- 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" ';
+ } else {
+ if (ref($hashref) eq 'HASH') {
+ foreach my $field (@fields) {
+ if ($hashref->{$field}) {
+ $checks{$field} = ' checked="checked" ';
+ }
+ }
}
}
}
}
}
+
my $total = scalar(@fields);
for (my $i=0; $i<$total; $i++) {
$rem = $i%($numinrow);
@@ -10443,7 +8877,7 @@ sub modifiable_userdata_row {
unless ($role eq 'emailusername') {
if (exists($checks{$fields[$i]})) {
$check = $checks{$fields[$i]};
- } elsif ($context ne 'lti') {
+ } else {
if ($role eq 'st') {
if (ref($settings) ne 'HASH') {
$check = ' checked="checked" ';
@@ -10453,7 +8887,6 @@ sub modifiable_userdata_row {
}
$output .= ''.
'';
- my $prefix = 'canmodify';
if ($role eq 'emailusername') {
unless ($checks{$fields[$i]} =~ /^(required|optional)$/) {
$checks{$fields[$i]} = 'omit';
@@ -10464,16 +8897,13 @@ 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]}.
' ';
}
@@ -10560,7 +8990,7 @@ sub insttypes_row {
$output .= ' '.
''.
' [$i].'"'.$check.$onclick.' />'.
+ 'value="'.$types->[$i].'"'.$check.$onclick.'/>'.
$usertypes->{$types->[$i]}.' ';
}
}
@@ -10676,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',
@@ -10700,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'};
}
}
@@ -10843,16 +9272,13 @@ 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}) =
- &Apache::lonconfigsettings::publishlogo($r,'upload',$formelem,$dom,$confname,
- "help/$lang",'','',$newfile{$lang},
- $modified);
+ (my $result,$newurl{$lang}) = &publishlogo($r,'upload',$formelem,$dom,$confname,
+ "help/$lang",'','',$newfile{$lang});
if ($result eq 'ok') {
$loginhash{'login'}{'helpurl'}{$lang} = $newurl{$lang};
$changes{'helpurl'}{$lang} = 1;
@@ -10865,7 +9291,6 @@ 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);
}
@@ -10923,14 +9348,11 @@ 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}) =
- &Apache::lonconfigsettings::publishlogo($r,'upload',$formelem,$dom,$confname,
- "login/headtag/$lonhost",'','',
- $env{'form.loginheadtag_'.$lonhost.'.filename'},
- $modified);
+ (my $result,$newheadtagurls{$lonhost}) = &publishlogo($r,'upload',$formelem,$dom,$confname,
+ "login/headtag/$lonhost",'','',
+ $env{'form.loginheadtag_'.$lonhost.'.filename'});
if ($result eq 'ok') {
$loginhash{'login'}{'headtag'}{$lonhost}{'url'} = $newheadtagurls{$lonhost};
$changes{'headtag'}{$lonhost} = 1;
@@ -10947,7 +9369,6 @@ 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);
}
@@ -10966,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'});
@@ -10990,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 {
@@ -11022,14 +9437,11 @@ 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) =
- &Apache::lonconfigsettings::publishlogo($r,'upload',$formelem,$dom,$confname,
- "login/saml/$lonhost",'','',
- $env{'form.saml_img_'.$lonhost.'.filename'},
- $modified);
+ my ($result,$imgurl) = &publishlogo($r,'upload',$formelem,$dom,$confname,
+ "login/saml/$lonhost",'','',
+ $env{'form.saml_img_'.$lonhost.'.filename'});
if ($result eq 'ok') {
$currsaml{$lonhost}{'img'} = $imgurl;
$loginhash{'login'}{'saml'}{$lonhost}{'img'} = $imgurl;
@@ -11040,7 +9452,6 @@ 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);
}
@@ -11204,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).' ';
@@ -11317,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",
@@ -11666,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') {
@@ -11688,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'};
}
}
@@ -11717,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;
@@ -11745,15 +10156,12 @@ 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) =
- &Apache::lonconfigsettings::publishlogo($r,'upload',$role.'_'.$img,
- $dom,$confname,$img,$width,$height,
- '',$modified);
+ &publishlogo($r,'upload',$role.'_'.$img,
+ $dom,$confname,$img,$width,$height);
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);
}
@@ -11775,15 +10183,12 @@ sub modify_colors {
# is confname an author?
if ($switchserver eq '') {
if ($author_ok eq 'ok') {
- my $modified = [];
my ($result,$logourl) =
- &Apache::lonconfigsettings::publishlogo($r,'copy',$domconfig->{$role}{$img},
- $dom,$confname,$img,$width,$height,
- '',$modified);
+ &publishlogo($r,'copy',$domconfig->{$role}{$img},
+ $dom,$confname,$img,$width,$height);
if ($result eq 'ok') {
$confhash->{$role}{$img} = $logourl;
$changes{$role}{'images'}{$img} = 1;
- &update_modify_urls($r,$modified);
}
}
}
@@ -12077,16 +10482,228 @@ sub check_authorstatus {
return $author_ok;
}
-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;
+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;
+ }
+ }
+ 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 {
@@ -12137,21 +10754,15 @@ sub subscribed_hosts {
sub check_switchserver {
my ($dom,$confname) = @_;
- my ($allowed,$switchserver,$home);
- if ($confname eq '') {
+ my ($allowed,$switchserver);
+ my $home = &Apache::lonnet::homeserver($confname,$dom);
+ if ($home eq 'no_host') {
$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;
}
@@ -12168,7 +10779,7 @@ sub modify_quotas {
$context = $action;
}
if ($context eq 'requestcourses') {
- @usertools = ('official','unofficial','community','textbook','lti');
+ @usertools = ('official','unofficial','community','textbook');
@options =('norequest','approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($dom);
%titles = &courserequest_titles();
@@ -12183,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);
@@ -12217,7 +10828,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','lti');
+ my @crstypes = ('official','unofficial','community','textbook');
my @hasuniquecode = &Apache::loncommon::get_env_multiple('form.uniquecode');
foreach my $type (@hasuniquecode) {
if (grep(/^\Q$type\E$/,@crstypes)) {
@@ -12339,7 +10950,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'};
@@ -12837,6 +11448,7 @@ sub modify_quotas {
$resulttext .= ''.&mt('Validated course requests identified as processed by: [_1]',
''.$changes{'validation'}{'dc'}.' ').' ';
}
+ $resulttext .= ' ';
}
}
}
@@ -12874,14 +11486,11 @@ 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) =
- &Apache::lonconfigsettings::publishlogo($r,'upload',$caller,$dom,$confname,
- "$type/$cdom/$cnum/cover",$width,$height,
- '',$modified);
+ &publishlogo($r,'upload',$caller,$dom,$confname,
+ "$type/$cdom/$cnum/cover",$width,$height);
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);
}
@@ -12894,1134 +11503,6 @@ sub process_textbook_image {
return ($url,$error);
}
-sub modify_ltitools {
- my ($r,$dom,$action,$lastactref,%domconfig) = @_;
- 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 ($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};
- }
- }
- }
- }
- }
- $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 ($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 (ref($lastactref) eq 'HASH') {
- if (($secchanges{'encrypt'}) || ($secchanges{'private'})) {
- $lastactref->{'domdefaults'} = 1;
- }
- }
- } else {
- $errors .= ''.&mt('Failed to save changes').' ';
- }
- if ($errors) {
- $resulttext .= &mt('The following errors occurred: ').'';
- }
- return $resulttext;
-}
-
-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'});
- }
- }
- }
- return ($cipher,$privnum);
-}
-
-sub get_lti_id {
- my ($domain,$consumer) = @_;
- # get lock on lti db
- my $lockhash = {
- lock => $env{'user.name'}.
- ':'.$env{'user.domain'},
- };
- my $tries = 0;
- my $gotlock = &Apache::lonnet::newput_dom('lti',$lockhash,$domain);
- my ($id,$error);
-
- while (($gotlock ne 'ok') && ($tries<10)) {
- $tries ++;
- sleep (0.1);
- $gotlock = &Apache::lonnet::newput_dom('lti',$lockhash,$domain);
- }
- if ($gotlock eq 'ok') {
- my %currids = &Apache::lonnet::dump_dom('lti',$domain);
- 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('lti',{ $id => $consumer },$domain) eq 'ok') {
- $error = 'nostore';
- }
- } else {
- $error = 'nonumber';
- }
- }
- my $dellockoutcome = &Apache::lonnet::del_dom('lti',['lock'],$domain);
- } else {
- $error = 'nolock';
- }
- return ($id,$error);
-}
-
sub modify_autoenroll {
my ($dom,$lastactref,%domconfig) = @_;
my ($resulttext,%changes);
@@ -14781,7 +12262,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) {
@@ -15231,7 +12712,7 @@ sub modify_contacts {
}
} else {
$resulttext = ''.
- &mt('An error occurred: [_1]',$putresult).' ';
+ &mt('An error occurred: [_1].',$putresult).'';
}
return $resulttext;
}
@@ -15403,6 +12884,7 @@ 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;
@@ -15411,15 +12893,12 @@ 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) =
- &Apache::lonconfigsettings::publishlogo($r,'upload','passwords_customfile',$dom,
- $confname,'customtext/resetpw','','',$customfn,
- $modified);
+ &publishlogo($r,'upload','passwords_customfile',$dom,
+ $confname,'customtext/resetpw','','',$customfn);
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);
}
@@ -15472,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 => [],
@@ -15732,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 'ltisecrets') || ($prefix eq 'toolsecrets')) {
- @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);
@@ -15881,7 +13344,7 @@ sub modify_usercreation {
}
my @authen_contexts = ('author','course','domain');
- my @authtypes = ('int','krb4','krb5','loc','lti');
+ my @authtypes = ('int','krb4','krb5','loc');
my %authhash;
foreach my $item (@authen_contexts) {
my @authallowed = &Apache::loncommon::get_env_multiple('form.'.$item.'_auth');
@@ -16096,6 +13559,7 @@ 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);
@@ -17073,7 +14537,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','lti');
+ my @authtypes = ('internal','krb4','krb5','localauth');
foreach my $item (@items) {
$newvalues{$item} = $env{'form.'.$item};
if ($item eq 'auth_def') {
@@ -17110,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 = (
@@ -17358,25 +14780,11 @@ sub modify_defaults {
krb4 => 'krb4',
krb5 => 'krb5',
localauth => 'loc',
- lti => 'lti',
);
$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 .= '';
@@ -17431,15 +14839,12 @@ 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) =
- &Apache::lonconfigsettings::publishlogo($r,'upload','scantronformat',$dom,
- $confname,'scantron','','',$custom,
- $modified);
+ &publishlogo($r,'upload','scantronformat',$dom,
+ $confname,'scantron','','',$custom);
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);
}
@@ -17591,8 +14996,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;
}
@@ -18323,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');
@@ -18335,7 +15739,6 @@ sub modify_coursedefaults {
uploadquota => 500,
postsubmit => 60,
mysqltables => 172800,
- domexttool => 1,
);
my %texoptions = (
MathJax => 'MathJax',
@@ -18527,47 +15930,6 @@ 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);
@@ -18577,9 +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'}) || ($changes{'domexttool'}) ||
- ($changes{'exttool'})) {
- 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};
}
@@ -18622,20 +15983,6 @@ 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') {
@@ -18675,6 +16022,7 @@ 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'}.' ').' '.
''.
'';
@@ -18757,40 +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').' ';
- }
- } 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 .= '';
@@ -19703,7 +17017,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).' ';
}
@@ -20586,7 +17900,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') {
@@ -20720,7 +18034,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;
@@ -20775,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;