version 1.155, 2006/06/02 22:02:51
|
version 1.209.4.2, 2009/09/23 19:42:20
|
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); |
|
use HTML::Entities; |
|
|
|
|
sub redirect_user { |
sub redirect_user { |
Line 53 sub redirect_user {
|
Line 55 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 90 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 107 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}) { |
if ($dcroles{$domain}) { |
&check_privs($domain,$coursenum,$then,$now); |
&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)$-)) { |
|
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); |
|
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}) { |
|
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 212 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 227 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 187 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 198 sub handler {
|
Line 266 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 289 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 310 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 324 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 332 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 360 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'}; |
|
if ($env{'form.destsymb'} ne '') { |
|
my $esc_symb = &HTML::Entities::encode($env{'form.destsymb'},'"<>&'); |
|
$dest .= '?symb='.$esc_symb; |
|
} |
|
&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 380 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 390 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 442 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 401 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? |
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 423 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) { |
'<h3><font color="red">'. |
$r->print( |
&mt('You need to choose another user role or enter a specific course for this function').'</font></h3>'); |
'<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">'. |
|
&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 540 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; |
|
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 471 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'; |
} |
} |
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 591 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'; |
$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=$rrole; |
$trole=Apache::lonnet::plaintext($role); |
} else { |
|
$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 634 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 654 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 692 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 607 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 615 ENDHEADER
|
Line 712 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 $queuetotal = &queued_selfenrollment($r); |
|
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>'); |
|
} |
|
} |
|
} |
|
|
# No active roles |
# No active roles |
if ($countactive==0) { |
if ($countactive==0) { |
if ($inrole) { |
if ($inrole) { |
Line 622 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>'); |
} |
} |
$r->print('</form>'.&Apache::loncommon::end_page()); |
&findcourse_advice($r,$numcourses); |
return OK; |
$r->print('</form>'); |
# Is there only one choice? |
if ($countfuture) { |
} elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) { |
$r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture)); |
$r->print('<h3>'.&mt('Please stand by.').'</h3>'. |
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole, |
'<input type="hidden" name="'.$possiblerole.'" value="1" />'); |
$nochoose); |
$r->print("</form>\n"); |
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles, |
$r->rflush(); |
\%roletext); |
$r->print('<script>document.forms.rolechoice.submit();</script>'); |
my $tremark=''; |
$r->print(&Apache::loncommon::end_page()); |
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; |
|
} elsif ($countactive==1) { # Is there only one choice? |
|
my $needs_switchserver; |
|
if ($env{'user.author'}) { |
|
$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>'); |
|
$r->print("</form>\n"); |
|
$r->rflush(); |
|
$r->print('<script type="text/javascript">document.forms.rolechoice.submit();</script>'); |
|
$r->print(&Apache::loncommon::end_page()); |
|
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 (($advanced) || ($nochoose)) { |
unless ((!&Apache::lonmenu::show_course()) || ($nochoose) || ($countactive==1)) { |
$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>'); |
|
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++; } |
|
} |
} |
|
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose); |
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 794 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 806 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') { |
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext); |
my $output; |
if ($countactive > 1) { |
foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) { |
my $tremark=''; |
if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { |
my $tfont='#003300'; |
$output.=$roletext{$sortrole{$which}}; |
if ($env{'request.role'} eq 'cm') { |
if ($sortrole{$which} =~ m-dc\./(\w+)/-) { |
$r->print('<tr bgcolor="#11CC55">'); |
if ($dcroles{$1}) { |
$tremark=&mt('Currently selected.').' '; |
$output .= &allcourses_row($1,''); |
$tfont='#002200'; |
} |
} else { |
} |
$r->print('<tr bgcolor="#77FF77">'); |
} |
} |
} |
unless ($nochoose) { |
if ($output) { |
if ($env{'request.role'} ne 'cm') { |
if ($doheaders > 0) { |
$r->print('<td><input type="submit" value="'. |
$r->print("<tr>". |
&mt('Select').'" name="cm" /></td>'); |
"<td align='center' colspan='5'><font face='arial'>".&mt($type)."</font></td></tr>"); |
} else { |
|
$r->print('<td> </td>'); |
} |
} |
$r->print($output); |
} |
} |
$r->print('<td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified'). |
} |
'</span></font></td><td><font color="'.$tfont.'">'.$tremark. |
my $tremark=''; |
' </font></td></tr>'."\n"); |
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">'); |
|
} |
|
unless ($nochoose) { |
|
if ($env{'request.role'} ne 'cm') { |
|
$r->print('<td><input type="submit" value="'. |
|
&mt('Select').'" name="cm"></td>'); |
|
} else { |
|
$r->print('<td> </td>'); |
|
} |
|
} |
|
$r->print('<td colspan="3"><font color="'.$tfont.'">'.&mt('No role specified'). |
|
'</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 731 ENDHEADER
|
Line 847 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) { |
|
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
|
$r->print('<p><small><i>' |
|
.&mt('This is LON-CAPA [_1]',$r->dir_config('lonVersion')) |
|
.'</i><br />' |
|
.'<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()); |
|
return OK; |
|
} |
|
|
foreach $envkey (sort keys %env) { |
sub role_timezone { |
if ($envkey=~/^user\.priv\.$env{'request.role'}\./) { |
my ($where,$timezones) = @_; |
my $where=$envkey; |
my $timezone; |
$where=~s/^user\.priv\.$env{'request.role'}\.//; |
if (ref($timezones) eq 'HASH') { |
my $ttype; |
if ($where =~ m{^/($match_domain)/($match_courseid)}) { |
my $twhere; |
my $cdom = $1; |
my ($tdom,$trest,$tsec)= |
my $cnum = $2; |
split(/\//,Apache::lonnet::declutter($where)); |
if ($cdom && $cnum) { |
if ($trest) { |
if (!exists($timezones->{$cdom.'_'.$cnum})) { |
if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') { |
my %timehash = |
$ttype='Construction Space'; |
&Apache::lonnet::get('environment',['timezone'],$cdom,$cnum); |
$twhere='User: '.$trest.', Domain: '.$tdom; |
if ($timehash{'timezone'} eq '') { |
} else { |
if (!exists($timezones->{$cdom})) { |
$ttype='Course'; |
my %domdefaults = |
if (defined($env{'course.'.$tdom.'_'.$trest.'.type'})) { |
&Apache::lonnet::get_domain_defaults($cdom); |
$ttype = $env{'course.'.$tdom.'_'.$trest.'.type'}; |
if ($domdefaults{'timezone_def'} eq '') { |
|
$timezones->{$cdom} = 'local'; |
|
} else { |
|
$timezones->{$cdom} = $domdefaults{'timezone_def'}; |
|
} |
} |
} |
$twhere=$env{'course.'.$tdom.'_'.$trest.'.description'}; |
$timezones->{$cdom.'_'.$cnum} = $timezones->{$cdom}; |
if ($tsec) { |
} else { |
$twhere.=' (Section: '.$tsec.')'; |
$timezones->{$cdom.'_'.$cnum} = |
} |
&Apache::lonlocal::gettimezone($timehash{'timezone'}); |
} |
} |
} elsif ($tdom) { |
} |
$ttype='Domain'; |
$timezone = $timezones->{$cdom.'_'.$cnum}; |
$twhere=$tdom; |
} |
} else { |
} else { |
$ttype='System'; |
my ($tdom) = ($where =~ m{^/($match_domain)}); |
$twhere='/'; |
if ($tdom) { |
} |
if (!exists($timezones->{$tdom})) { |
$r->print("\n<h3>".$ttype.': '.$twhere.'</h3><ul>'); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($tdom); |
foreach (sort split(/:/,$env{$envkey})) { |
if ($domdefaults{'timezone_def'} eq '') { |
if ($_) { |
$timezones->{$tdom} = 'local'; |
my ($prv,$restr)=split(/\&/,$_); |
} else { |
my $trestr=''; |
$timezones->{$tdom} = $domdefaults{'timezone_def'}; |
if ($restr ne 'F') { |
} |
my $i; |
} |
$trestr.=' ('; |
$timezone = $timezones->{$tdom}; |
for ($i=0;$i<length($restr);$i++) { |
} |
$trestr.= |
} |
Apache::lonnet::plaintext(substr($restr,$i,1)); |
if ($timezone eq 'local') { |
if ($i<length($restr)-1) { $trestr.=', '; } |
$timezone = undef; |
} |
} |
$trestr.=')'; |
} |
} |
return $timezone; |
$r->print('<li>'. |
} |
Apache::lonnet::plaintext($prv).$trestr. |
|
'</li>'); |
sub roletable_headers { |
|
my ($r,$roleclass,$sortrole,$nochoose) = @_; |
|
my $doheaders; |
|
if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) { |
|
$r->print('<br /><table id="LC_rolesmenu"><tr>'); |
|
if (!$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"); |
|
$doheaders=-1; |
|
my @roletypes = &roletypes(); |
|
foreach my $type (@roletypes) { |
|
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++; } |
|
} |
|
} |
|
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,''); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($output) { |
|
if ($doheaders > 0) { |
|
$r->print("<tr>". |
|
"<td align='center' colspan='5'><font face='arial'>". |
|
&mt($type)."</font></td></tr>"); |
|
} |
|
$r->print($output); |
|
} |
|
} |
|
} |
|
} |
|
|
|
sub findcourse_advice { |
|
my ($r,$numcourses) = @_; |
|
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
|
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).' |
|
<ul> |
|
<li>'.&mt('The course has yet to be created.').'</li> |
|
<li>'.&mt('Automatic enrollment of registered students has not been enabled for the course.').'</li> |
|
<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> |
|
<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>'); |
|
} 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 />'); |
|
} |
|
my $queuetotal = &queued_selfenrollment($r); |
|
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; |
|
} |
|
|
|
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 { |
|
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>".&mt($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 821 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.'">'; |
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 1140 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-Select').'" onClick="javascript:enterrole(this.form,\''. |
$trolecode."','".$buttonname.'\');"></td>'; |
$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>'; |
} 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>'; |
} |
} |
} |
} |
$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_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 { |
|
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 1241 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 1257 sub check_fordc {
|
return $numdc; |
return $numdc; |
} |
} |
|
|
|
sub adhoc_course_role { |
|
my ($then) = @_; |
|
my ($cdom,$cnum); |
|
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
if (&check_forcc($cdom,$cnum,$then)) { |
|
my $setprivs; |
|
if (!defined($env{'user.role.'.$env{'form.switchrole'}})) { |
|
$setprivs = 1; |
|
} else { |
|
my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}}); |
|
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_username/\w+$-) { |
|
$role .= $custom_role; |
|
} else { |
|
return; |
|
} |
|
} |
|
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 $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 1342 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 1361 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 1381 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 1394 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 1420 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 1445 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 { |