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

raeburn raeburn@source.lon-capa.org
Sat, 14 Mar 2009 02:04:22 -0000


This is a MIME encoded message

--raeburn1236996262
Content-Type: text/plain

raeburn		Sat Mar 14 02:04:22 2009 EDT

  Modified files:              
    /loncom/interface	createaccount.pm 
  Log:
  - Replace "button" form element with "submit" form element.
    - javascript traigger changed from "onclick" to "onsubmit".
  - Eliminate display of "Forgot password?" link in log-in box when log-in is reached from "New user" link on main log-in page.
  - Increase size of username and password input boxes in log-in box.
  - Replace custom data entry form by reusing loncreateuser::personal_data_display() for entry of user information for users requesting accounts with e-mail address as username.
  - Add udom form element to "server" form in login box, and modify javascript to synchronize server form's udom value with client form's value, so an institutional self-enroller's domain choice is not ignored.
  
  
--raeburn1236996262
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090314020422.txt"

Index: loncom/interface/createaccount.pm
diff -u loncom/interface/createaccount.pm:1.31 loncom/interface/createaccount.pm:1.32
--- loncom/interface/createaccount.pm:1.31	Thu Mar 12 14:13:34 2009
+++ loncom/interface/createaccount.pm	Sat Mar 14 02:04:22 2009
@@ -3,7 +3,7 @@
 # institutional log-in ID (institutional authentication required - localauth
 #  or kerberos) or an e-mail address.
 #
-# $Id: createaccount.pm,v 1.31 2009/03/12 14:13:34 bisitz Exp $
+# $Id: createaccount.pm,v 1.32 2009/03/14 02:04:22 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -313,9 +313,10 @@
 sub javascript_setforms {
     my ($now) =  @_;
     my $js = <<ENDSCRIPT;
- <script language="JavaScript">
+ <script type="text/javascript" language="JavaScript">
     function send() {
         this.document.server.elements.uname.value = this.document.client.elements.uname.value;
+        this.document.server.elements.udom.value = this.document.client.elements.udom.value;
         uextkey=this.document.client.elements.uextkey.value;
         lextkey=this.document.client.elements.lextkey.value;
         initkeys();
@@ -346,16 +347,16 @@
         var upasscheck = this.document.client.elements.upasscheck$now.value;
         if (upass == '') {
             alert("$nopass");
-            return;
+            return false;
         }
         if (upass == upasscheck) {
             this.document.client.elements.upasscheck$now.value='';
             send();
-            return;
+            return false;
         } else {
             alert("$mismatchpass");
-            return;
-        } 
+            return false;
+        }
     }
 </script>
 ENDSCRIPT
@@ -425,7 +426,9 @@
                 if ($courseid ne '') {
                     $output .= '<input type="hidden" name="courseid" value="'.$courseid.'"/>'."\n"; 
                 }
-                $output .= '<input type="submit" name="create_with_email" value="'. 
+                $output .=  &Apache::lonhtmlcommon::row_closure(1).
+                            &Apache::lonhtmlcommon::row_title().'<br />'.
+                            '<input type="submit" name="create_with_email" value="'. 
                             $submit_text.'" />'.
                             &Apache::lonhtmlcommon::row_closure(1).
                             &Apache::lonhtmlcommon::end_pick_box().'<br /><br />';
@@ -463,11 +466,11 @@
     my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount',
                                        $lonhost);
     $output = &serverform($logtoken,$lonhost,undef,$courseid,$context);
-    my $unameform = '<input type="text" name="uname" size="10" value="" />';
-    my $upassform = '<input type="password" name="upass'.$now.'" size="10" />';
-    $output .= '<form name="client" method="post" action="/adm/createaccount">'."\n".
-               &Apache::lonhtmlcommon::start_pick_box()."\n";
-    $output .= &Apache::lonhtmlcommon::row_title($titles{$context},
+    my $unameform = '<input type="text" name="uname" size="20" value="" />';
+    my $upassform = '<input type="password" name="upass'.$now.'" size="20" />';
+    $output .= '<form name="client" method="post" onsubmit="return(send());">'."\n".
+               &Apache::lonhtmlcommon::start_pick_box()."\n".
+               &Apache::lonhtmlcommon::row_title($titles{$context},
                                                  'LC_pick_box_title')."\n".
                $unameform."\n".
                &Apache::lonhtmlcommon::row_closure(1)."\n".
@@ -475,23 +478,27 @@
                                                 'LC_pick_box_title')."\n".
                $upassform;
     if ($context eq 'selfenroll') {
-        my $udomform =  '<input type="text" name="udom" size="10" value="'.
+        my $udomform = '<input type="text" name="udom" size="10" value="'.
                         $domain.'" />';
         $output .= &Apache::lonhtmlcommon::row_closure(1)."\n".
                    &Apache::lonhtmlcommon::row_title(&mt('Domain'),
                                                      'LC_pick_box_title')."\n".
                    $udomform."\n";
+    } else {
+        $output .= '<input type="hidden" name="udom" value="'.$domain.'" />';
     }
-
-    $output .= &Apache::lonhtmlcommon::row_closure(0).
+    $output .= &Apache::lonhtmlcommon::row_closure(1).
                &Apache::lonhtmlcommon::row_title().
-               '<input type="button" name="username_validation" value="'.
-               $submit_text.'" onclick="javascript:send()" />'."\n".
-               &Apache::lonhtmlcommon::row_closure(1)."\n".
-               &Apache::lonhtmlcommon::end_pick_box();
-    $output .= '<p>'.
-               '<a href="/adm/resetpw">'.&mt('Forgot password?').'</a>'.
-               '</p>'."\n";
+               '<br /><input type="submit" name="username_validation" value="'.
+               $submit_text.'" />'."\n";
+    if ($context eq 'selfenroll') {
+        $output .= '<br /><br /><table width="100%"><tr><td align="right">'.
+                   '<span class="LC_fontsize_medium">'.
+                   '<a href="/adm/resetpw">'.&mt('Forgot password?').'</a>'.
+                   '</span></td></tr></table>'."\n";
+    }
+    $output .= &Apache::lonhtmlcommon::row_closure(1)."\n".
+               &Apache::lonhtmlcommon::end_pick_box().'<br />'."\n";
     $output .= '<input type="hidden" name="lextkey" value="'.$lextkey.'">'."\n".
                '<input type="hidden" name="uextkey" value="'.$uextkey.'">'."\n".
                '</form>';
@@ -720,79 +727,65 @@
         my ($lextkey,$uextkey) = &getkeys($lkey,$ukey);
         my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount',
                                            $lonhost);
-        my @userinfo = ('firstname','middlename','lastname','generation','id',
-                        'permanentemail');
-        my %lt=&Apache::lonlocal::texthash(
-                    'pd'             => "Personal Data",
-                    'firstname'      => "First Name",
-                    'middlename'     => "Middle Name",
-                    'lastname'       => "Last Name",
-                    'generation'     => "Generation",
-                    'permanentemail' => "Permanent e-mail address",
-                    'id'             => "Student/Employee ID",
-                    'lg'             => "Login Data"
-        );
-        my %textboxsize = (
-                           firstname      => '15',
-                           middlename     => '15',
-                           lastname       => '15',
-                           generation     => '5',
-                           id             => '15',
-                          );
-        my $genhelp=&Apache::loncommon::help_open_topic('Generation');
-        $output .= '<div class="LC_left_float"><h3>'.$lt{'pd'}.'</h3>'.
-                  '<form name="server" method="post" target="_top" action="/adm/createaccount">'.
-                  &Apache::lonhtmlcommon::start_pick_box();
-        foreach my $item (@userinfo) {
-            my $rowtitle = $lt{$item};
-            if ($item eq 'generation') {
-                $rowtitle = $genhelp.$rowtitle;
-            }
-            $output .= &Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n";
-            if ($item eq 'permanentemail') {
-                $output .= $username;
-            } else {
-                $output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';
-            }
-            $output .= &Apache::lonhtmlcommon::row_closure(1);
+        my $formtag = '<form name="server" method="post" target="_top" action="/adm/createaccount">';
+        my ($datatable,$rowcount) =
+            &Apache::loncreateuser::personal_data_display($username,$domain,
+                                                          'email','selfcreate');
+        if ($rowcount) {
+            $output .= '<div class="LC_left_float">'.$formtag.$datatable;
+        } else {
+            $output .= $formtag;
         }
-        $output .= &Apache::lonhtmlcommon::end_pick_box();
         $output .= <<"ENDSERVERFORM";
    <input type="hidden" name="logtoken" value="$logtoken" />
    <input type="hidden" name="token" value="$mailtoken" />
    <input type="hidden" name="serverid" value="$lonhost" />
    <input type="hidden" name="uname" value="" />
    <input type="hidden" name="upass" value="" />
+   <input type="hidden" name="udom" value="" />
    <input type="hidden" name="phase" value="createaccount" />
-  </form></div>
+  </form>
 ENDSERVERFORM
+        if ($rowcount) {
+            $output .= '</div>'.
+                       '<div class="LC_left_float">';
+        }
         my $upassone = '<input type="password" name="upass'.$now.'" size="10" />';
         my $upasstwo = '<input type="password" name="upasscheck'.$now.'" size="10" />';
         my $submit_text = &mt('Create LON-CAPA account');
-        $output .= '<div class="LC_left_float"><h3>'.$lt{'lg'}.'</h3>'."\n".
-                   '<form name="client" method="post" />'."\n".
+        $output .= '<h3>'.&mt('Login Data').'</h3>'."\n".
+                   '<form name="client" method="post" '.
+                   'onsubmit="return checkpass();">'."\n".
                    &Apache::lonhtmlcommon::start_pick_box()."\n".
                    &Apache::lonhtmlcommon::row_title(&mt('Username'),
-                                                    'LC_pick_box_title')."\n".
+                                                     'LC_pick_box_title',
+                                                     'LC_oddrow_value')."\n".
                    $username."\n".
                    &Apache::lonhtmlcommon::row_closure(1)."\n".
                    &Apache::lonhtmlcommon::row_title(&mt('Password'),
-                                                    'LC_pick_box_title')."\n".
+                                                    'LC_pick_box_title',
+                                                    'LC_oddrow_value')."\n".
                    $upassone."\n".
                    &Apache::lonhtmlcommon::row_closure(1)."\n".
                    &Apache::lonhtmlcommon::row_title(&mt('Confirm password'),
-                                                'LC_pick_box_title')."\n".
-                   $upasstwo."\n".
+                                                     'LC_pick_box_title',
+                                                     'LC_oddrow_value')."\n".
+                   $upasstwo.
+                   &Apache::lonhtmlcommon::row_closure(1)."\n".
+                   &Apache::lonhtmlcommon::row_title()."\n".
+                   '<br /><input type="submit" name="createaccount" value="'.
+                   $submit_text.'" />'.
                    &Apache::lonhtmlcommon::row_closure(1)."\n".
                    &Apache::lonhtmlcommon::end_pick_box()."\n".
-                   '<input type="hidden" name="uname" value="'.$username.'">'."\n".
-                   '<input type="hidden" name="lextkey" value="'.$lextkey.'">'."\n".
-                   '<input type="hidden" name="uextkey" value="'.$uextkey.'">'."\n".
-                   '</form></div>'."\n".
-                   '<div class="LC_clear_float_footer"><br /><br />'."\n".
-                   '<form name="buttonform">'."\n".
-                   '<input type="button" name="createaccount" value="'.
-                   $submit_text.'" onclick="javascript:checkpass();" /></form></div>';
+                   '<input type="hidden" name="uname" value="'.$username.'" />'."\n".
+                   '<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>';
+        if ($rowcount) {
+            $output .= '</div>'."\n".
+                       '<div class="LC_clear_float_footer"></div>'."\n";
+        }
     } else {
         $output = &mt('Could not load javascript file [_1]','<tt>londes.js</tt>');
     }
@@ -1193,6 +1186,7 @@
    <input type="hidden" name="serverid" value="$lonhost" />
    <input type="hidden" name="uname" value="" />
    <input type="hidden" name="upass" value="" />
+   <input type="hidden" name="udom" value="" />
    <input type="hidden" name="phase" value="$phase" />
    <input type="hidden" name="courseid" value="$courseid" />
    $catalog_elements

--raeburn1236996262--