[LON-CAPA-cvs] cvs: loncom(version_2_10_X) /interface domainprefs.pm
raeburn
raeburn@source.lon-capa.org
Sat, 25 Dec 2010 00:52:58 -0000
raeburn Sat Dec 25 00:52:58 2010 EDT
Modified files: (Branch: version_2_10_X)
/loncom/interface domainprefs.pm
Log:
- Backport 1.141.
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.138.2.4 loncom/interface/domainprefs.pm:1.138.2.5
--- loncom/interface/domainprefs.pm:1.138.2.4 Tue Oct 5 18:44:08 2010
+++ loncom/interface/domainprefs.pm Sat Dec 25 00:52:58 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.138.2.4 2010/10/05 18:44:08 raeburn Exp $
+# $Id: domainprefs.pm,v 1.138.2.5 2010/12/25 00:52:58 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -230,7 +230,7 @@
},
'defaults' =>
- { text => 'Default authentication/language/timezone',
+ { text => 'Default authentication/language/timezone/portal',
help => 'Domain_Configuration_LangTZAuth',
header => [{col1 => 'Setting',
col2 => 'Value'}],
@@ -2817,9 +2817,9 @@
sub print_defaults {
my ($dom,$rowtotal) = @_;
my @items = ('auth_def','auth_arg_def','lang_def','timezone_def',
- 'datelocale_def');
+ 'datelocale_def','portal_def');
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my $titles = &defaults_titles();
+ my $titles = &defaults_titles($dom);
my $rownum = 0;
my ($datatable,$css_class);
foreach my $item (@items) {
@@ -2856,8 +2856,11 @@
my $includeempty = 1;
$datatable .= &Apache::loncommon::select_datelocale($item,$domdefaults{$item},undef,$includeempty);
} else {
+ if ($item eq 'portal_def') {
+ $size = ' size="25"';
+ }
$datatable .= '<input type="text" name="'.$item.'" value="'.
- $domdefaults{$item}.'" />';
+ $domdefaults{$item}.'"'.$size.' />';
}
$datatable .= '</td></tr>';
$rownum ++;
@@ -2867,13 +2870,25 @@
}
sub defaults_titles {
+ my ($dom) = @_;
my %titles = &Apache::lonlocal::texthash (
'auth_def' => 'Default authentication type',
'auth_arg_def' => 'Default authentication argument',
'lang_def' => 'Default language',
'timezone_def' => 'Default timezone',
'datelocale_def' => 'Default locale for dates',
+ 'portal_def' => 'Portal/Default URL',
);
+ if ($dom) {
+ my $uprimary_id = &Apache::lonnet::domain($dom,'primary');
+ my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);
+ my $protocol = $Apache::lonnet::protocol{$uprimary_id};
+ $protocol = 'http' if ($protocol ne 'https');
+ if ($uint_dom) {
+ $titles{'portal_def'} .= ' '.&mt('(for example: [_1])',$protocol.'://loncapa.'.
+ $uint_dom);
+ }
+ }
return (\%titles);
}
@@ -6009,7 +6024,7 @@
my ($dom,$r) = @_;
my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def');
+ my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def','portal_def');
my @authtypes = ('internal','krb4','krb5','localauth');
foreach my $item (@items) {
$newvalues{$item} = $env{'form.'.$item};
@@ -6045,6 +6060,12 @@
push(@errors,$item);
}
}
+ } elsif ($item eq 'portal_def') {
+ if ($newvalues{$item} ne '') {
+ unless ($newvalues{$item} =~ /^https?\:\/\/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/?$/) {
+ push(@errors,$item);
+ }
+ }
}
if (grep(/^\Q$item\E$/,@errors)) {
$newvalues{$item} = $domdefaults{$item};