[LON-CAPA-cvs] cvs: loncom /interface londropadd.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Sat, 27 Dec 2003 23:38:14 -0000
raeburn Sat Dec 27 18:38:14 2003 EDT
Modified files:
/loncom/interface londropadd.pm
Log:
Modifications to javascript_validations(), to support use by loncreatecourse.pm and lonmodifycourse.pm. For loncreatecourse.pm: Javascript function verify_message() now only requires an authentication type, if automated adds set to "Yes" (fix to bug #2468). Same function now requires a Kerberos domain if authtype is set to "krb" when called from loncreatecourse.pm and lonmodifycourse.pm.
Existing javascript code for use of javascript_validations() by other modules (e.g., londropadd.pm -directly) left unchanged, although it should be modified in the future if checking of the autharg field is desired - as written it will always deliver the default, i.e., no alert, regardless of the contents of the autharg field.
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.95 loncom/interface/londropadd.pm:1.96
--- loncom/interface/londropadd.pm:1.95 Mon Dec 22 17:50:37 2003
+++ loncom/interface/londropadd.pm Sat Dec 27 18:38:13 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.95 2003/12/22 22:50:37 albertel Exp $
+# $Id: londropadd.pm,v 1.96 2003/12/27 23:38:13 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -227,7 +227,7 @@
###############################################################
###############################################################
sub javascript_validations {
- my ($mode,$krbdefdom)=@_;
+ my ($mode,$krbdefdom,$curr_authtype,$curr_authfield)=@_;
my $authheader;
if ($mode eq 'auth') {
my %param = ( formname => 'studentform',
@@ -237,7 +237,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.',
@@ -258,21 +266,58 @@
my $auth_checks = (<<END);
var foundatype=0;
END
- unless ($mode eq 'createcourse') {
+ if ($mode eq 'createcourse') {
+ $auth_checks .= (<<END);
+ if (document.ccrs.autoadds[0].checked == true) {
+ if (current.radiovalue == null || current.radiovalue == 'nochange') {
+ alert('$alert{'authen'}');
+ return;
+ }
+ }
+END
+ } else {
$auth_checks .= (<<END);
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') || ($mode eq 'modifycourse') ) {
+ $auth_checks .= "
+ foundatype=1";
+ if ($mode eq 'createcourse') {
+ $auth_checks .= "
+ if ( (document.ccrs.autoadds[0].checked == true) &&
+ (document.ccrs.elements[current.argfield].value == null || document.ccrs.elements[current.argfield].value == '') ) {";
+ } elsif ($mode eq 'modifycourse') {
+ $auth_checks .= "
+ if (document.ccrs.elements[current.argfield].value == null || document.cmod.elements[current.argfield].value == '') }";
+ }
+ $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 = '';
@@ -296,8 +341,9 @@
}
}
END
+ }
my $optional_checks = '';
- if ($mode eq 'createcourse') {
+ if ( ($mode eq 'createcourse') || ($mode eq 'modifycourse') ) {
$optional_checks = (<<END);
vf.submit();
}
@@ -340,11 +386,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;