--- loncom/interface/loncommon.pm 2007/11/18 21:19:16 1.616
+++ loncom/interface/loncommon.pm 2007/12/21 05:13:07 1.626
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.616 2007/11/18 21:19:16 albertel Exp $
+# $Id: loncommon.pm,v 1.626 2007/12/21 05:13:07 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1942,6 +1942,11 @@ sub authform_kerberos {
if (defined($in{'curr_authtype'})) {
if ($in{'curr_authtype'} eq 'krb') {
$krbcheck = ' checked="on"';
+ if (defined($in{'mode'})) {
+ if ($in{'mode'} eq 'modifyuser') {
+ $krbcheck = '';
+ }
+ }
if (defined($in{'curr_kerb_ver'})) {
if ($in{'curr_krb_ver'} eq '5') {
$check5 = ' checked="on"';
@@ -2039,6 +2044,11 @@ sub authform_internal{
if ($in{'curr_authtype'} eq 'int') {
if ($can_assign{'int'}) {
$intcheck = 'checked="on" ';
+ if (defined($in{'mode'})) {
+ if ($in{'mode'} eq 'modifyuser') {
+ $intcheck = '';
+ }
+ }
if (defined($in{'curr_autharg'})) {
$intarg = $in{'curr_autharg'};
}
@@ -2073,6 +2083,7 @@ sub authform_internal{
$result = &mt
('[_1] Internally authenticated (with initial password [_2])',
''.$autharg);
+ $result.="';
return $result;
}
@@ -2088,6 +2099,11 @@ sub authform_local{
if ($in{'curr_authtype'} eq 'loc') {
if ($can_assign{'loc'}) {
$loccheck = 'checked="on" ';
+ if (defined($in{'mode'})) {
+ if ($in{'mode'} eq 'modifyuser') {
+ $loccheck = '';
+ }
+ }
if (defined($in{'curr_autharg'})) {
$locarg = $in{'curr_autharg'};
}
@@ -2137,6 +2153,11 @@ sub authform_filesystem{
if ($in{'curr_authtype'} eq 'fsys') {
if ($can_assign{'fsys'}) {
$fsyscheck = 'checked="on" ';
+ if (defined($in{'mode'})) {
+ if ($in{'mode'} eq 'modifyuser') {
+ $fsyscheck = '';
+ }
+ }
} else {
$result = &mt('Currently Filesystem Authenticated.');
return $result;
@@ -5038,7 +5059,6 @@ div.LC_clear_float_footer {
div.LC_grade_select_mode {
- float: left;
font-family: $sans;
}
div.LC_grade_select_mode div div {
@@ -5861,7 +5881,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}];
@@ -6148,24 +6167,24 @@ sub default_quota {
my ($udom,$inststatus) = @_;
my ($defquota,$settingstatus);
my %quotahash = &Apache::lonnet::get_dom('configuration',
- ['quota'],$udom);
- if (ref($quotahash{'quota'}) eq 'HASH') {
+ ['quotas'],$udom);
+ if (ref($quotahash{'quotas'}) eq 'HASH') {
if ($inststatus ne '') {
my @statuses = split(/:/,$inststatus);
foreach my $item (@statuses) {
- if ($quotahash{'quota'}{$item} ne '') {
+ if ($quotahash{'quotas'}{$item} ne '') {
if ($defquota eq '') {
- $defquota = $quotahash{'quota'}{$item};
+ $defquota = $quotahash{'quotas'}{$item};
$settingstatus = $item;
- } elsif ($quotahash{'quota'}{$item} > $defquota) {
- $defquota = $quotahash{'quota'}{$item};
+ } elsif ($quotahash{'quotas'}{$item} > $defquota) {
+ $defquota = $quotahash{'quotas'}{$item};
$settingstatus = $item;
}
}
}
}
if ($defquota eq '') {
- $defquota = $quotahash{'quota'}{'default'};
+ $defquota = $quotahash{'quotas'}{'default'};
$settingstatus = 'default';
}
} else {
@@ -6224,7 +6243,7 @@ sub user_picker {
srchby => 'lastname',
);
my $srchterm;
- if (ref($srch) eq 'HASH') {
+ if ((ref($srch) eq 'HASH') && ($env{'form.origform'} ne 'crtusername')) {
if ($srch->{'srchby'} ne '') {
$curr_selected{'srchby'} = $srch->{'srchby'};
}
@@ -6579,6 +6598,19 @@ sub instrule_disallow_msg {
return $response;
}
+sub personal_data_fieldtitles {
+ my %fieldtitles = &Apache::lonlocal::texthash (
+ id => 'Student/Employee ID',
+ permanentemail => 'E-mail address',
+ lastname => 'Last Name',
+ firstname => 'First Name',
+ middlename => 'Middle Name',
+ generation => 'Generation',
+ gen => 'Generation',
+ );
+ return %fieldtitles;
+}
+
=pod
=back
@@ -7637,6 +7669,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;
+}
+
############################################################
############################################################
@@ -7663,8 +7765,8 @@ sub commit_standardrole {
my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,
$one,$two,$sec,$context);
if (($result =~ /^error/) || ($result eq 'not_in_class') ||
- ($result eq 'unknown_course')) {
- $output = "Error: $result\n";
+ ($result eq 'unknown_course') || ($result eq 'refused')) {
+ $output = $logmsg.' '.&mt('Error: ').$result."\n";
} else {
$output = $logmsg.$linefeed.&mt('Assigning').' '.$three.' in '.$url.
($start?', '.&mt('starting').' '.localtime($start):'').
@@ -7693,7 +7795,7 @@ sub commit_standardrole {
sub commit_studentrole {
my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context) = @_;
- my ($result,$linefeed);
+ my ($result,$linefeed,$oldsecurl,$newsecurl);
if ($context eq 'auto') {
$linefeed = "\n";
} else {
@@ -7713,6 +7815,7 @@ sub commit_studentrole {
if ($oldsec) {
$uurl.='/'.$oldsec;
}
+ $oldsecurl = $uurl;
$expire_role_result = &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',time);
$result = $expire_role_result;
}
@@ -7721,21 +7824,35 @@ sub commit_studentrole {
$modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid);
if ($modify_section_result =~ /^ok/) {
if ($secchange == 1) {
- $$logmsg .= "Section for $uname switched from old section: $oldsec to new section: $sec".$linefeed;
+ $$logmsg .= &mt('Section for [_1] switched from old section: [_2] to new section: [_3].',$uname,$oldsec,$sec).$linefeed;
} elsif ($oldsec eq '-1') {
- $$logmsg .= "New student role for $uname in section $sec in course $cid".$linefeed;
+ $$logmsg .= &mt('New student role for [_1] in section [_2] in course [_3].',$uname,$sec,$cid).$linefeed;
} else {
- $$logmsg .= "Student $uname assigned to unchanged section $sec in course $cid".$linefeed;
+ $$logmsg .= &mt('Student [_1] assigned to unchanged section [_2] in course [_3].',$uname,$sec,$cid).$linefeed;
}
} else {
- $$logmsg .= "Error when attempting section change for $uname from old section $oldsec to new section: $sec in course $cid -error: $modify_section_result".$linefeed;
+ $$logmsg .= &mt('Error when attempting section change for [_1] from old section [_2] to new section: [_3] in course [_4] -error:',$uname,$oldsec,$sec,$cid).' '.$modify_section_result.$linefeed;
}
$result = $modify_section_result;
} elsif ($secchange == 1) {
- $$logmsg .= "Error when attempting to expire role for $uname in old section $oldsec in course $cid -error: $expire_role_result".$linefeed;
+ $$logmsg .= &mt('Error when attempting to expire role for [_1] in old section [_2] in course [_3] -error: ',$uname,$oldsec,$cid).' '.$expire_role_result.$linefeed;
+ if ($expire_role_result eq 'refused') {
+ my $newsecurl = '/'.$cid;
+ $newsecurl =~ s/\_/\//g;
+ if ($sec ne '') {
+ $newsecurl.='/'.$sec;
+ }
+ if (&Apache::lonnet::allowed('cst',$newsecurl) && !(&Apache::lonnet::allowed('cst',$oldsecurl))) {
+ if ($sec eq '') {
+ $$logmsg .= &mt('Although your current role has privileges to add students to section "[_1]", you do not have privileges to modify existing enrollments unaffiliated with any section.',$sec).$linefeed;
+ } else {
+ $$logmsg .= &mt('Although your current role has privileges to add students to section "[_1]", you do not have privileges to modify existing enrollments in other sections.',$sec).$linefeed;
+ }
+ }
+ }
}
} else {
- $$logmsg .= "Incomplete course id defined. Addition of user $uname from domain $udom to course $one\_$two, section $sec not completed.$linefeed";
+ $$logmsg .= &mt('Incomplete course id defined.').$linefeed.&mt('Addition of user [_1] from domain [_2] to course [_3], section [_4] not completed.',$uname,$udom,$one.'_'.$two,$sec).$linefeed;
$result = "error: incomplete course id\n";
}
return $result;