[LON-CAPA-cvs] cvs: loncom /interface selfenroll.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Wed, 14 May 2008 20:06:52 -0000
raeburn Wed May 14 16:06:52 2008 EDT
Modified files:
/loncom/interface selfenroll.pm
Log:
- selfcreation auth types are now stored as an array, instead of a single-valued scalar.
Index: loncom/interface/selfenroll.pm
diff -u loncom/interface/selfenroll.pm:1.2 loncom/interface/selfenroll.pm:1.3
--- loncom/interface/selfenroll.pm:1.2 Tue Mar 11 22:45:07 2008
+++ loncom/interface/selfenroll.pm Wed May 14 16:06:51 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Allow users to self-enroll in a course
#
-# $Id: selfenroll.pm,v 1.2 2008/03/12 02:45:07 raeburn Exp $
+# $Id: selfenroll.pm,v 1.3 2008/05/14 20:06:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -66,7 +66,7 @@
return OK;
}
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);
my $now = time;
%coursehash = &Apache::lonnet::coursedescription($cid);
@@ -122,7 +122,7 @@
$r->print(&Apache::loncommon::end_page());
return OK;
}
- $cancreate = &can_create($cdom);
+ @cancreate = &can_create($cdom);
my ($login_path,$firsturl,$create_path,$sso_url,$missing_formitem);
$login_path = '/adm/login';
$firsturl= '/adm/selfenroll?cid='.$cid;
@@ -140,7 +140,7 @@
&process_self_enroll($r,$cdom,$cnum,$selfenroll_types,$selfenroll_registered,
$selfenroll_access_start,$selfenroll_access_end,
$selfenroll_section,$now);
- } elsif ($cancreate) {
+ } elsif (@cancreate > 0) {
$r->print(<<END);
<script type="text/javascript">
function setPath(formaction,item,arg) {
@@ -167,14 +167,33 @@
</script>
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>');
- if ($cancreate eq 'any') {
- $r->print('<li>'.&mt('Otherwise [_1]create an account[_2].','<a href="javascript:setPath('."'$create_path','courseid','$cid'".')">','</a>'));
- } elsif ($cancreate 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 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 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 (@cancreate > 1) {
+ $r->print('<li>'.&mt('Otherwise:').'<br />');
+ my $count = 0;
+ foreach my $type ('sso','login','email') {
+ if ($count> 0) {
+ $r->print(' , '.&mt('or').'<br />');
+ }
+ 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 '*') {
$r->print('<br />'.&mt('You will have an opportunity to self enroll in the course once the account has been created.').'</li></ul>');
@@ -221,19 +240,23 @@
sub can_create {
my ($cdom) = @_;
- my $cancreate = '';
+ my @cancreate;
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$cdom);
if (ref($domconfig{'usercreation'}) eq 'HASH') {
if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') {
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') {
- $cancreate = '';
- }
- return $cancreate;
+ return @cancreate;
}
sub has_role {