--- loncom/interface/domainprefs.pm 2007/12/11 00:44:23 1.33
+++ loncom/interface/domainprefs.pm 2008/05/15 13:50:23 1.41.2.1
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.33 2007/12/11 00:44:23 raeburn Exp $
+# $Id: domainprefs.pm,v 1.41.2.1 2008/05/15 13:50:23 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -127,8 +127,10 @@ sub handler {
'usercreation' =>
{ text => 'User creation',
help => 'Domain_User_Creation',
- header => [{col1 => 'Setting',
- col2 => 'Value',},
+ header => [{col1 => 'Format Rule Type',
+ col2 => 'Format Rules in force'},
+ {col1 => 'User account creation',
+ col2 => 'Usernames which may be created',},
{col1 => 'Context',
col2 => 'Assignable Authentication Types'}],
},
@@ -245,7 +247,7 @@ sub handler {
my @ids=&Apache::lonnet::current_machine_ids();
if (!grep(/^\Q$primarylibserv\E$/,@ids)) {
my %designhash = &Apache::loncommon::get_domainconf($dom);
- my @loginimages = ('img','logo','domlogo');
+ my @loginimages = ('img','logo','domlogo','login');
my $custom_img_count = 0;
foreach my $img (@loginimages) {
if ($designhash{$dom.'.login.'.$img} ne '') {
@@ -279,11 +281,24 @@ sub handler {
' /> '.
'
');
+ ' />'."\n".''."\n");
+ $seconddiv = 1;
+ }
}
- $r->print('
'.&mt('Display options').' '."\n".
+ $r->print(''.
+ &mt('Display options').' '."\n".
''.&mt('Display using: ')."\n".
' '.
&mt('one column').' '.
@@ -372,7 +387,18 @@ sub print_config_box {
if ($action eq 'autoupdate') {
$output .= &print_autoupdate('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'usercreation') {
- $output .= &print_usercreation('bottom',$dom,$settings,\$rowtotal);
+ $output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).'
+
+
+
+
+
+
+
+ '.$item->{'header'}->[2]->{'col1'}.'
+ '.$item->{'header'}->[2]->{'col2'}.' '.
+ &print_usercreation('bottom',$dom,$settings,\$rowtotal);
+ $rowtotal ++;
} elsif ($action eq 'usermodification') {
$output .= &print_usermodification('bottom',$dom,$settings,\$rowtotal);
} else {
@@ -542,10 +568,12 @@ sub print_footer {
sub print_login {
my ($dom,$confname,$phase,$settings,$rowtotal) = @_;
my %choices = &login_choices();
- my ($catalogon,$catalogoff,$adminmailon,$adminmailoff);
+ my ($catalogon,$catalogoff,$adminmailon,$adminmailoff,$loginheader);
$catalogon = ' checked="checked" ';
$adminmailoff = ' checked="checked" ';
- my @images = ('img','logo','domlogo');
+ $loginheader = 'image';
+ my @images = ('img','logo','domlogo','login');
+ my @logintext = ('textcol','bgcol');
my @bgs = ('pgbg','mainbg','sidebg');
my @links = ('link','alink','vlink');
my %designhash = &Apache::loncommon::get_domainconf($dom);
@@ -560,6 +588,9 @@ sub print_login {
foreach my $item (@bgs) {
$defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
}
+ foreach my $item (@logintext) {
+ $defaults{'logintext'}{$item} = $defaultdesign{'login.'.$item};
+ }
foreach my $item (@links) {
$defaults{'links'}{$item} = $defaultdesign{'login.'.$item};
}
@@ -578,6 +609,15 @@ sub print_login {
$is_custom{$item} = 1;
}
}
+ foreach my $item (@logintext) {
+ if ($settings->{$item} ne '') {
+ $designs{'logintext'}{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ if ($settings->{'loginheader'} ne '') {
+ $loginheader = $settings->{'loginheader'};
+ }
if ($settings->{'font'} ne '') {
$designs{'font'} = $settings->{'font'};
$is_custom{'font'} = 1;
@@ -620,7 +660,8 @@ sub print_login {
}
my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner',
logo => 'Institution Logo',
- domlogo => 'Domain Logo');
+ domlogo => 'Domain Logo',
+ login => 'Login box');
my $itemcount = 1;
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
my $datatable =
@@ -641,7 +682,7 @@ sub print_login {
' '.&mt('No').' ';
$itemcount ++;
- $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal);
+ $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext,$loginheader);
$datatable .= '
';
return $datatable;
}
@@ -654,6 +695,9 @@ sub login_choices {
img => "Header",
logo => "Main Logo",
domlogo => "Domain Logo",
+ login => "Log-in Header",
+ textcol => "Text color",
+ bgcol => "Box color",
bgs => "Background colors",
links => "Link colors",
font => "Font color",
@@ -741,7 +785,7 @@ sub print_rolecolors {
sub display_color_options {
my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,
- $images,$bgs,$links,$alt_text,$rowtotal) = @_;
+ $images,$bgs,$links,$alt_text,$rowtotal,$logintext,$loginheader) = @_;
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
my $datatable = ''.
''.$choices->{'font'}.' ';
@@ -763,13 +807,19 @@ sub display_color_options {
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .= ' '.
''.$choices->{$img}.' ';
- my ($imgfile, $img_import);
+ my ($imgfile,$img_import,$login_hdr_pick,$logincolors);
if ($designs->{$img} ne '') {
$imgfile = $designs->{$img};
$img_import = ($imgfile =~ m{^/adm/});
} else {
$imgfile = $defaults->{$img};
}
+ if ($img eq 'login') {
+ $login_hdr_pick = &login_header_options($img,$role,$defaults,$is_custom,$choices,
+ $loginheader);
+ $logincolors =
+ &login_text_colors($img,$role,$logintext,$phase,$choices,$designs);
+ }
if ($imgfile) {
my ($showfile,$fullsize);
if ($imgfile =~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
@@ -810,25 +860,32 @@ sub display_color_options {
}
}
if ($showfile) {
- $showfile = &Apache::loncommon::lonhttpdurl($showfile);
- $fullsize = &Apache::loncommon::lonhttpdurl($imgfile);
- $datatable.= '';
- if (!$is_custom->{$img}) {
- $datatable .= &mt('Default in use:').' ';
- }
- if ($img_import) {
- $datatable.= ' ';
- }
- $datatable.= ' ';
- if ($is_custom->{$img}) {
- $datatable.=' '.&mt('Delete?').
- ' '.&mt('Replace:').' ';
- } else {
- $datatable.=''.&mt('Upload:').' ';
+ if ($showfile =~ m{^/(adm|res)/}) {
+ if ($showfile =~ m{^/res/}) {
+ my $local_showfile =
+ &Apache::lonnet::filelocation('',$showfile);
+ &Apache::lonnet::repcopy($local_showfile);
+ }
+ $showfile = &Apache::loncommon::lonhttpdurl($showfile);
+ }
+ if ($imgfile) {
+ if ($imgfile =~ m{^/(adm|res)/}) {
+ if ($imgfile =~ m{^/res/}) {
+ my $local_imgfile =
+ &Apache::lonnet::filelocation('',$imgfile);
+ &Apache::lonnet::repcopy($local_imgfile);
+ }
+ $fullsize = &Apache::loncommon::lonhttpdurl($imgfile);
+ } else {
+ $fullsize = $imgfile;
+ }
+ }
+ $datatable .= ' ';
+ if ($img eq 'login') {
+ $datatable .= $login_hdr_pick;
}
+ $datatable .= &image_changes($is_custom->{$img},$alt_text->{$img},$img_import,
+ $showfile,$fullsize,$role,$img,$imgfile,$logincolors);
} else {
$datatable .= ' '.
&mt('Upload:');
@@ -868,7 +925,7 @@ sub display_color_options {
$datatable .= ' ';
}
$datatable .= ' ';
+ '" onblur = "javascript:colchg_span('."'css_".$role.'_'.$item."'".',this);" />';
}
$datatable .= ' ';
$itemcount ++;
@@ -902,6 +959,79 @@ sub display_color_options {
return $datatable;
}
+sub login_header_options {
+ my ($img,$role,$defaults,$is_custom,$choices,$loginheader) = @_;
+ my $image_checked = ' checked="checked" ';
+ my $text_checked = ' ';
+ if ($loginheader eq 'text') {
+ $image_checked = ' ';
+ $text_checked = ' checked="checked" ';
+ }
+ my $output = ' '.
+ &mt('use image').' '.
+ ' '.&mt('use text').' '."\n";
+ if ((!$is_custom->{'textcol'}) || (!$is_custom->{'bgcol'})) {
+ $output .= &mt('Text default(s)').': ';
+ if (!$is_custom->{'textcol'}) {
+ $output .= $choices->{'textcol'}.': '.$defaults->{'logintext'}{'textcol'}.
+ ' ';
+ }
+ if (!$is_custom->{'bgcol'}) {
+ $output .= $choices->{'bgcol'}.': '.
+ ' ';
+ }
+ $output .= ' ';
+ }
+ $output .=' ';
+ return $output;
+}
+
+sub login_text_colors {
+ my ($img,$role,$logintext,$phase,$choices,$designs) = @_;
+ my $color_menu = ' ';
+ return $color_menu;
+}
+
+sub image_changes {
+ my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;
+ my $output;
+ if (!$is_custom) {
+ if ($img eq 'login') {
+ $output .= &mt('Default image:').' ';
+ } else {
+ $output .= &mt('Default in use:').' ';
+ }
+ }
+ if ($img_import) {
+ $output .= ' ';
+ }
+ $output .= ' ';
+ if ($is_custom) {
+ $output .= '
'.$logincolors.''.
+ ' '.&mt('Delete?').
+ ' '.&mt('Replace:').' ';
+ } else {
+ $output .= ' '.$logincolors.&mt('Upload:').' ';
+ }
+ return $output;
+}
+
sub color_pick {
my ($phase,$role,$item,$desc,$curcol) = @_;
my $link = '{'sender_uname'};
+ }
my $datatable=''.
''.&mt('Auto-enrollment active?').' '.
''.
@@ -1021,8 +1174,7 @@ sub print_autoenroll {
' '.
&mt('username').': '.
' '.&mt('domain').
+ $notif_sender.'" size="10" /> '.&mt('domain').
': '.$domform.' ';
$$rowtotal += 2;
return $datatable;
@@ -1165,9 +1317,11 @@ sub print_directorysrch {
foreach my $title (@{$titleorder}) {
if (defined($searchtitles->{$title})) {
my $check = ' ';
- if (ref($settings->{'searchby'}) eq 'ARRAY') {
- if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
- $check = ' checked="checked" ';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'searchby'}) eq 'ARRAY') {
+ if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
+ $check = ' checked="checked" ';
+ }
}
}
$datatable .= ' '.
@@ -1297,33 +1451,10 @@ sub print_usercreation {
my ($position,$dom,$settings,$rowtotal) = @_;
my $numinrow = 4;
my $datatable;
- my %lt = &Apache::lonlocal::texthash (
- nondc => 'User creation other than by Domain Coordinator: ',
- author => 'When adding a co-author/assistant author',
- course => 'When adding users to a course',
- );
if ($position eq 'top') {
- my %checked;
- if (ref($settings) eq 'HASH') {
- if (ref($settings->{'cancreate'}) eq 'ARRAY') {
- foreach my $item (@{$settings->{'cancreate'}}) {
- $checked{$item} = ' checked="checked" ';
- }
- }
- }
- $datatable = ' '.
- ''.$lt{'nondc'}.
- ' ';
$$rowtotal ++;
- my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username');
my $rowcount = 0;
+ my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username');
if (ref($rules) eq 'HASH') {
if (keys(%{$rules}) > 0) {
$datatable .= &user_formats_row('username',$settings,$rules,
@@ -1341,6 +1472,64 @@ sub print_usercreation {
$rowcount ++;
}
}
+ if ($rowcount == 0) {
+ $datatable .= ''.&mt('No format rules have been defined for usernames or IDs in this domain.').' ';
+ $$rowtotal ++;
+ $rowcount ++;
+ }
+ } elsif ($position eq 'middle') {
+ my @creators = ('author','course');
+ my ($rules,$ruleorder) =
+ &Apache::lonnet::inst_userrules($dom,'username');
+ my %lt = &usercreation_types();
+ my %checked;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'cancreate'}) eq 'HASH') {
+ foreach my $item (@creators) {
+ $checked{$item} = $settings->{'cancreate'}{$item};
+ }
+ } elsif (ref($settings->{'cancreate'}) eq 'ARRAY') {
+ foreach my $item (@creators) {
+ if (grep(/^\Q$item\E$/,@{$settings->{'cancreate'}})) {
+ $checked{$item} = 'none';
+ }
+ }
+ }
+ }
+ my $rownum = 0;
+ foreach my $item (@creators) {
+ $rownum ++;
+ if ($checked{$item} eq '') {
+ $checked{$item} = 'any';
+ }
+ my $css_class;
+ if ($rownum%2) {
+ $css_class = '';
+ } else {
+ $css_class = ' class="LC_odd_row" ';
+ }
+ $datatable .= ''.
+ ''.$lt{$item}.
+ ' ';
+ my @options = ('any');
+ if (ref($rules) eq 'HASH') {
+ if (keys(%{$rules}) > 0) {
+ push(@options,('official','unofficial'));
+ }
+ }
+ push(@options,'none');
+ foreach my $option (@options) {
+ my $check = ' ';
+ if ($checked{$item} eq $option) {
+ $check = ' checked="checked" ';
+ }
+ $datatable .= ''.
+ ' '.
+ $lt{$option}.' ';
+ }
+ $datatable .= ' ';
+ }
} else {
my @contexts = ('author','course','domain');
my @authtypes = ('int','krb4','krb5','loc');
@@ -1357,8 +1546,13 @@ sub print_usercreation {
}
}
}
+ } else {
+ foreach my $item (@contexts) {
+ foreach my $auth (@authtypes) {
+ $checked{$item}{$auth} = ' checked="checked" ';
+ }
+ }
}
- my @authtypes = ('int','krb4','krb5','loc');
my %title = &context_names();
my %authname = &authtype_names();
my $rownum = 0;
@@ -1412,9 +1606,11 @@ sub user_formats_row {
$output .= '';
}
my $check = ' ';
- if (ref($settings->{$type.'_rule'}) eq 'ARRAY') {
- if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}})) {
- $check = ' checked="checked" ';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$type.'_rule'}) eq 'ARRAY') {
+ if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}})) {
+ $check = ' checked="checked" ';
+ }
}
}
$output .= ''.
@@ -1437,6 +1633,18 @@ sub user_formats_row {
return $output;
}
+sub usercreation_types {
+ my %lt = &Apache::lonlocal::texthash (
+ author => 'When adding a co-author',
+ course => 'When adding a user to a course',
+ any => 'Any',
+ official => 'Institutional only ',
+ unofficial => 'Non-institutional only',
+ none => 'None',
+ );
+ return %lt;
+}
+
sub authtype_names {
my %lt = &Apache::lonlocal::texthash(
int => 'Internal',
@@ -1657,10 +1865,12 @@ sub usertype_update_row {
$datatable .= ' ';
}
my $check = ' ';
- if (ref($settings->{'fields'}) eq 'HASH') {
- if (ref($settings->{'fields'}{$type}) eq 'ARRAY') {
- if (grep(/^\Q$fields->[$i]\E$/,@{$settings->{'fields'}{$type}})) {
- $check = ' checked="checked" ';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'fields'}) eq 'HASH') {
+ if (ref($settings->{'fields'}{$type}) eq 'ARRAY') {
+ if (grep(/^\Q$fields->[$i]\E$/,@{$settings->{'fields'}{$type}})) {
+ $check = ' checked="checked" ';
+ }
}
}
}
@@ -1690,13 +1900,15 @@ sub modify_login {
my ($r,$dom,$confname,%domconfig) = @_;
my ($resulttext,$errors,$colchgtext,%changes,%colchanges);
my %title = ( coursecatalog => 'Display course catalog',
- adminmail => 'Display administrator E-mail address');
+ adminmail => 'Display administrator E-mail address',
+ 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'};
+ $loginhash{login}{loginheader} = $env{'form.loginheader'};
if (ref($colchanges{'login'}) eq 'HASH') {
$colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
\%loginhash);
@@ -1720,10 +1932,23 @@ sub modify_login {
($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;
+ }
if (keys(%changes) > 0 || $colchgtext) {
+ &Apache::loncommon::devalidate_domconfig_cache($dom);
$resulttext = &mt('Changes made:').'';
foreach my $item (sort(keys(%changes))) {
- $resulttext .= ''.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").' ';
+ if ($item eq 'loginheader') {
+ $resulttext .= ''.&mt("$title{$item} set to $env{'form.loginheader'}").' ';
+ } else {
+ $resulttext .= ''.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").' ';
+ }
}
$resulttext .= $colchgtext.' ';
} else {
@@ -1767,6 +1992,7 @@ sub modify_rolecolors {
$dom);
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
+ &Apache::loncommon::devalidate_domconfig_cache($dom);
$resulttext = &display_colorchgs($dom,\%changes,$roles,
$rolehash{'rolecolors'});
} else {
@@ -1786,24 +2012,28 @@ 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);
@@ -1817,6 +2047,9 @@ sub modify_colors {
}
}
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})
@@ -1924,20 +2157,31 @@ 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 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;
@@ -1948,6 +2192,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} = '';
@@ -1962,7 +2211,6 @@ sub default_change_checker {
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:').' ';
}
@@ -2820,7 +3068,7 @@ sub modify_contacts {
}
$resulttext .= '';
} else {
- $resulttext = &mt('No changes made to contact information.');
+ $resulttext = &mt('No changes made to contact information');
}
} else {
$resulttext = ''.
@@ -2831,7 +3079,7 @@ sub modify_contacts {
sub modify_usercreation {
my ($dom,%domconfig) = @_;
- my ($resulttext,%curr_usercreation,%changes,%authallowed);
+ my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate);
if (ref($domconfig{'usercreation'}) eq 'HASH') {
foreach my $key (keys(%{$domconfig{'usercreation'}})) {
$curr_usercreation{$key} = $domconfig{'usercreation'}{$key};
@@ -2843,21 +3091,34 @@ sub modify_usercreation {
);
my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule');
- my @cancreate = &Apache::loncommon::get_env_multiple('form.can_createuser');
- if (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') {
- foreach my $type (@{$curr_usercreation{'cancreate'}}) {
- if (!grep(/^\Q$type\E$/,@cancreate)) {
- push(@{$changes{'cancreate'}},$type);
- }
+ my @contexts = ('author','course');
+ foreach my $item(@contexts) {
+ $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);
+ }
}
- foreach my $type (@cancreate) {
- if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$type);
+ } elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') {
+ foreach my $item (@contexts) {
+ if (grep(/^\Q$item\E$/,@{$curr_usercreation{'cancreate'}})) {
+ if ($cancreate{$item} ne 'any') {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ } else {
+ if ($cancreate{$item} ne 'none') {
+ push(@{$changes{'cancreate'}},$item);
+ }
}
}
} else {
- push(@{$changes{'cancreate'}},@cancreate);
+ foreach my $item ('author','course') {
+ push(@{$changes{'cancreate'}},$item);
+ }
}
+
if (ref($curr_usercreation{'username_rule'}) eq 'ARRAY') {
foreach my $type (@{$curr_usercreation{'username_rule'}}) {
if (!grep(/^\Q$type\E$/,@username_rule)) {
@@ -2920,7 +3181,7 @@ sub modify_usercreation {
my %usercreation_hash = (
usercreation => {
- cancreate => \@cancreate,
+ cancreate => \%cancreate,
username_rule => \@username_rule,
id_rule => \@id_rule,
authtypes => \%authhash,
@@ -2933,15 +3194,19 @@ sub modify_usercreation {
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').'';
if (ref($changes{'cancreate'}) eq 'ARRAY') {
- my $chgtext = '';
- foreach my $type (@cancreate) {
- $chgtext .= ''.$title{$type}.' ';
- }
- $chgtext .= ' ';
- if (@cancreate > 0) {
- $resulttext .= ''.&mt('Creation of new users is permitted by a Domain Coordinator, and also by other users when: ').$chgtext.' ';
- } else {
- $resulttext .= ''.&mt("Creation of new users is now only allowed when the user's role is Domain Coordinator.").' ';
+ 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});
+ }
+ $resulttext .= ''.$chgtext.' ';
}
}
if (ref($changes{'username_rule'}) eq 'ARRAY') {