version 1.2, 2008/03/12 02:45:07
|
version 1.3, 2008/05/14 20:06:51
|
Line 66 sub handler {
|
Line 66 sub handler {
|
return OK; |
return OK; |
} |
} |
my ($cdom,$cnum,$canenroll,$selfenroll_types,$selfenroll_registered, |
my ($cdom,$cnum,$canenroll,$selfenroll_types,$selfenroll_registered, |
$cancreate,$knownuser,$selfenroll_access_start,$selfenroll_access_end, |
@cancreate,$knownuser,$selfenroll_access_start,$selfenroll_access_end, |
$selfenroll_section,%curr_role,%coursehash); |
$selfenroll_section,%curr_role,%coursehash); |
my $now = time; |
my $now = time; |
%coursehash = &Apache::lonnet::coursedescription($cid); |
%coursehash = &Apache::lonnet::coursedescription($cid); |
Line 122 sub handler {
|
Line 122 sub handler {
|
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} |
} |
$cancreate = &can_create($cdom); |
@cancreate = &can_create($cdom); |
my ($login_path,$firsturl,$create_path,$sso_url,$missing_formitem); |
my ($login_path,$firsturl,$create_path,$sso_url,$missing_formitem); |
$login_path = '/adm/login'; |
$login_path = '/adm/login'; |
$firsturl= '/adm/selfenroll?cid='.$cid; |
$firsturl= '/adm/selfenroll?cid='.$cid; |
Line 140 sub handler {
|
Line 140 sub handler {
|
&process_self_enroll($r,$cdom,$cnum,$selfenroll_types,$selfenroll_registered, |
&process_self_enroll($r,$cdom,$cnum,$selfenroll_types,$selfenroll_registered, |
$selfenroll_access_start,$selfenroll_access_end, |
$selfenroll_access_start,$selfenroll_access_end, |
$selfenroll_section,$now); |
$selfenroll_section,$now); |
} elsif ($cancreate) { |
} elsif (@cancreate > 0) { |
$r->print(<<END); |
$r->print(<<END); |
<script type="text/javascript"> |
<script type="text/javascript"> |
function setPath(formaction,item,arg) { |
function setPath(formaction,item,arg) { |
Line 167 function getIndexByName(item) {
|
Line 167 function getIndexByName(item) {
|
</script> |
</script> |
END |
END |
$r->print(&mt('You need to be logged into LON-CAPA to self-enroll in a course.').'<ul><li>'.&mt('If you have an account in LON-CAPA, [_1]log-in[_2].','<a href="javascript:setPath('."'$login_path','firsturl','$firsturl'".')">','</a>').'</li>'); |
$r->print(&mt('You need to be logged into LON-CAPA to self-enroll in a course.').'<ul><li>'.&mt('If you have an account in LON-CAPA, [_1]log-in[_2].','<a href="javascript:setPath('."'$login_path','firsturl','$firsturl'".')">','</a>').'</li>'); |
if ($cancreate eq 'any') { |
if (@cancreate > 1) { |
$r->print('<li>'.&mt('Otherwise [_1]create an account[_2].','<a href="javascript:setPath('."'$create_path','courseid','$cid'".')">','</a>')); |
$r->print('<li>'.&mt('Otherwise:').'<br />'); |
} elsif ($cancreate eq 'login') { |
my $count = 0; |
$r->print('<li>'.&mt('Otherwise, if you have an institutional login, [_1]create an account[_2].','<a href="javascript:setPath('."'$create_path','courseid','$cid'".')">','</a>')); |
foreach my $type ('sso','login','email') { |
} elsif ($cancreate eq 'email') { |
if ($count> 0) { |
$r->print('<li>'.&mt('Otherwise, you will use an e-mail address to [_1]create an account[_2].','<a href="javascript:setPath('."'$create_path','courseid','$cid'".')">','</a>')); |
$r->print(' , '.&mt('or').'<br />'); |
} elsif ($cancreate eq 'sso') { |
} |
$r->print('<li>'.&mt("Otherwise, use your institution's [_1]single sign on page[_2] to log-in, then create an account.",'<a href="javascript:setPath('."'$sso_url','firsturl','$firsturl'".')">','</a>')); |
if (grep(/^$type$/,@cancreate)) { |
|
if ($type eq 'sso') { |
|
$r->print(' '.&mt("if you have an institutional log-in, use your institution's [_1]single sign on page[_2] to log-in, then create an account",'<a href="javascript:setPath('."'$sso_url','firsturl','$firsturl'".')">','</a>')); |
|
} elsif ($type eq 'login') { |
|
$r->print(' '.&mt('if you have an institutional login, [_1]create an account[_2]','<a href="javascript:setPath('."'$create_path','courseid','$cid'".')">','</a>')); |
|
} elsif ($type eq 'email') { |
|
$r->print(' '.&mt('you can use an e-mail address to [_1]create an account[_2]','<a href="javascript:setPath('."'$create_path','courseid','$cid'".')">','</a>')); |
|
} |
|
$count ++; |
|
} |
|
} |
|
$r->print('.<br />'); |
|
} else { |
|
if ($cancreate[0] eq 'login') { |
|
$r->print('<li>'.&mt('Otherwise, if you have an institutional login, [_1]create an account[_2].','<a href="javascript:setPath('."'$create_path','courseid','$cid'".')">','</a>')); |
|
} elsif ($cancreate[0] eq 'email') { |
|
$r->print('<li>'.&mt('Otherwise, you will use an e-mail address to [_1]create an account[_2].','<a href="javascript:setPath('."'$create_path','courseid','$cid'".')">','</a>')); |
|
} elsif ($cancreate[0] eq 'sso') { |
|
$r->print('<li>'.&mt("Otherwise, use your institution's [_1]single sign on page[_2] to log-in, then create an account.",'<a href="javascript:setPath('."'$sso_url','firsturl','$firsturl'".')">','</a>')); |
|
} |
} |
} |
if ($selfenroll_types eq '*') { |
if ($selfenroll_types eq '*') { |
$r->print('<br />'.&mt('You will have an opportunity to self enroll in the course once the account has been created.').'</li></ul>'); |
$r->print('<br />'.&mt('You will have an opportunity to self enroll in the course once the account has been created.').'</li></ul>'); |
Line 221 sub user_is_known {
|
Line 240 sub user_is_known {
|
|
|
sub can_create { |
sub can_create { |
my ($cdom) = @_; |
my ($cdom) = @_; |
my $cancreate = ''; |
my @cancreate; |
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$cdom); |
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$cdom); |
if (ref($domconfig{'usercreation'}) eq 'HASH') { |
if (ref($domconfig{'usercreation'}) eq 'HASH') { |
if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') { |
if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') { |
if ($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne 'none') { |
if ($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne 'none') { |
$cancreate = $domconfig{'usercreation'}{'cancreate'}{'selfcreate'}; |
if (ref($domconfig{'usercreation'}{'cancreate'}{'selfcreate'}) eq 'ARRAY') { |
|
@cancreate = @{$domconfig{'usercreation'}{'cancreate'}{'selfcreate'}}; |
|
} else { |
|
if (($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne 'none') && |
|
($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne '')) { |
|
@cancreate = ($domconfig{'usercreation'}{'cancreate'}{'selfcreate'}); |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
if ($cancreate eq 'none') { |
return @cancreate; |
$cancreate = ''; |
|
} |
|
return $cancreate; |
|
} |
} |
|
|
sub has_role { |
sub has_role { |