Diff for /loncom/interface/lonsupportreq.pm between versions 1.11 and 1.17

version 1.11, 2004/11/27 17:23:09 version 1.17, 2004/12/20 20:04:48
Line 17  sub handler { Line 17  sub handler {
     if ($r->header_only) {      if ($r->header_only) {
         return OK;          return OK;
     }      }
       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['origurl','function']);
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','origurl','function']);      if ($r->uri eq '/adm/helpdesk') {
     my $action = $ENV{'form.action'};          &Apache::loncommon::get_posted_cgi($r);
       }
     my $function = $ENV{'form.function'};      my $function = $ENV{'form.function'};
     my $origurl = &Apache::lonnet::unescape($ENV{'form.origurl'});      my $origurl = &Apache::lonnet::unescape($ENV{'form.origurl'});
       my $action = $ENV{'form.action'};
   
     if ($action eq 'process') {      if ($action eq 'process') {
         &print_request_receipt($r,$origurl,$function);          &print_request_receipt($r,$origurl,$function);
     } else {      } else {
Line 36  sub print_request_form { Line 39  sub print_request_form {
     my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0",marginheight="0"',1);      my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0",marginheight="0"',1);
     my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');      my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
     if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) {      if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) {
         $tablecolor = '#CCCCFF';          $tablecolor = '#EEEE99';
     }      }
     $ccode = '';      $ccode = '';
     $os = $ENV{'browser.os'};      $os = $ENV{'browser.os'};
Line 50  sub print_request_form { Line 53  sub print_request_form {
     $usec = $ENV{'request.course.sec'};      $usec = $ENV{'request.course.sec'};
     $cid = $ENV{'request.course.id'};      $cid = $ENV{'request.course.id'};
     $server = $ENV{'SERVER_NAME'};      $server = $ENV{'SERVER_NAME'};
     my $scripttag = (<<END);      my $scripttag = (<<'END');
 function validate() {  function validate() {
     if (document.logproblem.email.value.indexOf("\@") == -1) {      if (validmail(document.logproblem.email) == false) {
         alert("You must enter a valid e-mail address");          alert("The e-mail address you entered: "+document.logproblem.email.value+" is not a valid e-mail address.");
         return          return;
     }      }
     document.logproblem.submit();      document.logproblem.submit();
 }  }
   
   function validmail(field) {
       var str = field.value;
       if (window.RegExp) {
           var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
           var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
           var reg1 = new RegExp(reg1str);
           var reg2 = new RegExp(reg2str);
           if (!reg1.test(str) && reg2.test(str)) {
               return true;
           }
           return false;
       }
       else
       {
           if(str.indexOf("@") >= 0) {
               return true;
           }
           return false;
       }
   }
 END  END
     if ($cid =~ m/_/) {      if ($cid =~ m/_/) {
         ($cdom,$cnum) = split/_/,$cid;          ($cdom,$cnum) = split/_/,$cid;
Line 124  END Line 148  END
             &javascript_code_selections($numtypes,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles);              &javascript_code_selections($numtypes,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles);
         }          }
     }      }
     $r->print(<<END);      $r->print(<<ENDHEAD);
 <html>  <html>
 <head>  <head>
  <title>LON-CAPA support request</title>   <title>LON-CAPA support request</title>
Line 134  $jscript Line 158  $jscript
 </script>  </script>
 </head>  </head>
 $bodytag  $bodytag
   ENDHEAD
       if ($r->uri eq '/adm/helpdesk') {
           &print_header($r,$origurl);
       }
       $r->print(<<"END");
   <form method="post" name="logproblem" enctype="multipart/form-data">
  <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">   <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
   <tr>    <tr>
    <td>     <td>
Line 144  $bodytag Line 174  $bodytag
         <tr>          <tr>
          <td>           <td>
   <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">    <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
            <form method="post" name="logproblem" enctype="multipart/form-data">  
            <tr>             <tr>
             <td width="140" bgcolor="$tablecolor">              <td width="140" bgcolor="$tablecolor">
              <table width="140" border="0" cellpadding="8" cellspacing="0">               <table width="140" border="0" cellpadding="8" cellspacing="0">
Line 169  END Line 198  END
         } elsif (defined($lastname) && $lastname ne '') {          } elsif (defined($lastname) && $lastname ne '') {
             $fullname= " $lastname";              $fullname= " $lastname";
         }          }
         $r->print('<input type="text" size="20" name="username" value="'.$fullname.'" /><br />');          $r->print('<input type="text" size="20" name="username" value="'.$fullname.'" />');
     }      }
     $r->print(<<END);      $r->print(<<END);
                   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="Submit Request" onClick="validate()"/>&nbsp;
                </td>                 </td>
               </tr>                </tr>
              </table>               </table>
Line 234  END Line 264  END
         }          }
         if ($udomform eq '') {          if ($udomform eq '') {
             $udomform = '<i>domain</i>:&nbsp;';              $udomform = '<i>domain</i>:&nbsp;';
             $udomform .= &Apache::loncommon::select_dom_form('','udom');              $udomform .= &Apache::loncommon::select_dom_form($defdom,'udom');
         }          }
         if ($unameform eq '') {          if ($unameform eq '') {
             $unameform= '<i>username</i>:&nbsp;<input type="text" size="20" name="loncname" value="'.$uname.'" />&nbsp;&nbsp;';              $unameform= '<i>username</i>:&nbsp;<input type="text" size="20" name="loncname" value="'.$uname.'" />&nbsp;&nbsp;';
Line 265  END Line 295  END
              <table width="100%" border="0" cellpadding="8" cellspacing="0">               <table width="100%" border="0" cellpadding="8" cellspacing="0">
               <tr>                <tr>
                <td>                 <td>
                 http://$server$origurl<input type="hidden" name="origurl" value="http://$server$origurl" />                  http://$server$origurl<input type="hidden" name="sourceurl" value="http://$server$origurl" />
                </td>                 </td>
               </tr>                </tr>
              </table>               </table>
Line 516  END Line 546  END
               <tr>                <tr>
                <td>                 <td>
                 <input type="hidden" name="action" value="process" />                  <input type="hidden" name="action" value="process" />
                 <input type="button" value="Submit Request Form" onClick="validate()"/> &nbsp;                  <input type="button" value="Submit Request" onClick="validate()"/> &nbsp;
                </td>                 </td>
                <td>&nbsp;</td>                 <td>&nbsp;</td>
                <td>                 <td>
Line 536  END Line 566  END
    </td>     </td>
   </tr>    </tr>
  </table>   </table>
   </form>
   </body>
   </html>
 END  END
     return;      return;
 }  }
Line 553  sub print_request_receipt { Line 586  sub print_request_receipt {
     my $fontcolor = &Apache::loncommon::designparm($function.'.font');      my $fontcolor = &Apache::loncommon::designparm($function.'.font');
     my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink');      my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink');
     my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');      my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
     my @formvars = ('username','email','uname','udom','origurl','phone','section','coursecode','title','subject','description','screenshot');      my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot');
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);
   
     my $supportmsg = qq|      my $supportmsg = qq|
Line 564  Tel: $ENV{'form.phone'} Line 597  Tel: $ENV{'form.phone'}
 Course Information: $ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'}  Course Information: $ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'}
 Subject: $ENV{'form.subject'}  Subject: $ENV{'form.subject'}
 Description: $ENV{'form.description'}  Description: $ENV{'form.description'}
 URL: $ENV{'form.origurl'}  URL: $ENV{'form.sourceurl'}
 Date/Time: $reporttime  Date/Time: $reporttime
   
     |;      |;
Line 578  Date/Time: $reporttime Line 611  Date/Time: $reporttime
 <font color="$fontcolor">Course Information: </font><font color="$vlinkcolor">$ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'}</font><br />  <font color="$fontcolor">Course Information: </font><font color="$vlinkcolor">$ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'}</font><br />
 <font color="$fontcolor">Subject: </font><font color="$vlinkcolor">$ENV{'form.subject'}</font><br />  <font color="$fontcolor">Subject: </font><font color="$vlinkcolor">$ENV{'form.subject'}</font><br />
 <font color="$fontcolor">Description: </font><font color="$vlinkcolor">$descrip</font><br />  <font color="$fontcolor">Description: </font><font color="$vlinkcolor">$descrip</font><br />
 <font color="$fontcolor">URL: </font><font color="$vlinkcolor">$ENV{'form.origurl'}</font><br />  <font color="$fontcolor">URL: </font><font color="$vlinkcolor">$ENV{'form.sourceurl'}</font><br />
 <font color="$fontcolor">Date/Time: </font><font color="$vlinkcolor">$reporttime</font><br />  <font color="$fontcolor">Date/Time: </font><font color="$vlinkcolor">$reporttime</font><br />
     |;      |;
       $r->print(<<"END");
     if ($to =~ m/^[^\@]+\@[^\@]+$/) {  
         $r->print(<<END);  
 <html>  <html>
 <head>  <head>
  <title>LON-CAPA support request recorded</title>   <title>LON-CAPA support request recorded</title>
 </head>  </head>
 $bodytag  $bodytag
  <h3>A support request has been sent to $to</h3>  <form name="logproblem">
   <input type="hidden" name="action" value="result">
   </form>
 END  END
       if ($r->uri eq '/adm/helpdesk') {
           &print_header($r,$url,'process');
       }
       if ($to =~ m/^[^\@]+\@[^\@]+$/) {
           $r->print("<h3>A support request has been sent to $to</h3>");
     } else {      } else {
         $to = $admin;          $to = $admin;
         if ($to =~ m/^[^\@]+\@[^\@]+$/) {          if ($to =~ m/^[^\@]+\@[^\@]+$/) {
             $r->print(<<END);              $r->print("<h3>A support request has been sent to $to</h3>");
 <html>  
 <head>  
  <title>LON-CAPA support request recorded</title>  
 </head>  
 $bodytag  
  <h3>A support request has been sent to $to</h3>  
 END  END
         } else {          } else {
             $r->print(<<END);              $r->print(<<END);
 <html>  
 <head>  
  <title>LON-CAPA support request recorded</title>  
 </head>  
 $bodytag  
  <h3>Warning: Problem with support e-mail address</h3>   <h3>Warning: Problem with support e-mail address</h3>
 As the e-mail address provided for this LON-CAPA server ($to) does not appear to be a valid e-mail address, your support request has <b>not</b> been sent to the LON-CAPA support staff or administrator at your institution. Instead a copy has been sent to the LON-CAPA support team at Michigan State University.   As the e-mail address provided for this LON-CAPA server ($to) does not appear to be a valid e-mail address, your support request has <b>not</b> been sent to the LON-CAPA support staff or administrator at your institution. Instead a copy has been sent to the LON-CAPA support team at Michigan State University. 
 END  END
Line 760  END Line 787  END
    </td>     </td>
   </tr>    </tr>
  </table>   </table>
   </body>
   </html>
     ");      ");
 }  }
   
   sub print_header {
       my ($r,$origurl,$action) = @_;
       my $location=&Apache::loncommon::lonhttpdurl("/adm");
       my $tablecolor = '#EEEE99';
       my ($component_url);
       my $helpdesk_link = '<a href="javascript:validate()">';
       if ($action eq 'process') {
           $helpdesk_link = '<a href="/adm/helpdesk">';
       }
       my %lt = &Apache::lonlocal::texthash (
                                              login => 'Log-in help',
                                              ask   => 'Ask helpdesk',
                                              getst => 'Getting started guide',
                                              back =>  'Back to last location'
                                            );  
       $r->print(<<END);
   <table width="620" border="0" cellspacing="0" cellpadding="0" height="55">   <tr height="50">    <td width='5'>&nbsp;</td>
      <td>
       <fieldset><legend><img src="$location/lonIcons/minilogo.gif" height='20' width='29' valign='bottom' />&nbsp;&nbsp;<b><font size="+1">LON-CAPA help/support</font></b></legend>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
     <tr>
      <td>
       <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
        <tr>
         <td>
          <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
           <tr>
            <td>
             <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
              <tr bgcolor="$tablecolor">
               <td align="center"><img src="$location/help/gif/smallHelp.gif" border="0" alt="(Login help)" valign="middle" />&nbsp;<b><a href="/adm/loginproblems.html">$lt{'login'}</a></td>
               <td align="center">&nbsp;<b>$helpdesk_link<img src="$location/lonIcons/helpdesk.gif" border="0" alt="(Ask helpdesk)" valign="middle" />&nbsp;$lt{'ask'}</a></b>&nbsp;</td>
               <td align="center">&nbsp;<b><a href="/adm/gettingstarted.html">$lt{'getst'}</a></td>
               <td align="center">&nbsp;<b><a href="$origurl" target="_top"><img src="$location/lonIcons/move_up.gif" border="0" alt="(Back to last location)" valign="middle" />&nbsp;$lt{'back'}</a></b>&nbsp;</td>
              </tr>
             </table>
            </td>
           </tr>
          </table>
         </td>
        </tr>
       </table>
      </td>
     </tr>
    </table>
   </fieldset>
     </td>
     <td width='5'>&nbsp;</td>
    </tr>
    <tr height='5'>
     <td colspan='3' height='5'>&nbsp;</td>
    </tr>
   END
       unless ($action eq 'process') {
           $r->print('
    <tr>
     <td colspan="3">'.&mt('
   Please read the "Log-in help" and "Getting started guide" if you can not log-in').'.  '.&mt('If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk').'.<br /><font size="-1"><b>'.&mt('Note').':</b> '.&mt('Student questions about course content should be directed to the course instructor').'.</font><br /><br />
     </td>
    </tr>');
       }
       $r->print('
   </table>');
       return;
   }
   
 sub retrieve_instcodes {  sub retrieve_instcodes {
     my ($coursecodes,$codedom,$totcodes) = @_;      my ($coursecodes,$codedom,$totcodes) = @_;
     my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.');      my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.');
Line 980  sub javascript_code_selections { Line 1075  sub javascript_code_selections {
 function courseSet(caller) {  function courseSet(caller) {
     var ids = new Array ("$seltitle_str");      var ids = new Array ("$seltitle_str");
     var formitems = new Array ($numtitles);      var formitems = new Array ($numtitles);
     var idyr = document.forms.logproblem.Year.selectedIndex      var idyr = document.logproblem.Year.selectedIndex
     var idsem  = document.forms.logproblem.Semester.selectedIndex      var idsem  = document.logproblem.Semester.selectedIndex
     var iddept = document.forms.logproblem.Department.selectedIndex      var iddept = document.logproblem.Department.selectedIndex
     var idclass = document.forms.logproblem.Number.selectedIndex      var idclass = document.logproblem.Number.selectedIndex
     var idyears = new Array("$$idlist{$$codetitles[0]}");      var idyears = new Array("$$idlist{$$codetitles[0]}");
     var idsems = new Array ($$idnums{$$codetitles[0]});      var idsems = new Array ($$idnums{$$codetitles[0]});
     var idsemlongs = new Array ($$idnums{$$codetitles[0]});      var idsemlongs = new Array ($$idnums{$$codetitles[0]});
Line 1010  END Line 1105  END
     }      }
     $$script_tag .= (<<END_OF_BLOCK);      $$script_tag .= (<<END_OF_BLOCK);
  if (caller == "Year") {   if (caller == "Year") {
    document.forms.logproblem.Department.length = 0     document.logproblem.Department.length = 0
    document.forms.logproblem.Number.length = 0     document.logproblem.Number.length = 0
    document.forms.logproblem.Department.options[0] = new Option("<-Pick Semester.","-1",true,true)     document.logproblem.Department.options[0] = new Option("<-Pick Semester.","-1",true,true)
    document.forms.logproblem.Number.options[0] = new Option("<-Pick Department","-1",true,true)     document.logproblem.Number.options[0] = new Option("<-Pick Department","-1",true,true)
    if (idyr == 0) {     if (idyr == 0) {
     document.forms.logproblem.Semester.length = 0      document.logproblem.Semester.length = 0
     document.forms.logproblem.Semester.options[0] = new Option("<-Pick Year","-1",true,true)      document.logproblem.Semester.options[0] = new Option("<-Pick Year","-1",true,true)
    }     }
    else {     else {
     document.forms.logproblem.Semester.length = 0      document.logproblem.Semester.length = 0
     document.forms.logproblem.Semester.options[0] = new Option("Select","-1",true,true)      document.logproblem.Semester.options[0] = new Option("Select","-1",true,true)
     for (var i=0; i<idsems[idyr-1].length; i++) {      for (var i=0; i<idsems[idyr-1].length; i++) {
       document.forms.logproblem.Semester.options[i+1] = new Option(idsemlongs[idyr-1][i],idsems[idyr-1][i],false,false)        document.logproblem.Semester.options[i+1] = new Option(idsemlongs[idyr-1][i],idsems[idyr-1][i],false,false)
     }      }
    }     }
    document.forms.logproblem.Semester.selectedIndex = 0;     document.logproblem.Semester.selectedIndex = 0;
  }   }
  if (caller == "Semester") {   if (caller == "Semester") {
    document.forms.logproblem.Department.length = 0     document.logproblem.Department.length = 0
    document.forms.logproblem.Number.length = 0     document.logproblem.Number.length = 0
    document.forms.logproblem.Number.options[0] = new Option("<-Pick Department.","-1",true,true)     document.logproblem.Number.options[0] = new Option("<-Pick Department.","-1",true,true)
    if (idsem == 0) {     if (idsem == 0) {
      document.forms.logproblem.Department.options[0] = new Option("<-Pick Semester.","-1",true,true)       document.logproblem.Department.options[0] = new Option("<-Pick Semester.","-1",true,true)
      document.forms.logproblem.Department.options[0] = new Option("<-Pick Semester","-1",true,true)       document.logproblem.Department.options[0] = new Option("<-Pick Semester","-1",true,true)
    }     }
    else {     else {
     document.forms.logproblem.Department.options[0] = new Option("Select","-1",true,true)          document.logproblem.Department.options[0] = new Option("Select","-1",true,true)    
     for (var i=0; i<idcodes[idyr-1][idsem-1].length; i++) {      for (var i=0; i<idcodes[idyr-1][idsem-1].length; i++) {
       document.forms.logproblem.Department.options[i+1] = new Option(idcodes[idyr-1][idsem-1][i],idcodes[idyr-1][idsem-1][i],false,false)        document.logproblem.Department.options[i+1] = new Option(idcodes[idyr-1][idsem-1][i],idcodes[idyr-1][idsem-1][i],false,false)
     }      }
    }     }
    document.forms.logproblem.Department.selectedIndex = 0     document.logproblem.Department.selectedIndex = 0
  }   }
  if (caller == "Department") {   if (caller == "Department") {
    document.forms.logproblem.Number.length = 0     document.logproblem.Number.length = 0
    if (iddept == 0) {     if (iddept == 0) {
      document.forms.logproblem.Number.options[0] = new Option("<-Pick Department.","-1",true,true)       document.logproblem.Number.options[0] = new Option("<-Pick Department.","-1",true,true)
    }     }
    else {     else {
     document.forms.logproblem.Number.options[0] = new Option("Select","-1",true,true)      document.logproblem.Number.options[0] = new Option("Select","-1",true,true)
     for (var i=0; i<idcourses[idyr-1][idsem-1][iddept-1].length; i++) {      for (var i=0; i<idcourses[idyr-1][idsem-1][iddept-1].length; i++) {
       document.forms.logproblem.Number.options[i+1] = new Option(idcourses[idyr-1][idsem-1][iddept-1][i],idcourses[idyr-1][idsem-1][iddept-1][i],false,false)        document.logproblem.Number.options[i+1] = new Option(idcourses[idyr-1][idsem-1][iddept-1][i],idcourses[idyr-1][idsem-1][iddept-1][i],false,false)
     }      }
    }     }
    document.forms.logproblem.Number.selectedIndex = 0     document.logproblem.Number.selectedIndex = 0
  }   }
 }  }
 END_OF_BLOCK  END_OF_BLOCK

Removed from v.1.11  
changed lines
  Added in v.1.17


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>