[LON-CAPA-cvs] cvs: loncom(version_1_1_X) /interface londropadd.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 21 Jan 2004 00:29:56 -0000


albertel		Tue Jan 20 19:29:56 2004 EDT

  Modified files:              (Branch: version_1_1_X)
    /loncom/interface	londropadd.pm 
  Log:
  - backport 1.96 and 1.97
  
  
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.91.2.1 loncom/interface/londropadd.pm:1.91.2.2
--- loncom/interface/londropadd.pm:1.91.2.1	Tue Jan 20 19:23:30 2004
+++ loncom/interface/londropadd.pm	Tue Jan 20 19:29:56 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.91.2.1 2004/01/21 00:23:30 albertel Exp $
+# $Id: londropadd.pm,v 1.91.2.2 2004/01/21 00:29:56 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -240,7 +240,7 @@
 ###############################################################
 ###############################################################
 sub javascript_validations {
-    my ($mode,$krbdefdom)=@_;
+    my ($mode,$krbdefdom,$curr_authtype,$curr_authfield)=@_;
     my $authheader;
     if ($mode eq 'auth') {
         my %param = ( formname => 'studentform',
@@ -250,7 +250,15 @@
         my %param = ( formname => 'ccrs',
                   kerb_def_dom => $krbdefdom );
         $authheader = &Apache::loncommon::authform_header(%param);
+    } elsif ($mode eq 'modifycourse') {
+        my %param = ( formname => 'cmod',
+                  kerb_def_dom => $krbdefdom,
+                  mode => 'modifycourse',
+                  curr_authtype => $curr_authtype,
+                  curr_autharg => $curr_authfield );
+        $authheader = &Apache::loncommon::authform_header(%param);
     }
+
     
     my %alert = &Apache::lonlocal::texthash
         (username => 'You need to specify the username field.',
@@ -268,24 +276,59 @@
     my $function_name =(<<END);
 function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail) {
 END
-    my $auth_checks = (<<END);
-    var foundatype=0;
+    my $auth_checks;
+    if ($mode eq 'createcourse') {
+        $auth_checks .= (<<END);
+    if (vf.autoadds[0].checked == true) {
+        if (current.radiovalue == null || current.radiovalue == 'nochange') {
+            alert('$alert{'authen'}');
+            return;
+        }
+    }
 END
-    unless ($mode eq 'createcourse') {
+    } else {
         $auth_checks .= (<<END);
+    var foundatype=0;
     if (founduname==0) {
 	alert('$alert{'username'}');
         return;
     }
-END
-    }
-    $auth_checks .= (<<END);
     // alert('current.radiovalue = '+current.radiovalue);
     if (current.radiovalue == null || current.radiovalue == 'nochange') {
         // They did not check any of the login radiobuttons.
         alert('$alert{'authen'}');
         return;
     }
+END
+    }
+    if ($mode eq 'createcourse') {
+        $auth_checks .= "
+    if ( (vf.autoadds[0].checked == true) &&
+         (vf.elements[current.argfield].value == null || vf.elements[current.argfield].value == '') ) {
+";
+    } elsif ($mode eq 'modifycourse') {
+        $auth_checks .= " 
+    if (vf.elements[current.argfield].value == null || vf.elements[current.argfield].value == '') {
+";
+    }
+    if ( ($mode eq 'createcourse') || ($mode eq 'modifycourse') ) {
+        $auth_checks .= (<<END);
+        var alertmsg = '';
+        switch (current.radiovalue) {
+            case 'krb':
+                alertmsg = '$alert{'krb'}';
+                break;
+            default:
+                alertmsg = '';
+        }
+        if (alertmsg != '') {
+            alert(alertmsg);
+            return;
+        }
+    }
+END
+    } else {
+        $auth_checks .= (<<END);
     foundatype=1;
     if (current.argfield == null || current.argfield == '') {
         var alertmsg = '';
@@ -309,8 +352,9 @@
         }
     }
 END
+    }
     my $optional_checks = '';
-    if ($mode eq 'createcourse') {
+    if ( ($mode eq 'createcourse') || ($mode eq 'modifycourse') ) {
         $optional_checks = (<<END);
     vf.submit();
 }
@@ -353,11 +397,11 @@
 END
     }
     my $result = $function_name;
-    if ( ($mode eq 'auth') || ($mode eq 'createcourse') ) {
+    if ( ($mode eq 'auth') || ($mode eq 'createcourse') || ($mode eq 'modifycourse')  ) {
         $result .= $auth_checks;
     }
     $result .= $optional_checks;
-    if ( ($mode eq 'auth') || ($mode eq 'createcourse') ) {
+    if ( ($mode eq 'auth') || ($mode eq 'createcourse') || ($mode eq 'modifycourse')  ) {
         $result .= $authheader;
     }
     return $result;