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

raeburn raeburn@source.lon-capa.org
Sun, 14 Nov 2010 20:34:48 -0000


raeburn		Sun Nov 14 20:34:48 2010 EDT

  Modified files:              
    /loncom/interface	lonuserutils.pm 
  Log:
  - Bug 6368.
    - Don't allow association of column with initial password field
      unless internal auth can be assigned to new users.
    - No need to reset authentication type if column is identified as initial 
      password, if internal auth is the only authentication type user can set.
  
  
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.131 loncom/interface/lonuserutils.pm:1.132
--- loncom/interface/lonuserutils.pm:1.131	Sun Nov 14 20:29:34 2010
+++ loncom/interface/lonuserutils.pm	Sun Nov 14 20:34:47 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA user accounts
 #
-# $Id: lonuserutils.pm,v 1.131 2010/11/14 20:29:34 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.132 2010/11/14 20:34:47 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -589,28 +589,43 @@
 ###############################################################
 sub upload_manager_javascript_forward_associate {
     my ($can_assign) = @_;
-    my $auth_update;
+    my ($auth_update,$numbuttons,$argreset);
     if (ref($can_assign) eq 'HASH') {
-        if (keys(%{$can_assign}) > 1) {
+        if ($can_assign->{'krb4'} || $can_assign->{'krb5'}) {
+            $argreset .= "      vf.krbarg.value='';\n";
+            $numbuttons ++ ;
+        }
+        if ($can_assign->{'int'}) {
+            $argreset .= "      vf.intarg.value='';\n";
+            $numbuttons ++;
+        }
+        if ($can_assign->{'loc'}) {
+            $argreset .= "      vf.locarg.value='';\n";
+            $numbuttons ++;
+        }
+        if (!$can_assign->{'int'}) {
+            my $warning = &mt('You may not specify an initial password for each user, as this is only available when new users use LON-CAPA internal authentication.\n').
+                          &mt('Your current role does not have rights to create users with that authentication type.');
+            $auth_update = <<"END";
+   // Currently the initial password field is only supported for internal auth
+   // (see bug 6368).
+   if (nw==9) {
+       eval('vf.f'+tf+'.selectedIndex=0;')
+       alert('$warning');
+   }
+END
+        } elsif ($numbuttons > 1) {
             $auth_update = <<"END";
    // If we set the password, make the password form below correspond to
    // the new value.
    if (nw==9) {
       changed_radio('int',document.studentform);
       set_auth_radio_buttons('int',document.studentform);
+$argreset
+   }
+
 END
         }
-        if ($can_assign->{'krb4'} || $can_assign->{'krb5'}) {
-           $auth_update .= "      vf.krbarg.value='';\n";
-        }
-        if ($can_assign->{'int'}) {
-           $auth_update .= "      vf.intarg.value='';\n";
-        }
-        if ($can_assign->{'loc'}) {
-           $auth_update .= "      vf.locarg.value='';\n";
-        }
-        $auth_update .= "
-   }\n";
     }
 
     return(<<ENDPICK);
@@ -708,28 +723,44 @@
 ###############################################################
 sub upload_manager_javascript_reverse_associate {
     my ($can_assign) = @_;
-    my $auth_update; 
+    my ($auth_update,$numbuttons,$argreset);
     if (ref($can_assign) eq 'HASH') {
-        if (keys(%{$can_assign}) > 1) {
+        if ($can_assign->{'krb4'} || $can_assign->{'krb5'}) {
+            $argreset .= "      vf.krbarg.value='';\n";
+            $numbuttons ++ ;
+        }
+        if ($can_assign->{'int'}) {
+            $argreset .= "      vf.intarg.value='';\n";
+            $numbuttons ++;
+        }
+        if ($can_assign->{'loc'}) {
+            $argreset .= "      vf.locarg.value='';\n";
+            $numbuttons ++;
+        }
+        if (!$can_assign->{'int'}) {
+            my $warning = &mt('You may not specify an initial password, as this is only available when new users use LON-CAPA internal authentication.\n').
+                          &mt('Your current role does not have rights to create users with that authentication type.');
+            $auth_update = <<"END";
+   // Currently the initial password field is only supported for internal auth
+   // (see bug 6368).
+   if (tf==8 && nw!=0) {
+       eval('vf.f'+tf+'.selectedIndex=0;')
+       alert('$warning');
+   }
+END
+        } elsif ($numbuttons > 1) {
             $auth_update = <<"END";
    // initial password specified, pick internal authentication
    if (tf==8 && nw!=0) {
       changed_radio('int',document.studentform);
       set_auth_radio_buttons('int',document.studentform);
+$argreset
+   }
+
 END
         }
-        if ($can_assign->{'krb'}) {      
-           $auth_update .= "      vf.krbarg.value='';\n";
-        }
-        if ($can_assign->{'int'}) {
-           $auth_update .= "      vf.intarg.value='';\n";
-        }
-        if ($can_assign->{'loc'}) {
-           $auth_update .= "      vf.locarg.value='';\n";
-        }
-        $auth_update .= "
-   }\n";
     }
+
     return(<<ENDPICK);
 function verify(vf,sec_caller) {
     var founduname=0;