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

raeburn raeburn at source.lon-capa.org
Sun Dec 12 17:10:45 EST 2021


raeburn		Sun Dec 12 22:10:45 2021 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	createaccount.pm 
  Log:
  - For 2.11
    Backport 1.83, 1.84, 1.85
  
  
Index: loncom/interface/createaccount.pm
diff -u loncom/interface/createaccount.pm:1.72.4.6 loncom/interface/createaccount.pm:1.72.4.7
--- loncom/interface/createaccount.pm:1.72.4.6	Mon Jan  4 04:42:13 2021
+++ loncom/interface/createaccount.pm	Sun Dec 12 22:10:45 2021
@@ -4,7 +4,7 @@
 # kerberos, or SSO) or an e-mail address. Requests to use an e-mail address as
 # username may be processed automatically, or may be queued for approval.
 #
-# $Id: createaccount.pm,v 1.72.4.6 2021/01/04 04:42:13 raeburn Exp $
+# $Id: createaccount.pm,v 1.72.4.7 2021/12/12 22:10:45 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -438,7 +438,9 @@
                 }
                 $setuserinfo .= '                    server.elements.'.$key.'.value=client.elements.'.$key.'.value;'."\n";
             }
-            $setuserinfo .= '                    server.elements.type.value=client.elements.type.value;'."\n"; 
+            if ($usertype ne '') {
+                $setuserinfo .= '                    server.elements.type.value=client.elements.type.value;'."\n";
+            }
         }
         if ($captcha eq 'original') {
             $setuserinfo .= '                    server.elements.code.value=client.elements.code.value;'."\n".
@@ -1181,42 +1183,54 @@
         my ($lextkey,$uextkey) = &getkeys($lkey,$ukey);
         my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount',
                                            $lonhost);
-        $output .=
+        my $showsubmit = 1;
+        my $serverform =
             '<form name="createaccount" method="post" target="_top" action="/adm/createaccount">';
         if ($courseid ne '') {
-            $output .= '<input type="hidden" name="courseid" value="'.$courseid.'"/>'."\n";
+            $serverform .= '<input type="hidden" name="courseid" value="'.$courseid.'"/>'."\n";
         }
         if (ref($emailusername) eq 'HASH') {
             if (ref($emailusername->{$usertype}) eq 'HASH') {
                 foreach my $field (sort(keys(%{$emailusername->{$usertype}}))) {
-                    $output .= '<input type="hidden" name="'.$field.'" value="" />'."\n";
+                    $serverform .= '<input type="hidden" name="'.$field.'" value="" />'."\n";
                 }
             }
         }
         if ($captcha eq 'original') {
-            $output .= '
+            $serverform .= '
    <input type="hidden" name="crypt" value="" />
    <input type="hidden" name="code" value="" />
 ';
         } elsif ($captcha eq 'recaptcha') {
             if ($recaptchaversion eq '2') {
-                $output .= "$captchaform\n";
+                $serverform .= &Apache::lonhtmlcommon::start_pick_box().
+                               &Apache::lonhtmlcommon::row_title(&mt('Validation').'<b>*</b>',
+                                                                 'LC_pick_box_title',
+                                                                 'LC_oddrow_value')."\n".
+                                                                 $captchaform.
+                               &Apache::lonhtmlcommon::row_closure(1)."\n".
+                               &Apache::lonhtmlcommon::row_title()."\n".
+                               '<br /><input type="button" name="createaccount" value="'.
+                               &mt('Create account').'" onclick="checkpass('."'createaccount','newemail'".')" />'.
+                               &Apache::lonhtmlcommon::row_closure(1)."\n".
+                               &Apache::lonhtmlcommon::end_pick_box();
                 undef($captchaform);
+                undef($showsubmit);
             } else {
-                $output .= '
+                $serverform .= '
    <input type="hidden" name="recaptcha_challenge_field" value="" />
    <input type="hidden" name="recaptcha_response_field" value="" />
 ';
             }
         }
         if ($usertype ne '') {
-            $output .= '<input type="hidden" name="type" value="'.
-                       &HTML::Entities::encode($usertype,'\'<>"&').'" />'."\n";
+            $serverform .= '<input type="hidden" name="type" value="'.
+                           &HTML::Entities::encode($usertype,'\'<>"&').'" />'."\n";
         }
         if ($usernameset eq 'free') {
-            $output .= '<input type="hidden" name="username" value="" />'."\n"; 
+            $serverform .= '<input type="hidden" name="username" value="" />'."\n"; 
         }
-        $output .= <<"ENDSERVERFORM";
+        $serverform .= <<"ENDSERVERFORM";
    <input type="hidden" name="logtoken" value="$logtoken" />
    <input type="hidden" name="serverid" value="$lonhost" />
    <input type="hidden" name="uname" value="" />
@@ -1228,25 +1242,33 @@
 ENDSERVERFORM
         my $beginclientform = '<form name="newemail" method="post" action="" '.
                               'onsubmit="return checkpass('."'createaccount','newemail'".');">'."\n";
-        my $endclientform = '<input type="hidden" name="udom" value="'.$domain.'" />'."\n".
-                            '<input type="hidden" name="lextkey" value="'.$lextkey.'" />'."\n".
-                            '<input type="hidden" name="uextkey" value="'.$uextkey.'" />'."\n".
-                            '</form>'."\n".
-                            '<p class="LC_info">'.&mt('Fields marked [_1]*[_2] are required.','<b>','</b>').'</p>';
+        my $endclientform;
+        unless ($showsubmit) {
+            if ($usertype ne '') {
+                $endclientform = '<input type="hidden" name="type" value="'.
+                                 &HTML::Entities::encode($usertype,'\'<>"&').'" />'."\n";
+            }
+        }
+        $endclientform .= '<input type="hidden" name="udom" value="'.$domain.'" />'."\n".
+                          '<input type="hidden" name="lextkey" value="'.$lextkey.'" />'."\n".
+                          '<input type="hidden" name="uextkey" value="'.$uextkey.'" />'."\n".
+                          '</form>'."\n";
         my ($datatable,$rowcount) =
             &Apache::loncreateuser::personal_data_display('',$domain,'email','selfcreate',
                                                           '','',$now,$captchaform,
                                                           $emailusername,$usertype,
-                                                          $usernameset,$condition,$excluded);
+                                                          $usernameset,$condition,$excluded,
+                                                          $showsubmit);
         if ($rowcount) {
-            $output .= '<div class="LC_left_float">'.$beginclientform.$datatable.$endclientform;
+            $output .= '<div class="LC_left_float">'.$beginclientform.$datatable.$endclientform.'</div>'."\n".
+                       '<div class="LC_clear_float_footer"></div>'."\n";
         } else {
             $output .= $beginclientform.$endclientform;
         }
-        if ($rowcount) {
-            $output .= '</div>'."\n".
-                       '<div class="LC_clear_float_footer"></div>'."\n";
-        }
+        $output .= $serverform.
+                   '<p class="LC_info">'.
+                   &mt('Fields marked [_1]*[_2] are required.','<b>','</b>').
+                   '</p>';
     } else {
         $output = &mt('Could not load javascript file [_1]','<tt>londes.js</tt>');
     }




More information about the LON-CAPA-cvs mailing list