';
+ $$rowtotal ++;
+ return $datatable;
+}
+
+sub legacy_scantronformat {
+ my ($r,$dom,$confname,$file,$legacyfile,$newurl,$newfile) = @_;
+ my ($url,$error);
+ my @statinfo = &Apache::lonnet::stat_file($newurl);
+ if ((!@statinfo) || ($statinfo[0] eq 'no_such_dir')) {
+ (my $result,$url) =
+ &publishlogo($r,'copy',$legacyfile,$dom,$confname,'scantron',
+ '','',$newfile);
+ if ($result ne 'ok') {
+ $error = &mt("An error occurred publishing the [_1] scantron format file in RES space. Error was: [_2].",$newfile,$result);
+ }
+ }
+ return ($url,$error);
+}
+
sub modifiable_userdata_row {
my ($context,$role,$settings,$numinrow,$rowcount) = @_;
my $rolename;
@@ -1807,25 +2039,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 +2114,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,21 +2132,32 @@ 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;
+ my @toggles = ('coursecatalog','adminmail','newuser');
+ my %defaultchecked = (
+ 'coursecatalog' => 'on',
+ 'adminmail' => 'off',
+ 'newuser' => 'off',
+ );
+ 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')) {
@@ -2034,16 +2261,8 @@ sub modify_colors {
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 +2294,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 +2397,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}) {
@@ -2309,7 +2543,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 +2551,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 +2559,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 +2589,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 +2785,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_(.+)$/) {
@@ -2683,7 +2920,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 +3049,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,20 +3315,26 @@ 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') {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth'))) {
+ if (($cancreate{$item} eq 'any') || ($cancreate{$item} eq 'login')) {
+ $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.');
+ }
+ }
+ }
}
if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
foreach my $item (@contexts) {
@@ -3101,7 +3344,7 @@ sub modify_usercreation {
}
} 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 +3355,7 @@ sub modify_usercreation {
}
}
} else {
- foreach my $item ('author','course') {
+ foreach my $item (@contexts) {
push(@{$changes{'cancreate'}},$item);
}
}
@@ -3147,10 +3390,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 +3419,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 +3430,7 @@ sub modify_usercreation {
}
}
} else {
- foreach my $item (@contexts) {
+ foreach my $item (@authen_contexts) {
push(@{$changes{'authtypes'}},$item);
}
}
@@ -3182,6 +3440,7 @@ sub modify_usercreation {
cancreate => \%cancreate,
username_rule => \@username_rule,
id_rule => \@id_rule,
+ email_rule => \@email_rule,
authtypes => \%authhash,
}
);
@@ -3194,15 +3453,29 @@ sub modify_usercreation {
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} eq 'none') {
+ $chgtext .= &mt('creation of a new user account is not permitted.');
+ } elsif ($cancreate{$type} eq 'any') {
+ $chgtext .= &mt('creation of a new account is permitted for users authenticated by institutional log-in and SSO, and also for e-mail addresses used as usernames.');
+ } elsif ($cancreate{$type} eq 'login') {
+ $chgtext .= &mt('creation of a new account is only permitted for users authenticated by institutional log-in.');
+ } elsif ($cancreate{$type} eq 'sso') {
+ $chgtext .= &mt('creation of a new account is only permitted for users authenticated by institutional single sign on.');
+ } elsif ($cancreate{$type} eq 'email') {
+ $chgtext .= &mt('creation of a new account is only permitted for users who provide a valid e-mail address for use as the username.');
+ }
+ } 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 .= '