';
+ } else {
+ my $higher = $depth-1;
+ if ($higher == 0) {
+ $name = &escape($parent).'::'.$higher;
+ } else {
+ if (ref($path) eq 'ARRAY') {
+ $name = &escape($parent).':'.&escape($path->[-2]).':'.$higher;
+ }
+ }
+ my $colspan;
+ if ($parent ne 'instcode') {
+ $colspan = $maxdepth - $depth - 1;
+ $text .= '
'.&mt('Add subcategory:').'
';
+ }
+ }
+ }
+ }
+ return $text;
+}
+
sub modifiable_userdata_row {
my ($context,$role,$settings,$numinrow,$rowcount) = @_;
my $rolename;
@@ -1807,25 +2430,6 @@ sub users_cansearch_row {
return $output;
}
-sub sorted_inst_types {
- my ($dom) = @_;
- my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
- my $othertitle = &mt('All users');
- my @types;
- if (ref($order) eq 'ARRAY') {
- @types = @{$order};
- }
- if (@types == 0) {
- if (ref($usertypes) eq 'HASH') {
- @types = sort(keys(%{$usertypes}));
- }
- }
- if (keys(%{$usertypes}) > 0) {
- $othertitle = &mt('Other users');
- }
- return ($othertitle,$usertypes,\@types);
-}
-
sub sorted_searchtitles {
my %searchtitles = &Apache::lonlocal::texthash(
'uname' => 'username',
@@ -1901,13 +2505,16 @@ sub modify_login {
my ($resulttext,$errors,$colchgtext,%changes,%colchanges);
my %title = ( coursecatalog => 'Display course catalog',
adminmail => 'Display administrator E-mail address',
+ newuser => 'Link for visitors to create a user account',
loginheader => 'Log-in box header');
my @offon = ('off','on');
my %loginhash;
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
\%domconfig,\%loginhash);
- $loginhash{login}{coursecatalog} = $env{'form.coursecatalog'};
- $loginhash{login}{adminmail} = $env{'form.adminmail'};
+ my @toggles = ('coursecatalog','adminmail','newuser');
+ foreach my $item (@toggles) {
+ $loginhash{login}{$item} = $env{'form.'.$item};
+ }
$loginhash{login}{loginheader} = $env{'form.loginheader'};
if (ref($colchanges{'login'}) eq 'HASH') {
$colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
@@ -1916,29 +2523,42 @@ sub modify_login {
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
- if (($domconfig{'login'}{'coursecatalog'} eq '0') &&
- ($env{'form.coursecatalog'} eq '1')) {
- $changes{'coursecatalog'} = 1;
- } elsif (($domconfig{'login'}{'coursecatalog'} eq '' ||
- $domconfig{'login'}{'coursecatalog'} eq '1') &&
- ($env{'form.coursecatalog'} eq '0')) {
- $changes{'coursecatalog'} = 1;
- }
- if (($domconfig{'login'}{'adminmail'} eq '1') &&
- ($env{'form.adminmail'} eq '0')) {
- $changes{'adminmail'} = 1;
- } elsif (($domconfig{'login'}{'adminmail'} eq '' ||
- $domconfig{'login'}{'adminmail'} eq '0') &&
- ($env{'form.adminmail'} eq '1')) {
- $changes{'adminmail'} = 1;
- }
- if (($domconfig{'login'}{'loginheader'} eq 'text') &&
- ($env{'form.loginheader'} eq 'image')) {
- $changes{'loginheader'} = 1;
- } elsif (($domconfig{'login'}{'loginheader'} eq '' ||
- $domconfig{'login'}{'loginheader'} eq 'image') &&
- ($env{'form.loginheader'} eq 'text')) {
- $changes{'loginheader'} = 1;
+ my @toggles = ('coursecatalog','adminmail','newuser');
+ my %defaultchecked = (
+ 'coursecatalog' => 'on',
+ 'adminmail' => 'off',
+ 'newuser' => 'off',
+ );
+ if (ref($domconfig{'login'}) eq 'HASH') {
+ foreach my $item (@toggles) {
+ if ($defaultchecked{$item} eq 'on') {
+ if (($domconfig{'login'}{$item} eq '0') &&
+ ($env{'form.'.$item} eq '1')) {
+ $changes{$item} = 1;
+ } elsif (($domconfig{'login'}{$item} eq '' ||
+ $domconfig{'login'}{$item} eq '1') &&
+ ($env{'form.'.$item} eq '0')) {
+ $changes{$item} = 1;
+ }
+ } elsif ($defaultchecked{$item} eq 'off') {
+ if (($domconfig{'login'}{$item} eq '1') &&
+ ($env{'form.'.$item} eq '0')) {
+ $changes{$item} = 1;
+ } elsif (($domconfig{'login'}{$item} eq '' ||
+ $domconfig{'login'}{$item} eq '0') &&
+ ($env{'form.'.$item} eq '1')) {
+ $changes{$item} = 1;
+ }
+ }
+ }
+ if (($domconfig{'login'}{'loginheader'} eq 'text') &&
+ ($env{'form.loginheader'} eq 'image')) {
+ $changes{'loginheader'} = 1;
+ } elsif (($domconfig{'login'}{'loginheader'} eq '' ||
+ $domconfig{'login'}{'loginheader'} eq 'image') &&
+ ($env{'form.loginheader'} eq 'text')) {
+ $changes{'loginheader'} = 1;
+ }
}
if (keys(%changes) > 0 || $colchgtext) {
&Apache::loncommon::devalidate_domconfig_cache($dom);
@@ -1971,6 +2591,7 @@ sub color_font_choices {
img => "Header",
bgs => "Background colors",
links => "Link colors",
+ images => "Images",
font => "Font color",
pgbg => "Page",
tabbg => "Header",
@@ -1986,6 +2607,11 @@ 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,
@@ -2012,7 +2638,7 @@ 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;
@@ -2027,23 +2653,17 @@ sub modify_colors {
}
if ($role eq 'login') {
@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,@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} = {};
@@ -2075,11 +2695,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);
@@ -2178,6 +2798,21 @@ sub modify_colors {
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,$logintext,$confhash,$changes) = @_;
foreach my $item (@{$links}) {
@@ -2204,7 +2839,7 @@ sub default_change_checker {
if ($confhash->{$role}{'font'}) {
$changes->{$role}{'font'} = 1;
}
-}
+}
sub display_colorchgs {
my ($dom,$changes,$roles,$confhash) = @_;
@@ -2309,7 +2944,7 @@ sub check_authorstatus {
my $end = 0;
$author_ok =
&Apache::lonnet::assignrole($dom,$confname,'/'.$dom.'/',
- 'au',$end,$start);
+ 'au',$end,$start,'','','domconfig');
} else {
$author_ok = 'ok';
}
@@ -2317,7 +2952,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'};
@@ -2325,6 +2960,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'); }
@@ -2352,7 +2990,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 {
@@ -2548,7 +3186,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_(.+)$/) {
@@ -2569,7 +3207,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;
}
}
@@ -2683,7 +3325,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',
@@ -2812,7 +3454,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 {
@@ -3078,30 +3720,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);
}
@@ -3112,7 +3820,7 @@ sub modify_usercreation {
}
}
} else {
- foreach my $item ('author','course') {
+ foreach my $item (@contexts) {
push(@{$changes{'cancreate'}},$item);
}
}
@@ -3147,10 +3855,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)) {
@@ -3161,7 +3884,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}) {
@@ -3172,7 +3895,7 @@ sub modify_usercreation {
}
}
} else {
- foreach my $item (@contexts) {
+ foreach my $item (@authen_contexts) {
push(@{$changes{'authtypes'}},$item);
}
}
@@ -3182,27 +3905,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 .= '