[LON-CAPA-cvs] cvs: loncom(version_2_5_X) /interface loncommon.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Tue, 04 Sep 2007 23:59:09 -0000


albertel		Tue Sep  4 19:59:09 2007 EDT

  Modified files:              (Branch: version_2_5_X)
    /loncom/interface	loncommon.pm 
  Log:
  - backport 1.570 1.571
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.564.2.5 loncom/interface/loncommon.pm:1.564.2.6
--- loncom/interface/loncommon.pm:1.564.2.5	Tue Sep  4 19:58:06 2007
+++ loncom/interface/loncommon.pm	Tue Sep  4 19:59:03 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.564.2.5 2007/09/04 23:58:06 albertel Exp $
+# $Id: loncommon.pm,v 1.564.2.6 2007/09/04 23:59:03 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5549,7 +5549,7 @@
 }
 
 sub user_picker {
-    my ($dom,$srch,$forcenewuser) = @_;
+    my ($dom,$srch,$forcenewuser,$caller) = @_;
     my $currdom = $dom;
     my %curr_selected = (
                         srchin => 'dom',
@@ -5583,6 +5583,14 @@
                     'exact'     => 'is',
                     'contains'  => 'contains',
                     'begins'    => 'begins with',
+                    'youm'      => "You must include some text to search for.",
+                    'thte'      => "The text you are searching for must contain at least two characters when using a 'begins' type search.",
+                    'thet'      => "The text you are searching for must contain at least three characters when using a 'contains' type search.",
+                    'yomc'      => "You must choose a domain when using an institutional directory search.",
+                    'ymcd'      => "You must choose a domain when using a domain search.",
+                    'whus'      => "When using searching by last,first you must include a comma as separator between last name and first name.",
+                    'whse'      => "When searching by last,first you must include at least one character in the first name.",
+                     'thfo'     => "The following need to be corrected before the search can be run:",
                                        );
     my $domform = &select_dom_form($currdom,'srchdomain',1,1);
     my $srchinsel = ' <select name="srchin">';
@@ -5632,29 +5640,29 @@
     my ($newuserscript,$new_user_create);
 
     if ($forcenewuser) {
-	$new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\');" /> </p>';
+	$new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\','.$caller.');" /> </p>';
         $newuserscript = <<"ENDSCRIPT";
 
-function setSearch(createnew) {
+function setSearch(createnew,callingForm) {
     if (createnew == 1) {
-        for (var i=0; i<document.crtuser.srchby.length; i++) {
-            if (document.crtuser.srchby.options[i].value == 'uname') {
-                document.crtuser.srchby.selectedIndex = i;
+        for (var i=0; i<callingForm.srchby.length; i++) {
+            if (callingForm.srchby.options[i].value == 'uname') {
+                callingForm.srchby.selectedIndex = i;
             }
         }
-        for (var i=0; i<document.crtuser.srchin.length; i++) {
-            if ( document.crtuser.srchin.options[i].value == 'dom') {
-		document.crtuser.srchin.selectedIndex = i;
+        for (var i=0; i<callingForm.srchin.length; i++) {
+            if ( callingForm.srchin.options[i].value == 'dom') {
+		callingForm.srchin.selectedIndex = i;
             }
         }
-        for (var i=0; i<document.crtuser.srchtype.length; i++) {
-            if (document.crtuser.srchtype.options[i].value == 'exact') {
-                document.crtuser.srchtype.selectedIndex = i;
+        for (var i=0; i<callingForm.srchtype.length; i++) {
+            if (callingForm.srchtype.options[i].value == 'exact') {
+                callingForm.srchtype.selectedIndex = i;
             }
         }
-        for (var i=0; i<document.crtuser.srchdomain.length; i++) {
-            if (document.crtuser.srchdomain.options[i].value == '$env{'request.role.domain'}') {
-                document.crtuser.srchdomain.selectedIndex = i;
+        for (var i=0; i<callingForm.srchdomain.length; i++) {
+            if (callingForm.srchdomain.options[i].value == '$env{'request.role.domain'}') {
+                callingForm.srchdomain.selectedIndex = i;
             }
         }
     }
@@ -5665,69 +5673,69 @@
 
     my $output = <<"END_BLOCK";
 <script type="text/javascript">
-function validateEntry() {
+function validateEntry(callingForm) {
 
     var checkok = 1;
     var srchin;
-    for (var i=0; i<document.crtuser.srchin.length; i++) {
-	if ( document.crtuser.srchin[i].checked ) {
-	    srchin = document.crtuser.srchin[i].value;
+    for (var i=0; i<callingForm.srchin.length; i++) {
+	if ( callingForm.srchin[i].checked ) {
+	    srchin = callingForm.srchin[i].value;
 	}
     }
 
-    var srchtype = document.crtuser.srchtype.options[document.crtuser.srchtype.selectedIndex].value;
-    var srchby = document.crtuser.srchby.options[document.crtuser.srchby.selectedIndex].value;
-    var srchdomain = document.crtuser.srchdomain.options[document.crtuser.srchdomain.selectedIndex].value;
-    var srchterm =  document.crtuser.srchterm.value;
-    var srchin = document.crtuser.srchin.options[document.crtuser.srchin.selectedIndex].value;
+    var srchtype = callingForm.srchtype.options[callingForm.srchtype.selectedIndex].value;
+    var srchby = callingForm.srchby.options[callingForm.srchby.selectedIndex].value;
+    var srchdomain = callingForm.srchdomain.options[callingForm.srchdomain.selectedIndex].value;
+    var srchterm =  callingForm.srchterm.value;
+    var srchin = callingForm.srchin.options[callingForm.srchin.selectedIndex].value;
     var msg = "";
 
     if (srchterm == "") {
         checkok = 0;
-        msg += "You must include some text to search for.\\n";
+        msg += "$lt{'youm'}\\n";
     }
 
     if (srchtype== 'begins') {
         if (srchterm.length < 2) {
             checkok = 0;
-            msg += "The text you are searching for must contain at least two characters when using a 'begins' type search.\\n";
+            msg += "$lt{'thte'}\\n";
         }
     }
 
     if (srchtype== 'contains') {
         if (srchterm.length < 3) {
             checkok = 0;
-            msg += "The text you are searching for must contain at least three characters when using a 'contains' type search.\\n";
+            msg += "$lt{'thet'}\\n";
         }
     }
     if (srchin == 'instd') {
         if (srchdomain == '') {
             checkok = 0;
-            msg += "You must choose a domain when using an institutional directory search.\\n";
+            msg += "$lt{'yomc'}\\n";
         }
     }
     if (srchin == 'dom') {
         if (srchdomain == '') {
             checkok = 0;
-            msg += "You must choose a domain when using a domain search.\\n";
+            msg += "$lt{'ymcd'}\\n";
         }
     }
     if (srchby == 'lastfirst') {
         if (srchterm.indexOf(",") == -1) {
             checkok = 0;
-            msg += "When using searching by last,first you must include a comma as separator between last name and first name.\\n";
+            msg += "$lt{'whus'}\\n";
         }
         if (srchterm.indexOf(",") == srchterm.length -1) {
             checkok = 0;
-            msg += "When searching by last,first you must include at least one character in the first name.\\n";
+            msg += "$lt{'whse'}\\n";
         }
     }
     if (checkok == 0) {
-        alert("The following need to be corrected before the search can be run:\\n"+msg);
+        alert("$lt{'thfo'}\\n"+msg);
         return;
     }
     if (checkok == 1) {
-        document.crtuser.submit();
+        callingForm.submit();
     }
 }