--- loncom/interface/loncommon.pm 2007/11/06 04:39:19 1.609
+++ loncom/interface/loncommon.pm 2007/12/04 04:43:21 1.619
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.609 2007/11/06 04:39:19 raeburn Exp $
+# $Id: loncommon.pm,v 1.619 2007/12/04 04:43:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -257,6 +257,7 @@ sub browser_and_searcher_javascript {
}
url += 'catalogmode=interactive&';
url += 'mode=$mode&';
+ url += 'inhibitmenu=yes&';
url += 'form=' + formname + '&';
if (only != null) {
url += 'only=' + only + '&';
@@ -4397,6 +4398,7 @@ table.LC_data_table, table.LC_mail_list
border: 1px solid #000000;
border-collapse: separate;
border-spacing: 1px;
+ background: $pgbg;
}
.LC_data_table_dense {
font-size: small;
@@ -4419,12 +4421,12 @@ table.LC_prior_tries tr th {
background-color: $data_table_head;
font-size: smaller;
}
-table.LC_data_table tr td,
+table.LC_data_table tr.LC_odd_row > td,
table.LC_aboutme_port tr td {
background-color: $data_table_light;
padding: 2px;
}
-table.LC_data_table tr.LC_even_row td,
+table.LC_data_table tr.LC_even_row > td,
table.LC_aboutme_port tr.LC_even_row td {
background-color: $data_table_dark;
}
@@ -4832,6 +4834,7 @@ table.LC_descriptive_input td.LC_descrip
font-weight: bold;
}
div.LC_feedback_link {
+ clear: both;
background: white;
width: 100%;
}
@@ -5095,13 +5098,22 @@ span.LC_grade_check_note {
right: 1em;
}
+table.LC_scantron_action {
+ width: 100%;
+}
+table.LC_scantron_action tr th {
+ font: normal bold $sans;
+}
-div.LC_edit_problem_header {
+div.LC_edit_problem_header,
+div.LC_edit_problem_footer {
font: normal medium $sans;
margin: 2px;
}
div.LC_edit_problem_header,
div.LC_edit_problem_header div,
+div.LC_edit_problem_footer,
+div.LC_edit_problem_footer div,
div.LC_edit_problem_editxml_header,
div.LC_edit_problem_editxml_header div {
margin-top: 5px;
@@ -5510,30 +5522,30 @@ sub simple_error_page {
}
{
- my $row_count;
+ my @row_count;
sub start_data_table {
my ($add_class) = @_;
my $css_class = (join(' ','LC_data_table',$add_class));
- undef($row_count);
+ unshift(@row_count,0);
return '
'."\n";
}
sub end_data_table {
- undef($row_count);
+ shift(@row_count);
return '
'."\n";;
}
sub start_data_table_row {
my ($add_class) = @_;
- $row_count++;
- my $css_class = ($row_count % 2)?'':'LC_even_row';
+ $row_count[0]++;
+ my $css_class = ($row_count[0] % 2)?'LC_odd_row':'LC_even_row';
$css_class = (join(' ',$css_class,$add_class));
return ''."\n";;
}
sub continue_data_table_row {
my ($add_class) = @_;
- my $css_class = ($row_count % 2)?'':'LC_even_row';
+ my $css_class = ($row_count[0] % 2)?'LC_odd_row':'LC_even_row';
$css_class = (join(' ',$css_class,$add_class));
return '
'."\n";;
}
@@ -5543,7 +5555,7 @@ sub simple_error_page {
}
sub start_data_table_empty_row {
- $row_count++;
+ $row_count[0]++;
return '
'."\n";;
}
@@ -5849,7 +5861,6 @@ sub get_course_users {
my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist($cdom,$cnum);
my $now = time;
foreach my $student (keys(%{$classlist})) {
- my $status;
my $match = 0;
my $secmatch = 0;
my $section = $$classlist{$student}[$idx{section}];
@@ -6428,57 +6439,143 @@ 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.");
- }
+sub user_rule_check {
+ my ($usershash,$checks,$alerts,$rulematch,$inst_results,$curr_rules,$got_rules) = @_;
+ my $response;
+ if (ref($usershash) eq 'HASH') {
+ foreach my $user (keys(%{$usershash})) {
+ my ($uname,$udom) = split(/:/,$user);
+ next if ($udom eq '' || $uname eq '');
+ my ($id,$newuser);
+ if (ref($usershash->{$user}) eq 'HASH') {
+ $newuser = $usershash->{$user}->{'newuser'};
+ $id = $usershash->{$user}->{'id'};
+ }
+ my $inst_response;
+ if (ref($checks) eq 'HASH') {
+ if (defined($checks->{'username'})) {
+ ($inst_response,%{$inst_results->{$user}}) =
+ &Apache::lonnet::get_instuser($udom,$uname);
+ } elsif (defined($checks->{'id'})) {
+ ($inst_response,%{$inst_results->{$user}}) =
+ &Apache::lonnet::get_instuser($udom,undef,$id);
+ }
+ } else {
+ ($inst_response,%{$inst_results->{$user}}) =
+ &Apache::lonnet::get_instuser($udom,$uname);
+ return;
+ }
+ if (!$got_rules->{$udom}) {
+ my %domconfig = &Apache::lonnet::get_dom('configuration',
+ ['usercreation'],$udom);
+ if (ref($domconfig{'usercreation'}) eq 'HASH') {
+ foreach my $item ('username','id') {
+ if (ref($domconfig{'usercreation'}{$item.'_rule'}) eq 'ARRAY') {
+ $$curr_rules{$udom}{$item} =
+ $domconfig{'usercreation'}{$item.'_rule'};
}
}
- last;
}
+ $got_rules->{$udom} = 1;
}
- 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).' ';
- foreach my $rule (@{$ruleorder}) {
- if (grep(/^\Q$rule\E$/,@curr_rules)) {
- if (ref($rules->{$rule}) eq 'HASH') {
- $response .= '- '.$rules->{$rule}{'name'}.': '.
- $rules->{$rule}{'desc'}.'
';
+ foreach my $item (keys(%{$checks})) {
+ if (ref($$curr_rules{$udom}) eq 'HASH') {
+ if (ref($$curr_rules{$udom}{$item}) eq 'ARRAY') {
+ if (@{$$curr_rules{$udom}{$item}} > 0) {
+ my %rule_check = &Apache::lonnet::inst_rulecheck($udom,$uname,$id,$item,$$curr_rules{$udom}{$item});
+ foreach my $rule (@{$$curr_rules{$udom}{$item}}) {
+ if ($rule_check{$rule}) {
+ $$rulematch{$user}{$item} = $rule;
+ if ($inst_response eq 'ok') {
+ if (ref($inst_results) eq 'HASH') {
+ if (ref($inst_results->{$user}) eq 'HASH') {
+ if (keys(%{$inst_results->{$user}}) == 0) {
+ $$alerts{$item}{$udom}{$uname} = 1;
+ }
+ }
+ }
+ }
+ last;
}
}
}
}
- $response .= '
';
}
}
}
}
- return ($response,$rulematch,$rules,%inst_results);
+ return;
+}
+
+sub user_rule_formats {
+ my ($domain,$domdesc,$curr_rules,$check) = @_;
+ my %text = (
+ 'username' => 'Usernames',
+ 'id' => 'IDs',
+ );
+ my $output;
+ my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($domain,$check);
+ if ((ref($rules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) {
+ if (@{$ruleorder} > 0) {
+ $output = '
'.&mt("$text{$check} with the following format(s) may only be used for verified users at [_1]:",$domdesc).' ';
+ foreach my $rule (@{$ruleorder}) {
+ if (ref($curr_rules) eq 'ARRAY') {
+ if (grep(/^\Q$rule\E$/,@{$curr_rules})) {
+ if (ref($rules->{$rule}) eq 'HASH') {
+ $output .= '- '.$rules->{$rule}{'name'}.': '.
+ $rules->{$rule}{'desc'}.'
';
+ }
+ }
+ }
+ }
+ $output .= '
';
+ }
+ }
+ return $output;
+}
+
+sub instrule_disallow_msg {
+ my ($checkitem,$domdesc,$count,$mode) = @_;
+ my $response;
+ my %text = (
+ item => 'username',
+ items => 'usernames',
+ match => 'matches',
+ do => 'does',
+ action => 'a username',
+ one => 'one',
+ );
+ if ($count > 1) {
+ $text{'item'} = 'usernames';
+ $text{'match'} ='match';
+ $text{'do'} = 'do';
+ $text{'action'} = 'usernames',
+ $text{'one'} = 'ones';
+ }
+ if ($checkitem eq 'id') {
+ $text{'items'} = 'IDs';
+ $text{'item'} = 'ID';
+ $text{'action'} = 'an ID';
+ if ($count > 1) {
+ $text{'item'} = 'IDs';
+ $text{'action'} = 'IDs';
+ }
+ }
+ $response = &mt("The $text{'item'} you chose $text{'match'} the format of $text{'items'} defined for [_1], but the $text{'item'} $text{'do'} not exist in the institutional directory.",$domdesc).'
';
+ if ($mode eq 'upload') {
+ if ($checkitem eq 'username') {
+ $response .= &mt("You will need to modify your upload file so it will include $text{'action'} with a different format -- $text{'one'} that will not conflict with 'official' institutional $text{'items'}.");
+ } elsif ($checkitem eq 'id') {
+ $response .= &mt("Either upload a file which includes $text{'action'} with a different format -- $text{'one'} that will not conflict with 'official' institutional $text{'items'}, or when associating fields with data columns, omit an association for the ID/Student Number field.");
+ }
+ } else {
+ if ($checkitem eq 'username') {
+ $response .= &mt("You must choose $text{'action'} with a different format -- $text{'one'} that will not conflict with 'official' institutional $text{'items'}.");
+ } elsif ($checkitem eq 'id') {
+ $response .= &mt("You must either choose $text{'action'} with a different format -- $text{'one'} that will not conflict with 'official' institutional $text{'items'}, or leave the ID field blank.");
+ }
+ }
+ return $response;
}
=pod
@@ -7539,6 +7636,76 @@ sub restore_settings {
}
}
+#######################################################
+#######################################################
+
+=pod
+
+=head1 Domain E-mail Routines
+
+=over 4
+
+=item &build_recipient_list
+
+Build recipient lists for three types of e-mail:
+(a) Error Reports, (b) Package Updates, (c) Help requests, generated by
+lonerrorhandler.pm, CHECKRPMS and lonsupportreq.pm respectively.
+
+Inputs:
+defmail (scalar - email address of default recipient),
+mailing type (scalar - errormail, packagesmail, or helpdeskmail),
+defdom (domain for which to retrieve configuration settings),
+origmail (scalar - email address of recipient from loncapa.conf,
+i.e., predates configuration by DC via domainprefs.pm
+
+Returns: comma separated list of addresses to which to send e-mail.
+
+=cut
+
+############################################################
+############################################################
+sub build_recipient_list {
+ my ($defmail,$mailing,$defdom,$origmail) = @_;
+ my @recipients;
+ my $otheremails;
+ my %domconfig =
+ &Apache::lonnet::get_dom('configuration',['contacts'],$defdom);
+ if (ref($domconfig{'contacts'}) eq 'HASH') {
+ if (ref($domconfig{'contacts'}{$mailing}) eq 'HASH') {
+ my @contacts = ('adminemail','supportemail');
+ foreach my $item (@contacts) {
+ if ($domconfig{'contacts'}{$mailing}{$item}) {
+ my $addr = $domconfig{'contacts'}{$item};
+ if (!grep(/^\Q$addr\E$/,@recipients)) {
+ push(@recipients,$addr);
+ }
+ }
+ $otheremails = $domconfig{'contacts'}{$mailing}{'others'};
+ }
+ }
+ } elsif ($origmail ne '') {
+ push(@recipients,$origmail);
+ }
+ if ($defmail ne '') {
+ push(@recipients,$defmail);
+ }
+ if ($otheremails) {
+ my @others;
+ if ($otheremails =~ /,/) {
+ @others = split(/,/,$otheremails);
+ } else {
+ push(@others,$otheremails);
+ }
+ foreach my $addr (@others) {
+ if (!grep(/^\Q$addr\E$/,@recipients)) {
+ push(@recipients,$addr);
+ }
+ }
+ }
+ my $recipientlist = join(',',@recipients);
+ return $recipientlist;
+}
+
############################################################
############################################################