--- loncom/interface/domainprefs.pm 2011/10/23 23:46:02 1.157
+++ loncom/interface/domainprefs.pm 2012/12/20 02:43:28 1.179
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.157 2011/10/23 23:46:02 www Exp $
+# $Id: domainprefs.pm,v 1.179 2012/12/20 02:43:28 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -86,8 +86,8 @@ $dom,$settings,$rowtotal,$action.
$dom is the domain, $settings is a reference to a hash of current settings for
the current context, $rowtotal is a reference to the scalar used to record the
-number of rows displayed on the page, and $action is the context (either quotas
-or requestcourses).
+number of rows displayed on the page, and $action is the context (quotas,
+requestcourses or requestauthor).
The print_quotas routine was orginally created to display/store information
about default quota sizes for portfolio spaces for the different types of
@@ -211,13 +211,19 @@ sub handler {
'directorysrch','usercreation','usermodification',
'contacts','defaults','scantron','coursecategories',
'serverstatuses','requestcourses','helpsettings',
- 'coursedefaults','usersessions','loadbalancing'],$dom);
+ 'coursedefaults','usersessions','loadbalancing',
+ 'requestauthor'],$dom);
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
'autoupdate','autocreate','directorysrch','contacts',
'usercreation','usermodification','scantron',
- 'requestcourses','coursecategories','serverstatuses','helpsettings',
+ 'requestcourses','requestauthor','coursecategories',
+ 'serverstatuses','helpsettings',
'coursedefaults','usersessions');
- if (keys(%servers) > 1) {
+ my %existing;
+ if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
+ %existing = %{$domconfig{'loadbalancing'}};
+ }
+ if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
push(@prefs_order,'loadbalancing');
}
my %prefs = (
@@ -236,10 +242,11 @@ sub handler {
'login' =>
{ text => 'Log-in page options',
help => 'Domain_Configuration_Login_Page',
- header => [{col1 => 'Item',
- col2 => '',}],
+ header => [{col1 => 'Log-in Page Items',
+ col2 => '',},
+ {col1 => 'Log-in Help',
+ col2 => 'Value'}],
},
-
'defaults' =>
{ text => 'Default authentication/language/timezone/portal',
help => 'Domain_Configuration_LangTZAuth',
@@ -247,7 +254,7 @@ sub handler {
col2 => 'Value'}],
},
'quotas' =>
- { text => 'User blogs, personal information pages, portfolios',
+ { text => 'Blogs, personal web pages, webDAV, portfolios',
help => 'Domain_Configuration_Quotas',
header => [{col1 => 'User affiliation',
col2 => 'Available tools',
@@ -323,6 +330,14 @@ sub handler {
{col1 => 'Setting',
col2 => 'Value'}],
},
+ 'requestauthor' =>
+ {text => 'Request authoring space',
+ help => 'Domain_Configuration_Request_Author',
+ header => [{col1 => 'User affiliation',
+ col2 => 'Availability/Processing of requests',},
+ {col1 => 'Setting',
+ col2 => 'Value'}],
+ },
'coursecategories' =>
{ text => 'Cataloging of courses/communities',
help => 'Domain_Configuration_Cataloging_Courses',
@@ -343,10 +358,8 @@ sub handler {
'helpsettings' =>
{text => 'Help page settings',
help => 'Domain_Configuration_Help_Settings',
- header => [{col1 => 'Authenticated Help Settings',
- col2 => ''},
- {col1 => 'Unauthenticated Help Settings',
- col2 => ''}],
+ header => [{col1 => 'Help Settings (logged-in users)',
+ col2 => 'Value'}],
},
'coursedefaults' =>
{text => 'Course/Community defaults',
@@ -375,7 +388,7 @@ sub handler {
'loadbalancing' =>
{text => 'Dedicated Load Balancer',
help => 'Domain_Configuration_Load_Balancing',
- header => [{col1 => 'Server',
+ header => [{col1 => 'Balancers',
col2 => 'Default destinations',
col3 => 'User affliation',
col4 => 'Overrides'},
@@ -388,26 +401,33 @@ sub handler {
header => [{col1 => 'Log-in Service',
col2 => 'Server Setting',},
{col1 => 'Log-in Page Items',
- col2 => ''}],
+ col2 => ''},
+ {col1 => 'Log-in Help',
+ col2 => 'Value'}],
};
}
+
+
+
my @roles = ('student','coordinator','author','admin');
my @actions = &Apache::loncommon::get_env_multiple('form.actions');
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'pickactions')",
text=>"Settings to display/modify"});
my $confname = $dom.'-domainconfig';
+
if ($phase eq 'process') {
&Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles);
} elsif ($phase eq 'display') {
- my $js;
- if (keys(%servers) > 1) {
+ my $js = &recaptcha_js();
+ if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($dom);
- $js = &lonbalance_targets_js($dom,$types,\%servers).
- &new_spares_js().
- &common_domprefs_js().
- &Apache::loncommon::javascript_array_indexof();
+ $js .= &lonbalance_targets_js($dom,$types,\%servers,
+ $domconfig{'loadbalancing'}).
+ &new_spares_js().
+ &common_domprefs_js().
+ &Apache::loncommon::javascript_array_indexof();
}
&Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js);
} else {
@@ -444,6 +464,7 @@ sub handler {
}
}
}
+
&Apache::lonconfigsettings::display_choices($r,$phase,$context,\@prefs_order,\%prefs);
}
return OK;
@@ -487,6 +508,8 @@ sub process_changes {
$output = &modify_serverstatuses($dom,%domconfig);
} elsif ($action eq 'requestcourses') {
$output = &modify_quotas($dom,$action,%domconfig);
+ } elsif ($action eq 'requestauthor') {
+ $output = &modify_quotas($dom,$action,%domconfig);
} elsif ($action eq 'helpsettings') {
$output = &modify_helpsettings($r,$dom,$confname,%domconfig);
} elsif ($action eq 'coursedefaults') {
@@ -503,6 +526,7 @@ sub print_config_box {
my ($r,$dom,$confname,$phase,$action,$item,$settings) = @_;
my $rowtotal = 0;
my $output;
+
if ($action eq 'coursecategories') {
$output = &coursecategories_javascript($settings);
}
@@ -521,7 +545,8 @@ sub print_config_box {
if ($numheaders > 1) {
my $colspan = '';
my $rightcolspan = '';
- if (($action eq 'rolecolors') || ($action eq 'coursecategories') || ($action eq 'helpsettings')) {
+ if (($action eq 'rolecolors') || ($action eq 'coursecategories') ||
+ (($action eq 'login') && ($numheaders < 3))) {
$colspan = ' colspan="2"';
}
if ($action eq 'usersessions') {
@@ -545,12 +570,16 @@ sub print_config_box {
} elsif ($action eq 'coursecategories') {
$output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal);
} elsif ($action eq 'login') {
- $output .= &print_login('top',$dom,$confname,$phase,$settings,\$rowtotal);
- $colspan = ' colspan="2"';
+ if ($numheaders == 3) {
+ $colspan = ' colspan="2"';
+ $output .= &print_login('service',$dom,$confname,$phase,$settings,\$rowtotal);
+ } else {
+ $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal);
+ }
} elsif ($action eq 'requestcourses') {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
- } elsif ($action eq 'helpsettings') {
- $output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal);
+ } elsif ($action eq 'requestauthor') {
+ $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
} elsif ($action eq 'usersessions') {
$output .= &print_usersessions('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'rolecolors') {
@@ -613,11 +642,26 @@ sub print_config_box {
} elsif ($action eq 'coursecategories') {
$output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
} elsif ($action eq 'login') {
- $output .= &print_login('bottom',$dom,$confname,$phase,$settings,\$rowtotal);
+ if ($numheaders == 3) {
+ $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).'
+
+
+
+
+
+
+
+ '.&mt($item->{'header'}->[2]->{'col1'}).' |
+ '.&mt($item->{'header'}->[2]->{'col2'}).' | '.
+ &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal);
+ $rowtotal ++;
+ } else {
+ $output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal);
+ }
} elsif ($action eq 'requestcourses') {
- $output .= &print_courserequestmail($dom,$settings,\$rowtotal);
- } elsif ($action eq 'helpsettings') {
- $output .= &print_helpsettings('bottom',$dom,$confname,$settings,\$rowtotal);
+ $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
+ } elsif ($action eq 'requestauthor') {
+ $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
} elsif ($action eq 'usersessions') {
$output .= &print_usersessions('middle',$dom,$settings,\$rowtotal).'
@@ -709,10 +753,7 @@ sub print_config_box {
}
$output .= ' |
';
$rowtotal ++;
- if ($action eq 'login') {
- $output .= &print_login('bottom',$dom,$confname,$phase,$settings,
- \$rowtotal);
- } elsif ($action eq 'quotas') {
+ if ($action eq 'quotas') {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
} elsif ($action eq 'autoenroll') {
$output .= &print_autoenroll($dom,$settings,\$rowtotal);
@@ -729,7 +770,7 @@ sub print_config_box {
} elsif ($action eq 'serverstatuses') {
$output .= &print_serverstatuses($dom,$settings,\$rowtotal);
} elsif ($action eq 'helpsettings') {
- $output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal);
+ $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal);
} elsif ($action eq 'loadbalancing') {
$output .= &print_loadbalancing($dom,$settings,\$rowtotal);
}
@@ -743,11 +784,11 @@ sub print_config_box {
}
sub print_login {
- my ($position,$dom,$confname,$phase,$settings,$rowtotal) = @_;
+ my ($caller,$dom,$confname,$phase,$settings,$rowtotal) = @_;
my ($css_class,$datatable);
my %choices = &login_choices();
- if ($position eq 'top') {
+ if ($caller eq 'service') {
my %servers = &Apache::lonnet::internet_dom_servers($dom);
my $choice = $choices{'disallowlogin'};
$css_class = ' class="LC_odd_row"';
@@ -774,7 +815,7 @@ sub print_login {
' | ';
return $datatable;
- }
-
- my %defaultchecked = (
- 'coursecatalog' => 'on',
- 'adminmail' => 'off',
- 'newuser' => 'off',
- );
- my @toggles = ('coursecatalog','adminmail','newuser');
- 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 @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);
- my %defaultdesign = %Apache::loncommon::defaultdesign;
- my (%is_custom,%designs);
- my %defaults = (
- font => $defaultdesign{'login.font'},
- );
- foreach my $item (@images) {
- $defaults{$item} = $defaultdesign{'login.'.$item};
- $defaults{'showlogo'}{$item} = 1;
- }
- 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};
- }
- if (ref($settings) eq 'HASH') {
+ } elsif ($caller eq 'page') {
+ my %defaultchecked = (
+ 'coursecatalog' => 'on',
+ 'adminmail' => 'off',
+ 'newuser' => 'off',
+ );
+ my @toggles = ('coursecatalog','adminmail','newuser');
+ my (%checkedon,%checkedoff);
foreach my $item (@toggles) {
- if ($settings->{$item} eq '1') {
- $checkedon{$item} = ' checked="checked" ';
+ if ($defaultchecked{$item} eq 'on') {
+ $checkedon{$item} = ' checked="checked" ';
$checkedoff{$item} = ' ';
- } elsif ($settings->{$item} eq '0') {
- $checkedoff{$item} = ' checked="checked" ';
+ } elsif ($defaultchecked{$item} eq 'off') {
+ $checkedoff{$item} = ' checked="checked" ';
$checkedon{$item} = ' ';
}
}
+ 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);
+ my %defaultdesign = %Apache::loncommon::defaultdesign;
+ my (%is_custom,%designs);
+ my %defaults = (
+ font => $defaultdesign{'login.font'},
+ );
foreach my $item (@images) {
- if (defined($settings->{$item})) {
- $designs{$item} = $settings->{$item};
- $is_custom{$item} = 1;
- }
- if (defined($settings->{'showlogo'}{$item})) {
- $designs{'showlogo'}{$item} = $settings->{'showlogo'}{$item};
- }
+ $defaults{$item} = $defaultdesign{'login.'.$item};
+ $defaults{'showlogo'}{$item} = 1;
+ }
+ foreach my $item (@bgs) {
+ $defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
}
foreach my $item (@logintext) {
- if ($settings->{$item} ne '') {
- $designs{'logintext'}{$item} = $settings->{$item};
- $is_custom{$item} = 1;
- }
+ $defaults{'logintext'}{$item} = $defaultdesign{'login.'.$item};
}
- if ($settings->{'font'} ne '') {
- $designs{'font'} = $settings->{'font'};
- $is_custom{'font'} = 1;
+ foreach my $item (@links) {
+ $defaults{'links'}{$item} = $defaultdesign{'login.'.$item};
}
- foreach my $item (@bgs) {
- if ($settings->{$item} ne '') {
- $designs{'bgs'}{$item} = $settings->{$item};
- $is_custom{$item} = 1;
+ if (ref($settings) eq 'HASH') {
+ 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 (@links) {
- if ($settings->{$item} ne '') {
- $designs{'links'}{$item} = $settings->{$item};
- $is_custom{$item} = 1;
+ foreach my $item (@images) {
+ if (defined($settings->{$item})) {
+ $designs{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ if (defined($settings->{'showlogo'}{$item})) {
+ $designs{'showlogo'}{$item} = $settings->{'showlogo'}{$item};
+ }
+ }
+ foreach my $item (@logintext) {
+ if ($settings->{$item} ne '') {
+ $designs{'logintext'}{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ if ($settings->{'font'} ne '') {
+ $designs{'font'} = $settings->{'font'};
+ $is_custom{'font'} = 1;
+ }
+ foreach my $item (@bgs) {
+ if ($settings->{$item} ne '') {
+ $designs{'bgs'}{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ foreach my $item (@links) {
+ if ($settings->{$item} ne '') {
+ $designs{'links'}{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ } else {
+ if ($designhash{$dom.'.login.font'} ne '') {
+ $designs{'font'} = $designhash{$dom.'.login.font'};
+ $is_custom{'font'} = 1;
+ }
+ foreach my $item (@images) {
+ if ($designhash{$dom.'.login.'.$item} ne '') {
+ $designs{$item} = $designhash{$dom.'.login.'.$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ foreach my $item (@bgs) {
+ if ($designhash{$dom.'.login.'.$item} ne '') {
+ $designs{'bgs'}{$item} = $designhash{$dom.'.login.'.$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ foreach my $item (@links) {
+ if ($designhash{$dom.'.login.'.$item} ne '') {
+ $designs{'links'}{$item} = $designhash{$dom.'.login.'.$item};
+ $is_custom{$item} = 1;
+ }
}
}
- } else {
- if ($designhash{$dom.'.login.font'} ne '') {
- $designs{'font'} = $designhash{$dom.'.login.font'};
- $is_custom{'font'} = 1;
+ my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner',
+ logo => 'Institution Logo',
+ domlogo => 'Domain Logo',
+ login => 'Login box');
+ my $itemcount = 1;
+ foreach my $item (@toggles) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .=
+ ''.$choices{$item}.
+ ' | '.
+ ' | '.
+ '
';
+ $itemcount ++;
}
- foreach my $item (@images) {
- if ($designhash{$dom.'.login.'.$item} ne '') {
- $designs{$item} = $designhash{$dom.'.login.'.$item};
- $is_custom{$item} = 1;
+ $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext);
+ $datatable .= '';
+ } elsif ($caller eq 'help') {
+ my ($defaulturl,$defaulttype,%url,%type,%lt,%langchoices);
+ my $switchserver = &check_switchserver($dom,$confname);
+ my $itemcount = 1;
+ $defaulturl = '/adm/loginproblems.html';
+ $defaulttype = 'default';
+ %lt = &Apache::lonlocal::texthash (
+ del => 'Delete?',
+ rep => 'Replace:',
+ upl => 'Upload:',
+ default => 'Default',
+ custom => 'Custom',
+ );
+ %langchoices = &Apache::lonlocal::texthash(&get_languages_hash());
+ my @currlangs;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'helpurl'}) eq 'HASH') {
+ foreach my $key (sort(keys(%{$settings->{'helpurl'}}))) {
+ next if ($settings->{'helpurl'}{$key} eq '');
+ $url{$key} = $settings->{'helpurl'}{$key}.'?inhibitmenu=yes';
+ $type{$key} = 'custom';
+ unless ($key eq 'nolang') {
+ push(@currlangs,$key);
+ }
+ }
+ } elsif ($settings->{'helpurl'} ne '') {
+ $type{'nolang'} = 'custom';
+ $url{'nolang'} = $settings->{'helpurl'}.'?inhibitmenu=yes';
}
}
- foreach my $item (@bgs) {
- if ($designhash{$dom.'.login.'.$item} ne '') {
- $designs{'bgs'}{$item} = $designhash{$dom.'.login.'.$item};
- $is_custom{$item} = 1;
+ foreach my $lang ('nolang',sort(@currlangs)) {
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= '';
+ if ($url{$lang} eq '') {
+ $url{$lang} = $defaulturl;
+ }
+ if ($type{$lang} eq '') {
+ $type{$lang} = $defaulttype;
+ }
+ $datatable .= '';
+ if ($lang eq 'nolang') {
+ $datatable .= &mt('Log-in help page if no specific language file: [_1]',
+ &Apache::loncommon::modal_link($url{$lang},$lt{$type{$lang}},600,500));
+ } else {
+ $datatable .= &mt('Log-in help page for language: [_1] is [_2]',
+ $langchoices{$lang},
+ &Apache::loncommon::modal_link($url{$lang},$lt{$type{$lang}},600,500));
+ }
+ $datatable .= ' | '."\n".
+ '';
+ if ($type{$lang} eq 'custom') {
+ $datatable .= ' '.$lt{'rep'}.'';
+ } else {
+ $datatable .= $lt{'upl'};
+ }
+ $datatable .=' ';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= '';
}
+ $datatable .= ' |
';
+ $itemcount ++;
}
- foreach my $item (@links) {
- if ($designhash{$dom.'.login.'.$item} ne '') {
- $designs{'links'}{$item} = $designhash{$dom.'.login.'.$item};
- $is_custom{$item} = 1;
+ my @addlangs;
+ foreach my $lang (sort(keys(%langchoices))) {
+ next if ((grep(/^\Q$lang\E$/,@currlangs)) || ($lang eq 'x_chef'));
+ push(@addlangs,$lang);
+ }
+ if (@addlangs > 0) {
+ my %toadd;
+ map { $toadd{$_} = $langchoices{$_} ; } @addlangs;
+ $toadd{''} = &mt('Select');
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ &mt('Add log-in help page for a specific language:').' '.
+ &Apache::loncommon::select_form('','loginhelpurl_add_lang',\%toadd).
+ ' | '.$lt{'upl'}.' ';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= '';
}
+ $datatable .= ' |
';
+ $itemcount ++;
}
+ $datatable .= &captcha_choice('login',$settings,$itemcount);
}
- my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner',
- logo => 'Institution Logo',
- domlogo => 'Domain Logo',
- login => 'Login box');
- my $itemcount = 1;
- 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);
- $datatable .= '';
return $datatable;
}
@@ -1058,6 +1188,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,$logintext) = @_;
+ my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
my $datatable = ''.
''.$choices->{'font'}.' | ';
@@ -1066,13 +1197,12 @@ sub display_color_options {
} else {
$datatable .= ' | ';
}
- my $fontlink = &color_pick($phase,$role,'font',$choices->{'font'},$designs->{'font'});
+ my $current_color = $designs->{'font'} ? $designs->{'font'} : $defaults->{'font'};
+
$datatable .= ''.
- ' '.$fontlink.
- ' '.
- ' |
';
+ ' '.
+ ' ';
unless ($role eq 'login') {
$datatable .= ''.
''.$choices->{'fontmenu'}.' | ';
@@ -1081,13 +1211,13 @@ sub display_color_options {
} else {
$datatable .= ' | ';
}
- $fontlink = &color_pick($phase,$role,'fontmenu',$choices->{'fontmenu'},$designs->{'fontmenu'});
+ $current_color = $designs->{'fontmenu'} ?
+ $designs->{'fontmenu'} : $defaults->{'fontmenu'};
$datatable .= ''.
- ' '.$fontlink.
- ' '.
- ' |
';
+ ' '.
+ ' ';
}
my $switchserver = &check_switchserver($dom,$confname);
foreach my $img (@{$images}) {
@@ -1135,11 +1265,11 @@ sub display_color_options {
$showfile = $imgfile;
my $imgdir = $1;
my $filename = $2;
- if (-e "/home/httpd/html/$imgdir/tn-".$filename) {
+ if (-e "$londocroot/$imgdir/tn-".$filename) {
$showfile = "/$imgdir/tn-".$filename;
} else {
- my $input = "/home/httpd/html".$imgfile;
- my $output = '/home/httpd/html/'.$imgdir.'/tn-'.$filename;
+ my $input = $londocroot.$imgfile;
+ my $output = "$londocroot/$imgdir/tn-".$filename;
if (!-e $output) {
my ($width,$height) = &thumb_dimensions();
my ($fullwidth,$fullheight) = &check_dimensions($input);
@@ -1147,7 +1277,7 @@ sub display_color_options {
if ($fullwidth > $width && $fullheight > $height) {
my $size = $width.'x'.$height;
system("convert -sample $size $input $output");
- $showfile = '/'.$imgdir.'/tn-'.$filename;
+ $showfile = "/$imgdir/tn-".$filename;
}
}
}
@@ -1214,13 +1344,16 @@ sub display_color_options {
}
$datatable .= ''.
' | ';
@@ -1242,13 +1375,13 @@ sub display_color_options {
$datatable .= ''.
'';
foreach my $item (@{$links}) {
- $datatable .= ''."\n".
- &color_pick($phase,$role,$item,$choices->{$item},
- $designs->{'links'}{$item});
+ my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item};
+ $datatable .= ' | '."\n";
+
if ($designs->{'links'}{$item}) {
- $datatable.=' ';
+ $datatable.=' ';
}
- $datatable .= '
| ';
}
$$rowtotal += $itemcount;
@@ -1375,14 +1508,19 @@ sub print_quotas {
@options =('norequest','approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($dom);
%titles = &courserequest_titles();
+ } elsif ($context eq 'requestauthor') {
+ @usertools = ('author');
+ @options = ('norequest','approval','automatic');
+ %titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','portfolio');
+ @usertools = ('aboutme','blog','webdav','portfolio');
%titles = &tool_titles();
}
if (ref($types) eq 'ARRAY') {
foreach my $type (@{$types}) {
my $currdefquota;
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') ||
+ ($context eq 'requestauthor')) {
if (ref($settings) eq 'HASH') {
if (ref($settings->{defaultquota}) eq 'HASH') {
$currdefquota = $settings->{defaultquota}->{$type};
@@ -1452,6 +1590,28 @@ sub print_quotas {
$cell{$item} .= $titles{'unlimited'};
}
}
+ } elsif ($context eq 'requestauthor') {
+ my $curroption;
+ if (ref($settings) eq 'HASH') {
+ $curroption = $settings->{$type};
+ }
+ if (!$curroption) {
+ $curroption = 'norequest';
+ }
+ foreach my $option (@options) {
+ my $val = $option;
+ if ($option eq 'norequest') {
+ $val = 0;
+ }
+ my $checked = '';
+ if ($option eq $curroption) {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= ' ';
+ }
} else {
my $checked = 'checked="checked" ';
if (ref($settings) eq 'HASH') {
@@ -1477,7 +1637,8 @@ sub print_quotas {
$datatable .= ' ';
}
$datatable .= ' | ';
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') ||
+ ($context eq 'requestauthor')) {
$datatable .=
''.
''.
+ $titles{$option}.' ';
+ }
} else {
my $checked = 'checked="checked" ';
if (ref($settings) eq 'HASH') {
@@ -1583,7 +1766,7 @@ sub print_quotas {
$datatable .= '';
}
$datatable .= ' | ';
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
$datatable .= ''.
' Mb | ';
@@ -1661,6 +1844,33 @@ sub print_quotas {
$advcell{$item} .= $titles{'unlimited'};
}
}
+ } elsif ($context eq 'requestauthor') {
+ my $curroption;
+ if (ref($settings) eq 'HASH') {
+ $curroption = $settings->{'_LC_adv'};
+ }
+ my $checked = '';
+ if ($curroption eq '') {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= ' ';
+ foreach my $option (@options) {
+ my $val = $option;
+ if ($option eq 'norequest') {
+ $val = 0;
+ }
+ my $checked = '';
+ if ($val eq $curroption) {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= ' ';
+ }
} else {
my $checked = 'checked="checked" ';
if (ref($settings) eq 'HASH') {
@@ -1690,8 +1900,8 @@ sub print_quotas {
return $datatable;
}
-sub print_courserequestmail {
- my ($dom,$settings,$rowtotal) = @_;
+sub print_requestmail {
+ my ($dom,$action,$settings,$rowtotal) = @_;
my ($now,$datatable,%dompersonnel,@domcoord,@currapproval,$rows);
$now = time;
$rows = 0;
@@ -1722,9 +1932,14 @@ sub print_courserequestmail {
my $numinrow = 4;
my $numdc = @domcoord;
my $css_class = 'class="LC_odd_row"';
- $datatable = ''.
- ' '.&mt('Receive notification of course requests requiring approval.').
- ' | '.
+ my $text;
+ if ($action eq 'requestcourses') {
+ $text = &mt('Receive notification of course requests requiring approval');
+ } else {
+ $text = &mt('Receive notification of authoring space requests requiring approval')
+ }
+ $datatable = '
'.
+ ' '.$text.' | '.
' ';
if (@domcoord > 0) {
$datatable .= '';
} else {
@@ -2162,99 +2377,21 @@ sub print_contacts {
}
sub print_helpsettings {
+ my ($dom,$confname,$settings,$rowtotal) = @_;
+ my ($datatable,$itemcount);
+ $itemcount = 1;
+ my (%choices,%defaultchecked,@toggles);
+ $choices{'submitbugs'} = &mt('Display link to: [_1]?',
+ &Apache::loncommon::modal_link('http://bugs.loncapa.org',
+ &mt('LON-CAPA bug tracker'),600,500));
+ %defaultchecked = ('submitbugs' => 'on');
+ @toggles = ('submitbugs',);
- my ($position,$dom,$confname,$settings,$rowtotal) = @_;
- my ($css_class,$datatable);
-
- my $switchserver = &check_switchserver($dom,$confname);
-
- my $itemcount = 1;
-
- if ($position eq 'top') {
-
- my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);
-
- %choices =
- &Apache::lonlocal::texthash (
- submitbugs => 'Display "Submit a bug" link?',
- );
-
- %defaultchecked = ('submitbugs' => 'on');
-
- @toggles = ('submitbugs',);
-
- 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} = ' ';
- }
- }
-
- if (ref($settings) eq 'HASH') {
- 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 (@toggles) {
- $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
- $datatable .=
- ' |
- '.$choices{$item}.' |
- |
-
-
- '.
- ' | '.
- '
';
- $itemcount ++;
- }
-
- } else {
-
- $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
-
- $datatable .= '';
-
- if (ref($settings) eq 'HASH') {
- if ($settings->{'loginhelpurl'} ne '') {
- my($directory, $filename) = $settings->{'loginhelpurl'} =~ m/(.*\/)(.*)$/;
- $datatable .= ' | ';
- $datatable .= ' | '
- } else {
- $datatable .= ' | ';
- $datatable .= ' | ';
- }
- } else {
- $datatable .= ' | ';
- $datatable .= ' | ';
- }
-
- $datatable .= '';
- if ($switchserver) {
- $datatable .= &mt('Upload to library server: [_1]',$switchserver);
- } else {
- $datatable .= &mt('Upload Custom Login Page Help File:');
- $datatable .='';
- }
- $datatable .= ' |
';
-
- }
-
- return $datatable;
-
+ ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
+ \%choices,$itemcount);
+ return $datatable;
}
-
sub radiobutton_prefs {
my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_;
return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
@@ -2751,16 +2888,13 @@ sub print_loadbalancing {
my $numinrow = 1;
my $datatable;
my %servers = &Apache::lonnet::internet_dom_servers($dom);
- my ($currbalancer,$currtargets,$currrules);
- if (keys(%servers) > 1) {
- if (ref($settings) eq 'HASH') {
- $currbalancer = $settings->{'lonhost'};
- $currtargets = $settings->{'targets'};
- $currrules = $settings->{'rules'};
- } else {
- ($currbalancer,$currtargets) =
- &Apache::lonnet::get_lonbalancer_config(\%servers);
- }
+ my (%currbalancer,%currtargets,%currrules,%existing);
+ if (ref($settings) eq 'HASH') {
+ %existing = %{$settings};
+ }
+ if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
+ &get_loadbalancers_config(\%servers,\%existing,\%currbalancer,
+ \%currtargets,\%currrules);
} else {
return;
}
@@ -2770,104 +2904,191 @@ sub print_loadbalancing {
if (ref($types) eq 'ARRAY') {
$rownum += scalar(@{$types});
}
- my $css_class = ' class="LC_odd_row"';
- my $targets_div_style = 'display: none';
- my $disabled_div_style = 'display: block';
- my $homedom_div_style = 'display: none';
- $datatable = ''.
- ''.
- ' | '.
- ' '.&mt('No dedicated Load Balancer').' '."\n".
- ''.&mt('Offloads to:').' ';
- my ($numspares,@spares) = &count_servers($currbalancer,%servers);
- my @sparestypes = ('primary','default');
- my %typetitles = &sparestype_titles();
- foreach my $sparetype (@sparestypes) {
- my $targettable;
- for (my $i=0; $i<$numspares; $i++) {
- my $checked;
- if (ref($currtargets) eq 'HASH') {
- if (ref($currtargets->{$sparetype}) eq 'ARRAY') {
- if (grep(/^\Q$spares[$i]\E$/,@{$currtargets->{$sparetype}})) {
- $checked = ' checked="checked"';
+ my @css_class = ('LC_odd_row','LC_even_row');
+ my $balnum = 0;
+ my $islast;
+ my (@toshow,$disabledtext);
+ if (keys(%currbalancer) > 0) {
+ @toshow = sort(keys(%currbalancer));
+ if (scalar(@toshow) < scalar(keys(%servers)) + 1) {
+ push(@toshow,'');
+ }
+ } else {
+ @toshow = ('');
+ $disabledtext = &mt('No existing load balancer');
+ }
+ foreach my $lonhost (@toshow) {
+ if ($balnum == scalar(@toshow)-1) {
+ $islast = 1;
+ } else {
+ $islast = 0;
+ }
+ my $cssidx = $balnum%2;
+ my $targets_div_style = 'display: none';
+ my $disabled_div_style = 'display: block';
+ my $homedom_div_style = 'display: none';
+ $datatable .= ' '.
+ ''.
+ ' ';
+ if ($lonhost eq '') {
+ $datatable .= '';
+ if (keys(%currbalancer) > 0) {
+ $datatable .= &mt('Add balancer:');
+ } else {
+ $datatable .= &mt('Enable balancer:');
+ }
+ $datatable .= ' '.
+ ''."\n".
+ ' '."\n";
+ } else {
+ $datatable .= ''.$lonhost.' '.
+ ''.
+ '';
+ $targets_div_style = 'display: block';
+ $disabled_div_style = 'display: none';
+ if ($dom eq &Apache::lonnet::host_domain($lonhost)) {
+ $homedom_div_style = 'display: block';
+ }
+ }
+ $datatable .= ' | '.
+ ' '.$disabledtext.' '."\n".
+ ''.&mt('Offloads to:').' ';
+ my ($numspares,@spares) = &count_servers($lonhost,%servers);
+ my @sparestypes = ('primary','default');
+ my %typetitles = &sparestype_titles();
+ foreach my $sparetype (@sparestypes) {
+ my $targettable;
+ for (my $i=0; $i<$numspares; $i++) {
+ my $checked;
+ if (ref($currtargets{$lonhost}) eq 'HASH') {
+ if (ref($currtargets{$lonhost}{$sparetype}) eq 'ARRAY') {
+ if (grep(/^\Q$spares[$i]\E$/,@{$currtargets{$lonhost}{$sparetype}})) {
+ $checked = ' checked="checked"';
+ }
+ }
+ }
+ my ($chkboxval,$disabled);
+ if (($lonhost ne '') && (exists($servers{$lonhost}))) {
+ $chkboxval = $spares[$i];
+ }
+ if (exists($currbalancer{$spares[$i]})) {
+ $disabled = ' disabled="disabled"';
+ }
+ $targettable .=
+ ' | | ';
+ my $rem = $i%($numinrow);
+ if ($rem == 0) {
+ if (($i > 0) && ($i < $numspares-1)) {
+ $targettable .= ' ';
+ }
+ if ($i < $numspares-1) {
+ $targettable .= ' ';
}
}
}
- my $chkboxval;
- if (($currbalancer ne '') && (grep((/^\Q$currbalancer\E$/,keys(%servers))))) {
- $chkboxval = $spares[$i];
- }
- $targettable .= ' | ';
- my $rem = $i%($numinrow);
- if ($rem == 0) {
- if ($i > 0) {
- $targettable .= ' ';
- }
- $targettable .= ' ';
+ if ($targettable ne '') {
+ my $rem = $numspares%($numinrow);
+ my $colsleft = $numinrow - $rem;
+ if ($colsleft > 1 ) {
+ $targettable .= ''.
+ ' | ';
+ } elsif ($colsleft == 1) {
+ $targettable .= ' | ';
+ }
+ $datatable .= ''.$typetitles{$sparetype}.' '.
+ ' ';
+ }
+ }
+ my $cssidx = $balnum%2;
+ $datatable .= ' '.
+ &loadbalancing_rules($dom,$intdom,$currrules{$lonhost},
+ $othertitle,$usertypes,$types,\%servers,
+ \%currbalancer,$lonhost,
+ $targets_div_style,$homedom_div_style,
+ $css_class[$cssidx],$balnum,$islast);
+ $$rowtotal += $rownum;
+ $balnum ++;
+ }
+ $datatable .= ' ';
+ return $datatable;
+}
+
+sub get_loadbalancers_config {
+ my ($servers,$existing,$currbalancer,$currtargets,$currrules) = @_;
+ return unless ((ref($servers) eq 'HASH') &&
+ (ref($existing) eq 'HASH') && (ref($currbalancer) eq 'HASH') &&
+ (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH'));
+ if (keys(%{$existing}) > 0) {
+ my $oldlonhost;
+ foreach my $key (sort(keys(%{$existing}))) {
+ if ($key eq 'lonhost') {
+ $oldlonhost = $existing->{'lonhost'};
+ $currbalancer->{$oldlonhost} = 1;
+ } elsif ($key eq 'targets') {
+ if ($oldlonhost) {
+ $currtargets->{$oldlonhost} = $existing->{'targets'};
+ }
+ } elsif ($key eq 'rules') {
+ if ($oldlonhost) {
+ $currrules->{$oldlonhost} = $existing->{'rules'};
+ }
+ } elsif (ref($existing->{$key}) eq 'HASH') {
+ $currbalancer->{$key} = 1;
+ $currtargets->{$key} = $existing->{$key}{'targets'};
+ $currrules->{$key} = $existing->{$key}{'rules'};
}
}
- if ($targettable ne '') {
- my $rem = $numspares%($numinrow);
- my $colsleft = $numinrow - $rem;
- if ($colsleft > 1 ) {
- $targettable .= ' '.
- ' | ';
- } elsif ($colsleft == 1) {
- $targettable .= ' | ';
+ } else {
+ my ($balancerref,$targetsref) =
+ &Apache::lonnet::get_lonbalancer_config($servers);
+ if ((ref($balancerref) eq 'HASH') && (ref($targetsref) eq 'HASH')) {
+ foreach my $server (sort(keys(%{$balancerref}))) {
+ $currbalancer->{$server} = 1;
+ $currtargets->{$server} = $targetsref->{$server};
}
- $datatable .= ' '.$typetitles{$sparetype}.''.
- ' ';
}
}
- $datatable .= ' |
'.
- &loadbalancing_rules($dom,$intdom,$currrules,$othertitle,
- $usertypes,$types,\%servers,$currbalancer,
- $targets_div_style,$homedom_div_style,$css_class);
- $$rowtotal += $rownum;
- return $datatable;
+ return;
}
sub loadbalancing_rules {
my ($dom,$intdom,$currrules,$othertitle,$usertypes,$types,$servers,
- $currbalancer,$targets_div_style,$homedom_div_style,$css_class) = @_;
+ $currbalancer,$lonhost,$targets_div_style,$homedom_div_style,
+ $css_class,$balnum,$islast) = @_;
my $output;
+ my $num = 0;
my ($alltypes,$othertypes,$titles) =
&loadbalancing_titles($dom,$intdom,$usertypes,$types);
if ((ref($alltypes) eq 'ARRAY') && (ref($titles) eq 'HASH')) {
foreach my $type (@{$alltypes}) {
+ $num ++;
my $current;
if (ref($currrules) eq 'HASH') {
$current = $currrules->{$type};
}
if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) {
- if ($dom ne &Apache::lonnet::host_domain($currbalancer)) {
+ if ($dom ne &Apache::lonnet::host_domain($lonhost)) {
$current = '';
}
}
$output .= &loadbalance_rule_row($type,$titles->{$type},$current,
- $servers,$currbalancer,$dom,
- $targets_div_style,$homedom_div_style,$css_class);
+ $servers,$currbalancer,$lonhost,$dom,
+ $targets_div_style,$homedom_div_style,
+ $css_class,$balnum,$num,$islast);
}
}
return $output;
@@ -2904,8 +3125,8 @@ sub loadbalancing_titles {
}
sub loadbalance_rule_row {
- my ($type,$title,$current,$servers,$currbalancer,$dom,$targets_div_style,
- $homedom_div_style,$css_class) = @_;
+ my ($type,$title,$current,$servers,$currbalancer,$lonhost,$dom,
+ $targets_div_style,$homedom_div_style,$css_class,$balnum,$num,$islast) = @_;
my @rulenames = ('default','homeserver');
my %ruletitles = &offloadtype_text();
if ($type eq '_LC_external') {
@@ -2913,13 +3134,20 @@ sub loadbalance_rule_row {
} else {
push(@rulenames,'specific');
}
+ push(@rulenames,'none');
my $style = $targets_div_style;
if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) {
$style = $homedom_div_style;
}
+ my $space;
+ if ($islast && $num == 1) {
+ $space = '
';
+ }
my $output =
- ''.$title.' | '."\n".
- ''."\n";
+ ' '.$space.
+ ' '.$title.' | '."\n".
+ ''.$space.
+ ''."\n";
for (my $i=0; $i<@rulenames; $i++) {
my $rule = $rulenames[$i];
my ($checked,$extra);
@@ -2935,17 +3163,20 @@ sub loadbalance_rule_row {
unless ($checked) {
$default = ' selected="selected"';
}
- $extra = ': | |