'.&mt("$title{$item} set to $env{'form.loginheader'}").'
';
+ } else {
+ $resulttext .= '
'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'
';
+ }
}
$resulttext .= $colchgtext.'
';
} else {
@@ -1833,6 +2684,7 @@ sub color_font_choices {
img => "Header",
bgs => "Background colors",
links => "Link colors",
+ images => "Images",
font => "Font color",
pgbg => "Page",
tabbg => "Header",
@@ -1848,12 +2700,18 @@ sub modify_rolecolors {
my ($r,$dom,$confname,$roles,%domconfig) = @_;
my ($resulttext,%rolehash);
$rolehash{'rolecolors'} = {};
+ if (ref($domconfig{'rolecolors'}) ne 'HASH') {
+ if ($domconfig{'rolecolors'} eq '') {
+ $domconfig{'rolecolors'} = {};
+ }
+ }
my ($errors,%changes) = &modify_colors($r,$dom,$confname,$roles,
$domconfig{'rolecolors'},$rolehash{'rolecolors'});
my $putresult = &Apache::lonnet::put_dom('configuration',\%rolehash,
$dom);
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
+ &Apache::loncommon::devalidate_domconfig_cache($dom);
$resulttext = &display_colorchgs($dom,\%changes,$roles,
$rolehash{'rolecolors'});
} else {
@@ -1873,37 +2731,36 @@ sub modify_rolecolors {
sub modify_colors {
my ($r,$dom,$confname,$roles,$domconfig,$confhash) = @_;
my (%changes,%choices);
- my @bgs = ('pgbg','mainbg','sidebg');
+ my @bgs;
my @links = ('link','alink','vlink');
+ my @logintext;
my @images;
my $servadm = $r->dir_config('lonAdmEMail');
my $errors;
foreach my $role (@{$roles}) {
if ($role eq 'login') {
%choices = &login_choices();
+ @logintext = ('textcol','bgcol');
} else {
%choices = &color_font_choices();
}
if ($role eq 'login') {
- @images = ('img','logo','domlogo');
+ @images = ('img','logo','domlogo','login');
+ @bgs = ('pgbg','mainbg','sidebg');
} else {
@images = ('img');
+ @bgs = ('pgbg','tabbg','sidebg');
}
$confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
- foreach my $item (@bgs,@links) {
+ foreach my $item (@bgs,@links,@logintext) {
$confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
}
- my ($configuserok,$author_ok,$switchserver,%currroles);
- my $uhome = &Apache::lonnet::homeserver($confname,$dom,1);
- ($configuserok,%currroles) = &check_configuser($uhome,$dom,
- $confname,$servadm);
- if ($configuserok eq 'ok') {
- $switchserver = &check_switchserver($dom,$confname);
- if ($switchserver eq '') {
- $author_ok = &check_authorstatus($dom,$confname,%currroles);
- }
- }
+ my ($configuserok,$author_ok,$switchserver) =
+ &config_check($dom,$confname,$servadm);
my ($width,$height) = &thumb_dimensions();
+ if (ref($domconfig->{$role}) ne 'HASH') {
+ $domconfig->{$role} = {};
+ }
foreach my $img (@images) {
if ( ! $env{'form.'.$role.'_'.$img.'.filename'}
&& !defined($domconfig->{$role}{$img})
@@ -1931,11 +2788,11 @@ sub modify_colors {
$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);
}
} else {
- $error = &mt("Upload of [_1] image for $role page(s) failed because an author role could not be assigned to a Domain Configuation user ([_2]) in domain: [_3]. Error was: [_4].",$choices{$img},$confname,$dom,$author_ok);
+ $error = &mt("Upload of [_1] image for $role page(s) failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$choices{$img},$confname,$dom,$author_ok);
}
}
} else {
- $error = &mt("Upload of [_1] image for $role page(s) failed because a Domain Configuation user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$choices{$img},$confname,$dom,$configuserok);
+ $error = &mt("Upload of [_1] image for $role page(s) failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$choices{$img},$confname,$dom,$configuserok);
}
if ($error) {
&Apache::lonnet::logthis($error);
@@ -2011,20 +2868,46 @@ sub modify_colors {
}
}
}
+ foreach my $item (@logintext) {
+ if ($domconfig->{$role}{$item} ne '') {
+ if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
+ $changes{$role}{'logintext'}{$item} = 1;
+ }
+ } else {
+ if ($confhash->{$role}{$item}) {
+ $changes{$role}{'logintext'}{$item} = 1;
+ }
+ }
+ }
} else {
&default_change_checker($role,\@images,\@links,\@bgs,
- $confhash,\%changes);
+ \@logintext,$confhash,\%changes);
}
} else {
&default_change_checker($role,\@images,\@links,\@bgs,
- $confhash,\%changes);
+ \@logintext,$confhash,\%changes);
}
}
return ($errors,%changes);
}
+sub config_check {
+ my ($dom,$confname,$servadm) = @_;
+ my ($configuserok,$author_ok,$switchserver,%currroles);
+ my $uhome = &Apache::lonnet::homeserver($confname,$dom,1);
+ ($configuserok,%currroles) = &check_configuser($uhome,$dom,
+ $confname,$servadm);
+ if ($configuserok eq 'ok') {
+ $switchserver = &check_switchserver($dom,$confname);
+ if ($switchserver eq '') {
+ $author_ok = &check_authorstatus($dom,$confname,%currroles);
+ }
+ }
+ return ($configuserok,$author_ok,$switchserver);
+}
+
sub default_change_checker {
- my ($role,$images,$links,$bgs,$confhash,$changes) = @_;
+ my ($role,$images,$links,$bgs,$logintext,$confhash,$changes) = @_;
foreach my $item (@{$links}) {
if ($confhash->{$role}{$item}) {
$changes->{$role}{'links'}{$item} = 1;
@@ -2035,6 +2918,11 @@ sub default_change_checker {
$changes->{$role}{'bgs'}{$item} = 1;
}
}
+ foreach my $item (@{$logintext}) {
+ if ($confhash->{$role}{$item}) {
+ $changes->{$role}{'logintext'}{$item} = 1;
+ }
+ }
foreach my $img (@{$images}) {
if ($env{'form.'.$role.'_del_'.$img}) {
$confhash->{$role}{$img} = '';
@@ -2044,12 +2932,11 @@ sub default_change_checker {
if ($confhash->{$role}{'font'}) {
$changes->{$role}{'font'} = 1;
}
-}
+}
sub display_colorchgs {
my ($dom,$changes,$roles,$confhash) = @_;
my (%choices,$resulttext);
- &Apache::loncommon::devalidate_domconfig_cache($dom);
if (!grep(/^login$/,@{$roles})) {
$resulttext = &mt('Changes made:').' ';
}
@@ -2145,12 +3032,12 @@ sub check_configuser {
sub check_authorstatus {
my ($dom,$confname,%currroles) = @_;
my $author_ok;
- if (!$currroles{$confname.':'.$dom.':au'}) {
+ if (!$currroles{':'.$dom.':au'}) {
my $start = time;
my $end = 0;
$author_ok =
&Apache::lonnet::assignrole($dom,$confname,'/'.$dom.'/',
- 'au',$end,$start);
+ 'au',$end,$start,'','','domconfig');
} else {
$author_ok = 'ok';
}
@@ -2158,7 +3045,7 @@ sub check_authorstatus {
}
sub publishlogo {
- my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight) = @_;
+ my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight,$savefileas) = @_;
my ($output,$fname,$logourl);
if ($action eq 'upload') {
$fname=$env{'form.'.$formname.'.filename'};
@@ -2166,6 +3053,9 @@ sub publishlogo {
} 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'); }
@@ -2193,7 +3083,7 @@ sub publishlogo {
!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('File name not allowed a rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2);
+ $output = &mt('File name 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('File name is a directory name - rename the file and re-upload');
} else {
@@ -2389,7 +3279,7 @@ END
sub modify_quotas {
my ($dom,%domconfig) = @_;
my ($resulttext,%changes);
- my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
my %formhash;
foreach my $key (keys(%env)) {
if ($key =~ /^form\.quota_(.+)$/) {
@@ -2410,7 +3300,11 @@ sub modify_quotas {
}
foreach my $key (keys(%formhash)) {
if ($formhash{$key} ne '') {
- if (!exists($domconfig{'quotas'}{$key})) {
+ if (ref($domconfig{'quotas'}) eq 'HASH') {
+ if (!exists($domconfig{'quotas'}{$key})) {
+ $changes{$key} = 1;
+ }
+ } else {
$changes{$key} = 1;
}
}
@@ -2524,7 +3418,7 @@ sub modify_autoupdate {
run => 'Auto-update:',
classlists => 'Updates to user information in classlists?'
);
- my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
my %fieldtitles = &Apache::lonlocal::texthash (
id => 'Student/Employee ID',
permanentemail => 'E-mail address',
@@ -2653,7 +3547,7 @@ sub modify_directorysrch {
my @cansearch = &Apache::loncommon::get_env_multiple('form.cansearch');
my @searchby = &Apache::loncommon::get_env_multiple('form.searchby');
- my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
if (keys(%{$usertypes}) == 0) {
@cansearch = ('default');
} else {
@@ -2919,30 +3813,96 @@ sub modify_contacts {
sub modify_usercreation {
my ($dom,%domconfig) = @_;
my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate);
+ my $warningmsg;
if (ref($domconfig{'usercreation'}) eq 'HASH') {
foreach my $key (keys(%{$domconfig{'usercreation'}})) {
$curr_usercreation{$key} = $domconfig{'usercreation'}{$key};
}
}
- my %title = &Apache::lonlocal::texthash (
- author => 'adding co-authors/assistant authors',
- course => 'adding users to a course',
- );
my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule');
- my @contexts = ('author','course');
+ my @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule');
+ my @contexts = ('author','course','selfcreate');
foreach my $item(@contexts) {
- $cancreate{$item} = $env{'form.can_createuser_'.$item};
+ if ($item eq 'selfcreate') {
+ @{$cancreate{$item}} = &Apache::loncommon::get_env_multiple('form.can_createuser_'.$item);
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth'))) {
+ if (ref($cancreate{$item}) eq 'ARRAY') {
+ if (grep(/^login$/,@{$cancreate{$item}})) {
+ $warningmsg = &mt('Although account creation has been set to be available for institutional logins, currently default authentication in this domain has not been set to support this.').' '.&mt('You need to set the default authentication type to Kerberos 4 or 5 (with a Kerberos domain specified), or to Local authentication, if the localauth module has been customized in your domain to authenticate institutional logins.');
+ }
+ }
+ }
+ } else {
+ $cancreate{$item} = $env{'form.can_createuser_'.$item};
+ }
}
if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
foreach my $item (@contexts) {
- if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) {
- push(@{$changes{'cancreate'}},$item);
- }
+ if ($item eq 'selfcreate') {
+ if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
+ foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) {
+ if (!grep(/^$curr$/,@{$cancreate{$item}})) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ }
+ } else {
+ if ($curr_usercreation{'cancreate'}{$item} eq '') {
+ if (@{$cancreate{$item}} > 0) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ } else {
+ if ($curr_usercreation{'cancreate'}{$item} eq 'any') {
+ if (@{$cancreate{$item}} < 3) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ } elsif ($curr_usercreation{'cancreate'}{$item} eq 'none') {
+ if (@{$cancreate{$item}} > 0) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ } elsif (!grep(/^$curr_usercreation{'cancreate'}{$item}$/,@{$cancreate{$item}})) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ }
+ }
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ foreach my $type (@{$cancreate{$item}}) {
+ if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
+ if (!grep(/^$type$/,@{$curr_usercreation{'cancreate'}{$item}})) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ } elsif (($curr_usercreation{'cancreate'}{$item} ne 'any') &&
+ ($curr_usercreation{'cancreate'}{$item} ne 'none')) {
+ if ($curr_usercreation{'cancreate'}{$item} ne $type) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ }
+ }
+ }
+ } else {
+ if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
}
} elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') {
foreach my $item (@contexts) {
- if (grep(/^\Q$item\E$/,@{$curr_usercreation{'cancreate'}})) {
+ if (!grep(/^\Q$item\E$/,@{$curr_usercreation{'cancreate'}})) {
if ($cancreate{$item} ne 'any') {
push(@{$changes{'cancreate'}},$item);
}
@@ -2953,7 +3913,7 @@ sub modify_usercreation {
}
}
} else {
- foreach my $item ('author','course') {
+ foreach my $item (@contexts) {
push(@{$changes{'cancreate'}},$item);
}
}
@@ -2988,10 +3948,25 @@ sub modify_usercreation {
push(@{$changes{'id_rule'}},@id_rule);
}
- my @contexts = ('author','course','domain');
+ if (ref($curr_usercreation{'email_rule'}) eq 'ARRAY') {
+ foreach my $type (@{$curr_usercreation{'email_rule'}}) {
+ if (!grep(/^\Q$type\E$/,@email_rule)) {
+ push(@{$changes{'email_rule'}},$type);
+ }
+ }
+ foreach my $type (@email_rule) {
+ if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'email_rule'}})) {
+ push(@{$changes{'email_rule'}},$type);
+ }
+ }
+ } else {
+ push(@{$changes{'email_rule'}},@email_rule);
+ }
+
+ my @authen_contexts = ('author','course','domain');
my @authtypes = ('int','krb4','krb5','loc');
my %authhash;
- foreach my $item (@contexts) {
+ foreach my $item (@authen_contexts) {
my @authallowed = &Apache::loncommon::get_env_multiple('form.'.$item.'_auth');
foreach my $auth (@authtypes) {
if (grep(/^\Q$auth\E$/,@authallowed)) {
@@ -3002,7 +3977,7 @@ sub modify_usercreation {
}
}
if (ref($curr_usercreation{'authtypes'}) eq 'HASH') {
- foreach my $item (@contexts) {
+ foreach my $item (@authen_contexts) {
if (ref($curr_usercreation{'authtypes'}{$item}) eq 'HASH') {
foreach my $auth (@authtypes) {
if ($authhash{$item}{$auth} ne $curr_usercreation{'authtypes'}{$item}{$auth}) {
@@ -3013,7 +3988,7 @@ sub modify_usercreation {
}
}
} else {
- foreach my $item (@contexts) {
+ foreach my $item (@authen_contexts) {
push(@{$changes{'authtypes'}},$item);
}
}
@@ -3023,27 +3998,46 @@ sub modify_usercreation {
cancreate => \%cancreate,
username_rule => \@username_rule,
id_rule => \@id_rule,
+ email_rule => \@email_rule,
authtypes => \%authhash,
}
);
my $putresult = &Apache::lonnet::put_dom('configuration',\%usercreation_hash,
$dom);
+
+ my %selfcreatetypes = (
+ sso => 'users authenticated by institutional single sign on',
+ login => 'users authenticated by institutional log-in',
+ email => 'users who provide a valid e-mail address for use as the username',
+ );
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').'
';
if (ref($changes{'cancreate'}) eq 'ARRAY') {
my %lt = &usercreation_types();
foreach my $type (@{$changes{'cancreate'}}) {
- my $chgtext;
- if ($cancreate{$type} eq 'none') {
- $chgtext = $lt{$type}.' '.&mt('creation of new users is not permitted, except by a Domain Coordinator.');
- } elsif ($cancreate{$type} eq 'any') {
- $chgtext = $lt{$type}.' '.&mt('creation of new users is permitted for both institutional and non-institutional usernames.');
- } elsif ($cancreate{$type} eq 'official') {
- $chgtext = $lt{$type}.' '.&mt('creation of new users is only permitted for institutional usernames.',$lt{$type});
- } elsif ($cancreate{$type} eq 'unofficial') {
- $chgtext = $lt{$type}.' '.&mt('creation of new users is only permitted for non-institutional usernames.',$lt{$type});
+ my $chgtext = $lt{$type}.', ';
+ if ($type eq 'selfcreate') {
+ if (@{$cancreate{$type}} == 0) {
+ $chgtext .= &mt('creation of a new user account is not permitted.');
+ } else {
+ $chgtext .= &mt('creation of a new account is permitted for:
';
+ }
+ } else {
+ if ($cancreate{$type} eq 'none') {
+ $chgtext .= &mt('creation of new users is not permitted, except by a Domain Coordinator.');
+ } elsif ($cancreate{$type} eq 'any') {
+ $chgtext .= &mt('creation of new users is permitted for both institutional and non-institutional usernames.');
+ } elsif ($cancreate{$type} eq 'official') {
+ $chgtext .= &mt('creation of new users is only permitted for institutional usernames.');
+ } elsif ($cancreate{$type} eq 'unofficial') {
+ $chgtext .= &mt('creation of new users is only permitted for non-institutional usernames.');
+ }
}
$resulttext .= '