version 1.155, 2006/06/02 22:02:51
|
version 1.196, 2008/07/04 14:19:16
|
Line 40 use Apache::lonhtmlcommon;
|
Line 40 use Apache::lonhtmlcommon;
|
use Apache::lonannounce; |
use Apache::lonannounce; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonpageflip(); |
use Apache::lonpageflip(); |
|
use Apache::lonnavdisplay(); |
use GDBM_File; |
use GDBM_File; |
use LONCAPA; |
use LONCAPA qw(:DEFAULT :match); |
|
|
|
|
sub redirect_user { |
sub redirect_user { |
Line 53 sub redirect_user {
|
Line 54 sub redirect_user {
|
my $swinfo=&Apache::lonmenu::rawconfig(); |
my $swinfo=&Apache::lonmenu::rawconfig(); |
my $navwindow; |
my $navwindow; |
if ($launch_nav eq 'on') { |
if ($launch_nav eq 'on') { |
$navwindow.=&Apache::lonnavmaps::launch_win('now',undef,undef, |
$navwindow.=&Apache::lonnavdisplay::launch_win('now',undef,undef, |
($url =~ m-^/adm/whatsnew-)); |
($url =~ m-^/adm/whatsnew-)); |
} else { |
} else { |
$navwindow.=&Apache::lonnavmaps::close(); |
$navwindow.=&Apache::lonnavmaps::close(); |
} |
} |
Line 88 sub error_page {
|
Line 89 sub error_page {
|
&Apache::lonmenu::rawconfig().'</script>'. |
&Apache::lonmenu::rawconfig().'</script>'. |
'<p>'.&mt('The following problems occurred:'). |
'<p>'.&mt('The following problems occurred:'). |
$error. |
$error. |
'</p><br /><a href="'.$dest.'>'.&mt('Continue').'</a>'. |
'</p><br /><a href="'.$dest.'">'.&mt('Continue').'</a>'. |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
} |
} |
|
|
Line 105 sub handler {
|
Line 106 sub handler {
|
|
|
# ================================================================== Roles Init |
# ================================================================== Roles Init |
if ($env{'form.selectrole'}) { |
if ($env{'form.selectrole'}) { |
|
|
|
my $locknum=&Apache::lonnet::get_locks(); |
|
if ($locknum) { return 409; } |
|
|
if ($env{'form.newrole'}) { |
if ($env{'form.newrole'}) { |
$env{'form.'.$env{'form.newrole'}}=1; |
$env{'form.'.$env{'form.newrole'}}=1; |
} |
} |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
|
# Check if user is CC trying to select a course role |
|
if ($env{'form.switchrole'}) { |
|
if (!defined($env{'user.role.'.$env{'form.switchrole'}})) { |
|
&adhoc_course_role($then); |
|
} |
|
} |
my %temp=('logout_'.$env{'request.course.id'} => time); |
my %temp=('logout_'.$env{'request.course.id'} => time); |
&Apache::lonnet::put('email_status',\%temp); |
&Apache::lonnet::put('email_status',\%temp); |
&Apache::lonnet::delenv('user.state.'.$env{'request.course.id'}); |
&Apache::lonnet::delenv('user.state.'.$env{'request.course.id'}); |
} |
} |
&Apache::lonnet::appenv("request.course.id" => '', |
&Apache::lonnet::appenv({"request.course.id" => '', |
"request.course.fn" => '', |
"request.course.fn" => '', |
"request.course.uri" => '', |
"request.course.uri" => '', |
"request.course.sec" => '', |
"request.course.sec" => '', |
"request.role" => 'cm', |
"request.role" => 'cm', |
"request.role.adv" => $env{'user.adv'}, |
"request.role.adv" => $env{'user.adv'}, |
"request.role.domain" => $env{'user.domain'}); |
"request.role.domain" => $env{'user.domain'}}); |
|
# Check if user is a DC trying to enter a course or author space and needs privs to be created |
# Check if user is a DC trying to enter a course and needs privs to be created |
|
if ($numdc > 0) { |
if ($numdc > 0) { |
foreach my $envkey (keys %env) { |
foreach my $envkey (keys %env) { |
|
# Is this an ad-hoc CC-role? |
if (my ($domain,$coursenum) = |
if (my ($domain,$coursenum) = |
($envkey =~ m-^form\.cc\./(\w+)/(\w+)$-)) { |
($envkey =~ m-^form\.cc\./($match_domain)/($match_courseid)$-)) { |
|
if ($dcroles{$domain}) { |
|
&check_privs($domain,$coursenum,$then,$now,'cc'); |
|
} |
|
last; |
|
} |
|
# Is this an ad-hoc CA-role? |
|
if (my ($domain,$user) = |
|
($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) { |
|
# Check if author blocked ca-access |
|
my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user); |
|
if ($blocked{'domcoord.author'} eq 'blocked') { |
|
delete($env{$envkey}); |
|
$env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access'; |
|
last; |
|
} |
if ($dcroles{$domain}) { |
if ($dcroles{$domain}) { |
&check_privs($domain,$coursenum,$then,$now); |
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
|
if (($server_status eq 'ok') || ($server_status eq 'switchserver')) { |
|
&check_privs($domain,$user,$then,$now,'ca'); |
|
if ($server_status eq 'switchserver') { |
|
my $trolecode = 'ca./'.$domain.'/'.$user; |
|
my $switchserver = '/adm/switchserver?' |
|
.'otherserver='.$home.'&role='.$trolecode; |
|
$r->internal_redirect($switchserver); |
|
} |
|
} else { |
|
delete($env{$envkey}); |
|
} |
|
} else { |
|
delete($env{$envkey}); |
} |
} |
last; |
last; |
} |
} |
Line 149 sub handler {
|
Line 188 sub handler {
|
|
|
# store role if recent_role list being kept |
# store role if recent_role list being kept |
if ($env{'environment.recentroles'}) { |
if ($env{'environment.recentroles'}) { |
|
my %frozen_roles = |
|
&Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'}); |
&Apache::lonhtmlcommon::store_recent('roles', |
&Apache::lonhtmlcommon::store_recent('roles', |
$trolecode,' '); |
$trolecode,' ',$frozen_roles{$trolecode}); |
} |
} |
|
|
|
|
Line 162 sub handler {
|
Line 203 sub handler {
|
my $authnum=$cnum; |
my $authnum=$cnum; |
if ($env{'course.'.$cdom.'_'.$cnum.'.keyauth'}) { |
if ($env{'course.'.$cdom.'_'.$cnum.'.keyauth'}) { |
($authnum,$authdom)= |
($authnum,$authdom)= |
split(/\W/,$env{'course.'.$cdom.'_'.$cnum.'.keyauth'}); |
split(/:/,$env{'course.'.$cdom.'_'.$cnum.'.keyauth'}); |
} |
} |
# check with key authority |
# check with key authority |
unless (&Apache::lonnet::validate_access_key( |
unless (&Apache::lonnet::validate_access_key( |
Line 198 sub handler {
|
Line 239 sub handler {
|
} |
} |
$r->print(<<ENDENTEREDKEY); |
$r->print(<<ENDENTEREDKEY); |
$start_page |
$start_page |
<script> |
<script type="text/javascript"> |
$swinfo |
$swinfo |
</script> |
</script> |
<form method="post"> |
<form method="post"> |
Line 221 ENDENTEREDKEY
|
Line 262 ENDENTEREDKEY
|
my $end_page=&Apache::loncommon::end_page(); |
my $end_page=&Apache::loncommon::end_page(); |
$r->print(<<ENDENTERKEY); |
$r->print(<<ENDENTERKEY); |
$start_page |
$start_page |
<script> |
<script type="text/javascript"> |
$swinfo |
$swinfo |
</script> |
</script> |
<form method="post"> |
<form method="post"> |
Line 242 ENDENTERKEY
|
Line 283 ENDENTERKEY
|
"Role ".$trolecode); |
"Role ".$trolecode); |
|
|
&Apache::lonnet::appenv( |
&Apache::lonnet::appenv( |
'request.role' => $trolecode, |
{'request.role' => $trolecode, |
'request.role.domain' => $cdom, |
'request.role.domain' => $cdom, |
'request.course.sec' => $csec, |
'request.course.sec' => $csec, |
'request.course.groups' => $cgrps); |
'request.course.groups' => $cgrps}); |
my $tadv=0; |
my $tadv=0; |
|
|
if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) { |
if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) { |
Line 256 ENDENTERKEY
|
Line 297 ENDENTERKEY
|
($env{'form.orgurl'}!~/^\/adm\/flip/)) { |
($env{'form.orgurl'}!~/^\/adm\/flip/)) { |
my $dest=$env{'form.orgurl'}; |
my $dest=$env{'form.orgurl'}; |
if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; } |
if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; } |
&Apache::lonnet::appenv('request.role.adv'=>$tadv); |
&Apache::lonnet::appenv({'request.role.adv'=>$tadv}); |
if (($ferr) && ($tadv)) { |
if (($ferr) && ($tadv)) { |
&error_page($r,$ferr,$dest); |
&error_page($r,$ferr,$dest); |
} else { |
} else { |
Line 264 ENDENTERKEY
|
Line 305 ENDENTERKEY
|
} |
} |
return OK; |
return OK; |
} else { |
} else { |
my $type = 'Course/Group'; |
|
if (!$env{'request.course.id'}) { |
if (!$env{'request.course.id'}) { |
if (defined($env{'course.'. |
|
$env{'request.course.id'}.'.type'})) { |
|
$type = $env{'course.'. |
|
$env{'request.course.id'}.'.type'}; |
|
} |
|
&Apache::lonnet::appenv( |
&Apache::lonnet::appenv( |
"request.course.id" => $cdom.'_'.$cnum); |
{"request.course.id" => $cdom.'_'.$cnum}); |
$furl='/adm/roles?tryagain=1'; |
$furl='/adm/roles?tryagain=1'; |
$msg= |
$msg= |
'<h1><font color="red">'. |
'<h1><span class="LC_error">'. |
&mt('Could not initialize [_1] at this time.',lc($type)). |
&mt('Could not initialize [_1] at this time.', |
'</font></h1><h3>'.&mt('Please try again.').'</h3>'.$ferr; |
$env{'course.'.$cdom.'_'.$cnum.'.description'}). |
|
'</span></h1><h3>'.&mt('Please try again.').'</h3>'.$ferr; |
} |
} |
if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; } |
if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; } |
&Apache::lonnet::appenv('request.role.adv'=>$tadv); |
&Apache::lonnet::appenv({'request.role.adv'=>$tadv}); |
|
|
if (($ferr) && ($tadv)) { |
if (($ferr) && ($tadv)) { |
&error_page($r,$ferr,$furl); |
&error_page($r,$ferr,$furl); |
Line 297 ENDENTERKEY
|
Line 333 ENDENTERKEY
|
$furl = "/adm/helper/course.initialization.helper"; |
$furl = "/adm/helper/course.initialization.helper"; |
# Send the user to the course they selected |
# Send the user to the course they selected |
} elsif ($env{'request.course.id'}) { |
} elsif ($env{'request.course.id'}) { |
|
if ($env{'form.destinationurl'}) { |
|
my $dest = $env{'form.destinationurl'}; |
|
&redirect_user($r,&mt('Entering [_1]', |
|
$env{'course.'.$courseid.'.description'}), |
|
$dest,$msg, |
|
$env{'environment.remotenavmap'}); |
|
return OK; |
|
} |
if (&Apache::lonnet::allowed('whn', |
if (&Apache::lonnet::allowed('whn', |
$env{'request.course.id'}) |
$env{'request.course.id'}) |
|| &Apache::lonnet::allowed('whn', |
|| &Apache::lonnet::allowed('whn', |
Line 305 ENDENTERKEY
|
Line 349 ENDENTERKEY
|
) { |
) { |
my $startpage = &courseloadpage($courseid); |
my $startpage = &courseloadpage($courseid); |
unless ($startpage eq 'firstres') { |
unless ($startpage eq 'firstres') { |
$msg = &mt('Entering [_1] ....',lc($type)); |
$msg = &mt('Entering [_1] ....', |
|
$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, |
$env{'environment.remotenavmap'}); |
$env{'environment.remotenavmap'}); |
Line 314 ENDENTERKEY
|
Line 359 ENDENTERKEY
|
} |
} |
} |
} |
# Are we allowed to look at the first resource? |
# Are we allowed to look at the first resource? |
if (!&Apache::lonnet::allowed('bre',$furl)) { |
if ($furl !~ m|^/adm/|) { |
# Guess not ... |
# Guess not ... |
$furl=&Apache::lonpageflip::first_accessible_resource(); |
$furl=&Apache::lonpageflip::first_accessible_resource(); |
} |
} |
$msg = &mt('Entering [_1] ...',lc($type)); |
$msg = &mt('Entering [_1] ...', |
&redirect_user($r,&mt('Entering [_1]',$type), |
$env{'course.'.$courseid.'.description'}); |
|
&redirect_user($r,&mt('Entering [_1]', |
|
$env{'course.'.$courseid.'.description'}), |
$furl,$msg, |
$furl,$msg, |
$env{'environment.remotenavmap'}); |
$env{'environment.remotenavmap'}); |
} |
} |
Line 364 ENDENTERKEY
|
Line 411 ENDENTERKEY
|
my $start_page=&Apache::loncommon::start_page('User Roles'); |
my $start_page=&Apache::loncommon::start_page('User Roles'); |
my $standby=&mt('Role selected. Please stand by.'); |
my $standby=&mt('Role selected. Please stand by.'); |
$standby=~s/\n/\\n/g; |
$standby=~s/\n/\\n/g; |
my $helptag='<table><tr><td>'.&Apache::loncommon::help_open_menu('','General Intro','General_Intro','User Roles',1,undef,undef,undef,undef,,&mt("Click here for help")).'</td></td></tr></table>'; |
my $noscript='<span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />'; |
|
|
$r->print(<<ENDHEADER); |
$r->print(<<ENDHEADER); |
$start_page |
$start_page |
$helptag<br /> |
<br /> |
<script> |
<noscript> |
|
$noscript |
|
</noscript> |
|
<script type="text/javascript"> |
$swinfo |
$swinfo |
window.focus(); |
window.focus(); |
|
|
Line 405 ENDHEADER
|
Line 456 ENDHEADER
|
# -------------------------------------------------------- Generate Page Output |
# -------------------------------------------------------- Generate Page Output |
# --------------------------------------------------------------- Error Header? |
# --------------------------------------------------------------- Error Header? |
if ($error) { |
if ($error) { |
$r->print("<h1>LON-CAPA Access Control</h1>"); |
$r->print("<h1>".&mt('LON-CAPA Access Control')."</h1>"); |
$r->print("<!-- LONCAPAACCESSCONTROLERRORSCREEN --><hr /><pre>Access : ". |
$r->print("<!-- LONCAPAACCESSCONTROLERRORSCREEN --><hr /><pre>"); |
Apache::lonnet::plaintext($priv)."\n"); |
if ($priv ne '') { |
$r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n"); |
$r->print(&mt('Access : ').&Apache::lonnet::plaintext($priv)."\n"); |
$r->print("Action : $msg\n</pre><hr />"); |
} |
|
if ($fn ne '') { |
|
$r->print(&mt('Resource: ').&Apache::lonenc::check_encrypt($fn)."\n"); |
|
} |
|
if ($msg ne '') { |
|
$r->print(&mt('Action : ').$msg."\n"); |
|
} |
|
$r->print("</pre><hr />"); |
my $url=$fn; |
my $url=$fn; |
my $last; |
my $last; |
if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db', |
if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db', |
Line 424 ENDHEADER
|
Line 482 ENDHEADER
|
} else { |
} else { |
if ($env{'user.error.msg'}) { |
if ($env{'user.error.msg'}) { |
$r->print( |
$r->print( |
'<h3><font color="red">'. |
'<h3><span class="LC_error">'. |
&mt('You need to choose another user role or enter a specific course for this function').'</font></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) { |
$r->print("<h2>".&mt('Sorry ...')."</h2>\n". |
$r->print("<h2>".&mt('Sorry ...')."</h2>\n<span class='LC_error'>". |
&mt('This action is currently not authorized.'). |
&mt('This action is currently not authorized.').'</span>'. |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} else { |
} else { |
if ($advanced) { |
|
$r->print(&mt("Your home server is "). |
|
$Apache::lonnet::hostname{&Apache::lonnet::homeserver |
|
($env{'user.name'},$env{'user.domain'})}. |
|
"<br />\n"); |
|
$r->print(&mt( |
|
"Author and Co-Author roles are not available on servers other than their respective home servers.")); |
|
} |
|
if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) { |
if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) { |
$fn.='?'.$ENV{'REDIRECT_QUERY_STRING'}; |
$fn.='?'.$ENV{'REDIRECT_QUERY_STRING'}; |
} |
} |
Line 451 ENDHEADER
|
Line 501 ENDHEADER
|
$r->print('<input type="hidden" name="selectrole" value="1" />'); |
$r->print('<input type="hidden" name="selectrole" value="1" />'); |
$r->print('<input type="hidden" name="newrole" value="" />'); |
$r->print('<input type="hidden" name="newrole" value="" />'); |
} |
} |
if ($env{'user.adv'}) { |
|
$r->print( |
|
'<br /><label>'.&mt('Show all roles').': <input type="checkbox" name="showall"'); |
|
if ($env{'form.showall'}) { $r->print(' checked="checked" '); } |
|
$r->print(' /></label><input type="submit" value="'.&mt('Display').'" />'); |
|
} |
|
|
|
my (%roletext,%sortrole,%roleclass); |
my (%roletext,%sortrole,%roleclass); |
my $countactive=0; |
my $countactive=0; |
|
my $countfuture=0; |
|
my $countwill=0; |
my $inrole=0; |
my $inrole=0; |
my $possiblerole=''; |
my $possiblerole=''; |
|
my %futureroles; |
|
my %roles_nextlogin; |
foreach $envkey (sort keys %env) { |
foreach $envkey (sort keys %env) { |
my $button = 1; |
my $button = 1; |
my $switchserver=''; |
my $switchserver=''; |
Line 485 ENDHEADER
|
Line 532 ENDHEADER
|
$tstatus='selected'; |
$tstatus='selected'; |
} |
} |
my $tbg; |
my $tbg; |
if (($tstatus eq 'is') || ($tstatus eq 'selected') || |
if (($tstatus eq 'is') |
($env{'form.showall'})) { |
|| ($tstatus eq 'selected') |
|
|| ($tstatus eq 'will') |
|
|| ($tstatus eq 'future') |
|
|| ($env{'form.showall'})) { |
if ($tstatus eq 'is') { |
if ($tstatus eq 'is') { |
$tbg='#77FF77'; |
$tbg='#77FF77'; |
$tfont='#003300'; |
$tfont='#003300'; |
Line 495 ENDHEADER
|
Line 545 ENDHEADER
|
} elsif ($tstatus eq 'future') { |
} elsif ($tstatus eq 'future') { |
$tbg='#FFFF77'; |
$tbg='#FFFF77'; |
$button=0; |
$button=0; |
|
$futureroles{$trolecode} = $tstart.':'.$tend; |
|
$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; |
|
$countwill ++; |
} elsif ($tstatus eq 'expired') { |
} elsif ($tstatus eq 'expired') { |
$tbg='#FF7777'; |
$tbg='#FF7777'; |
$tfont='#330000'; |
$tfont='#330000'; |
Line 518 ENDHEADER
|
Line 572 ENDHEADER
|
if ($tremark) { $tremark.='<br />'; } |
if ($tremark) { $tremark.='<br />'; } |
$tremark.=&mt('Defined by ').$rauthor. |
$tremark.=&mt('Defined by ').$rauthor. |
&mt(' at ').$rdomain.'.'; |
&mt(' at ').$rdomain.'.'; |
$trole=$rrole; |
} |
} else { |
$trole=Apache::lonnet::plaintext($role); |
$trole=Apache::lonnet::plaintext($role); |
|
} |
|
my $ttype; |
my $ttype; |
my $twhere; |
my $twhere; |
my ($tdom,$trest,$tsection)= |
my ($tdom,$trest,$tsection)= |
Line 537 ENDHEADER
|
Line 589 ENDHEADER
|
$switchserver='otherserver='.$home.'&role='.$trolecode; |
$switchserver='otherserver='.$home.'&role='.$trolecode; |
} |
} |
#next if ($home eq 'no_host'); |
#next if ($home eq 'no_host'); |
$home = $Apache::lonnet::hostname{$home}; |
$home = &Apache::lonnet::hostname($home); |
$ttype='Construction Space'; |
$ttype='Construction Space'; |
$twhere=&mt('User').': '.$trest.'<br />'.&mt('Domain'). |
$twhere=&mt('User').': '.$trest.'<br />'.&mt('Domain'). |
': '.$tdom.'<br />'. |
': '.$tdom.'<br />'. |
Line 557 ENDHEADER
|
Line 609 ENDHEADER
|
$switchserver='otherserver='.$home.'&role='.$trolecode; |
$switchserver='otherserver='.$home.'&role='.$trolecode; |
} |
} |
#next if ($home eq 'no_host'); |
#next if ($home eq 'no_host'); |
$home = $Apache::lonnet::hostname{$home}; |
$home = &Apache::lonnet::hostname($home); |
$ttype='Construction Space'; |
$ttype='Construction Space'; |
$twhere=&mt('Domain').': '.$tdom.'<br />'.&mt('Server'). |
$twhere=&mt('Domain').': '.$tdom.'<br />'.&mt('Server'). |
': '.$home; |
': '.$home; |
Line 595 ENDHEADER
|
Line 647 ENDHEADER
|
} |
} |
} |
} |
if ($tsection) { |
if ($tsection) { |
$twhere.='<br />'.&mt('Section/Group').': '.$tsection; |
$twhere.='<br />'.&mt('Section').': '.$tsection; |
} |
} |
if ($role ne 'st') { $twhere.="<br />".&mt('Domain').":".$tdom; } |
if ($role ne 'st') { $twhere.="<br />".&mt('Domain').":".$tdom; } |
} elsif ($tdom) { |
} elsif ($tdom) { |
Line 615 ENDHEADER
|
Line 667 ENDHEADER
|
} |
} |
} |
} |
} |
} |
|
if ($env{'user.adv'}) { |
|
$r->print( |
|
'<br /><span class="LC_rolesinfo"><label>'.&mt('Show all roles').': <input type="checkbox" name="showall"'); |
|
if ($env{'form.showall'}) { $r->print(' checked="checked" '); } |
|
$r->print(' /></label><input type="submit" value="'.&mt('Display').'" /></span>'); |
|
} else { |
|
if ($countactive > 0) { |
|
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
|
$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>'); |
|
} |
|
} |
|
|
# No active roles |
# No active roles |
if ($countactive==0) { |
if ($countactive==0) { |
if ($inrole) { |
if ($inrole) { |
Line 622 ENDHEADER
|
Line 686 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>'); |
} |
} |
$r->print('</form>'.&Apache::loncommon::end_page()); |
&findcourse_advice($r); |
|
$r->print('</form>'); |
|
if ($countfuture) { |
|
$r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture)); |
|
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole, |
|
$nochoose); |
|
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles, |
|
\%roletext); |
|
my $tremark=''; |
|
my $tfont='#003300'; |
|
if ($env{'request.role'} eq 'cm') { |
|
$r->print('<tr bgcolor="#11CC55">'); |
|
$tremark=&mt('Currently selected. '); |
|
$tfont='#002200'; |
|
} else { |
|
$r->print('<tr bgcolor="#77FF77">'); |
|
} |
|
$r->print('<td></td><td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified'). |
|
'</span></font></td><td><font color="'.$tfont.'">'.$tremark. |
|
' </font></td></tr>'."\n"); |
|
|
|
$r->print('</table>'); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
# Is there only one choice? |
# Is there only one choice? |
} elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) { |
} elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) { |
$r->print('<h3>'.&mt('Please stand by.').'</h3>'. |
$r->print('<h3>'.&mt('Please stand by.').'</h3>'. |
'<input type="hidden" name="'.$possiblerole.'" value="1" />'); |
'<input type="hidden" name="'.$possiblerole.'" value="1" />'. |
|
'<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>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; |
} |
} |
# More than one possible role |
# More than one possible role |
# ----------------------------------------------------------------------- Table |
# ----------------------------------------------------------------------- Table |
unless (($advanced) || ($nochoose)) { |
unless ((!&Apache::lonmenu::show_course()) || ($nochoose)) { |
$r->print("<h2>".&mt('Select a Course/Group to Enter')."</h2>\n"); |
$r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n"); |
} |
} |
$r->print('<br /><table><tr>'); |
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose); |
unless ($nochoose) { $r->print('<th> </th>'); } |
|
$r->print('<th>'.&mt('User Role').'</th><th>'.&mt('Extent'). |
|
'</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th></tr>'."\n"); |
|
my $doheaders=-1; |
|
foreach my $type ('Domain','Construction Space','Course','Group','Unavailable','System') { |
|
my $haverole=0; |
|
foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) { |
|
if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { |
|
$haverole=1; |
|
} |
|
} |
|
if ($haverole) { $doheaders++; } |
|
} |
|
|
|
if ($env{'environment.recentroles'}) { |
if ($env{'environment.recentroles'}) { |
my %recent_roles = |
my %recent_roles = |
&Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'}); |
&Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'}); |
Line 661 ENDHEADER
|
Line 735 ENDHEADER
|
foreach (sort(keys(%recent_roles))) { |
foreach (sort(keys(%recent_roles))) { |
if (defined($roletext{'user.role.'.$_})) { |
if (defined($roletext{'user.role.'.$_})) { |
$output.=$roletext{'user.role.'.$_}; |
$output.=$roletext{'user.role.'.$_}; |
if ($_ =~ m-dc\./(\w+)/- && $dcroles{$1}) { |
if ($_ =~ m-dc\./($match_domain)/- |
$output .= &allcourses_row($1,'recent'); |
&& $dcroles{$1}) { |
|
$output .= &adhoc_roles_row($1,'recent'); |
} |
} |
} elsif ($numdc > 0) { |
} elsif ($numdc > 0) { |
unless ($_ =~/^error\:/) { |
unless ($_ =~/^error\:/) { |
Line 672 ENDHEADER
|
Line 747 ENDHEADER
|
} |
} |
if ($output) { |
if ($output) { |
$r->print("<tr><td align='center' colspan='5'><font face='arial'>". |
$r->print("<tr><td align='center' colspan='5'><font face='arial'>". |
&mt('Recent Roles')."</font></td>"); |
&mt('Recent Roles')."</font></td></tr>"); |
$r->print($output); |
$r->print($output); |
$r->print("</tr>"); |
|
$doheaders ++; |
$doheaders ++; |
} |
} |
} |
} |
|
|
if ($numdc > 0) { |
if ($numdc > 0) { |
$r->print(&coursepick_jscript()); |
$r->print(&coursepick_jscript()); |
$r->print(&Apache::loncommon::coursebrowser_javascript()); |
$r->print(&Apache::loncommon::coursebrowser_javascript(). |
} |
&Apache::loncommon::authorbrowser_javascript()); |
foreach my $type ('Construction Space','Domain','Course','Group','Unavailable','System') { |
|
my $output; |
|
foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) { |
|
if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { |
|
$output.=$roletext{$sortrole{$which}}; |
|
if ($sortrole{$which} =~ m-dc\./(\w+)/-) { |
|
if ($dcroles{$1}) { |
|
$output .= &allcourses_row($1,''); |
|
} |
|
} |
|
} |
|
} |
|
if ($output) { |
|
if ($doheaders > 0) { |
|
$r->print("<tr>". |
|
"<td align='center' colspan='5'><font face='arial'>".&mt($type)."</font></td></tr>"); |
|
} |
|
$r->print($output); |
|
} |
|
} |
} |
|
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext); |
my $tremark=''; |
my $tremark=''; |
my $tfont='#003300'; |
my $tfont='#003300'; |
if ($env{'request.role'} eq 'cm') { |
if ($env{'request.role'} eq 'cm') { |
Line 715 ENDHEADER
|
Line 771 ENDHEADER
|
unless ($nochoose) { |
unless ($nochoose) { |
if ($env{'request.role'} ne 'cm') { |
if ($env{'request.role'} ne 'cm') { |
$r->print('<td><input type="submit" value="'. |
$r->print('<td><input type="submit" value="'. |
&mt('Select').'" name="cm"></td>'); |
&mt('Select').'" name="cm" /></td>'); |
} else { |
} else { |
$r->print('<td> </td>'); |
$r->print('<td> </td>'); |
} |
} |
} |
} |
$r->print('<td colspan="3"><font color="'.$tfont.'">'.&mt('No role specified'). |
$r->print('<td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified'). |
'</font></td><td><font color="'.$tfont.'">'.$tremark. |
'</span></font></td><td><font color="'.$tfont.'">'.$tremark. |
' </font></td></tr>'."\n"); |
' </font></td></tr>'."\n"); |
|
|
$r->print('</table>'); |
$r->print('</table>'); |
Line 731 ENDHEADER
|
Line 787 ENDHEADER
|
# ------------------------------------------------------------ Privileges Info |
# ------------------------------------------------------------ Privileges Info |
if (($advanced) && (($env{'user.error.msg'}) || ($error))) { |
if (($advanced) && (($env{'user.error.msg'}) || ($error))) { |
$r->print('<hr /><h2>Current Privileges</h2>'); |
$r->print('<hr /><h2>Current Privileges</h2>'); |
|
$r->print(&privileges_info()); |
|
} |
|
$r->print(&Apache::lonnet::getannounce()); |
|
if ($advanced) { |
|
$r->print('<p><small><i>' |
|
.&mt('This is LON-CAPA [_1]',$r->dir_config('lonVersion')) |
|
.'</i><br />' |
|
.'<a href="/adm/logout">'.&mt('Logout').'</a></small></p>'); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
return OK; |
|
} |
|
|
foreach $envkey (sort keys %env) { |
sub roletable_headers { |
if ($envkey=~/^user\.priv\.$env{'request.role'}\./) { |
my ($r,$roleclass,$sortrole,$nochoose) = @_; |
my $where=$envkey; |
my $doheaders; |
$where=~s/^user\.priv\.$env{'request.role'}\.//; |
if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) { |
my $ttype; |
$r->print('<br /><table id="LC_rolesmenu"><tr>'); |
my $twhere; |
if (!$nochoose) { $r->print('<th> </th>'); } |
my ($tdom,$trest,$tsec)= |
$r->print('<th>'.&mt('User Role').'</th><th>'.&mt('Extent') |
split(/\//,Apache::lonnet::declutter($where)); |
.'</th><th>'.&mt('Start').'</th><th>'.&mt('End') |
if ($trest) { |
.'</th></tr>'."\n"); |
if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') { |
$doheaders=-1; |
$ttype='Construction Space'; |
my @roletypes = &roletypes(); |
$twhere='User: '.$trest.', Domain: '.$tdom; |
foreach my $type (@roletypes) { |
} else { |
my $haverole=0; |
$ttype='Course'; |
foreach my $which (sort {uc($a) cmp uc($b)} (keys(%{$sortrole}))) { |
if (defined($env{'course.'.$tdom.'_'.$trest.'.type'})) { |
if ($roleclass->{$sortrole->{$which}} =~ /^\Q$type\E/) { |
$ttype = $env{'course.'.$tdom.'_'.$trest.'.type'}; |
$haverole=1; |
|
} |
|
} |
|
if ($haverole) { $doheaders++; } |
|
} |
|
} |
|
return $doheaders; |
|
} |
|
|
|
sub roletypes { |
|
my @types = ('Domain','Construction Space','Course','Unavailable','System'); |
|
return @types; |
|
} |
|
|
|
sub print_rolerows { |
|
my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext) = @_; |
|
if ((ref($roleclass) eq 'HASH') && (ref($sortrole) eq 'HASH')) { |
|
my @types = &roletypes(); |
|
foreach my $type (@types) { |
|
my $output; |
|
foreach my $which (sort {uc($a) cmp uc($b)} (keys(%{$sortrole}))) { |
|
if ($roleclass->{$sortrole->{$which}} =~ /^\Q$type\E/) { |
|
if (ref($roletext) eq 'HASH') { |
|
$output.=$roletext->{$sortrole->{$which}}; |
|
if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) { |
|
if (ref($dcroles) eq 'HASH') { |
|
if ($dcroles->{$1}) { |
|
$output .= &adhoc_roles_row($1,''); |
|
} |
|
} |
} |
} |
$twhere=$env{'course.'.$tdom.'_'.$trest.'.description'}; |
} |
if ($tsec) { |
} |
$twhere.=' (Section: '.$tsec.')'; |
} |
} |
if ($output) { |
} |
if ($doheaders > 0) { |
} elsif ($tdom) { |
$r->print("<tr>". |
$ttype='Domain'; |
"<td align='center' colspan='5'><font face='arial'>". |
$twhere=$tdom; |
&mt($type)."</font></td></tr>"); |
} else { |
} |
$ttype='System'; |
$r->print($output); |
$twhere='/'; |
} |
} |
} |
$r->print("\n<h3>".$ttype.': '.$twhere.'</h3><ul>'); |
} |
foreach (sort split(/:/,$env{$envkey})) { |
} |
if ($_) { |
|
my ($prv,$restr)=split(/\&/,$_); |
sub findcourse_advice { |
my $trestr=''; |
my ($r) = @_; |
if ($restr ne 'F') { |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $i; |
if (&check_autoenroll($env{'user.domain'})) { |
$trestr.=' ('; |
$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).' |
for ($i=0;$i<length($restr);$i++) { |
<ul> |
$trestr.= |
<li>'.&mt('The course has yet to be created.').'</li> |
Apache::lonnet::plaintext(substr($restr,$i,1)); |
<li>'.&mt('Automatic enrollment of registered students has not been enabled for the course.').'</li> |
if ($i<length($restr)-1) { $trestr.=', '; } |
<li>'.&mt('You are in a section of course for which automatic enrollment in the corresponding LON-CAPA course is not active.').'</li> |
} |
<li>'.&mt('The start date for automated enrollment has yet to be reached.').'</li> |
$trestr.=')'; |
<li>'.&mt('You registered for the course recently and there is a time lag between the time you register, and the time this information becomes available for the update of LON-CAPA course rosters.').'</li> |
} |
</ul>'); |
$r->print('<li>'. |
} else { |
Apache::lonnet::plaintext($prv).$trestr. |
$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 />'); |
'</li>'); |
} |
|
$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 />'); |
|
$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; |
|
} |
|
|
|
sub privileges_info { |
|
my ($which) = @_; |
|
my $output; |
|
|
|
$which ||= $env{'request.role'}; |
|
|
|
foreach my $envkey (sort(keys(%env))) { |
|
next if ($envkey!~/^user\.priv\.\Q$which\E\.(.*)/); |
|
|
|
my $where=$1; |
|
my $ttype; |
|
my $twhere; |
|
my (undef,$tdom,$trest,$tsec)=split(m{/},$where); |
|
if ($trest) { |
|
if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') { |
|
$ttype='Construction Space'; |
|
$twhere='User: '.$trest.', Domain: '.$tdom; |
|
} else { |
|
$ttype= &Apache::loncommon::course_type($tdom.'_'.$trest); |
|
$twhere=$env{'course.'.$tdom.'_'.$trest.'.description'}; |
|
if ($tsec) { |
|
my $sec_type = 'Section'; |
|
if (exists($env{"user.role.gr.$where"})) { |
|
$sec_type = 'Group'; |
} |
} |
|
$twhere.=' ('.$sec_type.': '.$tsec.')'; |
} |
} |
$r->print('</ul>'); |
|
} |
} |
|
} elsif ($tdom) { |
|
$ttype='Domain'; |
|
$twhere=$tdom; |
|
} else { |
|
$ttype='System'; |
|
$twhere='/'; |
} |
} |
|
$output .= "\n<h3>".$ttype.': '.$twhere.'</h3>'."\n<ul>"; |
|
foreach my $priv (sort(split(/:/,$env{$envkey}))) { |
|
next if (!$priv); |
|
|
|
my ($prv,$restr)=split(/\&/,$priv); |
|
my $trestr=''; |
|
if ($restr ne 'F') { |
|
$trestr.=' ('. |
|
join(', ', |
|
map { &Apache::lonnet::plaintext($_) } |
|
(split('',$restr))).') '; |
|
} |
|
$output .= "\n\t". |
|
'<li>'.&Apache::lonnet::plaintext($prv).$trestr.'</li>'; |
|
} |
|
$output .= "\n".'</ul>'; |
} |
} |
$r->print(&Apache::lonnet::getannounce()); |
return $output; |
if ($advanced) { |
|
$r->print('<p><small><i>This is LON-CAPA '. |
|
$r->dir_config('lonVersion').'</i><br />'. |
|
'<a href="/adm/logout">'.&mt('Logout').'</a></small></p>'); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
return OK; |
|
} |
} |
|
|
sub role_status { |
sub role_status { |
Line 822 sub role_status {
|
Line 963 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) = @_; |
my $roletext='<tr bgcolor="'.$tbg.'">'; |
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) ? '' |
: ' rowspan="2" '; |
: ' rowspan="2" '; |
Line 832 sub build_roletext {
|
Line 973 sub build_roletext {
|
$buttonname=~s/\W//g; |
$buttonname=~s/\W//g; |
if (!$button) { |
if (!$button) { |
if ($switchserver) { |
if ($switchserver) { |
$roletext.='<td'.$rowspan.'><a href="/adm/switchserver?'. |
$roletext.='<td'.$rowspan.'><span class="LC_rolesinfo"><a href="/adm/switchserver?'. |
$switchserver.'">'.&mt('Switch Server').'</a></td>'; |
$switchserver.'">'.&mt('Switch Server').'</a></span></td>'; |
} else { |
} else { |
$roletext.=('<td> </td>'); |
$roletext.=('<td'.$rowspan.'> </td>'); |
} |
} |
} elsif ($tstatus eq 'is') { |
} elsif ($tstatus eq 'is') { |
$roletext.='<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
$roletext.='<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
&mt('Select').'" onClick="javascript:enterrole(this.form,\''. |
&mt('Select').'" onClick="javascript:enterrole(this.form,\''. |
$trolecode."','".$buttonname.'\');"></td>'; |
$trolecode."','".$buttonname.'\');" /></td>'; |
} elsif ($tryagain) { |
} elsif ($tryagain) { |
$roletext.= |
$roletext.= |
'<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
'<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
&mt('Try Selecting Again').'" onClick="javascript:enterrole(this.form,\''. |
&mt('Try Selecting Again').'" onClick="javascript:enterrole(this.form,\''. |
$trolecode."','".$buttonname.'\');"></td>'; |
$trolecode."','".$buttonname.'\');" /></td>'; |
} 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-Initialize').'" onClick="javascript:enterrole(this.form,\''. |
$trolecode."','".$buttonname.'\');"></td>'; |
$trolecode."','".$buttonname.'\');" /></td>'; |
} else { |
} else { |
$roletext.='<td'.$rowspan.'> </td>'; |
$roletext.='<td'.$rowspan.'> </td>'; |
} |
} |
} |
} |
$tremark.=&Apache::lonannounce::showday(time,1, |
if ($trolecode !~ m/^(dc|ca|au|aa)\./) { |
&Apache::lonannounce::readcalendar($tdom.'_'.$trest)); |
$tremark.=&Apache::lonannounce::showday(time,1, |
|
&Apache::lonannounce::readcalendar($tdom.'_'.$trest)); |
|
} |
$roletext.='<td><font color="'.$tfont.'">'.$trole. |
$roletext.='<td><font color="'.$tfont.'">'.$trole. |
'</font></td><td><font color="'.$tfont.'">'.$twhere. |
'</font></td><td><font color="'.$tfont.'">'.$twhere. |
'</font></td><td><font color="'.$tfont.'">'.$tpstart. |
'</font></td><td><font color="'.$tfont.'">'.$tpstart. |
'</font></td><td><font color="'.$tfont.'">'.$tpend. |
'</font></td><td><font color="'.$tfont.'">'.$tpend. |
'</font></td></tr>'; |
'</font></td></tr>'; |
if (!$is_dc) { |
if (!$is_dc) { |
$roletext.='<tr bgcolor="'.$tbg.'"><td colspan="4"><font color="'.$tfont.'">'.$tremark. |
$roletext.='<tr bgcolor="'.$tbg.'"><td colspan="4"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.$tremark. |
' </font></td></tr><tr><td colspan="5" height="3"></td></tr>'."\n"; |
'</span> </font></td></tr><tr><td colspan="5" height="3"></td></tr>'."\n"; |
} |
} |
return $roletext; |
return $roletext; |
} |
} |
|
|
|
sub check_author_homeserver { |
|
my ($uname,$udom)=@_; |
|
if (($uname eq '') || ($udom eq '')) { |
|
return ('fail',''); |
|
} |
|
my $home = &Apache::lonnet::homeserver($uname,$udom); |
|
if (&Apache::lonnet::host_domain($home) ne $udom) { |
|
return ('fail',$home); |
|
} |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
if (grep(/^\Q$home\E$/,@ids)) { |
|
return ('ok',$home); |
|
} else { |
|
return ('switchserver',$home); |
|
} |
|
} |
|
|
sub check_privs { |
sub check_privs { |
my ($cdom,$cnum,$then,$now) = @_; |
my ($cdom,$cnum,$then,$now,$checkrole) = @_; |
my $cckey = 'user.role.cc./'.$cdom.'/'.$cnum; |
my $cckey = 'user.role.'.$checkrole.'./'.$cdom.'/'.$cnum; |
if ($env{$cckey}) { |
if ($env{$cckey}) { |
my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont); |
my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont); |
&role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend); |
&role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend); |
unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) { |
unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) { |
&set_privileges($cdom,$cnum); |
&set_privileges($cdom,$cnum,$checkrole); |
} |
} |
} else { |
} else { |
&set_privileges($cdom,$cnum); |
&set_privileges($cdom,$cnum,$checkrole); |
} |
} |
} |
} |
|
|
Line 889 sub check_fordc {
|
Line 1048 sub check_fordc {
|
my $numdc = 0; |
my $numdc = 0; |
if ($env{'user.adv'}) { |
if ($env{'user.adv'}) { |
foreach my $envkey (sort keys %env) { |
foreach my $envkey (sort keys %env) { |
if ($envkey=~/^user\.role\.dc\.\/(\w+)\/$/) { |
if ($envkey=~/^user\.role\.dc\.\/($match_domain)\/$/) { |
my $dcdom = $1; |
my $dcdom = $1; |
my $livedc = 1; |
my $livedc = 1; |
my ($tstart,$tend)=split(/\./,$env{$envkey}); |
my ($tstart,$tend)=split(/\./,$env{$envkey}); |
Line 905 sub check_fordc {
|
Line 1064 sub check_fordc {
|
return $numdc; |
return $numdc; |
} |
} |
|
|
|
sub adhoc_course_role { |
|
my ($then) = @_; |
|
my ($cdom,$cnum); |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
if (&check_forcc($cdom,$cnum,$then)) { |
|
my $setprivs; |
|
if (!defined($env{'user.role.'.$env{'form.selectrole'}})) { |
|
$setprivs = 1; |
|
} else { |
|
my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.selectrole'}}); |
|
if (($start && ($start>$then || $start == -1)) || |
|
($end && $end<$then)) { |
|
$setprivs = 1; |
|
} |
|
} |
|
if ($setprivs) { |
|
if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E(/?\w*)$-) { |
|
my $role = $1; |
|
my $custom_role = $2; |
|
my $usec = $3; |
|
if ($role eq 'cr') { |
|
if ($custom_role =~ m-^$match_domain/$match_courseid/\w+$-) { |
|
$role .= $custom_role; |
|
} else { |
|
return; |
|
} |
|
} |
|
my (%userroles,%newrole,%newgroups); |
|
my $area = '/'.$cdom.'/'.$cnum; |
|
my $spec = $role.'.'.$area; |
|
if ($usec ne '') { |
|
$spec .= '/'.$usec; |
|
$area .= '/'.$usec; |
|
} |
|
&Apache::lonnet::standard_roleprivs(\%newrole,$role,$cdom,$spec,$cnum,$area); |
|
&Apache::lonnet::set_userprivs(\%userroles,\%newrole,%newgroups); |
|
my $adhocstart = $then-1; |
|
$userroles{'user.role.'.$spec} = $adhocstart.'.'; |
|
&Apache::lonnet::appenv(\%userroles,[$role,'cm']); |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub check_forcc { |
|
my ($cdom,$cnum,$then) = @_; |
|
my $is_cc; |
|
if ($cdom ne '' && $cnum ne '') { |
|
if (&Apache::lonnet::is_course($cdom,$cnum)) { |
|
my $envkey = 'user.role.cc./'.$cdom.'/'.$cnum; |
|
if (defined($env{$envkey})) { |
|
$is_cc = 1; |
|
my ($tstart,$tend)=split(/\./,$env{$envkey}); |
|
if ($tstart && $tstart>$then) { $is_cc = 0; } |
|
if ($tend && $tend <$then) { $is_cc = 0; } |
|
} |
|
} |
|
} |
|
return $is_cc; |
|
} |
|
|
sub courselink { |
sub courselink { |
my ($dcdom,$rowtype,$selecttype) = @_; |
my ($dcdom,$rowtype) = @_; |
my $courseform=&Apache::loncommon::selectcourse_link |
my $courseform=&Apache::loncommon::selectcourse_link |
('rolechoice','dccourse'.$rowtype.'_'.$dcdom, |
('rolechoice','dccourse'.$rowtype.'_'.$dcdom, |
'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'. |
'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'. |
$dcdom,$dcdom,undef,$selecttype); |
$dcdom,$dcdom,undef); |
my $hiddenitems = '<input type="hidden" name="dcdomain'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'. |
my $hiddenitems = '<input type="hidden" name="dcdomain'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'. |
'<input type="hidden" name="origdom'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'. |
'<input type="hidden" name="origdom'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'. |
'<input type="hidden" name="dccourse'.$rowtype.'_'.$dcdom.'" value="" />'. |
'<input type="hidden" name="dccourse'.$rowtype.'_'.$dcdom.'" value="" />'. |
Line 919 sub courselink {
|
Line 1141 sub courselink {
|
} |
} |
|
|
sub coursepick_jscript { |
sub coursepick_jscript { |
|
my %lt = &Apache::lonlocal::texthash( |
|
plsu => "Please use the 'Select Course' link to open a separate pick course window where you may select the course you wish to enter.", |
|
youc => 'You can only use this screen to select courses in the current domain.', |
|
); |
my $verify_script = <<"END"; |
my $verify_script = <<"END"; |
<script> |
<script type="text/javascript"> |
function verifyCoursePick(caller) { |
function verifyCoursePick(caller) { |
var numbutton = getIndex(caller) |
var numbutton = getIndex(caller) |
var pickedCourse = document.rolechoice.elements[numbutton+4].value |
var pickedCourse = document.rolechoice.elements[numbutton+4].value |
Line 934 function verifyCoursePick(caller) {
|
Line 1160 function verifyCoursePick(caller) {
|
} |
} |
} |
} |
else { |
else { |
alert("Please use the 'Select Course' link to open a separate pick course window where you may select the course you wish to enter."); |
alert("$lt{'plsu'}"); |
} |
} |
} |
} |
else { |
else { |
alert("You can only use this screen to select courses in the current domain") |
alert("$lt{'youc'}") |
} |
} |
} |
} |
function getIndex(caller) { |
function getIndex(caller) { |
Line 954 END
|
Line 1180 END
|
return $verify_script; |
return $verify_script; |
} |
} |
|
|
sub processpick { |
sub coauthorlink { |
my $process_pick = <<"END"; |
my ($dcdom,$rowtype) = @_; |
<script> |
my $coauthorform=&Apache::loncommon::selectauthor_link('rolechoice',$dcdom); |
function process_pick(dom) { |
my $hiddenitems = '<input type="hidden" name="adhoccauname'.$rowtype.'_'.$dcdom.'" value="" />'; |
var pickedCourse=opener.document.rolechoice.$env{'form.cnumelement'}.value; |
return $coauthorform.$hiddenitems; |
var pickedDomain=opener.document.rolechoice.$env{'form.cdomelement'}.value; |
|
var okDomain = 0; |
|
|
|
if (pickedDomain == dom) { |
|
if (pickedCourse != '') { |
|
var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse |
|
opener.document.title='Role selected. Please stand by.'; |
|
opener.status='Role selected. Please stand by.'; |
|
opener.document.rolechoice.newrole.value=courseTarget |
|
opener.document.rolechoice.submit() |
|
} |
|
} else { |
|
alert("You may only use this screen to select courses in the current domain: "+dom+"\\nPlease return to the roles page window and click the 'Select Course' link for domain: "+pickedDomain+",\\n if you are a Domain Coordinator in that domain, and wish to become a Course Coordinator in a course in the domain"); |
|
} |
|
} |
|
|
|
</script> |
|
END |
|
return $process_pick; |
|
} |
} |
|
|
sub display_cc_role { |
sub display_cc_role { |
Line 986 sub display_cc_role {
|
Line 1193 sub display_cc_role {
|
my $advanced = $env{'user.adv'}; |
my $advanced = $env{'user.adv'}; |
my $tryagain = $env{'form.tryagain'}; |
my $tryagain = $env{'form.tryagain'}; |
unless ($rolekey =~/^error\:/) { |
unless ($rolekey =~/^error\:/) { |
if ($rolekey =~ m-^user\.role.cc\./(\w+)/(\w+)$-) { |
if ($rolekey =~ m-^user\.role.cc\./($match_domain)/($match_courseid)$-) { |
my $tcourseid = $1.'_'.$2; |
my $tcourseid = $1.'_'.$2; |
my $trolecode = 'cc./'.$1.'/'.$2; |
my $trolecode = 'cc./'.$1.'/'.$2; |
my $twhere; |
my $twhere; |
Line 1012 sub display_cc_role {
|
Line 1219 sub display_cc_role {
|
return ($roletext); |
return ($roletext); |
} |
} |
|
|
sub allcourses_row { |
sub adhoc_roles_row { |
my ($dcdom,$rowtype) = @_; |
my ($dcdom,$rowtype) = @_; |
my $output = '<tr bgcolor="#77FF77">'. |
my $output = '<tr bgcolor="#77FF77">'. |
' <td colspan="5">'; |
' <td colspan="5"><table><tr><td><span class="LC_rolesinfo">' |
foreach my $type ('Course','Group') { |
.&mt('[_1]Ad hoc[_2] roles in domain [_3] --', |
my $selectlink = &courselink($dcdom,$rowtype,$type); |
'<span class="LC_cusr_emph">','</span>',$dcdom).'</span></td><td>'; |
my $ccrole = &Apache::lonnet::plaintext('cc',$type); |
my $selectcclink = &courselink($dcdom,$rowtype); |
$output.= '<font color="#002200">'.$ccrole.'</font>'. |
my $ccrole = &Apache::lonnet::plaintext('cc'); |
' <b>'.$selectlink.'</b>'. |
my $carole = &Apache::lonnet::plaintext('ca'); |
' from '.&mt('Domain').' '.$dcdom.'<br />'; |
my $selectcalink = &coauthorlink($dcdom,$rowtype); |
} |
$output.= '<span class="LC_rolesinfo">'. |
$output .= '</tr><tr><td colspan="5" height="3"></td></tr>'."\n"; |
&mt('[_1]: [_2]',$ccrole,$selectcclink). |
|
'</span><br /></td><td> </td><td><span class="LC_rolesinfo">'. |
|
&mt('[_1]: [_2]',$carole,$selectcalink). |
|
'</span><br /></td></tr></table></td></tr>'. |
|
'<tr><td colspan="5" height="3"></td></tr>'."\n"; |
return $output; |
return $output; |
} |
} |
|
|
Line 1033 sub recent_filename {
|
Line 1244 sub recent_filename {
|
} |
} |
|
|
sub set_privileges { |
sub set_privileges { |
my ($dcdom,$pickedcourse) = @_; |
# role can be cc or ca |
|
my ($dcdom,$pickedcourse,$role) = @_; |
my $area = '/'.$dcdom.'/'.$pickedcourse; |
my $area = '/'.$dcdom.'/'.$pickedcourse; |
my $role = 'cc'; |
|
my $spec = $role.'.'.$area; |
my $spec = $role.'.'.$area; |
my %userroles = &Apache::lonnet::set_arearole($role,$area,'','',$dcdom,$env{'user.name'}); |
my %userroles = &Apache::lonnet::set_arearole($role,$area,'','', |
|
$env{'user.domain'}, |
|
$env{'user.name'}); |
my %ccrole = (); |
my %ccrole = (); |
&Apache::lonnet::standard_roleprivs(\%ccrole,$role,$dcdom,$spec,$pickedcourse,$area); |
&Apache::lonnet::standard_roleprivs(\%ccrole,$role,$dcdom,$spec,$pickedcourse,$area); |
my ($author,$adv)= &Apache::lonnet::set_userprivs(\%userroles,\%ccrole); |
my ($author,$adv)= &Apache::lonnet::set_userprivs(\%userroles,\%ccrole); |
&Apache::lonnet::appenv(%userroles); |
&Apache::lonnet::appenv(\%userroles,[$role,'cm']); |
|
|
&Apache::lonnet::log($env{'user.domain'}, |
&Apache::lonnet::log($env{'user.domain'}, |
$env{'user.name'}, |
$env{'user.name'}, |
$env{'user.home'}, |
$env{'user.home'}, |
"Role ".$role); |
"Role ".$role); |
&Apache::lonnet::appenv( |
&Apache::lonnet::appenv( |
'request.role' => $spec, |
{'request.role' => $spec, |
'request.role.domain' => $dcdom, |
'request.role.domain' => $dcdom, |
'request.course.sec' => ''); |
'request.course.sec' => ''}); |
my $tadv=0; |
my $tadv=0; |
if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; } |
if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; } |
&Apache::lonnet::appenv('request.role.adv' => $tadv); |
&Apache::lonnet::appenv({'request.role.adv' => $tadv}); |
} |
} |
|
|
sub courseloadpage { |
sub courseloadpage { |
Line 1072 sub courseloadpage {
|
Line 1286 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__ |
|
|