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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Sun, 13 Jan 2008 16:53:46 -0000


This is a MIME encoded message

--raeburn1200243226
Content-Type: text/plain

raeburn		Sun Jan 13 11:53:46 2008 EDT

  Modified files:              
    /loncom/interface	lonsupportreq.pm 
  Log:
  Bugs 3047, 5570.  Ccs can be specified in the help request form which sends e-mail to he helpdesk. 
  
  
--raeburn1200243226
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080113115346.txt"

Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.45 loncom/interface/lonsupportreq.pm:1.46
--- loncom/interface/lonsupportreq.pm:1.45	Mon Dec  3 23:43:21 2007
+++ loncom/interface/lonsupportreq.pm	Sun Jan 13 11:53:46 2008
@@ -1,5 +1,5 @@
 #
-# $Id: lonsupportreq.pm,v 1.45 2007/12/04 04:43:21 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.46 2008/01/13 16:53:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -99,7 +99,8 @@
                   rdes => 'You must include a description',
                   name => 'Name',
                   subm => 'Submit Request',
-                  emad => 'E-mail address',
+                  emad => 'Your e-mail address',
+                  emac => 'Cc', 
                   unme => 'username',
                   doma => 'domain',
                   entu => 'Enter the username you use to log-in to LON-CAPA',
@@ -258,7 +259,10 @@
                 '<input type="text" size="20" name="email" value="'.
                 &HTML::Entities::encode($email,'"<>&').'" /><br />'."\n".
                 &Apache::lonhtmlcommon::row_closure().
-                &Apache::lonhtmlcommon::row_title("$lt{'unme'}/$lt{'doma'}",undef,'LC_oddrow_value');
+                &Apache::lonhtmlcommon::row_title($lt{'emac'},undef,'LC_oddrow_value').
+                '<input type="text" size="50" name="cc" value="" /><br />'."\n".
+                &Apache::lonhtmlcommon::row_closure().
+                &Apache::lonhtmlcommon::row_title("$lt{'unme'}/$lt{'doma'}",undef,'LC_evenrow_value');
     my $udom_input = '<input type="hidden" name="udom" value="'.
                      &HTML::Entities::encode($udom,'"<>&').'" />';
     my $uname_input = '<input type="hidden" name="uname" value="'.
@@ -291,15 +295,15 @@
         $output .= $unameform.$udomform;
     }
     $output .= &Apache::lonhtmlcommon::row_closure().
-               &Apache::lonhtmlcommon::row_title("$lt{'urlp'}",undef,'LC_evenrow_value').
+               &Apache::lonhtmlcommon::row_title("$lt{'urlp'}",undef,'LC_oddrow_value').
                $showserver.'<input type="hidden" name="sourceurl" value="'.
                &HTML::Entities::encode($server,'"<>&').'" />'.
                &Apache::lonhtmlcommon::row_closure().
-               &Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef,'LC_oddrow_value').
+               &Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef,'LC_evenrow_value').
                '<input type="text" size="15" name="phone" /><br />'.
                &Apache::lonhtmlcommon::row_closure().
-               &Apache::lonhtmlcommon::row_title("$lt{'crsd'}$details_title",undef,'LC_evenrow_value');
-    if ($cnum) { 
+               &Apache::lonhtmlcommon::row_title("$lt{'crsd'}$details_title",undef,'LC_oddrow_value');
+    if ($cnum) {
         if ($coursecodes{$cnum}) {
             foreach my $item (@codetitles) {
                 $output .= '<i>'.$item.'</i>:&nbsp;'.$codes{$cnum}{$item}.';&nbsp;';
@@ -377,7 +381,7 @@
                  <input type="text" name="title" size="25" value="" />'."\n";
     }
     $output .= &Apache::lonhtmlcommon::row_closure().
-               &Apache::lonhtmlcommon::row_title($lt{'secn'},undef,'LC_oddrow_value');
+               &Apache::lonhtmlcommon::row_title($lt{'secn'},undef,'LC_evenrow_value');
     if ($sectionlist) {
         $output .= "<select name=\"section\"\n>".
                    "  <option value=\"\" selected=\"selected\">$lt{'sele'}</option>\n";
@@ -397,15 +401,15 @@
         $output .= '<input type="text" name="section" size="10" />';
     }
     $output .= &Apache::lonhtmlcommon::row_closure().
-               &Apache::lonhtmlcommon::row_title($lt{'subj'},undef,'LC_evenrow_value').
+               &Apache::lonhtmlcommon::row_title($lt{'subj'},undef,'LC_oddrow_value').
                '  <input type="text" size="40" name="subject" />'."\n".
                &Apache::lonhtmlcommon::row_closure().
-               &Apache::lonhtmlcommon::row_title($lt{'detd'},undef,'LC_oddrow_value').
+               &Apache::lonhtmlcommon::row_title($lt{'detd'},undef,'LC_evenrow_value').
                '  <textarea rows="10" cols="45" name="description" wrap="virtual"></textarea>'.
                &Apache::lonhtmlcommon::row_closure();
     my $lastrow = 'LC_evenrow_value';
     if (defined($env{'user.name'})) {
-        $output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,'LC_evenrow_value').
+        $output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,'LC_oddrow_value').
                    ' <input type="file" name="screenshot" size="20" /><br />'.$lt{'uplf'}."\n".
         &Apache::lonhtmlcommon::row_closure();
         $lastrow = 'LC_oddrow_value';
@@ -471,6 +475,7 @@
     my %lt = &Apache::lonlocal::texthash (
                  username    => 'Name',
                  email       => 'Email',
+                 cc          => 'Cc',
                  user        => 'Username/domain',
                  phone       => 'Phone',
                  crsi        => 'Course Information',
@@ -486,12 +491,46 @@
                  info        => 'Information supplied',
                  adin        => 'Additional information recorded',
     );
- 
+
+    my (@ok_ccs,@bad_ccs,$badccmsg,$okcclist);
+    if (defined($env{'form.cc'})) {
+        my @ccs;
+        if ($env{'form.cc'} =~ /,/) {
+            @ccs = split(/,/,$env{'form.cc'});
+        } else {
+            $env{'form.cc'} =~ s/^\s+//;
+            $env{'form.cc'} =~ s/\s+$//;
+            @ccs = $env{'form.cc'};
+        }
+        foreach my $cc (@ccs) {
+            $cc =~ s/^\s+//g;
+            $cc =~ s/\s+$//g;
+            if ($cc =~ m/^[^\@]+\@[^\@]+$/) {
+                if (!(grep(/^\Q$cc\E$/,@ok_ccs))) {
+                    push(@ok_ccs,$cc);
+                }
+            } else {
+                if (!(grep(/^\Q$cc\E$/,@bad_ccs))) {
+                    push(@bad_ccs,$cc);
+                }
+            }
+        }
+        if (@ok_ccs > 0) {
+           $okcclist = join(', ',@ok_ccs); 
+        } 
+        if (@bad_ccs == 1) {
+            $badccmsg .= '<br />'.&mt('The following Cc e-mail address is invalid: ').$bad_ccs[0];
+        } elsif (@bad_ccs > 1) {
+            my $bad_cc_string = join(', ',@bad_ccs);
+            $badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: ').$bad_cc_string;
+        }
+    }
     $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'";
     $env{'form.csri'} = $env{'form.title'}.' - '.$coursecode.' - '.$lt{'sect'}.': '.$env{'form.section'};
     my $supportmsg = <<END;
 $lt{'username'}: $env{'form.username'}
 $lt{'email'}: $env{'form.email'}
+$lt{'cc'}: $okcclist
 $lt{'user'}: $env{'form.user'}
 $lt{'phone'}: $env{'form.phone'}
 $lt{'crsi'}: $env{'form.csri'}
@@ -502,7 +541,7 @@
 
 END
     my $displaymsg;
-    foreach my $item ('username','email','user','phone','crsi','subject','description','sourceurl') {
+    foreach my $item ('username','email','cc','user','phone','crsi','subject','description','sourceurl') {
         if ($env{'form.'.$item} ne '') {
             if ($item eq 'description') {
                 my $descrip = $env{'form.description'};
@@ -516,6 +555,10 @@
                 $displaymsg .= 
                     '<span class="LC_helpform_receipt_cat">'.
                     "$lt{$item}</span>: $showurl<br />\n";
+            } elsif ($item eq 'cc') {
+                $displaymsg .=
+                    '<span class="LC_helpform_receipt_cat">'.
+                    "$lt{$item}</span>: $okcclist<br />\n";
             } else {
                 $displaymsg .= 
                     '<span class="LC_helpform_receipt_cat">'.
@@ -549,7 +592,9 @@
         my @ok_email; 
         foreach my $email (split(/,/,$to)) {
             if ($email =~ m/^[^\@]+\@[^\@]+$/) {
-                push(@ok_email,$email);
+                if (!grep(/^\Q$email\E$/,@ok_email)) {
+                    push(@ok_email,$email);
+                }
             }
         }
         if (@ok_email > 0) {
@@ -575,11 +620,19 @@
         $r->print('<h3>'.$lt{'asup'}.' '.$to.'</h3>');
     }
     if (defined($env{'form.email'})) {
+        $env{'form.email'} =~ s/^\s+//;
+        $env{'form.email'} =~ s/\s+$//;
         if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
             $from = $env{'form.email'};
         }
     }
 
+    if (defined($env{'form.cc'})) {
+        if ($badccmsg) {
+            $displaymsg .= $badccmsg;
+        }
+    }
+
     my $subject = $env{'form.subject'};
     $subject =~ s/(`)/'/g;
     $subject =~ s/\$/\(\$\)/g;
@@ -630,6 +683,10 @@
                  Type    =>'TEXT',
                  Data    => $supportmsg,
                  );
+    if (@ok_ccs > 0) {
+        my $cc_string = join(', ',@ok_ccs);
+        $msg->add("Cc" => $cc_string);
+    }
 
     if ($attachmentpath) {
         my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);

--raeburn1200243226--