[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /interface lonsupportreq.pm

raeburn raeburn@source.lon-capa.org
Wed, 14 Apr 2010 07:31:21 -0000


raeburn		Wed Apr 14 07:31:21 2010 EDT

  Modified files:              (Branch: version_2_9_X)
    /loncom/interface	lonsupportreq.pm 
  Log:
  - Backport 1.56
  
  
Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.55.4.2 loncom/interface/lonsupportreq.pm:1.55.4.3
--- loncom/interface/lonsupportreq.pm:1.55.4.2	Sat Feb 13 00:09:20 2010
+++ loncom/interface/lonsupportreq.pm	Wed Apr 14 07:31:21 2010
@@ -1,5 +1,5 @@
 #
-# $Id: lonsupportreq.pm,v 1.55.4.2 2010/02/13 00:09:20 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.55.4.3 2010/04/14 07:31:21 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -77,8 +77,11 @@
     $browser = $env{'browser.type'};
     $bversion = $env{'browser.version'};
     $uhost = $env{'request.host'};
-    $uname = $env{'user.name'};
-    $udom = $env{'user.domain'};
+    my ($uname,$udom);
+    if (($env{'user.name'} ne 'public') && ($env{'user.domain'} ne 'public')) {
+        $uname = $env{'user.name'};
+        $udom = $env{'user.domain'};
+    }
     $uhome = $env{'user.home'};
     $urole = $env{'request.role'};
     $usec = $env{'request.course.sec'};
@@ -266,7 +269,7 @@
                &Apache::lonhtmlcommon::row_closure();
     $num ++;
     $i = $num%2;
-    if (defined($env{'user.name'})) {
+    if (defined($uname)) {
         $output .= &Apache::lonhtmlcommon::row_title($lt{'emac'},undef,$css[$i]).
                    '<input type="text" size="50" name="cc" value="" /><br />'."\n".
                    &Apache::lonhtmlcommon::row_closure();
@@ -428,7 +431,7 @@
                &Apache::lonhtmlcommon::row_closure();
     $num ++;
     $i = $num%2; 
-    if (defined($env{'user.name'})) {
+    if (defined($uname)) {
         $output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,$css[$i]).
                    ' <input type="file" name="screenshot" size="20" /><br />'.$lt{'uplf'}."\n".
         &Apache::lonhtmlcommon::row_closure();
@@ -474,6 +477,32 @@
     my $to = &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
                                                       $defdom,$origmail);
     my $from = $admin;
+    my $bcc;
+    my %domconfig =
+         &Apache::lonnet::get_dom('configuration',['contacts'],$defdom);
+    if (ref($domconfig{'contacts'}) eq 'HASH') {
+        if (exists($domconfig{'contacts'}{'helpdeskmail'})) {
+            if (ref($domconfig{'contacts'}{'helpdeskmail'}) eq 'HASH') {
+                my $bccmail = $domconfig{'contacts'}{'helpdeskmail'}{'bcc'};
+                if ($bccmail ne '') {
+                    my @bccs = split(/,/,$bccmail);
+                    my @ok_bccs;
+                    foreach my $bcc (@bccs) {
+                        $bcc =~ s/^\s+//g;
+                        $bcc =~ s/\s+$//g;
+                        if ($bcc =~ m/^[^\@]+\@[^\@]+$/) {
+                            if (!(grep(/^\Q$bcc\E$/,@ok_bccs))) {
+                                push(@ok_bccs,$bcc);
+                            }
+                        }
+                    }
+                    if (@ok_bccs > 0) {
+                        $bcc = join(', ',@ok_bccs);
+                    }
+                }
+            }
+        }
+    }
     my $reporttime = &Apache::lonlocal::locallocaltime(time);
     my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot');
 
@@ -669,7 +698,8 @@
 
     my $attachmentpath = '';
     my $attachmentsize = '';
-    if (defined($env{'user.name'})) {
+    if ((defined($env{'user.name'})) && ($env{'user.name'} ne 'public')
+        && ($env{'user.domain'} ne 'public')) {
         if ($env{'form.screenshot.filename'}) {
             $attachmentsize = length($env{'form.screenshot'});
             if ($attachmentsize > 131072) {
@@ -717,6 +747,9 @@
         my $cc_string = join(', ',@ok_ccs);
         $msg->add("Cc" => $cc_string);
     }
+    if ($bcc ne '') {
+        $msg->add("Bcc" => $bcc);
+    }
 
     if ($attachmentpath) {
         my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);