--- loncom/interface/domainprefs.pm 2008/05/15 13:50:23 1.41.2.1
+++ loncom/interface/domainprefs.pm 2008/02/15 17:02:31 1.42
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.41.2.1 2008/05/15 13:50:23 raeburn Exp $
+# $Id: domainprefs.pm,v 1.42 2008/02/15 17:02:31 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -568,10 +568,22 @@ sub print_footer {
sub print_login {
my ($dom,$confname,$phase,$settings,$rowtotal) = @_;
my %choices = &login_choices();
- my ($catalogon,$catalogoff,$adminmailon,$adminmailoff,$loginheader);
- $catalogon = ' checked="checked" ';
- $adminmailoff = ' checked="checked" ';
- $loginheader = 'image';
+ my %defaultchecked = (
+ 'coursecatalog' => 'on',
+ 'adminmail' => 'off',
+ );
+ my @toggles = ('coursecatalog','adminmail');
+ my (%checkedon,%checkedoff);
+ foreach my $item (@toggles) {
+ if ($defaultchecked{$item} eq 'on') {
+ $checkedon{$item} = ' checked="checked" ';
+ $checkedoff{$item} = ' ';
+ } elsif ($defaultchecked{$item} eq 'off') {
+ $checkedoff{$item} = ' checked="checked" ';
+ $checkedon{$item} = ' ';
+ }
+ }
+ my $loginheader = 'image';
my @images = ('img','logo','domlogo','login');
my @logintext = ('textcol','bgcol');
my @bgs = ('pgbg','mainbg','sidebg');
@@ -595,13 +607,14 @@ sub print_login {
$defaults{'links'}{$item} = $defaultdesign{'login.'.$item};
}
if (ref($settings) eq 'HASH') {
- if ($settings->{'coursecatalog'} eq '0') {
- $catalogoff = $catalogon;
- $catalogon = ' ';
- }
- if ($settings->{'adminmail'} eq '1') {
- $adminmailon = $adminmailoff;
- $adminmailoff = ' ';
+ foreach my $item (@toggles) {
+ if ($settings->{$item} eq '1') {
+ $checkedon{$item} = ' checked="checked" ';
+ $checkedoff{$item} = ' ';
+ } elsif ($settings->{$item} eq '0') {
+ $checkedoff{$item} = ' checked="checked" ';
+ $checkedon{$item} = ' ';
+ }
}
foreach my $item (@images) {
if ($settings->{$item} ne '') {
@@ -663,25 +676,19 @@ sub print_login {
domlogo => 'Domain Logo',
login => 'Login box');
my $itemcount = 1;
- my $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $datatable =
- '
'.$choices{'coursecatalog'}.
- ' | '.
- ' '.
- ' | '.
- '
';
- $itemcount ++;
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
- $datatable .= ''.
- ''.$choices{'adminmail'}.' | '.
- ''.
- ' '.
- ' |
';
- $itemcount ++;
+ my ($css_class,$datatable);
+ foreach my $item (@toggles) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .=
+ ''.$choices{$item}.
+ ' | '.
+ ' | '.
+ '
';
+ $itemcount ++;
+ }
$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;
@@ -1906,8 +1913,10 @@ sub modify_login {
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');
+ 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 +1925,31 @@ 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');
+ my %defaultchecked = (
+ 'coursecatalog' => 'on',
+ 'adminmail' => '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')) {
@@ -2012,7 +2031,7 @@ sub modify_rolecolors {
sub modify_colors {
my ($r,$dom,$confname,$roles,$domconfig,$confhash) = @_;
my (%changes,%choices);
- my @bgs;
+ my @bgs = ('pgbg','mainbg','sidebg');
my @links = ('link','alink','vlink');
my @logintext;
my @images;
@@ -2027,10 +2046,8 @@ 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) {