--- loncom/interface/createaccount.pm 2010/12/08 05:28:48 1.45
+++ loncom/interface/createaccount.pm 2012/05/17 17:41:48 1.49
@@ -3,7 +3,7 @@
# institutional log-in ID (institutional authentication required - localauth
# or kerberos) or an e-mail address.
#
-# $Id: createaccount.pm,v 1.45 2010/12/08 05:28:48 raeburn Exp $
+# $Id: createaccount.pm,v 1.49 2012/05/17 17:41:48 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -45,6 +45,8 @@ use Crypt::DES;
use LONCAPA qw(:DEFAULT :match);
use HTML::Entities;
+#TODO this module needs documentation
+
sub handler {
my $r = shift;
&Apache::loncommon::content_type($r,'text/html');
@@ -65,14 +67,8 @@ sub handler {
if ($sso_username ne '' && $sso_domain ne '') {
$domain = $sso_domain;
} else {
- $domain = &Apache::lonnet::default_login_domain();
- if (defined($env{'form.courseid'})) {
- if (&validate_course($env{'form.courseid'})) {
- if ($env{'form.courseid'} =~ /^($match_domain)_($match_courseid)$/) {
- $domain = $1;
- }
- }
- }
+ ($domain, undef) = Apache::lonnet::is_course($env{'form.courseid'});
+ $domain ||= &Apache::lonnet::default_login_domain();
}
my $domdesc = &Apache::lonnet::domain($domain,'description');
my $contact_name = &mt('LON-CAPA helpdesk');
@@ -98,9 +94,7 @@ sub handler {
}
my ($js,$courseid,$title);
- if (defined($env{'form.courseid'})) {
- $courseid = &validate_course($env{'form.courseid'});
- }
+ $courseid = Apache::lonnet::is_course($env{'form.courseid'});
if ($courseid ne '') {
$js = &catreturn_js();
$title = 'Self-enroll in a LON-CAPA course';
@@ -295,17 +289,6 @@ sub selfenroll_crumbs {
return;
}
-sub validate_course {
- my ($courseid) = @_;
- my ($cdom,$cnum) = ($courseid =~ /^($match_domain)_($match_courseid)$/);
- if (($cdom ne '') && ($cnum ne '')) {
- if (&Apache::lonnet::is_course($cdom,$cnum)) {
- return ($courseid);
- }
- }
- return;
-}
-
sub javascript_setforms {
my ($now) = @_;
my $js = <