version 1.196, 2008/07/04 14:19:16
|
version 1.209.4.2, 2009/09/23 19:42:20
|
Line 43 use Apache::lonpageflip();
|
Line 43 use Apache::lonpageflip();
|
use Apache::lonnavdisplay(); |
use Apache::lonnavdisplay(); |
use GDBM_File; |
use GDBM_File; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
use HTML::Entities; |
|
|
|
|
sub redirect_user { |
sub redirect_user { |
Line 145 sub handler {
|
Line 146 sub handler {
|
# Is this an ad-hoc CA-role? |
# Is this an ad-hoc CA-role? |
if (my ($domain,$user) = |
if (my ($domain,$user) = |
($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) { |
($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) { |
# Check if author blocked ca-access |
if (($domain eq $env{'user.domain'}) && ($user eq $env{'user.name'})) { |
|
delete($env{$envkey}); |
|
$env{'form.au./'.$domain.'/'} = 1; |
|
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
|
if ($server_status eq 'switchserver') { |
|
my $trolecode = 'au./'.$domain.'/'; |
|
my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode; |
|
$r->internal_redirect($switchserver); |
|
} |
|
last; |
|
} |
|
if (my ($castart,$caend) = ($env{'user.role.ca./'.$domain.'/'.$user} =~ /^(\d*)\.(\d*)$/)) { |
|
if (((($castart) && ($castart < $now)) || !$castart) && |
|
((!$caend) || (($caend) && ($caend > $now)))) { |
|
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
|
if ($server_status eq 'switchserver') { |
|
my $trolecode = 'ca./'.$domain.'/'.$user; |
|
my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode; |
|
$r->internal_redirect($switchserver); |
|
} |
|
last; |
|
} |
|
} |
|
# Check if author blocked ca-access |
my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user); |
my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user); |
if ($blocked{'domcoord.author'} eq 'blocked') { |
if ($blocked{'domcoord.author'} eq 'blocked') { |
delete($env{$envkey}); |
delete($env{$envkey}); |
$env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access'; |
$env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access'; |
last; |
last; |
} |
} |
if ($dcroles{$domain}) { |
if ($dcroles{$domain}) { |
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
Line 228 sub handler {
|
Line 252 sub handler {
|
$cdom,$cnum, |
$cdom,$cnum, |
$env{'user.domain'}, |
$env{'user.domain'}, |
$env{'user.name'}, |
$env{'user.name'}, |
'Assigned from '.$ENV{'REMOTE_ADDR'}.' at '.localtime().' for '. |
&mt('Assigned from [_1] at [_2] for [_3]' |
$trolecode); |
,$ENV{'REMOTE_ADDR'} |
|
,&Apache::lonlocal::locallocaltime() |
|
,$trolecode) |
|
); |
unless ($assignresult eq 'ok') { |
unless ($assignresult eq 'ok') { |
$assignresult=~s/^error\:\s*//; |
$assignresult=~s/^error\:\s*//; |
$message=&mt($assignresult). |
$message=&mt($assignresult). |
Line 335 ENDENTERKEY
|
Line 362 ENDENTERKEY
|
} elsif ($env{'request.course.id'}) { |
} elsif ($env{'request.course.id'}) { |
if ($env{'form.destinationurl'}) { |
if ($env{'form.destinationurl'}) { |
my $dest = $env{'form.destinationurl'}; |
my $dest = $env{'form.destinationurl'}; |
|
if ($env{'form.destsymb'} ne '') { |
|
my $esc_symb = &HTML::Entities::encode($env{'form.destsymb'},'"<>&'); |
|
$dest .= '?symb='.$esc_symb; |
|
} |
&redirect_user($r,&mt('Entering [_1]', |
&redirect_user($r,&mt('Entering [_1]', |
$env{'course.'.$courseid.'.description'}), |
$env{'course.'.$courseid.'.description'}), |
$dest,$msg, |
$dest,$msg, |
Line 349 ENDENTERKEY
|
Line 380 ENDENTERKEY
|
) { |
) { |
my $startpage = &courseloadpage($courseid); |
my $startpage = &courseloadpage($courseid); |
unless ($startpage eq 'firstres') { |
unless ($startpage eq 'firstres') { |
$msg = &mt('Entering [_1] ....', |
$msg = &mt('Entering [_1] ...', |
$env{'course.'.$courseid.'.description'}); |
$env{'course.'.$courseid.'.description'}); |
&redirect_user($r,&mt('New in course'), |
&redirect_user($r,&mt('New in course'), |
'/adm/whatsnew?refpage=start',$msg, |
'/adm/whatsnew?refpage=start',$msg, |
Line 452 ENDHEADER
|
Line 483 ENDHEADER
|
my $advanced=$env{'user.adv'}; |
my $advanced=$env{'user.adv'}; |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['tryagain']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['tryagain']); |
my $tryagain=$env{'form.tryagain'}; |
my $tryagain=$env{'form.tryagain'}; |
|
my $reinit=$env{'user.reinit'}; |
|
delete $env{'user.reinit'}; |
|
|
# -------------------------------------------------------- Generate Page Output |
# -------------------------------------------------------- Generate Page Output |
# --------------------------------------------------------------- Error Header? |
# --------------------------------------------------------------- Error Header? |
Line 481 ENDHEADER
|
Line 514 ENDHEADER
|
&Apache::lonenc::check_encrypt($fn)); |
&Apache::lonenc::check_encrypt($fn)); |
} else { |
} else { |
if ($env{'user.error.msg'}) { |
if ($env{'user.error.msg'}) { |
$r->print( |
if ($reinit) { |
|
$r->print( |
|
'<h3><span class="LC_error">'. |
|
&mt('As your session file for the course has expired, you will need to re-select the course.').'</span></h3>'); |
|
} else { |
|
$r->print( |
'<h3><span class="LC_error">'. |
'<h3><span class="LC_error">'. |
&mt('You need to choose another user role or enter a specific course for this function').'</span></h3>'); |
&mt('You need to choose another user role or enter a specific course for this function').'</span></h3>'); |
} |
} |
|
} |
} |
} |
# -------------------------------------------------------- Choice or no choice? |
# -------------------------------------------------------- Choice or no choice? |
if ($nochoose) { |
if ($nochoose) { |
Line 509 ENDHEADER
|
Line 548 ENDHEADER
|
my $possiblerole=''; |
my $possiblerole=''; |
my %futureroles; |
my %futureroles; |
my %roles_nextlogin; |
my %roles_nextlogin; |
|
my %timezones; |
|
my $numcourses; |
|
if ($env{'user.adv'}) { |
|
my %courses = &Apache::lonnet::courseiddump($env{'user.domain'},'.','.','.','.','.',undef,undef,'Course'); |
|
$numcourses = keys(%courses); |
|
} |
foreach $envkey (sort keys %env) { |
foreach $envkey (sort keys %env) { |
my $button = 1; |
my $button = 1; |
my $switchserver=''; |
my $switchserver=''; |
Line 518 ENDHEADER
|
Line 563 ENDHEADER
|
my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont); |
my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont); |
&role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend); |
&role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend); |
next if (!defined($role) || $role eq '' || $role =~ /^gr/); |
next if (!defined($role) || $role eq '' || $role =~ /^gr/); |
|
my $timezone = &role_timezone($where,\%timezones); |
$tremark=''; |
$tremark=''; |
$tpstart=' '; |
$tpstart=' '; |
$tpend=' '; |
$tpend=' '; |
$tfont='#000000'; |
$tfont='#000000'; |
if ($tstart) { |
if ($tstart) { |
$tpstart=&Apache::lonlocal::locallocaltime($tstart); |
$tpstart=&Apache::lonlocal::locallocaltime($tstart,$timezone); |
} |
} |
if ($tend) { |
if ($tend) { |
$tpend=&Apache::lonlocal::locallocaltime($tend); |
$tpend=&Apache::lonlocal::locallocaltime($tend,$timezone); |
} |
} |
if ($env{'request.role'} eq $trolecode) { |
if ($env{'request.role'} eq $trolecode) { |
$tstatus='selected'; |
$tstatus='selected'; |
Line 549 ENDHEADER
|
Line 595 ENDHEADER
|
$countfuture ++; |
$countfuture ++; |
} elsif ($tstatus eq 'will') { |
} elsif ($tstatus eq 'will') { |
$tbg='#FFAA77'; |
$tbg='#FFAA77'; |
$tremark.=&mt('Active at next login. '); |
$tremark.=&mt('Active at next login.').' '; |
$roles_nextlogin{$trolecode} = $tstart.':'.$tend; |
$roles_nextlogin{$trolecode} = $tstart.':'.$tend; |
$countwill ++; |
$countwill ++; |
} elsif ($tstatus eq 'expired') { |
} elsif ($tstatus eq 'expired') { |
Line 558 ENDHEADER
|
Line 604 ENDHEADER
|
$button=0; |
$button=0; |
} elsif ($tstatus eq 'will_not') { |
} elsif ($tstatus eq 'will_not') { |
$tbg='#AAFF77'; |
$tbg='#AAFF77'; |
$tremark.=&mt('Expired after logout. '); |
$tremark.=&mt('Expired after logout.').' '; |
} elsif ($tstatus eq 'selected') { |
} elsif ($tstatus eq 'selected') { |
$tbg='#11CC55'; |
$tbg='#11CC55'; |
$tfont='#002200'; |
$tfont='#002200'; |
$inrole=1; |
$inrole=1; |
$countactive++; |
$countactive++; |
$tremark.=&mt('Currently selected. '); |
$tremark.=&mt('Currently selected.').' '; |
} |
} |
my $trole; |
my $trole; |
if ($role =~ /^cr\//) { |
if ($role =~ /^cr\//) { |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
if ($tremark) { $tremark.='<br />'; } |
if ($tremark) { $tremark.='<br />'; } |
$tremark.=&mt('Defined by ').$rauthor. |
$tremark.=&mt('Defined by [_1] at [_2].',$rauthor,$rdomain); |
&mt(' at ').$rdomain.'.'; |
|
} |
} |
$trole=Apache::lonnet::plaintext($role); |
$trole=Apache::lonnet::plaintext($role); |
my $ttype; |
my $ttype; |
Line 659 ENDHEADER
|
Line 704 ENDHEADER
|
$twhere=&mt('system wide'); |
$twhere=&mt('system wide'); |
$sortkey=$role.$twhere; |
$sortkey=$role.$twhere; |
} |
} |
$roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver); |
$roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit); |
$roletext{$envkey}=$roletext; |
$roletext{$envkey}=$roletext; |
if (!$sortkey) {$sortkey=$twhere."\0".$envkey;} |
if (!$sortkey) {$sortkey=$twhere."\0".$envkey;} |
$sortrole{$sortkey}=$envkey; |
$sortrole{$sortkey}=$envkey; |
Line 674 ENDHEADER
|
Line 719 ENDHEADER
|
$r->print(' /></label><input type="submit" value="'.&mt('Display').'" /></span>'); |
$r->print(' /></label><input type="submit" value="'.&mt('Display').'" /></span>'); |
} else { |
} else { |
if ($countactive > 0) { |
if ($countactive > 0) { |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $queuetotal = &queued_selfenrollment($r); |
$r->print('<p>'.&mt('[_1]Visit the [_2]Course Catalog[_3] to view all [_4] LON-CAPA courses.','<b>','<a href="/adm/coursecatalog">','</a></b>',$domdesc).'<br />'.&mt('If a course is [_1]not[_2] in your list of current courses below, you may be able to enroll if self-enrollment is permitted.','<b>','</b>').'</p>'); |
if (($numcourses-$queuetotal) > 1) { |
|
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
|
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
|
$r->print('<p>'.&mt('[_1]Visit the [_2]Course Catalog[_3] to view all [_4] GCI WebCenter courses.','<b>','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a></b>',$domdesc).'<br />'.&mt('If a course is [_1]not[_2] in your list of current courses below, you may be able to enroll if self-enrollment is permitted.','<b>','</b>').'</p>'); |
|
} |
} |
} |
} |
} |
|
|
Line 686 ENDHEADER
|
Line 735 ENDHEADER
|
} else { |
} else { |
$r->print('<h2>'.&mt('Currently no active roles or courses').'</h2>'); |
$r->print('<h2>'.&mt('Currently no active roles or courses').'</h2>'); |
} |
} |
&findcourse_advice($r); |
&findcourse_advice($r,$numcourses); |
$r->print('</form>'); |
$r->print('</form>'); |
if ($countfuture) { |
if ($countfuture) { |
$r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture)); |
$r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture)); |
Line 698 ENDHEADER
|
Line 747 ENDHEADER
|
my $tfont='#003300'; |
my $tfont='#003300'; |
if ($env{'request.role'} eq 'cm') { |
if ($env{'request.role'} eq 'cm') { |
$r->print('<tr bgcolor="#11CC55">'); |
$r->print('<tr bgcolor="#11CC55">'); |
$tremark=&mt('Currently selected. '); |
$tremark=&mt('Currently selected.').' '; |
$tfont='#002200'; |
$tfont='#002200'; |
} else { |
} else { |
$r->print('<tr bgcolor="#77FF77">'); |
$r->print('<tr bgcolor="#77FF77">'); |
Line 711 ENDHEADER
|
Line 760 ENDHEADER
|
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
# Is there only one choice? |
} elsif ($countactive==1) { # Is there only one choice? |
} elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) { |
my $needs_switchserver; |
$r->print('<h3>'.&mt('Please stand by.').'</h3>'. |
if ($env{'user.author'}) { |
'<input type="hidden" name="'.$possiblerole.'" value="1" />'. |
$needs_switchserver = &check_needs_switchserver($possiblerole); |
|
} |
|
if ((!$needs_switchserver) && ($env{'request.role'} eq 'cm')) { |
|
$r->print('<h3>'.&mt('Please stand by.').'</h3>'. |
|
'<input type="hidden" name="'.$possiblerole.'" value="1" />'. |
'<noscript><br /><input type="submit" name="submit" value="'.&mt('Continue').'" /></noscript>'); |
'<noscript><br /><input type="submit" name="submit" value="'.&mt('Continue').'" /></noscript>'); |
$r->print("</form>\n"); |
$r->print("</form>\n"); |
$r->rflush(); |
$r->rflush(); |
$r->print('<script type="text/javascript">document.forms.rolechoice.submit();</script>'); |
$r->print('<script type="text/javascript">document.forms.rolechoice.submit();</script>'); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
|
} |
|
if ($needs_switchserver) { |
|
$r->print("<h2>".&mt('Server Switch Required')."</h2>\n". |
|
&mt('Construction Space access is only available from '. |
|
'the home server of the corresponding Author.').'<br />'. |
|
&mt("Click the 'Switch Server' link to go there.").'<br />'); |
|
} |
} |
} |
# More than one possible role |
|
# ----------------------------------------------------------------------- Table |
# ----------------------------------------------------------------------- Table |
unless ((!&Apache::lonmenu::show_course()) || ($nochoose)) { |
unless ((!&Apache::lonmenu::show_course()) || ($nochoose) || ($countactive==1)) { |
$r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n"); |
$r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n"); |
} |
} |
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose); |
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose); |
Line 759 ENDHEADER
|
Line 818 ENDHEADER
|
&Apache::loncommon::authorbrowser_javascript()); |
&Apache::loncommon::authorbrowser_javascript()); |
} |
} |
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext); |
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext); |
my $tremark=''; |
if ($countactive > 1) { |
my $tfont='#003300'; |
my $tremark=''; |
if ($env{'request.role'} eq 'cm') { |
my $tfont='#003300'; |
$r->print('<tr bgcolor="#11CC55">'); |
if ($env{'request.role'} eq 'cm') { |
$tremark=&mt('Currently selected. '); |
$r->print('<tr bgcolor="#11CC55">'); |
$tfont='#002200'; |
$tremark=&mt('Currently selected.').' '; |
} else { |
$tfont='#002200'; |
$r->print('<tr bgcolor="#77FF77">'); |
} else { |
} |
$r->print('<tr bgcolor="#77FF77">'); |
unless ($nochoose) { |
} |
if ($env{'request.role'} ne 'cm') { |
unless ($nochoose) { |
$r->print('<td><input type="submit" value="'. |
if ($env{'request.role'} ne 'cm') { |
&mt('Select').'" name="cm" /></td>'); |
$r->print('<td><input type="submit" value="'. |
} else { |
&mt('Select').'" name="cm" /></td>'); |
$r->print('<td> </td>'); |
} else { |
} |
$r->print('<td> </td>'); |
} |
} |
$r->print('<td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified'). |
} |
'</span></font></td><td><font color="'.$tfont.'">'.$tremark. |
$r->print('<td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified'). |
' </font></td></tr>'."\n"); |
'</span></font></td><td><font color="'.$tfont.'">'.$tremark. |
|
' </font></td></tr>'."\n"); |
|
} |
$r->print('</table>'); |
$r->print('</table>'); |
unless ($nochoose) { |
unless ($nochoose) { |
$r->print("</form>\n"); |
$r->print("</form>\n"); |
Line 791 ENDHEADER
|
Line 851 ENDHEADER
|
} |
} |
$r->print(&Apache::lonnet::getannounce()); |
$r->print(&Apache::lonnet::getannounce()); |
if ($advanced) { |
if ($advanced) { |
|
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
$r->print('<p><small><i>' |
$r->print('<p><small><i>' |
.&mt('This is LON-CAPA [_1]',$r->dir_config('lonVersion')) |
.&mt('This is LON-CAPA [_1]',$r->dir_config('lonVersion')) |
.'</i><br />' |
.'</i><br />' |
.'<a href="/adm/logout">'.&mt('Logout').'</a></small></p>'); |
.'<a href="/adm/logout">'.&mt('Logout').'</a>'); |
|
if ($numcourses>1) { |
|
$r->print(' '. |
|
'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">'. |
|
&mt('Course Catalog'). |
|
'</small>'); |
|
} |
|
$r->print('</p>'); |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} |
} |
|
|
|
sub role_timezone { |
|
my ($where,$timezones) = @_; |
|
my $timezone; |
|
if (ref($timezones) eq 'HASH') { |
|
if ($where =~ m{^/($match_domain)/($match_courseid)}) { |
|
my $cdom = $1; |
|
my $cnum = $2; |
|
if ($cdom && $cnum) { |
|
if (!exists($timezones->{$cdom.'_'.$cnum})) { |
|
my %timehash = |
|
&Apache::lonnet::get('environment',['timezone'],$cdom,$cnum); |
|
if ($timehash{'timezone'} eq '') { |
|
if (!exists($timezones->{$cdom})) { |
|
my %domdefaults = |
|
&Apache::lonnet::get_domain_defaults($cdom); |
|
if ($domdefaults{'timezone_def'} eq '') { |
|
$timezones->{$cdom} = 'local'; |
|
} else { |
|
$timezones->{$cdom} = $domdefaults{'timezone_def'}; |
|
} |
|
} |
|
$timezones->{$cdom.'_'.$cnum} = $timezones->{$cdom}; |
|
} else { |
|
$timezones->{$cdom.'_'.$cnum} = |
|
&Apache::lonlocal::gettimezone($timehash{'timezone'}); |
|
} |
|
} |
|
$timezone = $timezones->{$cdom.'_'.$cnum}; |
|
} |
|
} else { |
|
my ($tdom) = ($where =~ m{^/($match_domain)}); |
|
if ($tdom) { |
|
if (!exists($timezones->{$tdom})) { |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($tdom); |
|
if ($domdefaults{'timezone_def'} eq '') { |
|
$timezones->{$tdom} = 'local'; |
|
} else { |
|
$timezones->{$tdom} = $domdefaults{'timezone_def'}; |
|
} |
|
} |
|
$timezone = $timezones->{$tdom}; |
|
} |
|
} |
|
if ($timezone eq 'local') { |
|
$timezone = undef; |
|
} |
|
} |
|
return $timezone; |
|
} |
|
|
sub roletable_headers { |
sub roletable_headers { |
my ($r,$roleclass,$sortrole,$nochoose) = @_; |
my ($r,$roleclass,$sortrole,$nochoose) = @_; |
my $doheaders; |
my $doheaders; |
Line 862 sub print_rolerows {
|
Line 980 sub print_rolerows {
|
} |
} |
|
|
sub findcourse_advice { |
sub findcourse_advice { |
my ($r) = @_; |
my ($r,$numcourses) = @_; |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
if (&check_autoenroll($env{'user.domain'})) { |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
|
if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) { |
$r->print(&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).' |
$r->print(&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).' |
<ul> |
<ul> |
<li>'.&mt('The course has yet to be created.').'</li> |
<li>'.&mt('The course has yet to be created.').'</li> |
Line 876 sub findcourse_advice {
|
Line 995 sub findcourse_advice {
|
} else { |
} else { |
$r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'<br />'); |
$r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'<br />'); |
} |
} |
$r->print('<p>'.&mt('The [_1]Course Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created.','<a href="/adm/coursecatalog">','</a>',$domdesc).'<br />'); |
my $queuetotal = &queued_selfenrollment($r); |
$r->print(&mt('You can search the course catalog for courses which permit self-enrollment, if you would like to enroll in a course.').'</p>'); |
if (($numcourses - $queuetotal) > 0) { |
|
$r->print('<p>'.&mt('The [_1]Course Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created.','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a>',$domdesc).'<br />'); |
|
$r->print(&mt('You can search the course catalog for courses which permit self-enrollment, if you would like to enroll in a course.').'</p>'); |
|
} |
return; |
return; |
} |
} |
|
|
|
sub queued_selfenrollment { |
|
my ($r) = @_; |
|
my %selfenrollrequests = &Apache::lonnet::dump('selfenrollrequests'); |
|
my %reqs_by_date; |
|
my $queuetotal = 0; |
|
foreach my $item (keys(%selfenrollrequests)) { |
|
if (ref($selfenrollrequests{$item}) eq 'HASH') { |
|
if ($selfenrollrequests{$item}{'status'} eq 'request') { |
|
if ($selfenrollrequests{$item}{'timestamp'}) { |
|
push(@{$reqs_by_date{$selfenrollrequests{$item}{'timestamp'}}},$item); |
|
} |
|
} |
|
} |
|
} |
|
if (keys(%reqs_by_date)) { |
|
my $rolename = &Apache::lonnet::plaintext('st'); |
|
$r->print('<b>'.&mt('Enrollment requests pending Course Coordinator approval').'</b><br />'. |
|
&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_header_row(). |
|
'<th>'.&mt('Date requested').'</th><th>'.&mt('Course title').'</th>'. |
|
'<th>'.&mt('User role').'</th><th>'.&mt('Section').'</th>'. |
|
&Apache::loncommon::end_data_table_header_row()); |
|
my @sorted = sort { $a <=> $b } (keys(%reqs_by_date)); |
|
foreach my $item (@sorted) { |
|
if (ref($reqs_by_date{$item}) eq 'ARRAY') { |
|
foreach my $crs (@{$reqs_by_date{$item}}) { |
|
my %courseinfo = &Apache::lonnet::coursedescription($crs); |
|
my $usec = $selfenrollrequests{$crs}{'section'}; |
|
if ($usec eq '') { |
|
$usec = &mt('No section'); |
|
} |
|
$r->print(&Apache::loncommon::start_data_table_row(). |
|
'<td>'.&Apache::lonlocal::locallocaltime($item).'</td>'. |
|
'<td>'.$courseinfo{'description'}.'</td>'. |
|
'<td>'.$rolename.'</td><td>'.$usec.'</td>'. |
|
&Apache::loncommon::end_data_table_row()); |
|
$queuetotal ++; |
|
} |
|
} |
|
} |
|
$r->print(&Apache::loncommon::end_data_table()); |
|
} |
|
return $queuetotal; |
|
} |
|
|
sub privileges_info { |
sub privileges_info { |
my ($which) = @_; |
my ($which) = @_; |
my $output; |
my $output; |
Line 916 sub privileges_info {
|
Line 1083 sub privileges_info {
|
$ttype='System'; |
$ttype='System'; |
$twhere='/'; |
$twhere='/'; |
} |
} |
$output .= "\n<h3>".$ttype.': '.$twhere.'</h3>'."\n<ul>"; |
$output .= "\n<h3>".&mt($ttype).': '.$twhere.'</h3>'."\n<ul>"; |
foreach my $priv (sort(split(/:/,$env{$envkey}))) { |
foreach my $priv (sort(split(/:/,$env{$envkey}))) { |
next if (!$priv); |
next if (!$priv); |
|
|
Line 962 sub role_status {
|
Line 1129 sub role_status {
|
} |
} |
|
|
sub build_roletext { |
sub build_roletext { |
my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_; |
my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit) = @_; |
my $roletext='<tr bgcolor="'.$tbg.'" class="LC_rolesmenu_'.$tstatus.'">'; |
my $roletext='<tr bgcolor="'.$tbg.'" class="LC_rolesmenu_'.$tstatus.'">'; |
my $is_dc=($trolecode =~ m/^dc\./); |
my $is_dc=($trolecode =~ m/^dc\./); |
my $rowspan=($is_dc) ? '' |
my $rowspan=($is_dc) ? '' |
Line 990 sub build_roletext {
|
Line 1157 sub build_roletext {
|
} elsif ($advanced) { |
} elsif ($advanced) { |
$roletext.= |
$roletext.= |
'<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
'<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
&mt('Re-Initialize').'" onClick="javascript:enterrole(this.form,\''. |
&mt('Re-Select').'" onClick="javascript:enterrole(this.form,\''. |
|
$trolecode."','".$buttonname.'\');" /></td>'; |
|
} elsif ($reinit) { |
|
$roletext.= |
|
'<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
|
&mt('Re-Select').'" onClick="javascript:enterrole(this.form,\''. |
$trolecode."','".$buttonname.'\');" /></td>'; |
$trolecode."','".$buttonname.'\');" /></td>'; |
} else { |
} else { |
$roletext.='<td'.$rowspan.'> </td>'; |
$roletext.= |
|
'<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
|
&mt('Re-Select').'" onClick="javascript:enterrole(this.form,\''. |
|
$trolecode."','".$buttonname.'\');" /></td>'; |
} |
} |
} |
} |
if ($trolecode !~ m/^(dc|ca|au|aa)\./) { |
if ($trolecode !~ m/^(dc|ca|au|aa)\./) { |
Line 1012 sub build_roletext {
|
Line 1187 sub build_roletext {
|
return $roletext; |
return $roletext; |
} |
} |
|
|
|
sub check_needs_switchserver { |
|
my ($possiblerole) = @_; |
|
my $needs_switchserver; |
|
my ($role,$where) = split(/\./,$possiblerole,2); |
|
my (undef,$tdom,$twho) = split(/\//,$where); |
|
my ($server_status,$home); |
|
if (($role eq 'ca') || ($role eq 'aa')) { |
|
($server_status,$home) = &check_author_homeserver($twho,$tdom); |
|
} else { |
|
($server_status,$home) = &check_author_homeserver($env{'user.name'}, |
|
$env{'user.domain'}); |
|
} |
|
if ($server_status eq 'switchserver') { |
|
$needs_switchserver = 1; |
|
} |
|
return $needs_switchserver; |
|
} |
|
|
sub check_author_homeserver { |
sub check_author_homeserver { |
my ($uname,$udom)=@_; |
my ($uname,$udom)=@_; |
if (($uname eq '') || ($udom eq '')) { |
if (($uname eq '') || ($udom eq '')) { |
Line 1067 sub check_fordc {
|
Line 1260 sub check_fordc {
|
sub adhoc_course_role { |
sub adhoc_course_role { |
my ($then) = @_; |
my ($then) = @_; |
my ($cdom,$cnum); |
my ($cdom,$cnum); |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
if (&check_forcc($cdom,$cnum,$then)) { |
if (&check_forcc($cdom,$cnum,$then)) { |
my $setprivs; |
my $setprivs; |
if (!defined($env{'user.role.'.$env{'form.selectrole'}})) { |
if (!defined($env{'user.role.'.$env{'form.switchrole'}})) { |
$setprivs = 1; |
$setprivs = 1; |
} else { |
} else { |
my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.selectrole'}}); |
my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}}); |
if (($start && ($start>$then || $start == -1)) || |
if (($start && ($start>$then || $start == -1)) || |
($end && $end<$then)) { |
($end && $end<$then)) { |
$setprivs = 1; |
$setprivs = 1; |
} |
} |
} |
} |
if ($setprivs) { |
if ($setprivs) { |
if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E(/?\w*)$-) { |
if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { |
my $role = $1; |
my $role = $1; |
my $custom_role = $2; |
my $custom_role = $2; |
my $usec = $3; |
my $usec = $3; |
if ($role eq 'cr') { |
if ($role eq 'cr') { |
if ($custom_role =~ m-^$match_domain/$match_courseid/\w+$-) { |
if ($custom_role =~ m-^/$match_domain/$match_username/\w+$-) { |
$role .= $custom_role; |
$role .= $custom_role; |
} else { |
} else { |
return; |
return; |
} |
} |
} |
} |
my (%userroles,%newrole,%newgroups); |
my (%userroles,%newrole,%newgroups,%group_privs); |
|
my %cgroups = |
|
&Apache::lonnet::get_active_groups($env{'user.domain'}, |
|
$env{'user.name'},$cdom,$cnum); |
|
foreach my $group (keys(%cgroups)) { |
|
$group_privs{$group} = |
|
$env{'user.priv.cc./'.$cdom.'/'.$cnum.'./'.$cdom.'/'.$cnum.'/'.$group}; |
|
} |
|
$newgroups{'/'.$cdom.'/'.$cnum} = \%group_privs; |
my $area = '/'.$cdom.'/'.$cnum; |
my $area = '/'.$cdom.'/'.$cnum; |
my $spec = $role.'.'.$area; |
my $spec = $role.'.'.$area; |
if ($usec ne '') { |
if ($usec ne '') { |
Line 1100 sub adhoc_course_role {
|
Line 1301 sub adhoc_course_role {
|
$area .= '/'.$usec; |
$area .= '/'.$usec; |
} |
} |
&Apache::lonnet::standard_roleprivs(\%newrole,$role,$cdom,$spec,$cnum,$area); |
&Apache::lonnet::standard_roleprivs(\%newrole,$role,$cdom,$spec,$cnum,$area); |
&Apache::lonnet::set_userprivs(\%userroles,\%newrole,%newgroups); |
&Apache::lonnet::set_userprivs(\%userroles,\%newrole,\%newgroups); |
my $adhocstart = $then-1; |
my $adhocstart = $then-1; |
$userroles{'user.role.'.$spec} = $adhocstart.'.'; |
$userroles{'user.role.'.$spec} = $adhocstart.'.'; |
&Apache::lonnet::appenv(\%userroles,[$role,'cm']); |
&Apache::lonnet::appenv(\%userroles,[$role,'cm']); |
Line 1286 sub courseloadpage {
|
Line 1487 sub courseloadpage {
|
return $startpage; |
return $startpage; |
} |
} |
|
|
sub check_autoenroll { |
|
my ($dom) = @_; |
|
my $run_enroll = 0; |
|
my $settings; |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['autoenroll'],$dom); |
|
if (ref($domconfig{'autoenroll'}) eq 'HASH') { |
|
$settings = $domconfig{'autoenroll'}; |
|
if ($settings->{'run'} eq '1') { |
|
$run_enroll = 1; |
|
} |
|
} else { |
|
$run_enroll = &localenroll::run($dom); |
|
} |
|
return $run_enroll; |
|
} |
|
|
|
|
|
1; |
1; |
__END__ |
__END__ |
|
|