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

raeburn lon-capa-cvs@mail.lon-capa.org
Sat, 27 Dec 2003 23:55:10 -0000


raeburn		Sat Dec 27 18:55:10 2003 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  Modifications to &authform_header(), &authform_kerberos(), &authform_internal() and &authform_local() to support use of these functions by lonmodifycourse, where an authentication mechanism and authentication parameter may already exist (and the user wants to change it). 
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.164 loncom/interface/loncommon.pm:1.165
--- loncom/interface/loncommon.pm:1.164	Fri Dec 26 16:17:37 2003
+++ loncom/interface/loncommon.pm	Sat Dec 27 18:55:10 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.164 2003/12/26 21:17:37 www Exp $
+# $Id: loncommon.pm,v 1.165 2003/12/27 23:55:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1010,10 +1010,25 @@
         $Javascript_toUpperCase = "";
     }
 
+    my $radioval = "'nochange'";
+    my $argfield = 'null';
+    if ( grep/^mode$/,(keys %in) ) {
+        if ($in{'mode'} eq 'modifycourse')  {
+            if ( grep/^curr_authtype$/,(keys %in) ) {
+                $radioval = "'$in{'curr_authtype'}'";
+            }
+            if ( grep/^curr_autharg$/,(keys %in) ) {
+                unless ($in{'curr_autharg'} eq '') {
+                    $argfield = "'$in{'curr_autharg'}'";
+                }
+            }
+        }
+    }
+
     $result.=<<"END";
 var current = new Object();
-current.radiovalue = 'nochange';
-current.argfield = null;
+current.radiovalue = $radioval;
+current.argfield = $argfield;
 
 function changed_radio(choice,currentform) {
     var choicearg = choice + 'arg';
@@ -1100,20 +1115,32 @@
               kerb_def_auth => 'krb4',
               @_,
               );
-    my ($check4,$check5);
+    my ($check4,$check5,$krbarg);
     if ($in{'kerb_def_auth'} eq 'krb5') {
        $check5 = " checked=\"on\"";
     } else {
        $check4 = " checked=\"on\"";
     }
+    $krbarg = $in{'kerb_def_dom'};
+
+    my $krbcheck = "";
+    if ( grep/^curr_authtype$/,(keys %in) ) {
+        if ($in{'curr_authtype'} =~ m/^krb/) {
+            $krbcheck = " checked=\"on\"";
+            if ( grep/^curr_autharg$/,(keys %in) ) {
+                $krbarg = $in{'curr_autharg'};
+            }
+        }
+    }
+
     my $jscall = "javascript:changed_radio('krb',$in{'formname'});";
     my $result .= &mt
         ('[_1] Kerberos authenticated with domain [_2] '.
          '[_3] Version 4 [_4] Version 5',
          '<input type="radio" name="login" value="krb" '.
-             'onclick="'.$jscall.'" onchange="'.$jscall.'" />',
+             'onclick="'.$jscall.'" onchange="'.$jscall.'"'.$krbcheck.' />',
          '<input type="text" size="10" name="krbarg" '.
-             'value="'.$in{'kerb_def_dom'}.'" '.
+             'value="'.$krbarg.'" '.
              'onchange="'.$jscall.'" />',
          '<input type="radio" name="krbver" value="4" '.$check4.' />',
          '<input type="radio" name="krbver" value="5" '.$check5.' />');
@@ -1126,13 +1153,25 @@
                 kerb_def_dom => 'MSU.EDU',
                 @_,
                 );
+
+    my $intcheck = "";
+    my $intarg = 'value=""';
+    if ( grep/^curr_authtype$/,(keys %args) ) {
+        if ($args{'curr_authtype'} eq 'int') {
+            $intcheck = " checked=\"on\"";
+            if ( grep/^curr_autharg$/,(keys %args) ) {
+                $intarg = "value=\"$args{'curr_autharg'}\"";
+            }
+        }
+    }
+
     my $jscall = "javascript:changed_radio('int',$args{'formname'});";
     my $result.=&mt
         ('[_1] Internally authenticated (with initial password [_2])',
-         '<input type="radio" name="login" value="int" '.
-             'onchange="'.$jscall.'" onclick="'.$jscall.'" />',
-         '<input type="text" size="10" name="intarg" value="" '.
-             'onchange="'.$jscall.'" />');
+         '<input type="radio" name="login" value="int" '.$intcheck.
+             ' onchange="'.$jscall.'" onclick="'.$jscall.'" />',
+         '<input type="text" size="10" name="intarg" '.$intarg.
+             ' onchange="'.$jscall.'" />');
     return $result;
 }
 
@@ -1142,12 +1181,24 @@
               kerb_def_dom => 'MSU.EDU',
               @_,
               );
+
+    my $loccheck = "";
+    my $locarg = 'value=""';
+    if ( grep/^curr_authtype$/,(keys %in) ) {
+        if ($in{'curr_authtype'} eq 'loc') {
+            $loccheck = " checked=\"on\"";
+            if ( grep/^curr_autharg$/,(keys %in) ) {
+                $locarg = "value=\"$in{'curr_autharg'}\"";
+            }
+        }
+    }
+
     my $jscall = "javascript:changed_radio('loc',$in{'formname'});";
     my $result.=&mt('[_1] Local Authentication with argument [_2]',
-                    '<input type="radio" name="login" value="loc" '.
-                        'onchange="'.$jscall.'" onclick="'.$jscall.'" />',
-                    '<input type="text" size="10" name="locarg" value="" '.
-                        'onchange="'.$jscall.'" />');
+                    '<input type="radio" name="login" value="loc" '.$loccheck.
+                        ' onchange="'.$jscall.'" onclick="'.$jscall.'" />',
+                    '<input type="text" size="10" name="locarg" '.$locarg.
+                        ' onchange="'.$jscall.'" />');
     return $result;
 }