[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonerrorhandler.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Mon, 03 Dec 2007 22:58:46 -0000


raeburn		Mon Dec  3 17:58:46 2007 EDT

  Modified files:              
    /loncom/interface	lonerrorhandler.pm loncommon.pm 
  Log:
  - Localization of error reporting screen for ISEs
  - E-mail recipients for error reports from those defined in domain configuration,
    for 'main' domain on host server. 
  
  
Index: loncom/interface/lonerrorhandler.pm
diff -u loncom/interface/lonerrorhandler.pm:1.12 loncom/interface/lonerrorhandler.pm:1.13
--- loncom/interface/lonerrorhandler.pm:1.12	Sat Sep  2 16:49:20 2006
+++ loncom/interface/lonerrorhandler.pm	Mon Dec  3 17:58:46 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Internal Server Error Handler
 #
-# $Id: lonerrorhandler.pm,v 1.12 2006/09/02 20:49:20 albertel Exp $
+# $Id: lonerrorhandler.pm,v 1.13 2007/12/03 22:58:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -34,6 +34,7 @@
 use Apache::lonnet;
 use Apache::lonmsg();
 use Apache::lonacc();
+use Apache::lonlocal;
 
 sub handler {
     my $r = shift;
@@ -53,27 +54,44 @@
 	if ($env{'form.reproducible'}) {
 	    $repro='yes';
 	}
+        my %lt = &Apache::lonlocal::texthash (
+                     msg => 'LON-CAPA Error Message',
+                     rep => 'Reproducible',
+                     ver => 'Version',
+                     syl => 'Syllabus',
+                     pri => 'Prior Action',
+                     gue => 'Guesses',
+                     env => 'Environment',
+                 );
 	my $message=(<<ENDMESSAGE);
-LON-CAPA Error Message
-Reproducible: $repro
-Version: $env{'form.version'}
-Syllabus:
+$lt{'msg'}
+$lt{'rep'}: $repro
+$lt{'ver'}: $env{'form.version'}
+$lt{'syl'}:
 $env{'form.syllabus'}
 
-Prior Action:
+$lt{'pri'}:
 $env{'form.prioraction'}
 
-Guesses:
+$lt{'gue'}:
 $env{'form.guesses'}
 
-Environment:
+$lt{'env'}:
 $env{'form.environment'}
 ENDMESSAGE
-	my $recipients=$r->dir_config('lonAdmEMail').','.
-	    $r->dir_config('lonSysEMail'); 
-
-        &Apache::lonmsg::sendemail($recipients,'ERROR REPORT',$message);
-	$r->print('<h2>Report submitted</h2>Thank you!');
+        my $sysmail = $r->dir_config('lonSysEMail');
+        my $defdom = $r->dir_config('lonDefDomain');
+        my $recipients = &Apache::loncommon::build_recipient_list($r,$sysmail,
+                                                         'errormail',$defdom);
+        if ($recipients ne '') {
+            &Apache::lonmsg::sendemail($recipients,'ERROR REPORT',$message);
+	    $r->print('<h2>'.&mt('Report submitted').'</h2>'.&mt('Thank you!'));
+        } else {
+            $r->print('<h2>'.&mt('Warning: Report not submitted').'</h2>'.
+                      '<span class="LC_error">'.&mt("The administrators of
+                      the domain ($defdom) have not set any e-mail addresses
+                      for receipt of your error report.").'</span>');
+        }
     } else {
 # ------------------------------------------------------------- Get environment
 	my $envkey;
@@ -95,46 +113,46 @@
 	my $version=$r->dir_config('lonVersion');
 
 # ----------------------------------------------------------- Print error form
-	$r->print(<<ENDDOCUMENT);
-<h2>Somewhere something went wrong - please help us to find out what.</h2>
-Please take a moment to fill out the form below. Your information, together
-with internal debugging information, will be emailed to the system and server
-administrators.
+	$r->print('<h2>'.
+&mt('Somewhere something went wrong - please help us to find out what.').'</h2>'.
+&mt('Please take a moment to fill out the form below.').' '.&mt('Your information,
+ together with internal debugging information, will be emailed to the system and 
+server administrators.').'
 <form action="/adm/errorhandler" method="post">
-<input type="submit" value="Send Information" />
-<h3>Please describe what you did just before this screen came up</h3>
+<input type="submit" value="'.&mt('Send Information').'" />
+<h3>'.&mt('Please describe what you did just before this screen came up').'</h3>
 <textarea name="prioraction" cols="50" rows="5">
 </textarea>
-<h3>Is this problem reproducible?</h3>
+<h3>'.&mt('Is this problem reproducible?').'</h3>
 <label>
-<input type="checkbox" name="reproducible" value="yes" /> Yes!
+<input type="checkbox" name="reproducible" value="yes" /> '.&mt('Yes!').'
 </label>
-<h3>Do you have any guesses why this might have happened?</h3>
+<h3>'.&mt('Do you have any guesses why this might have happened?').'</h3>
 <textarea name="guesses" cols="50" rows="5">
 </textarea>
-<input type="hidden" name="version" value="$version" />
-<input type="hidden" name="environment" value="$env" />
-<input type="hidden" name="syllabus" value="$syllabus" />
+<input type="hidden" name="version" value="'.$version.'" />
+<input type="hidden" name="environment" value="'.$env.'" />
+<input type="hidden" name="syllabus" value="'.$syllabus.'" />
 <input type="hidden" name="sendinfo" value="1" />
 <p>
-<input type="submit" value="Send Information" />
+<input type="submit" value="'.&mt('Send Information').'" />
 </p>
 </form>
-<h1>Thank you for your help!</h1>
+<h1>'.&mt('Thank you for your help!').'</h1>
 <font size="-1">
 <pre>
-Internal info:
-$syllabus
+'.&mt('Internal info:').
+$syllabus.'
 </pre>
 </font>
-ENDDOCUMENT
+');
 # -------------------------- Better terminate this in case something was sticky
 
         $r->child_terminate();
     }
     $r->print(&Apache::loncommon::end_page());
     return OK;
-} 
+}
 
 1;
 __END__
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.617 loncom/interface/loncommon.pm:1.618
--- loncom/interface/loncommon.pm:1.617	Fri Nov 30 22:42:47 2007
+++ loncom/interface/loncommon.pm	Mon Dec  3 17:58:46 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.617 2007/12/01 03:42:47 albertel Exp $
+# $Id: loncommon.pm,v 1.618 2007/12/03 22:58:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -7636,6 +7636,66 @@
     }
 }
 
+#######################################################
+#######################################################
+
+=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 lonhelpdesk.pm respectively.
+
+Inputs:
+Request object, defmail (scalar - email address of default recipient), 
+mailing type (scalar - errormail, packagesmail, or helpdeskmail), 
+defdom (domain for which to retrieve configuration settings).
+
+Returns: comma separated list of addresses to which to send e-mail.   
+
+=cut
+
+############################################################
+############################################################
+sub build_recipient_list {
+    my ($r,$defmail,$mailing,$defdom) = @_;
+    my @recipients;
+    my $otheremails;
+    my $defdom = $r->dir_config('lonDefDomain');
+    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}) {
+                    push(@recipients,$domconfig{'contacts'}{$item});
+                }
+                $otheremails = $domconfig{'contacts'}{$mailing}{'others'};
+            }
+        } else {
+            push(@recipients,$r->dir_config('lonAdmEMail'));
+        }
+    }
+    if ($defmail ne '') {
+        push(@recipients,$defmail);
+    }
+    my $recipientlist = join(',',@recipients);
+    if ($otheremails) {
+        if ($recipientlist ne '') {
+            $recipientlist .= ','.$otheremails;
+        } else {
+            $recipientlist = $otheremails;
+        }
+    }
+    return $recipientlist;
+}
+
 ############################################################
 ############################################################