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

raeburn lon-capa-cvs@mail.lon-capa.org
Mon, 20 Dec 2004 19:58:41 -0000


raeburn		Mon Dec 20 14:58:41 2004 EDT

  Modified files:              
    /loncom/interface	lonsupportreq.pm lonhelpmenu.pm 
  Log:
  Fix bug #3489.
  
  
Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.15 loncom/interface/lonsupportreq.pm:1.16
--- loncom/interface/lonsupportreq.pm:1.15	Sat Dec 18 19:21:46 2004
+++ loncom/interface/lonsupportreq.pm	Mon Dec 20 14:58:41 2004
@@ -201,6 +201,7 @@
         $r->print('<input type="text" size="20" name="username" value="'.$fullname.'" /><br />');
     }
     $r->print(<<END);
+                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="Submit Request" onClick="validate()"/>&nbsp;
                </td>
               </tr>
              </table>
@@ -619,6 +620,9 @@
  <title>LON-CAPA support request recorded</title>
 </head>
 $bodytag
+<form name="logproblem">
+<input type="hidden" name="action" value="result">
+</form>
 END
     if ($r->uri eq '/adm/helpdesk') {
         &print_header($r,$url,'process');
Index: loncom/interface/lonhelpmenu.pm
diff -u loncom/interface/lonhelpmenu.pm:1.16 loncom/interface/lonhelpmenu.pm:1.17
--- loncom/interface/lonhelpmenu.pm:1.16	Sat Dec  4 16:15:33 2004
+++ loncom/interface/lonhelpmenu.pm	Mon Dec 20 14:58:41 2004
@@ -78,9 +78,64 @@
     my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
     my $location=&Apache::loncommon::lonhttpdurl("/adm");
     if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) {
-        $tablecolor = '#CCCCFF';
+        $tablecolor = '#EEEE99';
     }
+    my $scripttag = '';
+    if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
+        my $displayurl = &Apache::lonnet::escape($origurl);
+        $scripttag = (<<"SCRIPT_ONE");
+<script>
+function gohelpdesk() {
+    var actiontype = null;
+    try {
+        actiontype = parent.bodyframe.document.logproblem.action.value;
+    }
+    catch(error) {
+        parent.bodyframe.location = "/adm/support?origurl=$displayurl&function=$function";
+        return;
+    }
+    if (actiontype) {
+        var loc = parent.bodyframe.location.href;
+        if (loc.indexOf("/adm/support") > -1) {
+            if (parent.bodyframe.document.logproblem.action.value == "process") {
+                if (validmail(parent.bodyframe.document.logproblem.email) == false) {
+                    alert("The e-mail address you entered: "+parent.bodyframe.document.logproblem.email.value+" is not a valid e-mail address.");
+                    return;
+                }
+                parent.bodyframe.document.logproblem.submit();
+                return;
+            }
+        }
+        parent.bodyframe.location = "/adm/support?origurl=$displayurl&function=$function";
+        return;
+    }
+}
+SCRIPT_ONE
+        $scripttag .= (<<'SCRIPT_TWO');
+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;
+    }
+}
+</script>
+SCRIPT_TWO
+    }
     $r->print(<<END);
 <html>
 <head>
@@ -93,6 +148,7 @@
  a:hover {text-decoration: underline; color: $vlinkcolor; }
 -->
 </style>
+$scripttag
 </head>
 $bodytag
 END
@@ -130,7 +186,7 @@
     }
     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
         $r->print('
-            <td align="center">&nbsp;<b><a href="/adm/support?origurl='.&Apache::lonnet::escape($origurl).'&function='.$function.'" target="bodyframe"><img src="'.$location.'/lonIcons/helpdesk.gif" border="0" alt="(Ask helpdesk)" valign="middle" />&nbsp;Ask helpdesk</a></b>&nbsp;</td>');
+            <td align="center">&nbsp;<b><a href="javascript:gohelpdesk()"><img src="'.$location.'/lonIcons/helpdesk.gif" border="0" alt="(Ask helpdesk)" valign="middle" />&nbsp;Ask helpdesk</a></b>&nbsp;</td>');
     }
     if ($faq && $ENV{'user.adv'}) {
         $r->print(<<END);