version 1.4, 2008/06/03 03:07:38
|
version 1.8, 2008/07/10 00:19:56
|
Line 92 sub handler {
|
Line 92 sub handler {
|
foreach my $key (keys(%env)) { |
foreach my $key (keys(%env)) { |
if ($key =~ m-^user\.role\.st\./$cdom/$cnum/?(\w*)$-) { |
if ($key =~ m-^user\.role\.st\./$cdom/$cnum/?(\w*)$-) { |
my $sec = $1; |
my $sec = $1; |
if ($sec eq '') { |
|
$sec = &mt('none'); |
|
} |
|
my ($start,$end) = split(/\./,$env{$key}); |
my ($start,$end) = split(/\./,$env{$key}); |
my $status = 'active'; |
my $status = 'active'; |
if (($end) && ($end<=$now)) { |
if (($end) && ($end<=$now)) { |
Line 106 sub handler {
|
Line 103 sub handler {
|
if ($status eq 'active' || $status eq 'future') { |
if ($status eq 'active' || $status eq 'future') { |
$curr_role{'status'} = $status; |
$curr_role{'status'} = $status; |
$curr_role{'section'} = $sec; |
$curr_role{'section'} = $sec; |
|
if ($curr_role{'section'} eq '') { |
|
$curr_role{'section'} = &mt('none'); |
|
} |
$curr_role{'start'} = &Apache::lonlocal::locallocaltime($start); |
$curr_role{'start'} = &Apache::lonlocal::locallocaltime($start); |
$curr_role{'role'} = 'st./'.$cdom.'/'.$cnum; |
$curr_role{'role'} = 'st./'.$cdom.'/'.$cnum; |
if ($sec ne '') { |
if ($sec ne '') { |
Line 280 sub process_self_enroll {
|
Line 280 sub process_self_enroll {
|
my %userhash = &Apache::lonnet::userenvironment($udom,$uname,@info); |
my %userhash = &Apache::lonnet::userenvironment($udom,$uname,@info); |
my ($enrolltypes,$longtypes,$alldoms) = |
my ($enrolltypes,$longtypes,$alldoms) = |
&get_selfenroll_filters($selfenroll_types,$udom); |
&get_selfenroll_filters($selfenroll_types,$udom); |
my @inststatuses = &unescape(split(/:/,$userhash{'inststatus'})); |
my @inststatuses; |
if (@inststatuses == 0) { |
if ($userhash{'inststatus'} eq '') { |
push(@inststatuses,'other'); |
push(@inststatuses,'other'); |
|
} else { |
|
my @esc_statuses = split(/:/,$userhash{'inststatus'}); |
|
@inststatuses = map { &unescape($_); } (@esc_statuses); |
} |
} |
my $selfenroll = 0; |
my $selfenroll = 0; |
if ($alldoms) { |
if ($alldoms) { |
Line 310 sub process_self_enroll {
|
Line 313 sub process_self_enroll {
|
my ($registered,$instsec,$message) = &check_registered($cdom,$cnum); |
my ($registered,$instsec,$message) = &check_registered($cdom,$cnum); |
$usec = $instsec; |
$usec = $instsec; |
if (!$registered) { |
if (!$registered) { |
$r->print(&mt('Self-enrollment is restricted to officially registered students.').'<br />'); |
$r->print(&mt('Self-enrollment is restricted to students officially registered for this course.').'<br />'); |
if ($message) { |
if ($message) { |
$r->print($message); |
$r->print($message); |
} else { |
} else { |
Line 321 sub process_self_enroll {
|
Line 324 sub process_self_enroll {
|
} |
} |
my $enrollresult = |
my $enrollresult = |
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef, |
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef, |
undef,undef,$usec,$selfenroll_access_end,$selfenroll_access_start, 'manual',undef,$cdom.'_'.$cnum,$selfenroll); |
undef,undef,$usec,$selfenroll_access_end,$selfenroll_access_start, |
|
'manual',undef,$cdom.'_'.$cnum,$selfenroll); |
if ($enrollresult eq 'ok') { |
if ($enrollresult eq 'ok') { |
my (%userroles,%newrole,%newgroups); |
my (%userroles,%newrole,%newgroups); |
my $role = 'st'; |
my $role = 'st'; |
Line 335 sub process_self_enroll {
|
Line 339 sub process_self_enroll {
|
$area); |
$area); |
&Apache::lonnet::set_userprivs(\%userroles,\%newrole,%newgroups); |
&Apache::lonnet::set_userprivs(\%userroles,\%newrole,%newgroups); |
$userroles{'user.role.'.$spec} = $selfenroll_access_start.'.'.$selfenroll_access_end; |
$userroles{'user.role.'.$spec} = $selfenroll_access_start.'.'.$selfenroll_access_end; |
&Apache::lonnet::appenv(\%userroles,[$role]); |
&Apache::lonnet::appenv(\%userroles,[$role,'cm']); |
if ($selfenroll_access_end && $selfenroll_access_end <= $now) { |
if ($selfenroll_access_end && $selfenroll_access_end <= $now) { |
$r->print(&mt('The end date for access to this course for users who self-enroll has passed.').'<br />'.&mt('Consequently, although a new role was created for you in the course, it is an inactive role which does not provide access to the course.')); |
$r->print(&mt('The end date for access to this course for users who self-enroll has passed.').'<br />'.&mt('Consequently, although a new role was created for you in the course, it is an inactive role which does not provide access to the course.')); |
} else { |
} else { |
Line 431 sub print_selfenroll_types {
|
Line 435 sub print_selfenroll_types {
|
} |
} |
} |
} |
} else { |
} else { |
$output = &mt('Self-enrollment in this course is only available to users in the following domains (with the following status): ').'<ul>'; |
$output = &mt('Self-enrollment in this course is only available to users in the following domains (with the following status):').' <ul>'; |
foreach my $selfdom (sort(keys(%{$longtypes}))) { |
foreach my $selfdom (sort(keys(%{$longtypes}))) { |
if (ref($longtypes->{$selfdom}) eq 'ARRAY') { |
if (ref($longtypes->{$selfdom}) eq 'ARRAY') { |
$output .= '<li>'.$selfdom.': '.join(', ',@{$longtypes->{$selfdom}}).'</li>'; |
$output .= '<li>'.$selfdom.': '.join(', ',@{$longtypes->{$selfdom}}).'</li>'; |
Line 440 sub print_selfenroll_types {
|
Line 444 sub print_selfenroll_types {
|
$output .= '</ul>'; |
$output .= '</ul>'; |
} |
} |
} else { |
} else { |
$output = &mt('Self-enrollment is not currently available in this course'); |
$output = &mt('Self-enrollment is not currently available for this course.'); |
} |
} |
} |
} |
return $output; |
return $output; |