[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm loncreateuser.pm londropadd.pm

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 22 Apr 2002 15:26:46 -0000


This is a MIME encoded message

--matthew1019489206
Content-Type: text/plain

matthew		Mon Apr 22 11:26:46 2002 EDT

  Modified files:              
    /loncom/interface	loncommon.pm londropadd.pm loncreateuser.pm 
  Log:
  New javascript to handle authentication forms.
  
  
--matthew1019489206
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20020422112646.txt"

Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.31 loncom/interface/loncommon.pm:1.32
--- loncom/interface/loncommon.pm:1.31	Mon Apr 15 19:37:37 2002
+++ loncom/interface/loncommon.pm	Mon Apr 22 11:26:46 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.31 2002/04/15 23:37:37 albertel Exp $
+# $Id: loncommon.pm,v 1.32 2002/04/22 15:26:46 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -143,10 +143,193 @@
               "<font color=yellow>INFO: Read file types and thesaurus</font>");
     $readit=1;
 }
-
+    
 }
 # ============================================================= END BEGIN BLOCK
 
+###############################################################
+##    Authentication changing form generation subroutines    ##
+###############################################################
+##
+## All of the authform_xxxxxxx subroutines take their inputs in a
+## hash, and have reasonable default values.
+##
+##    formname = the name given in the <form> tag.
+sub authform_header{  
+    my %in = (
+        formname => 'cu',
+        kerb_def_dom => 'MSU.EDU',
+        @_,
+    );
+    $in{'formname'} = 'document.' . $in{'formname'};
+    my $result='';
+    $result.=<<"END";
+var current = new Object();
+current.radiovalue = 'nochange';
+current.argfield = null;
+
+function changed_radio(choice,currentform) {
+    var choicearg = choice + 'arg';
+    // If a radio button in changed, we need to change the argfield
+    if (current.radiovalue != choice) {
+        current.radiovalue = choice;
+        if (current.argfield != null) {
+            currentform.elements[current.argfield].value = '';
+        }
+        if (choice == 'nochange') {
+            current.argfield = null;
+        } else {
+            current.argfield = choicearg;
+            switch(choice) {
+                case 'krb': 
+                    currentform.elements[current.argfield].value = 
+                        "$in{'kerb_def_dom'}";
+                break;
+              default:
+                break;
+            }
+        }
+    }
+    return;
+}
+
+function changed_text(choice,currentform) {
+    var choicearg = choice + 'arg';
+    if (currentform.elements[choicearg].value !='') {
+        switch (choice) {
+            case 'krb': currentform.elements[choicearg].value =
+                currentform.elements[choicearg].value.toUpperCase();
+                break;
+            default:
+        }
+        // clear old field
+        if ((current.argfield != choicearg) && (current.argfield != null)) {
+            currentform.elements[current.argfield].value = '';
+        }
+        current.argfield = choicearg;
+    }
+    set_auth_radio_buttons(choice,currentform);
+    return;
+}
+
+function set_auth_radio_buttons(newvalue,currentform) {
+    var i=0;
+    while (i < currentform.login.length) {
+        if (currentform.login[i].value == newvalue) { break; }
+        i++;
+    }
+    if (i == currentform.login.length) {
+        return;
+    }
+    current.radiovalue = newvalue;
+    currentform.login[i].checked = true;
+    return;
+}
+END
+    return $result;
+}
+
+sub authform_authorwarning{
+    my $result='';
+    $result=<<"END";
+<i>As a general rule, only authors or co-authors should be filesystem
+authenticated (which allows access to the server filesystem).</i>
+END
+    return $result;
+}
+
+sub authform_nochange{  
+    my %in = (
+              formname => 'document.cu',
+              kerb_def_dom => 'MSU.EDU',
+              @_,
+          );
+    my $result='';
+    $result.=<<"END";
+<input type="radio" name="login" value="nochange" checked="checked"
+       onclick="javascript:changed_radio('nochange',$in{'formname'});">
+Do not change login data
+END
+    return $result;
+}
+
+sub authform_kerberos{  
+    my %in = (
+              formname => 'document.cu',
+              kerb_def_dom => 'MSU.EDU',
+              @_,
+              );
+    my $result='';
+    $result.=<<"END";
+<input type="radio" name="login" value="krb" 
+       onclick="javascript:changed_radio('krb',$in{'formname'});"
+       onchange="javascript:changed_radio('krb',$in{'formname'});">
+Kerberos authenticated with domain
+<input type="text" size="10" name="krbarg" value=""
+       onchange="javascript:changed_text('krb',$in{'formname'});">
+END
+    return $result;
+}
+
+sub authform_internal{  
+    my %args = (
+                formname => 'document.cu',
+                kerb_def_dom => 'MSU.EDU',
+                @_,
+                );
+    my $result='';
+    $result.=<<"END";
+<input type="radio" name="login" value="int"
+       onchange="javascript:changed_radio('int',$args{'formname'});"
+       onclick="javascript:changed_radio('int',$args{'formname'});">
+Internally authenticated (with initial password 
+<input type="text" size="10" name="intarg" value=""
+       onchange="javascript:changed_text('int',$args{'formname'});">
+END
+    return $result;
+}
+
+sub authform_local{  
+    my %in = (
+              formname => 'document.cu',
+              kerb_def_dom => 'MSU.EDU',
+              @_,
+              );
+    my $result='';
+    $result.=<<"END";
+<input type="radio" name="login" value="loc"
+       onchange="javascript:changed_radio('loc',$in{'formname'});"
+       onclick="javascript:changed_radio('loc',$in{'formname'});"> 
+Local Authentication with argument
+<input type="text" size="10" name="locarg" value=""
+       onchange="javascript:changed_text('loc',$in{'formname'});">
+END
+    return $result;
+}
+
+sub authform_filesystem{  
+    my %in = (
+              formname => 'document.cu',
+              kerb_def_dom => 'MSU.EDU',
+              @_,
+              );
+    my $result='';
+    $result.=<<"END";
+<input type="radio" name="login" value="fsys" 
+       onchange="javascript:changed_radio('fsys',$in{'formname'});"
+       onclick="javascript:changed_radio('fsys',$in{'formname'});"> 
+Filesystem authenticated (with initial password 
+<input type="text" size="10" name="fsysarg" value=""
+       onchange="javascript:changed_text('fsys',$in{'formname'});">
+END
+    return $result;
+}
+
+###############################################################
+##   End Authentication changing form generation functions   ##
+###############################################################
+
+
 
 # ---------------------------------------------------------- Is this a keyword?
 
@@ -566,7 +749,7 @@
 	$r->print('<tr><td>'.$display.'</td>');
 
 	$r->print('<td><select name=f'.$i.
-		  ' onChange="flip(this.form,'.$i.');">');
+		  ' onchange="javascript:flip(this.form,'.$i.');">');
 	$r->print('<option value="none"></option>');
 	foreach (sort({$a <=> $b} keys(%sone))) {
 	    $r->print('<option value="'.$_.'">Column '.($_+1).'</option>');
@@ -595,7 +778,7 @@
 
     foreach (sort keys %sone) {
 	$r->print('<tr><td><select name=f'.$i.
-		  ' onChange="flip(this.form,'.$i.');">');
+		  ' onchange="javascript:flip(this.form,'.$i.');">');
 	foreach (@$d) {
 	    my ($value,$display)=@{ $_ };
 	    $r->print('<option value='.$value.'>'.$display.'</option>');
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.27 loncom/interface/londropadd.pm:1.28
--- loncom/interface/londropadd.pm:1.27	Wed Apr 17 09:55:35 2002
+++ loncom/interface/londropadd.pm	Mon Apr 22 11:26:46 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.27 2002/04/17 13:55:35 matthew Exp $
+# $Id: londropadd.pm,v 1.28 2002/04/22 15:26:46 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -146,7 +146,7 @@
 <input type="hidden" name="upfile_associate" 
                                        value="$ENV{'form.upfile_associate'}" />
 <hr />
-<script>
+<script type="text/javascript" language="Javascript">
 $javascript
 $javascript_validations
 </script>
@@ -155,36 +155,45 @@
 
 sub javascript_validations {
     my ($krbdefdom)=@_;
+    my %param = ( formname => 'studentform',
+                  kerb_def_dom => $krbdefdom );
+    my $authheader = &Apache::loncommon::authform_header(%param);
     return (<<ENDPICK);
 function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec) {
     var foundatype=0;
     var message='';
     if (founduname==0) {
-	alert('You need to specify at least the username field');
+	alert('You need to specify the username field');
         return;
     }
-    if (vf.login[0].checked) {
-	foundatype=1;
-        if (vf.krbdom.value=='') {
-	    alert('You need to specify the Kerberos domain');
-            return;
-        }
+    if (vf.login.value == null) {
+        // They did not check any of the login radiobuttons.
+        alert('You must choose an authentication type');
+        return;
     }
-    if (vf.login[1].checked) {
-	foundatype=1;
-        if ((vf.intpwd.value=='') && (foundpwd==0)) {
-	    alert('You need to specify the initial password');
+    foundatype=1;
+    if (vf.login.argfield.value == '') {
+        var alertmsg = '';
+        switch (vf.login.value) {
+            case 'krb': 
+                alertmsg = 'You need to specify the Kerberos domain';
+                break;
+            case 'loc':
+            case 'fsys':
+                alertmsg = 'You need to specify the initial password';
+                break;
+            case 'fsys':
+                alertmsg = '';
+                break;
+            default: 
+                alertmsg = '';
+        }
+        if (alertmsg != '') {
+            alert(alertmsg);
             return;
         }
     }
-    if (vf.login[2].checked) {
-	foundatype=1;
-	//An argument is not required
-    }
-    if (foundatype==0) {
-	alert('You need to set the login type');
-        return;
-    }
+
     if (foundname==0) { message='No name fields specified. '; }
     if (foundid==0) { message+='No ID or student number field specified. '; }
     if (foundsec==0) { message+='No section or group field specified. '; }
@@ -212,49 +221,6 @@
     }
 }
 
-function setkrb(vf) {
-    if (vf.krbdom.value!='') {
-       clearpwd(vf);
-       vf.login[0].checked=true;
-       vf.krbdom.value=vf.krbdom.value.toUpperCase();
-       vf.intpwd.value='';
-       vf.locarg.value='';
-   }
-}
-
-function setint(vf) {
-    if (vf.intpwd.value!='') {
-       clearpwd(vf);
-       vf.login[1].checked=true;
-       vf.krbdom.value='';
-       vf.locarg.value='';
-   }
-}
-
-function setloc(vf) {
-    if (vf.locarg.value!='') {
-       vf.login[2].checked=true;
-       vf.krbdom.value='';
-       vf.intpwd.value='';
-   }
-}
-
-function clickkrb(vf) {
-    vf.krbdom.value='$krbdefdom';
-    clearpwd(vf);
-    vf.intpwd.value='';
-    vf.locarg.value='';
-}
-
-function clickint(vf) {
-    vf.krbdom.value='';
-    vf.locarg.value='';
-}
-
-function clickloc(vf) {
-    vf.krbdom.value='';
-    vf.intpwd.value='';
-}
 
     function pclose() {
         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
@@ -283,7 +249,9 @@
         pclose();
     }
 
+$authheader
 ENDPICK
+
 }
 
 sub phase_two_javascript_forward_associate {
@@ -335,9 +303,10 @@
       }
    }
    if (nw==9) {
-       vf.login[1].checked=true;
-       vf.intpwd.value='';
-       vf.krbdom.value='';
+       changed_radio('int',document.studentform);
+       set_auth_radio_buttons('int',document.studentform);
+       vf.intarg.value='';
+       vf.krbarg.value='';
        vf.locarg.value='';
    }
 }
@@ -390,9 +359,10 @@
    }
    // intial password specified, pick internal authentication
    if (tf==8 && nw!=0) {
-       vf.login[1].checked=true;
-       vf.intpwd.value='';
-       vf.krbdom.value='';
+       changed_radio('int',document.studentform);
+       set_auth_radio_buttons('int',document.studentform);
+       vf.krbarg.value='';
+       vf.intarg.value='';
        vf.locarg.value='';
    }
 }
@@ -408,6 +378,10 @@
 
 sub phase_two_end {
     my ($r,$i,$keyfields,$defdom,$today,$halfyear)=@_;
+    my %param = ( formname => 'document.studentform');
+    my $krbform = &Apache::loncommon::authform_kerberos(%param);
+    my $intform = &Apache::loncommon::authform_internal(%param);
+    my $locform = &Apache::loncommon::authform_local(%param);
     $r->print(<<ENDPICK);
 </table>
 <input type=hidden name=nfields value=$i>
@@ -415,19 +389,13 @@
 <h3>Login Type</h3>
 <p>Note: this will not take effect if the user already exists</p>
 <p>
-<input type="radio" name="login" value="krb" onClick="clickkrb(this.form);" />
-Kerberos authenticated with domain
-<input type="text" size="10" name="krbdom" onChange="setkrb(this.form);" />
+$krbform
 </p>
 <p>
-<input type="radio" name="login" value="int" onClick="clickint(this.form);" />
-Internally authenticated (with initial password 
-<input type="text" size="10" name="intpwd" onChange="setint(this.form);" />)
+$intform
 </p>
 <p>
-<input type="radio" name="login" value="loc" onClick="clickloc(this.form);" />
-Local Authentication with argument
-<input type="text" size="10" name="locarg" onChange="setloc(this.form);" />
+$locform
 </p>
 <h3>LON-CAPA Domain for Students</h3>
 LON-CAPA domain: <input type=text size=10 value=$defdom name=lcdomain><p>
@@ -510,10 +478,10 @@
         my $genpwd='';
         if ($ENV{'form.login'} eq 'krb') {
            $amode='krb4';
-           $genpwd=$ENV{'form.krbdom'};
+           $genpwd=$ENV{'form.krbarg'};
         } elsif ($ENV{'form.login'} eq 'int') {
            $amode='internal';
-           $genpwd=$ENV{'form.intpwd'};
+           $genpwd=$ENV{'form.intarg'};
         }  elsif ($ENV{'form.login'} eq 'loc') {
 	    $amode='localauth';
 	    $genpwd=$ENV{'form.locarg'};
@@ -546,8 +514,14 @@
     my $halfyear = $today+15552000;
     my $defdom=$r->dir_config('lonDefDomain');
     my $javascript_validations=&javascript_validations($krbdefdom);
+    # Set up authentication forms
+    my %param = ( formname => 'document.studentform');
+    my $krbform = &Apache::loncommon::authform_kerberos(%param);
+    my $intform = &Apache::loncommon::authform_internal(%param);
+    my $locform = &Apache::loncommon::authform_local(%param);
+    # Print it all out
     $r->print(<<ENDSENROLL);
-<script>
+<script type="text/javascript" language="Javascript">
 function verify(vf) {
     var founduname=0;
     var foundpwd=0;
@@ -598,17 +572,11 @@
 <p>Domain:   <input type="text" name="cdomain" size="10" value="$defdom"></p>
 <p>Note: login settings below  will not take effect if the user already exists
 </p><p>
-<input type="radio" name="login" value="krb" onClick="clickkrb(this.form);">
-Kerberos authenticated with domain 
-<input type="text" name="krbdom" size="10"  onChange="setkrb(this.form);">
+$krbform
 </p><p>
-<input type="radio" name="login"  value="int" onClick="clickint(this.form);"> 
-Internally authenticated (with initial password 
-<input type="text"  name="intpwd" size="10" onChange="setint(this.form);">)
+$intform
 </p><p>
-<input type="radio" name="login" value="loc" onClick="clickloc(this.form);" />
-Local Authentication with argument
-<input type="text" name="locarg" size="10"  onChange="setloc(this.form);" />
+$locform
 </p><p>
 <h3>Starting and Ending Dates</h3>
 <input type="hidden" value='' name="pres_value">
@@ -747,11 +715,11 @@
     my $genpwd = '';
     if ($ENV{'form.login'} eq 'krb') {
         $amode='krb4';
-        $genpwd=$ENV{'form.krbdom'};
+        $genpwd=$ENV{'form.krbarg'};
     } elsif ($ENV{'form.login'} eq 'int') {
         $amode='internal';
-        if ((defined($ENV{'form.intpwd'})) && ($ENV{'form.intpwd'})) {
-            $genpwd=$ENV{'form.intpwd'};
+        if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) {
+            $genpwd=$ENV{'form.intarg'};
         }
     } elsif ($ENV{'form.login'} eq 'loc') {
         $amode='localauth';
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.30 loncom/interface/loncreateuser.pm:1.31
--- loncom/interface/loncreateuser.pm:1.30	Thu Apr 18 16:16:43 2002
+++ loncom/interface/loncreateuser.pm	Mon Apr 22 11:26:46 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.30 2002/04/18 20:16:43 matthew Exp $
+# $Id: loncreateuser.pm,v 1.31 2002/04/22 15:26:46 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -47,7 +47,7 @@
 # 11/12,11/13,11/15 Scott Harrison
 # 02/11/02 Matthew Hall
 #
-# $Id: loncreateuser.pm,v 1.30 2002/04/18 20:16:43 matthew Exp $
+# $Id: loncreateuser.pm,v 1.31 2002/04/22 15:26:46 matthew Exp $
 ###
 
 package Apache::loncreateuser;
@@ -68,116 +68,16 @@
     $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
     my $krbdefdom=$1;
     $krbdefdom=~tr/a-z/A-Z/;
-    $authformnop=(<<END);
-<p>
-<input type="radio" name="login" value="nochange" checked="checked"
-       onclick="changed_radio('nochange',document.cu);">
-Do not change login data
-</p>
-END
-    $authformkrb=(<<END);
-<p>
-<input type="radio" name="login" value="krb" 
-       onclick="changed_radio('krb',document.cu);">
-Kerberos authenticated with domain
-<input type="text" size="10" name="krbarg" 
-       onclick="changed_text('krb',document.cu);"
-       onchange="changed_text('krb',document.cu);">
-</p>
-END
-    $authformint=(<<END);
-<p>
-<input type="radio" name="login" value="int" 
-       onclick="changed_radio('int',document.cu);"> 
-Internally authenticated (with initial password 
-<input type="text" size="10" name="intarg" 
-       onclick="changed_text('int',document.cu);"
-       onchange="changed_text('int',document.cu);">
-</p>
-END
-    $authformfsys=(<<END);
-<p>
-<input type="radio" name="login" value="fsys" 
-       onclick="changed_radio('fsys',document.cu);"> 
-Filesystem authenticated (with initial password 
-<input type="text" size="10" name="fsysarg"
-       onclick="changed_text('fsys',document.cu);"
-       onchange="changed_text('fsys',document.cu);">
-</p>
-END
-    $authformloc=(<<END);
-<p>
-<input type="radio" name="login" value="loc"
-       onclick="changed_radio('loc',document.cu);"> 
-Local Authentication with argument
-<input type="text" size="10" name="locarg" 
-       onclick="changed_text('loc',document.cu);"
-       onchange="changed_text('loc',document.cu);">
-</p>
-END
-    $loginscript=(<<ENDLOGINSCRIPT);
-<script>
-
-var authvalues = new Object();
-authvalues.names = new Array('krbarg','intarg','fsysarg','locarg');
-authvalues.defaults = new Array('MSU.EDU','','','');
-
-function changed_radio(choice,currentform) {
-    var choicearg = choice + 'arg';
-    if (currentform.elements[choicearg].value == '') {
-        clear(currentform,authvalues.names);
-        for (var i=0; i<authvalues.names.length; i++) {
-            if (authvalues.names[i] == choicearg) {
-                currentform.elements[choicearg].value = authvalues.defaults[i];
-            }
-        }
-    }
-}
-
-function changed_text(choice,currentform) {
-    var choicearg = choice + 'arg';
-    if (currentform.elements[choicearg].value !='') {
-        // clear the other values
-        var keep = currentform.elements[choicearg].value;
-        clear(currentform,authvalues.names);
-        currentform.elements[choicearg].value = keep;
-        // validate our value
-        if (choice == 'krb') {
-            currentform.elements[choicearg].value = keep.toUpperCase();
-        }
-        // check the appropriate checkbox
-        set_checked('login',choice,currentform);
-    } 
-}
-
-function clear(currentform,names) {
-    for (var i=0; i< currentform.elements.length; i++) {
-        for (var j = 0; j< names.length; j++) {
-            if (currentform.elements[i].name == names[j]) {
-                currentform.elements[i].value = '';
-            }
-        }
-    }
-}
-
-function set_checked(name,choice,currentform) {
-    for (var i=0; i< currentform.elements.length; i++) {
-        if (currentform.elements[i].name == name) {
-            if (currentform.elements[i].value == choice) {
-                currentform.elements[i].checked =true;
-            }
-        }
-    }
-}
-
-</script>
-ENDLOGINSCRIPT
-    $generalrule=<<END;
-<p>
-<i>As a general rule, only authors or co-authors should be filesystem
-authenticated (which allows access to the server filesystem).</i>
-</p>
-END
+    my %param = ( formname => 'document.cu',
+                  kerb_def_dom => $krbdefdom 
+                  );
+    $loginscript  = &Apache::loncommon::authform_header(%param);
+    $generalrule  = &Apache::loncommon::authform_authorwarning(%param);
+    $authformnop  = &Apache::loncommon::authform_nochange(%param);
+    $authformkrb  = &Apache::loncommon::authform_kerberos(%param);
+    $authformint  = &Apache::loncommon::authform_internal(%param);
+    $authformfsys = &Apache::loncommon::authform_filesystem(%param);
+    $authformloc  = &Apache::loncommon::authform_local(%param);
 }
 
 # =================================================================== Phase one
@@ -212,6 +112,10 @@
     $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
     my $krbdefdom=$1;
     $krbdefdom=~tr/a-z/A-Z/;
+    my %param = ( formname => 'document.cu',
+                  kerb_def_dom => $krbdefdom 
+                  );
+    $loginscript  = &Apache::loncommon::authform_header(%param);
 
     my $defdom=$ENV{'user.domain'};
 
@@ -221,7 +125,7 @@
 <html>
 <head>
 <title>The LearningOnline Network with CAPA</title>
-<script>
+<script type="text/javascript" language="Javascript">
 
     function pclose() {
         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
@@ -283,7 +187,9 @@
 <h1>Create New User</h1>
 $forminfo
 <h2>New user "$ccuname" in domain $ccdomain</h2>
+<script type="text/javascript" language="Javascript">
 $loginscript
+</script>
 <input type='hidden' name='makeuser' value='1' />
 <h3>Personal Data</h3>
 <p>
@@ -301,11 +207,11 @@
 Home Server: <select name="hserver" size="1"> $home_server_list </select>
 <hr />
 <h3>Login Data</h3>
-$generalrule
-$authformkrb
-$authformint
-$authformfsys
-$authformloc
+<p>$generalrule </p>
+<p>$authformkrb </p>
+<p>$authformint </p>
+<p>$authformfsys</p>
+<p>$authformloc </p>
 ENDNEWUSER
     } else { # user already exists
 	$r->print(<<ENDCHANGEUSER);
@@ -410,7 +316,10 @@
 	if ($currentauth=~/^krb4:/) {
 	    $currentauth=~/^krb4:(.*)/;
 	    my $krbdefdom2=$1;
-	    $loginscript=~s/vf\.krbdom\.value='.*?';/vf.krbdom.value='$krbdefdom2';/;
+            my %param = ( formname => 'document.cu',
+                          kerb_def_dom => $krbdefdom 
+                          );
+            $loginscript  = &Apache::loncommon::authform_header(%param);
 	}
 	# Check for a bad authentication type
         unless ($currentauth=~/^krb4:/ or
@@ -421,23 +330,27 @@
 	    if (&Apache::lonnet::allowed('mau',$ENV{'user.domain'})) {
 		$r->print(<<ENDBADAUTH);
 <hr />
+<script type="text/javascript" language="Javascript">
 $loginscript
+</script>
 <font color='#ff0000'>ERROR:</font>
 This user has an unrecognized authentication scheme ($currentauth).
 Please specify login data below.
 <h3>Login Data</h3>
-$generalrule
-$authformkrb
-$authformint
-$authformfsys
-$authformloc
+<p>$generalrule</p>
+<p>$authformkrb</p>
+<p>$authformint</p>
+<p>$authformfsys</p>
+<p>$authformloc</p>
 ENDBADAUTH
             } else { 
                 # This user is not allowed to modify the users 
                 # authentication scheme, so just notify them of the problem
 		$r->print(<<ENDBADAUTH);
 <hr />
+<script type="text/javascript" language="Javascript">
 $loginscript
+</script>
 <font color="#ff0000"> ERROR: </font>
 This user has an unrecognized authentication scheme ($currentauth).
 Please alert a domain coordinator of this situation.
@@ -449,40 +362,23 @@
 	    my $authform_other='';
 	    if ($currentauth=~/^krb4:/) {
 		$authformcurrent=$authformkrb;
-		$authform_other=$authformint.$authformfsys.$authformloc;
-		# embarrassing script hack here
-		$loginscript=~s/login\[3\]/login\[4\]/; # loc
-		$loginscript=~s/login\[2\]/login\[3\]/; # fsys
-		$loginscript=~s/login\[1\]/login\[2\]/; # int
-		$loginscript=~s/login\[0\]/login\[1\]/; # krb4
+		$authform_other="<p>$authformint</p>\n".
+                    "<p>$authformfsys</p><p>$authformloc</p>";
 	    }
 	    elsif ($currentauth=~/^internal:/) {
 		$authformcurrent=$authformint;
-		$authform_other=$authformkrb.$authformfsys.$authformloc;
-		# embarrassing script hack here
-		$loginscript=~s/login\[3\]/login\[4\]/; # loc
-		$loginscript=~s/login\[2\]/login\[3\]/; # fsys
-		$loginscript=~s/login\[1\]/login\[1\]/; # int
-		$loginscript=~s/login\[0\]/login\[2\]/; # krb4
+		$authform_other="<p>$authformkrb</p>".
+                    "<p>$authformfsys</p><p>$authformloc</p>";
 	    }
 	    elsif ($currentauth=~/^unix:/) {
 		$authformcurrent=$authformfsys;
-		$authform_other=$authformkrb.$authformint.$authformloc;
-		# embarrassing script hack here
-		$loginscript=~s/login\[3\]/login\[4\]/; # loc
-		$loginscript=~s/login\[1\]/login\[3\]/; # int
-		$loginscript=~s/login\[2\]/login\[1\]/; # fsys
-		$loginscript=~s/login\[0\]/login\[2\]/; # krb4
+		$authform_other="<p>$authformkrb</p>".
+                    "<p>$authformint</p><p>$authformloc;</p>";
 	    }
 	    elsif ($currentauth=~/^localauth:/) {
 		$authformcurrent=$authformloc;
-		$authform_other=$authformkrb.$authformint.$authformfsys;
-		# embarrassing script hack here
-		$loginscript=~s/login\[3\]/login\[loc\]/; # loc
-		$loginscript=~s/login\[2\]/login\[4\]/; # fsys
-		$loginscript=~s/login\[1\]/login\[3\]/; # int
-		$loginscript=~s/login\[0\]/login\[2\]/; # krb4
-		$loginscript=~s/login\[loc\]/login\[1\]/; # loc
+		$authform_other="<p>$authformkrb</p>".
+                    "<p>$authformint</p><p>$authformfsys</p>";
 	    }
 	    $authformcurrent=<<ENDCURRENTAUTH;
 <table border='1'>
@@ -498,11 +394,13 @@
 		# Current user has login modification privileges
 		$r->print(<<ENDOTHERAUTHS);
 <hr />
+<script type="text/javascript" language="Javascript">
 $loginscript
+</script>
 <h3>Change Current Login Data</h3>
-$generalrule
-$authformnop
-$authformcurrent
+<p>$generalrule</p>
+<p>$authformnop</p>
+<p>$authformcurrent</p>
 <h3>Enter New Login Data</h3>
 $authform_other
 ENDOTHERAUTHS
@@ -685,7 +583,7 @@
 	# Only allow authentification modification if the person has authority
 	if (&Apache::lonnet::allowed('mau',$ENV{'user.domain'})) {
 	    $r->print('Modifying authentication: '.
-		  &Apache::lonnet::modifyuserauth(
+                      &Apache::lonnet::modifyuserauth(
 		       $ENV{'form.ccdomain'},$ENV{'form.ccuname'},
                        $amode,$genpwd));
             $r->print('<br>Home server: '.&Apache::lonnet::homeserver

--matthew1019489206--