--- loncom/interface/loncommon.pm 2007/09/11 20:36:30 1.582
+++ loncom/interface/loncommon.pm 2007/09/12 23:32:59 1.585
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.582 2007/09/11 20:36:30 albertel Exp $
+# $Id: loncommon.pm,v 1.585 2007/09/12 23:32:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2531,9 +2531,11 @@ sub preferred_languages {
@languages=(@languages,
split(/\s*(\,|\;|\:)\s*/,$env{'environment.languages'}));
}
- my $browser=(split(/\;/,$ENV{'HTTP_ACCEPT_LANGUAGE'}))[0];
+ my $browser=$ENV{'HTTP_ACCEPT_LANGUAGE'};
if ($browser) {
- @languages=(@languages,split(/\s*(\,|\;|\:)\s*/,$browser));
+ my @browser =
+ map { (split(/\s*;\s*/,$_))[0] } (split(/\s*,\s*/,$browser));
+ push(@languages,@browser);
}
if (&Apache::lonnet::domain($env{'user.domain'},'lang_def')) {
@languages=(@languages,
@@ -2555,11 +2557,14 @@ sub preferred_languages {
my @genlanguages;
foreach my $lang (@languages) {
unless ($lang=~/\w/) { next; }
- push (@genlanguages,$lang);
+ push(@genlanguages,$lang);
if ($lang=~/(\-|\_)/) {
push(@genlanguages,(split(/(\-|\_)/,$lang))[0]);
}
}
+ #uniqueify the languages list
+ my %count;
+ @genlanguages = map { $count{$_}++ == 0 ? $_ : () } @genlanguages;
return @genlanguages;
}
@@ -4642,6 +4647,13 @@ table.LC_docs_adddocs th {
background: #DDDDDD;
}
+table.LC_sty_begin {
+ background: #BBFFBB;
+}
+table.LC_sty_end {
+ background: #FFBBBB;
+}
+
END
}
@@ -5896,6 +5908,59 @@ END_BLOCK
return $output;
}
+sub username_rule_check {
+ my ($srch,$caller) = @_;
+ my ($response,@curr_rules,%inst_results,$rulematch);
+ my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($srch->{'srchdomain'});
+ if (ref($srch) eq 'HASH') {
+ (my $inst_response,%inst_results) =
+ &Apache::lonnet::get_instuser($srch->{'srchdomain'},
+ $srch->{'srchterm'});
+ my %domconfig = &Apache::lonnet::get_dom('configuration',
+ ['usercreation'],$srch->{'srchdomain'});
+ if (ref($domconfig{'usercreation'}) eq 'HASH') {
+ if (ref($domconfig{'usercreation'}{'username_rule'}) eq 'ARRAY') {
+ @curr_rules = @{$domconfig{'usercreation'}{'username_rule'}};
+ }
+ }
+ if (@curr_rules > 0) {
+ my $domdesc = &Apache::lonnet::domain($srch->{'srchdomain'},'description');
+ my $instuser_reqd;
+ my %rule_check = &Apache::lonnet::inst_rulecheck($srch->{'srchdomain'},$srch->{'srchterm'},\@curr_rules);
+ foreach my $rule (@curr_rules) {
+ if ($rule_check{$rule}) {
+ $rulematch = $rule;
+ if ($inst_response eq 'ok') {
+ if (keys(%inst_results) == 0) {
+ if ($caller eq 'new') {
+ $response = &mt('The username you chose matches the format of usernames defined for [_1], but the user does not exist in the institutional directory.',$domdesc).'
'.&mt("You must choose a username with a different format -- one that will not conflict with 'official' institutional usernames.");
+ }
+ }
+ }
+ last;
+ }
+ }
+ if ($response) {
+ if ((ref($rules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) {
+ if (@{$ruleorder} > 0) {
+ $response .= '
'.&mt('Usernames with the following format(s) may only be used for verified users at [_1]:',$domdesc).'