[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface loncreateuser.pm

raeburn raeburn at source.lon-capa.org
Tue Aug 27 10:45:05 EDT 2019


raeburn		Tue Aug 27 14:45:05 2019 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	loncreateuser.pm 
  Log:
  - For 2.11
    Backport 1.451, 1.452
  
  
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.406.2.16 loncom/interface/loncreateuser.pm:1.406.2.17
--- loncom/interface/loncreateuser.pm:1.406.2.16	Tue Jul 30 13:55:16 2019
+++ loncom/interface/loncreateuser.pm	Tue Aug 27 14:45:04 2019
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.406.2.16 2019/07/30 13:55:16 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.406.2.17 2019/08/27 14:45:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1486,7 +1486,7 @@
              ($env{'request.role.domain'} eq $ccdomain)) {
             $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);
         }
-        $user_text{'auth'} =  &user_authentication($ccuname,$ccdomain,$formname);
+        $user_text{'auth'} =  &user_authentication($ccuname,$ccdomain,$formname,$crstype,$permission);
         if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
             (&Apache::lonnet::allowed('mut',$ccdomain)) ||
             (&Apache::lonnet::allowed('udp',$ccdomain))) {
@@ -2164,7 +2164,7 @@
 }
 
 sub user_authentication {
-    my ($ccuname,$ccdomain,$formname) = @_;
+    my ($ccuname,$ccdomain,$formname,$crstype,$permission) = @_;
     my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
     my $outcome;
     my %lt=&Apache::lonlocal::texthash(
@@ -2236,6 +2236,43 @@
             }
             $outcome .= &Apache::loncommon::end_data_table();
         } else {
+            if (($currentauth =~ /^internal:/) &&
+                (&Apache::lonuserutils::can_change_internalpass($ccuname,$ccdomain,$crstype,$permission))) {
+                $outcome = <<"ENDJS";
+<script type="text/javascript">
+// <![CDATA[
+function togglePwd(form) {
+    if (form.newintpwd.length) {
+        if (document.getElementById('LC_ownersetpwd')) {
+            for (var i=0; i<form.newintpwd.length; i++) {
+                if (form.newintpwd[i].checked) {
+                    if (form.newintpwd[i].value == 1) {
+                        document.getElementById('LC_ownersetpwd').style.display = 'inline-block';
+                    } else {
+                        document.getElementById('LC_ownersetpwd').style.display = 'none';
+                    }
+                }
+            }
+        }
+    }
+}
+// ]]>
+</script>
+ENDJS
+
+                $outcome .= '<h3>'.$lt{'ld'}.'</h3>'.
+                            &Apache::loncommon::start_data_table().
+                            &Apache::loncommon::start_data_table_row().
+                            '<td>'.&mt('Internally authenticated').'<br />'.&mt("Change user's password?").
+                            '<label><input type="radio" name="newintpwd" value="0" checked="checked" onclick="togglePwd(this.form);" />'.
+                            &mt('No').'</label>'.(' 'x2).
+                            '<label><input type="radio" name="newintpwd" value="1" onclick="togglePwd(this.form);" />'.&mt('Yes').'</label>'.
+                            '<div id="LC_ownersetpwd" style="display:none">'.
+                            '  '.&mt('Password').' <input type="password" size="15" name="intarg" value="" />'.
+                            '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.intarg.type='."'text'".' } else { this.form.intarg.type='."'password'".' }" />'.&mt('Visible input').'</label></div></td>'.
+                            &Apache::loncommon::end_data_table_row().
+                            &Apache::loncommon::end_data_table();
+            }
             if (&Apache::lonnet::allowed('udp',$ccdomain)) {
                 # Current user has rights to view domain preferences for user's domain
                 my $result;
@@ -2670,7 +2707,7 @@
 
 # ================================================================= Phase Three
 sub update_user_data {
-    my ($r,$context,$crstype,$brcrum,$showcredits) = @_; 
+    my ($r,$context,$crstype,$brcrum,$showcredits,$permission) = @_; 
     my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
                                           $env{'form.ccdomain'});
     # Error messages
@@ -2955,8 +2992,15 @@
 		  ($env{'form.ccuname'},$env{'form.ccdomain'}));
 	} else {
 	    # Okay, this is a non-fatal error.
-	    $r->print($error.&mt('You do not have the authority to modify this users authentication information.').$end);    
+	    $r->print($error.&mt('You do not have privileges to modify the authentication configuration for this user.').$end);    
 	}
+    } elsif (($env{'form.intarg'} ne '') &&
+             (&Apache::lonnet::queryauthenticate($env{'form.ccuname'},$env{'form.ccdomain'}) =~ /^internal:/) &&
+             (&Apache::lonuserutils::can_change_internalpass($env{'form.ccuname'},$env{'form.ccdomain'},$crstype,$permission))) {
+        $r->print('Modifying authentication: '.
+                  &Apache::lonnet::modifyuserauth(
+                  $env{'form.ccdomain'},$env{'form.ccuname'},
+                  'internal',$env{'form.intarg'}));
     }
     $r->rflush(); # Finish display of header before time consuming actions start
     &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state);
@@ -4862,7 +4906,7 @@
                 &print_useraccesslogs_display($r,$ccuname,$ccdomain,$permission,$brcrum);
             }
         } elsif ($env{'form.phase'} eq 'update_user_data') {
-            &update_user_data($r,$context,$crstype,$brcrum,$showcredits);
+            &update_user_data($r,$context,$crstype,$brcrum,$showcredits,$permission);
         } else {
             &print_username_entry_form($r,$context,undef,$srch,undef,$crstype,
                                        $brcrum,$permission);




More information about the LON-CAPA-cvs mailing list