[LON-CAPA-cvs] cvs: loncom /interface createaccount.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Mon, 14 Jul 2008 08:26:59 -0000
This is a MIME encoded message
--raeburn1216024019
Content-Type: text/plain
raeburn Mon Jul 14 04:26:59 2008 EDT
Modified files:
/loncom/interface createaccount.pm
Log:
- move generation of log-in screen to &login_box().
- additional possible phase - selfenroll_login - when log-in box is to be generated for users wishing to self-enroll in a course, who are not logged in, and clicked "logg-in" link.
--raeburn1216024019
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080714042659.txt"
Index: loncom/interface/createaccount.pm
diff -u loncom/interface/createaccount.pm:1.19 loncom/interface/createaccount.pm:1.20
--- loncom/interface/createaccount.pm:1.19 Sun Jul 13 13:57:58 2008
+++ loncom/interface/createaccount.pm Mon Jul 14 04:26:57 2008
@@ -3,7 +3,7 @@
# institutional log-in ID (institutional authentication required - localauth
# or kerberos) or an e-mail address.
#
-# $Id: createaccount.pm,v 1.19 2008/07/13 17:57:58 raeburn Exp $
+# $Id: createaccount.pm,v 1.20 2008/07/14 08:26:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -87,16 +87,39 @@
$r->print($start_page."\n".'<h2>'.&mt('You are already logged in').'</h2>'.
'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]logout[_4].','<a href="/adm/roles">','</a>','<a href="/adm/logout">','</a>').
'</p><p><a href="/adm/loginproblems.html">'.&mt('Login problems?').'</a></p>'.$end_page);
- return OK;
+ return OK;
}
- $start_page =
- &Apache::loncommon::start_page('Create a user account in LON-CAPA','',
- {'no_inline_link' => 1,});
- if ($env{'form.phase'} eq 'username_activation') {
+
+ my $courseid;
+ if (defined($env{'form.courseid'})) {
+ $courseid = &validate_course($env{'form.courseid'});
+ }
+ if ($env{'form.phase'} eq 'selfenroll_login') {
if ($env{'form.udom'} ne '') {
$domain = $env{'form.udom'};
}
+ my ($result,$output) =
+ &username_validation($r,$env{'form.uname'},$domain,$domdesc,
+
+ $contact_name,$contact_email,$courseid,
+ $lonhost);
+ if ($result eq 'existingaccount') {
+ $r->print($output);
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ } else {
+ $start_page =
+ &Apache::loncommon::start_page('Self-enroll in a LON-CAPA course','',
+ {'no_inline_link' => 1,});
+ &print_header($r,$start_page);
+ $r->print($output.&Apache::loncommon::end_page());
+ return OK;
+ }
}
+
+ $start_page =
+ &Apache::loncommon::start_page('Create a user account in LON-CAPA','',
+ {'no_inline_link' => 1,});
my @cancreate;
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
if (ref($domconfig{'usercreation'}) eq 'HASH') {
@@ -120,11 +143,6 @@
return OK;
}
- my $courseid;
- if (defined($env{'form.courseid'})) {
- $courseid = &validate_course($env{'form.courseid'});
- }
-
if ($sso_username ne '') {
&print_header($r,$start_page);
my ($msg,$sso_logout);
@@ -325,31 +343,10 @@
my %domdefaults = &Apache::lonnet::get_domain_defaults($domain);
if ((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth')) {
$output = '<div class="LC_left_float"><h3>'.&mt('Create account with a username provided by this institution').'</h3>';
- $output .= &mt('If you already have a log-in ID at this institution,[_1] you may be able to use it for LON-CAPA.','<br />').'<br /><br />'.&mt('Type in your log-in ID and password to find out.').'<br /><br />';
- my ($lkey,$ukey) = &Apache::lonpreferences::des_keys();
- my ($lextkey,$uextkey) = &getkeys($lkey,$ukey);
- my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount',
- $lonhost);
- $output .= &serverform($logtoken,$lonhost,undef,$courseid);
- my $unameform = '<input type="text" name="uname" size="10" value="" />';
- my $upassform = '<input type="password" name="upass'.$now.'" size="10" />';
my $submit_text = &mt('Create LON-CAPA account');
- $output .= '<form name="client" method="post" action="/adm/createaccount">'."\n".
- &Apache::lonhtmlcommon::start_pick_box()."\n".
- &Apache::lonhtmlcommon::row_title(&mt('Log-in ID'),
- 'LC_pick_box_title')."\n".
- $unameform."\n".
- &Apache::lonhtmlcommon::row_closure(1)."\n".
- &Apache::lonhtmlcommon::row_title(&mt('Password'),
- 'LC_pick_box_title')."\n".
- $upassform."\n".'<br /><br />'."\n".
- '<input type="button" name="username_validation" value="'.
- $submit_text.'" onclick="javascript:send()" />'."\n".
- &Apache::lonhtmlcommon::row_closure(1)."\n".
- &Apache::lonhtmlcommon::end_pick_box().'<br /><br />'."\n".
- '<input type="hidden" name="lextkey" value="'.$lextkey.'">'."\n".
- '<input type="hidden" name="uextkey" value="'.$uextkey.'">'."\n".
- '</form></div>';
+ $output .= &mt('If you already have a log-in ID at this institution,[_1] you may be able to use it for LON-CAPA.','<br />').'<br /><br />'.&mt('Type in your log-in ID and password to find out.').'<br /><br />';
+ $output .= &login_box($now,$lonhost,$courseid,$submit_text,
+ $domain,'createaccount');
}
}
if (grep(/^email$/,@{$cancreate})) {
@@ -389,6 +386,48 @@
return $output;
}
+sub login_box {
+ my ($now,$lonhost,$courseid,$submit_text,$domain,$context) = @_;
+ my $output;
+ my %titles = &Apache::lonlocal::texthash(
+ createaccount => 'Log-in ID',
+ selfenroll => 'Username',
+ );
+ my ($lkey,$ukey) = &Apache::lonpreferences::des_keys();
+ my ($lextkey,$uextkey) = &getkeys($lkey,$ukey);
+ 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";
+ if ($context eq 'selfenroll') {
+ my $udomform = '<input type="text" name="udom" size="10" value="'.
+ $domain.'" />';
+ $output .= &Apache::lonhtmlcommon::row_title(&mt('Domain'),
+ 'LC_pick_box_title')."\n".
+ $udomform."\n".
+ &Apache::lonhtmlcommon::row_closure(1)."\n";
+ }
+
+ $output .= &Apache::lonhtmlcommon::row_title($titles{$context},
+ 'LC_pick_box_title')."\n".
+ $unameform."\n".
+ &Apache::lonhtmlcommon::row_closure(1)."\n".
+ &Apache::lonhtmlcommon::row_title(&mt('Password'),
+ 'LC_pick_box_title')."\n".
+ $upassform."\n".'<br /><br />'."\n".
+ '<input type="button" name="username_validation" value="'.
+ $submit_text.'" onclick="javascript:send()" />'."\n".
+ &Apache::lonhtmlcommon::row_closure(1)."\n".
+ &Apache::lonhtmlcommon::end_pick_box().'<br /><br />'."\n".
+ '<input type="hidden" name="lextkey" value="'.$lextkey.'">'."\n".
+ '<input type="hidden" name="uextkey" value="'.$uextkey.'">'."\n".
+ '</form></div>';
+ return $output;
+}
+
sub process_email_request {
my ($useremail,$domain,$domdesc,$contact_name,$contact_email,$cancreate,
$server,$settings,$courseid) = @_;
@@ -1016,15 +1055,19 @@
}
sub serverform {
- my ($logtoken,$lonhost,$mailtoken,$courseid) = @_;
+ my ($logtoken,$lonhost,$mailtoken,$courseid,$context) = @_;
+ my $phase = 'username_validation"';
+ if ($context eq 'selfenroll') {
+ $phase = 'selfenroll_login';
+ }
my $output .= <<ENDSERVERFORM;
- <form name="server" method="post" target="_top">
+ <form name="server" method="post" action="/adm/createaccount">
<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="phase" value="username_validation" />
+ <input type="hidden" name="phase" value="$phase" />
<input type="hidden" name="courseid" value="$courseid" />
</form>
ENDSERVERFORM
--raeburn1216024019--