--- loncom/interface/lonsupportreq.pm 2007/09/05 05:46:19 1.44 +++ loncom/interface/lonsupportreq.pm 2008/10/01 17:47:06 1.50 @@ -1,5 +1,5 @@ # -# $Id: lonsupportreq.pm,v 1.44 2007/09/05 05:46:19 raeburn Exp $ +# $Id: lonsupportreq.pm,v 1.50 2008/10/01 17:47:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -99,7 +99,8 @@ sub print_request_form { 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', @@ -171,11 +172,8 @@ END my ($sec,$grp) = split(/:/,$section); $groupid{$sec} = $grp; } - my $codedom = $Apache::lonnet::perlvar{'lonDefDomain'}; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom']); - if (exists($env{'form.codedom'})) { - $codedom = $env{'form.codedom'}; - } + my $codedom = &get_domain(); my $details_title; if ($codedom) { $details_title = '
('.$codedom.')'; @@ -197,9 +195,6 @@ function initialize_codes() { return; } |; - if ($cdom) { - $codedom = $cdom; - } if ($cnum) { $coursecodes{$cnum} = $ccode; if ($ccode eq '') { @@ -243,9 +238,12 @@ function initialize_codes() { if ($r->uri eq '/adm/helpdesk') { &print_header($r,$origurl); } + my @css = ('LC_evenrow_value','LC_oddrow_value'); + my $num = 1; + my $i = $num%2; $r->print('
'."\n"); my $output = &Apache::lonhtmlcommon::start_pick_box(). - &Apache::lonhtmlcommon::row_title($lt{'name'},undef,'LC_oddrow_value')."\n"; + &Apache::lonhtmlcommon::row_title($lt{'name'},undef,$css[$num])."\n"; my $fullname = ''; if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) { $fullname = "$firstname $lastname"; @@ -259,12 +257,23 @@ function initialize_codes() { $output .= '&').'" />'; } $output .= '      '. - &Apache::lonhtmlcommon::row_closure()."\n". - &Apache::lonhtmlcommon::row_title($lt{'emad'},undef,'LC_evenrow_value'). - '&').'" />
'."\n". - &Apache::lonhtmlcommon::row_closure(). - &Apache::lonhtmlcommon::row_title("$lt{'unme'}/$lt{'doma'}",undef,'LC_oddrow_value'); + &Apache::lonhtmlcommon::row_closure()."\n"; + $num ++; + $i = $num%2; + $output .= &Apache::lonhtmlcommon::row_title($lt{'emad'},undef,$css[$i]). + '&').'" />
'."\n". + &Apache::lonhtmlcommon::row_closure(); + $num ++; + $i = $num%2; + if (defined($env{'user.name'})) { + $output .= &Apache::lonhtmlcommon::row_title($lt{'emac'},undef,$css[$i]). + '
'."\n". + &Apache::lonhtmlcommon::row_closure(); + $num ++; + $i = $num%2; + } + $output .= &Apache::lonhtmlcommon::row_title("$lt{'unme'}/$lt{'doma'}",undef,$css[$i]); my $udom_input = '&').'" />'; my $uname_input = '&').'" />'. &Apache::lonhtmlcommon::row_closure(). - &Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef,'LC_oddrow_value'). + &Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef,'LC_evenrow_value'). '
'. - &Apache::lonhtmlcommon::row_closure(). - &Apache::lonhtmlcommon::row_title("$lt{'crsd'}$details_title",undef,'LC_evenrow_value'); - if ($cnum) { + &Apache::lonhtmlcommon::row_closure(); + $num ++; + $i = $num%2; + $output .= &Apache::lonhtmlcommon::row_title("$lt{'crsd'}$details_title",undef,$css[$i]); + if ($cnum) { if ($coursecodes{$cnum}) { foreach my $item (@codetitles) { $output .= ''.$item.': '.$codes{$cnum}{$item}.'; '; @@ -382,8 +395,10 @@ function initialize_codes() { $output .= '
'.$lt{'enct'}.':  '."\n"; } - $output .= &Apache::lonhtmlcommon::row_closure(). - &Apache::lonhtmlcommon::row_title($lt{'secn'},undef,'LC_oddrow_value'); + $output .= &Apache::lonhtmlcommon::row_closure(); + $num ++; + $i = $num%2; + $output .= &Apache::lonhtmlcommon::row_title($lt{'secn'},undef,$css[$i]); if ($sectionlist) { $output .= "'; } - $output .= &Apache::lonhtmlcommon::row_closure(). - &Apache::lonhtmlcommon::row_title($lt{'subj'},undef,'LC_evenrow_value'). + $output .= &Apache::lonhtmlcommon::row_closure(); + $num ++; + $i = $num%2; + $output .= &Apache::lonhtmlcommon::row_title($lt{'subj'},undef,'LC_oddrow_value'). ' '."\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'). ' '. &Apache::lonhtmlcommon::row_closure(); - my $lastrow = 'LC_evenrow_value'; + $num ++; + $i = $num%2; if (defined($env{'user.name'})) { - $output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,'LC_evenrow_value'). + $output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,$css[$i]). '
'.$lt{'uplf'}."\n". &Apache::lonhtmlcommon::row_closure(); - $lastrow = 'LC_oddrow_value'; + $num ++; + $i = $num%2; } - $output .= &Apache::lonhtmlcommon::row_title($lt{'fini'},undef,$lastrow); + $output .= &Apache::lonhtmlcommon::row_title($lt{'fini'},undef,$css[$i]); $output .= < @@ -450,7 +469,10 @@ sub print_request_receipt { my @cookievars = ('lonID'); my $admin = $Apache::lonnet::perlvar{'lonAdminMail'}; - my $to = $Apache::lonnet::perlvar{'lonSupportEMail'}; + my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; + my $defdom = &get_domain(); + my $to = &Apache::loncommon::build_recipient_list(undef,'helpdeskmail', + $defdom,$origmail); my $from = $admin; my $reporttime = &Apache::lonlocal::locallocaltime(time); my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot'); @@ -474,6 +496,7 @@ sub print_request_receipt { my %lt = &Apache::lonlocal::texthash ( username => 'Name', email => 'Email', + cc => 'Cc', user => 'Username/domain', phone => 'Phone', crsi => 'Course Information', @@ -489,12 +512,46 @@ sub print_request_receipt { info => 'Information supplied', adin => 'Additional information recorded', ); - + + my (@ok_ccs,@bad_ccs,$badccmsg,$okcclist); + if ((defined($env{'user.name'})) && (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 .= '
'.&mt('The following Cc e-mail address is invalid: ').$bad_ccs[0]; + } elsif (@bad_ccs > 1) { + my $bad_cc_string = join(', ',@bad_ccs); + $badccmsg .= '
'.&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 = <: $showurl
\n"; + } elsif ($item eq 'cc') { + $displaymsg .= + ''. + "$lt{$item}: $okcclist
\n"; } else { $displaymsg .= ''. @@ -547,25 +608,52 @@ END if ($r->uri eq '/adm/helpdesk') { &print_header($r,$url,'process'); } - if ($to =~ m/^[^\@]+\@[^\@]+$/) { - $r->print('

'.$lt{'asup'}.' '.$to.'

'); - } else { - $to = $admin; - if ($to =~ m/^[^\@]+\@[^\@]+$/) { - $r->print('

'.$lt{'asup'}.' '.$to.'

'); + my $bad_email = 0; + if ($to =~ /,/) { + my @ok_email; + foreach my $email (split(/,/,$to)) { + if ($email =~ m/^[^\@]+\@[^\@]+$/) { + if (!grep(/^\Q$email\E$/,@ok_email)) { + push(@ok_email,$email); + } + } + } + if (@ok_email > 0) { + $to = join(',',@ok_email); + } elsif ($admin =~ m/^[^\@]+\@[^\@]+$/) { + $to = $admin; } else { - $r->print(' + $bad_email = 1; + } + } elsif ($to !~ m/^[^\@]+\@[^\@]+$/) { + if ($admin =~ m/^[^\@]+\@[^\@]+$/) { + $to = $admin; + } else { + $bad_email = 1; + } + } + if ($bad_email) { + $r->print('

'.$lt{'warn'}.'

'. &mt('As the e-mail address provided for this LON-CAPA server ([_1]) does not appear to be a valid e-mail address, your support request has not been sent to the LON-CAPA support staff or administrator at your institution.',$to).' '.&mt('Instead a copy has been sent to the LON-CAPA support team at Michigan State University.')); $to = 'helpdesk@lon-capa.org'; - } + } else { + $r->print('

'.$lt{'asup'}.' '.$to.'

'); } 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; @@ -616,6 +704,10 @@ END 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); @@ -691,20 +783,23 @@ sub print_header { login => 'Log-in help', ask => 'Ask helpdesk', getst => 'Getting started guide', - back => 'Back to last location' + back => 'Back to last location', + headline => 'help/support', ); - my ($getstartlink,$getstarttext); + my ($getstartlink,$reviewtext); if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/adm/gettingstarted.html') { $getstartlink = qq| $lt{'getst'}|; - $getstarttext = ' '.&mt('and the "Getting started" guide').' '; + $reviewtext = &mt('Please review the information in "Log-in help" and the "Getting started" guide if you are unable to log-in.'); + } else { + $reviewtext = &mt('Please review the information in "Log-in help" if you are unable to log-in.'); } $r->print(<   -
  LON-CAPA help/support +
  LON-CAPA $lt{'headline'} - + $getstartlink @@ -720,8 +815,11 @@ END if ($command ne 'process') { $r->print(' - '); } @@ -730,4 +828,18 @@ Please review the information in "Log-in return; } +sub get_domain { + my $codedom; + if (exists($env{'form.codedom'})) { + $codedom = $env{'form.codedom'}; + } elsif ($env{'request.course.id'}) { + $codedom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + } elsif ($env{'request.role.domain'}) { + $codedom = $env{'request.role.domain'}; + } else { + $codedom = $Apache::lonnet::perlvar{'lonDefDomain'}; + } + return $codedom; +} + 1;