version 1.280, 2013/01/01 03:45:13
|
version 1.368, 2022/10/19 00:03:11
|
Line 128 package Apache::lonroles;
|
Line 128 package Apache::lonroles;
|
use strict; |
use strict; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::lonuserstate(); |
use Apache::lonuserstate(); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common REDIRECT); |
use Apache::File(); |
use Apache::File(); |
use Apache::lonmenu; |
use Apache::lonmenu; |
use Apache::loncommon; |
use Apache::loncommon; |
Line 139 use Apache::lonpageflip();
|
Line 139 use Apache::lonpageflip();
|
use Apache::lonnavdisplay(); |
use Apache::lonnavdisplay(); |
use Apache::loncoursequeueadmin; |
use Apache::loncoursequeueadmin; |
use Apache::longroup; |
use Apache::longroup; |
|
use Apache::lonrss; |
|
use Apache::lonplacementtest; |
use GDBM_File; |
use GDBM_File; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use HTML::Entities; |
use HTML::Entities; |
|
|
|
my $registered_cleanup; |
|
my $rosterupdates; |
|
|
|
sub start_loading_course { |
|
my ($r,$title,$only_body) = @_; |
|
&Apache::loncommon::content_type($r,'text/html'); |
|
&Apache::loncommon::no_cache($r); |
|
$r->send_http_header; |
|
if ($only_body) { |
|
$r->print(&Apache::loncommon::start_page($title,undef,{'only_body' => 1, |
|
'add_progressbar' => 1})); |
|
} else { |
|
my $swinfo=&Apache::lonmenu::rawconfig(); |
|
# Breadcrumbs |
|
my $brcrum = [{'href' => '', |
|
'text' => $title},]; |
|
my $start_page = &Apache::loncommon::start_page($title,undef, |
|
{'bread_crumbs' => $brcrum, |
|
'bread_crumbs_nomenu' => 1, |
|
'links_disabled' => 1}); |
|
$r->print(<<ENDREDIR); |
|
$start_page |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
$swinfo |
|
|
|
document.body.addEventListener('click', function (event) { |
|
// filter out clicks on any other elements |
|
if (event.target.nodeName == 'A' && event.target.getAttribute('aria-disabled') == 'true') { |
|
event.preventDefault(); |
|
} |
|
}); |
|
// ]]> |
|
</script> |
|
ENDREDIR |
|
} |
|
return; |
|
} |
|
|
|
sub finish_loading_course { |
|
my ($r,$msg,$url,$only_body) = @_; |
|
my $link = '<div id="LC_course_loaded" style="display:none"><a href="'. |
|
&HTML::Entities::encode($url,'"<>&').'">'.&mt('Continue').'</a></div>'; |
|
my $end_page = &Apache::loncommon::end_page(); |
|
my $js_url = &js_escape($url); |
|
my $reenable; |
|
unless ($only_body) { |
|
$reenable = <<REENABLE; |
|
\$('.isDisabled > a').removeAttr("aria-disabled"); |
|
\$('.isDisabled').removeClass("isDisabled"); |
|
REENABLE |
|
} |
|
$r->print(<<END); |
|
$msg |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
\$(document).ready(function() { |
|
\$("#LC_course_loaded").css("display","block"); |
|
$reenable |
|
var url = "$js_url"; |
|
\$(location).attr('href',url); |
|
}); |
|
// ]]> |
|
</script> |
|
$link |
|
$end_page |
|
END |
|
return; |
|
} |
|
|
sub redirect_user { |
sub redirect_user { |
my ($r,$title,$url,$msg) = @_; |
my ($r,$title,$url,$msg) = @_; |
Line 151 sub redirect_user {
|
Line 222 sub redirect_user {
|
&Apache::loncommon::no_cache($r); |
&Apache::loncommon::no_cache($r); |
$r->send_http_header; |
$r->send_http_header; |
|
|
# Breadcrumbs |
my $start_page; |
my $brcrum = [{'href' => $url, |
if ($env{'request.lti.login'}) { |
'text' => 'Switching Role'},]; |
$start_page = &Apache::loncommon::start_page(undef,undef, |
my $start_page = &Apache::loncommon::start_page('Switching Role',undef, |
{'redirect' => [0,$url],}).$msg; |
{'redirect' => [1,$url], |
} else { |
'bread_crumbs' => $brcrum,}); |
# Breadcrumbs |
my $end_page = &Apache::loncommon::end_page(); |
my $brcrum = [{'href' => $url, |
|
'text' => 'Switching Role'},]; |
|
$start_page = &Apache::loncommon::start_page('Switching Role',undef, |
|
{'redirect' => [1,$url], |
|
'bread_crumbs' => $brcrum,}). |
|
"\n<p>$msg</p>"; |
|
} |
|
my $end_page = &Apache::loncommon::end_page(); |
|
|
# Note to style police: |
# Note to style police: |
# This must only replace the spaces, nothing else, or it bombs elsewhere. |
# This must only replace the spaces, nothing else, or it bombs elsewhere. |
$url=~s/ /\%20/g; |
$url=~s/ /\%20/g; |
$r->print(<<ENDREDIR); |
$r->print(<<ENDREDIR); |
$start_page |
$start_page |
<p>$msg</p> |
|
$end_page |
$end_page |
ENDREDIR |
ENDREDIR |
return; |
return; |
Line 172 ENDREDIR
|
Line 249 ENDREDIR
|
|
|
sub error_page { |
sub error_page { |
my ($r,$error,$dest)=@_; |
my ($r,$error,$dest)=@_; |
&Apache::loncommon::content_type($r,'text/html'); |
my %lt = &Apache::lonlocal::texthash( |
&Apache::loncommon::no_cache($r); |
pdc => 'Problems during Course Initialization', |
$r->send_http_header; |
tfp => 'The following problems occurred:', |
return OK if $r->header_only; |
con => 'Continue', |
# Breadcrumbs |
|
my $brcrum = [{'href' => $dest, |
|
'text' => 'Problems during Course Initialization'},]; |
|
$r->print(&Apache::loncommon::start_page('Problems during Course Initialization', |
|
undef, |
|
{'bread_crumbs' => $brcrum,}) |
|
); |
|
$r->print( |
|
'<script type="text/javascript">'. |
|
'// <![CDATA['. |
|
&Apache::lonmenu::rawconfig(). |
|
'// ]]>'. |
|
'</script>'. |
|
'<p class="LC_error">'.&mt('The following problems occurred:'). |
|
'<br />'. |
|
$error. |
|
'</p><br /><a href="'.$dest.'">'.&mt('Continue').'</a>' |
|
); |
); |
$r->print(&Apache::loncommon::end_page()); |
my $end_page = &Apache::loncommon::end_page(); |
|
$dest = &HTML::Entities::encode($dest,'"<>&'); |
|
$r->print(<<END); |
|
<h3>$lt{'pdc'}</h3> |
|
<p class="LC_error">$lt{'tfp'} |
|
<br /> |
|
$error |
|
</p><br /><a href="$dest">$lt{'con'}</a> |
|
$end_page |
|
END |
|
return; |
} |
} |
|
|
sub handler { |
sub handler { |
|
|
my $r = shift; |
my $r = shift; |
|
|
|
# Check for critical messages and redirect if present. |
|
my ($redirect,$url) = &Apache::loncommon::critical_redirect(300,'roles'); |
|
if ($redirect) { |
|
&Apache::loncommon::content_type($r,'text/html'); |
|
$r->header_out(Location => $url); |
|
return REDIRECT; |
|
} |
|
|
my $now=time; |
my $now=time; |
my $then=$env{'user.login.time'}; |
my $then=$env{'user.login.time'}; |
my $refresh=$env{'user.refresh.time'}; |
my $refresh=$env{'user.refresh.time'}; |
Line 212 sub handler {
|
Line 290 sub handler {
|
$update = $then; |
$update = $then; |
} |
} |
|
|
|
my ($norolelist,$blocked_by_ip,$blocked_type,$clientip); |
|
$clientip = &Apache::lonnet::get_requestor_ip($r); |
|
if (($env{'request.course.id'}) && ($env{'request.deeplink.login'})) { |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; |
|
my $deeplink_symb = &Apache::loncommon::deeplink_login_symb($cnum,$cdom); |
|
if ($deeplink_symb) { |
|
my ($menucoll,$deeplinkmenu,$menuref) = &Apache::loncommon::menucoll_in_effect(); |
|
if (ref($menuref) eq 'HASH') { |
|
unless (($menuref->{'role'}) || ($env{'request.role.adv'})) { |
|
foreach my $envkey (keys(%env)) { |
|
next unless ($envkey =~ /^form\./); |
|
if ($envkey =~ m{\./($match_domain)/($match_courseid)(?:/(\w+)|$)}) { |
|
unless (($1 eq $cdom) && ($2 eq $cnum)) { |
|
delete($env{$envkey}); |
|
} |
|
} |
|
} |
|
if ($env{'form.selectrole'}) { |
|
if ($env{'form.switchrole'} =~ m{\./($match_domain)/($match_courseid)(?:/(\w+)|$)}) { |
|
unless (($1 eq $cdom) && ($2 eq $cnum)) { |
|
delete($env{'form.selectrole'}); |
|
delete($env{'form.switchrole'}); |
|
} |
|
} elsif ($env{'form.newrole'} =~ m{\./($match_domain)/($match_courseid)(?:/(\w+)|$)}) { |
|
unless (($1 eq $cdom) && ($2 eq $cnum)) { |
|
delete($env{'form.selectrole'}); |
|
delete($env{'form.newrole'}); |
|
} |
|
} |
|
} |
|
$norolelist = 1; |
|
} |
|
} |
|
} |
|
} |
|
|
|
if ($env{'form.selectrole'}) { |
|
my ($role,$cdom,$cnum,$rest); |
|
if ($env{'form.switchrole'} =~ m{^(co|cc|in|ta|ep|ad|st|cr).*?\./($match_domain)/($match_courseid)(/(\w+)|$)}) { |
|
($role,$cdom,$cnum,$rest) = ($1,$2,$3,$4); |
|
} elsif ($env{'form.newrole'} =~ m{^(co|cc|in|ta|ep|ad|st|cr).*?\./($match_domain)/($match_courseid)(/(\w+)|$)}) { |
|
($role,$cdom,$cnum,$rest) = ($1,$2,$3,$4); |
|
} |
|
if ($cdom ne '') { |
|
my ($has_evb,$check_ipaccess,$showrole); |
|
$showrole = 1; |
|
my $checkrole = "cm./$cdom/$cnum"; |
|
if ($rest ne '') { |
|
$checkrole .= "/$rest"; |
|
} |
|
if ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) && |
|
($role ne 'st')) { |
|
$has_evb = 1; |
|
} |
|
unless ($has_evb) { |
|
my @machinedoms = &Apache::lonnet::current_machine_domains(); |
|
my $udom = $env{'user.domain'}; |
|
if ($udom eq $cdom) { |
|
$check_ipaccess = 1; |
|
} elsif (($udom ne '') && (grep(/^\Q$udom\E$/,@machinedoms))) { |
|
$check_ipaccess = 1; |
|
} else { |
|
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
|
my $internet_names = &Apache::lonnet::get_internet_names($lonhost); |
|
my $cprim = &Apache::lonnet::domain($cdom,'primary'); |
|
my $cintdom = &Apache::lonnet::internet_dom($cprim); |
|
if (($cintdom ne '') && (ref($internet_names) eq 'ARRAY')) { |
|
if (grep(/^\Q$cintdom\E$/,@{$internet_names})) { |
|
$check_ipaccess = 1; |
|
} |
|
} |
|
} |
|
if ($check_ipaccess) { |
|
my ($ipaccessref,$cached)=&Apache::lonnet::is_cached_new('ipaccess',$cdom); |
|
unless (defined($cached)) { |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['ipaccess'],$cdom); |
|
$ipaccessref = &Apache::lonnet::do_cache_new('ipaccess',$cdom,$domconfig{'ipaccess'},1800); |
|
} |
|
if (ref($ipaccessref) eq 'HASH') { |
|
foreach my $id (keys(%{$ipaccessref})) { |
|
if (ref($ipaccessref->{$id}) eq 'HASH') { |
|
my $range = $ipaccessref->{$id}->{'ip'}; |
|
if ($range) { |
|
my $type = 'exclude'; |
|
if (&Apache::lonnet::ip_match($clientip,$range)) { |
|
$type = 'include'; |
|
} |
|
if (ref($ipaccessref->{$id}->{'courses'}) eq 'HASH') { |
|
if ($ipaccessref->{$id}->{'courses'}{$cdom.'_'.$cnum}) { |
|
if ($type eq 'include') { |
|
$showrole = 1; |
|
last; |
|
} else { |
|
$showrole = 0; |
|
} |
|
} else { |
|
if ($type eq 'include') { |
|
$showrole = 0; |
|
} else { |
|
$showrole = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
unless ($showrole) { |
|
$blocked_by_ip = 1; |
|
$blocked_type = &Apache::loncommon::course_type($cdom.'_'.$cnum); |
|
delete($env{'form.selectrole'}); |
|
delete($env{'form.newrole'}); |
|
} |
|
} |
|
} |
|
|
|
$registered_cleanup=0; |
|
@{$rosterupdates}=(); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
|
|
# -------------------------------------------------- Check if setting hot list |
# -------------------------------------------------- Check if setting hot list |
my $hotlist; |
my $hotlist; |
if ($env{'form.action'} eq 'verify_and_change_rolespref') { |
if ($env{'form.action'} eq 'verify_and_change_rolespref') { |
$hotlist = &Apache::lonpreferences::verify_and_change_rolespref($r); |
$hotlist = &Apache::lonpreferences::verify_and_change_rolespref($r); |
Line 245 sub handler {
|
Line 446 sub handler {
|
|
|
my $envkey; |
my $envkey; |
my %dcroles = (); |
my %dcroles = (); |
my $numdc = &check_fordc(\%dcroles,$update,$then); |
my %helpdeskroles = (); |
my $loncaparev = $Apache::lonnet::perlvar{'lonVersion'}; |
my ($numdc,$numhelpdesk,$numadhoc) = |
|
&check_for_adhoc(\%dcroles,\%helpdeskroles,$update,$then); |
|
my $loncaparev = $r->dir_config('lonVersion'); |
|
|
# ================================================================== Roles Init |
# ================================================================== Roles Init |
if ($env{'form.selectrole'}) { |
if ($env{'form.selectrole'}) { |
|
if (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq '')) { |
|
if ($env{'form.ltitarget'} eq 'iframe') { |
|
&Apache::lonnet::appenv({'request.lti.target' => 'iframe'}); |
|
delete($env{'form.ltitarget'}); |
|
} |
|
} |
|
|
my $locknum=&Apache::lonnet::get_locks(); |
my $locknum=&Apache::lonnet::get_locks(); |
if ($locknum) { return 409; } |
if ($locknum) { return 409; } |
|
|
|
my $custom_adhoc; |
if ($env{'form.newrole'}) { |
if ($env{'form.newrole'}) { |
$env{'form.'.$env{'form.newrole'}}=1; |
$env{'form.'.$env{'form.newrole'}}=1; |
|
# Check if this is a Domain Helpdesk or Domain Helpdesk Assistant role trying to enter a course |
|
if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/\w+\./\1/$match_courseid$}) { |
|
if ($helpdeskroles{$1}) { |
|
$custom_adhoc = 1; |
|
} |
|
} |
} |
} |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
# Check if user is CC trying to select a course role |
# Check if user is CC trying to select a course role |
Line 277 sub handler {
|
Line 493 sub handler {
|
&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.course.tied" => '', |
"request.course.tied" => '', |
"request.role" => 'cm', |
"request.course.timechecked" => '', |
"request.role.adv" => $env{'user.adv'}, |
"request.course.suppupdated" => '', |
"request.role.domain" => $env{'user.domain'}}); |
"request.role" => 'cm', |
# Check if user is a DC trying to enter a course or author space and needs privs to be created |
"request.role.adv" => $env{'user.adv'}, |
if ($numdc > 0) { |
"request.role.domain" => $env{'user.domain'}}); |
foreach my $envkey (keys %env) { |
# Check if Domain Helpdesk role trying to enter a course needs privs to be created |
# Is this an ad-hoc Coordinator role? |
if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)(?:/(\w+)|$)}) { |
if (my ($ccrole,$domain,$coursenum) = |
my $cdom = $1; |
($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) { |
my $rolename = $2; |
if ($dcroles{$domain}) { |
my $cnum = $3; |
if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum, |
my $sec = $4; |
$update,$refresh,$now,$ccrole)) { |
if ($custom_adhoc) { |
&Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.$ccrole.adhoc" => time}); |
my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum,1); |
|
if (ref($possroles) eq 'ARRAY') { |
|
if (grep(/^\Q$rolename\E$/,@{$possroles})) { |
|
if (&Apache::lonnet::check_adhoc_privs($cdom,$cnum,$update,$refresh,$now, |
|
"cr/$cdom/$cdom".'-domainconfig/'.$rolename,undef,$sec)) { |
|
&Apache::lonnet::appenv({"environment.internal.$cdom.$cnum.cr/$cdom/$cdom".'-domainconfig/'."$rolename.adhoc" => time}); |
} |
} |
} |
} |
last; |
|
} |
} |
# Is this an ad-hoc CA-role? |
} |
if (my ($domain,$user) = |
} elsif (($numdc > 0) || ($numhelpdesk > 0)) { |
($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) { |
# Check if user is a DC trying to enter a course or author space and needs privs to be created |
if (($domain eq $env{'user.domain'}) && ($user eq $env{'user.name'})) { |
# Check if user is a DH or DA trying to enter a course and needs privs to be created |
delete($env{$envkey}); |
foreach my $envkey (keys(%env)) { |
$env{'form.au./'.$domain.'/'} = 1; |
# Is this an ad-hoc Coordinator role? |
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
if ($numdc) { |
if ($server_status eq 'switchserver') { |
if (my ($ccrole,$domain,$coursenum) = |
my $trolecode = 'au./'.$domain.'/'; |
($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) { |
my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode; |
if ($dcroles{$domain}) { |
$r->internal_redirect($switchserver); |
if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum, |
|
$update,$refresh,$now,$ccrole)) { |
|
&Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.$ccrole.adhoc" => time}); |
|
} |
} |
} |
last; |
last; |
} |
} |
if (my ($castart,$caend) = ($env{'user.role.ca./'.$domain.'/'.$user} =~ /^(\d*)\.(\d*)$/)) { |
# Is this an ad-hoc CA-role? |
if (((($castart) && ($castart < $now)) || !$castart) && |
if (my ($domain,$user) = |
((!$caend) || (($caend) && ($caend > $now)))) { |
($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); |
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
if ($server_status eq 'switchserver') { |
if ($server_status eq 'switchserver') { |
my $trolecode = 'ca./'.$domain.'/'.$user; |
my $trolecode = 'au./'.$domain.'/'; |
my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode; |
my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode; |
$r->internal_redirect($switchserver); |
$r->internal_redirect($switchserver); |
|
return OK; |
} |
} |
last; |
last; |
} |
} |
} |
if (my ($castart,$caend) = ($env{'user.role.ca./'.$domain.'/'.$user} =~ /^(\d*)\.(\d*)$/)) { |
# Check if author blocked ca-access |
if (((($castart) && ($castart < $now)) || !$castart) && |
my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user); |
((!$caend) || (($caend) && ($caend > $now)))) { |
if ($blocked{'domcoord.author'} eq 'blocked') { |
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
delete($env{$envkey}); |
if ($server_status eq 'switchserver') { |
$env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access'; |
my $trolecode = 'ca./'.$domain.'/'.$user; |
|
my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode; |
|
$r->internal_redirect($switchserver); |
|
return OK; |
|
} |
|
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')) { |
|
&Apache::lonnet::check_adhoc_privs($domain,$user,$update, |
|
$refresh,$now,'ca'); |
|
if ($server_status eq 'switchserver') { |
|
my $trolecode = 'ca./'.$domain.'/'.$user; |
|
my $switchserver = '/adm/switchserver?' |
|
.'otherserver='.$home.'&role='.$trolecode; |
|
$r->internal_redirect($switchserver); |
|
return OK; |
|
} |
|
} else { |
|
delete($env{$envkey}); |
|
} |
|
} else { |
|
delete($env{$envkey}); |
|
} |
last; |
last; |
} |
} |
if ($dcroles{$domain}) { |
} |
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
if ($numhelpdesk) { |
if (($server_status eq 'ok') || ($server_status eq 'switchserver')) { |
# Is this an ad hoc custom role in a course/community? |
&Apache::lonnet::check_adhoc_privs($domain,$user,$update, |
if (my ($domain,$rolename,$coursenum,$sec) = ($envkey =~ m{^form\.cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)(?:/(\w+)|$)})) { |
$refresh,$now,'ca'); |
if ($helpdeskroles{$domain}) { |
if ($server_status eq 'switchserver') { |
my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($domain.'_'.$coursenum,1); |
my $trolecode = 'ca./'.$domain.'/'.$user; |
if (ref($possroles) eq 'ARRAY') { |
my $switchserver = '/adm/switchserver?' |
if (grep(/^\Q$rolename\E$/,@{$possroles})) { |
.'otherserver='.$home.'&role='.$trolecode; |
if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum,$update,$refresh,$now, |
$r->internal_redirect($switchserver); |
"cr/$domain/$domain".'-domainconfig/'.$rolename, |
|
undef,$sec)) { |
|
&Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.cr/$domain/$domain". |
|
'-domainconfig/'."$rolename.adhoc" => time}); |
|
} |
|
} else { |
|
delete($env{$envkey}); |
|
} |
|
} else { |
|
delete($env{$envkey}); |
} |
} |
} else { |
} else { |
delete($env{$envkey}); |
delete($env{$envkey}); |
} |
} |
} else { |
last; |
delete($env{$envkey}); |
|
} |
} |
last; |
|
} |
} |
} |
} |
} |
} |
|
foreach $envkey (keys(%env)) { |
foreach $envkey (keys %env) { |
|
next if ($envkey!~/^user\.role\./); |
next if ($envkey!~/^user\.role\./); |
my ($where,$trolecode,$role,$tstatus,$tend,$tstart); |
my ($where,$trolecode,$role,$tstatus,$tend,$tstart); |
&Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where, |
&Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where, |
Line 370 sub handler {
|
Line 635 sub handler {
|
my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired'); |
my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired'); |
if ($curr_reqd_hash{'internal.releaserequired'} ne '') { |
if ($curr_reqd_hash{'internal.releaserequired'} ne '') { |
my ($switchserver,$switchwarning) = |
my ($switchserver,$switchwarning) = |
&check_release_required($loncaparev,$cdom.'_'.$cnum,$trolecode,$curr_reqd_hash{'internal.releaserequired'}); |
&Apache::loncommon::check_release_required($loncaparev,$cdom.'_'.$cnum,$trolecode, |
|
$curr_reqd_hash{'internal.releaserequired'}); |
if ($switchwarning ne '' || $switchserver ne '') { |
if ($switchwarning ne '' || $switchserver ne '') { |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::no_cache($r); |
&Apache::loncommon::no_cache($r); |
$r->send_http_header; |
$r->send_http_header; |
my $end_page=&Apache::loncommon::end_page(); |
$r->print(&Apache::loncommon::check_release_result($switchwarning,$switchserver)); |
$r->print(&Apache::loncommon::start_page('Selected course unavailable on this server'). |
|
'<p class="LC_warning">'); |
|
if ($switchwarning) { |
|
$r->print($switchwarning.'<br /><a href="/adm/roles">'); |
|
if (&Apache::loncommon::show_course()) { |
|
$r->print(&mt('Display courses')); |
|
} else { |
|
$r->print(&mt('Display roles')); |
|
} |
|
$r->print('</a>'); |
|
} elsif ($switchserver) { |
|
$r->print(&mt('This course requires a newer version of LON-CAPA than is installed on this server.'). |
|
'<br />'. |
|
'<a href="/adm/switchserver?'.$switchserver.'">'. |
|
&mt('Switch Server'). |
|
'</a>'); |
|
} |
|
$r->print('</p>'.&Apache::loncommon::end_page()); |
|
return OK; |
return OK; |
} |
} |
} |
} |
Line 439 sub handler {
|
Line 687 sub handler {
|
my $end_page=&Apache::loncommon::end_page(); |
my $end_page=&Apache::loncommon::end_page(); |
my $buttontext=&mt('Enter Course'); |
my $buttontext=&mt('Enter Course'); |
my $message=&mt('Successfully registered key'); |
my $message=&mt('Successfully registered key'); |
|
my $ip = &Apache::lonnet::get_requestor_ip(); |
my $assignresult= |
my $assignresult= |
&Apache::lonnet::assign_access_key( |
&Apache::lonnet::assign_access_key( |
$env{'form.newkey'}, |
$env{'form.newkey'}, |
Line 447 sub handler {
|
Line 696 sub handler {
|
$env{'user.domain'}, |
$env{'user.domain'}, |
$env{'user.name'}, |
$env{'user.name'}, |
&mt('Assigned from [_1] at [_2] for [_3]' |
&mt('Assigned from [_1] at [_2] for [_3]' |
,$ENV{'REMOTE_ADDR'} |
,$ip |
,&Apache::lonlocal::locallocaltime() |
,&Apache::lonlocal::locallocaltime() |
,$trolecode) |
,$trolecode) |
); |
); |
Line 506 ENDENTERKEY
|
Line 755 ENDENTERKEY
|
$env{'user.name'}, |
$env{'user.name'}, |
$env{'user.home'}, |
$env{'user.home'}, |
"Role ".$trolecode); |
"Role ".$trolecode); |
|
|
&Apache::lonnet::appenv( |
&Apache::lonnet::appenv( |
{'request.role' => $trolecode, |
{'request.role' => $trolecode, |
'request.role.domain' => $cdom, |
'request.role.domain' => $cdom, |
Line 515 ENDENTERKEY
|
Line 764 ENDENTERKEY
|
my $tadv=0; |
my $tadv=0; |
|
|
if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) { |
if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) { |
my $msg; |
if ($role =~ m{^\Qcr/$cdom/$cdom\E\-domainconfig/(\w+)$}) { |
my ($furl,$ferr)= |
my $rolename = $1; |
&Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
my %domdef = &Apache::lonnet::get_domain_defaults($cdom); |
unless (($ferr) || ($env{'form.switchrole'}) || |
if (ref($domdef{'adhocroles'}) eq 'HASH') { |
($env{"environment.internal.$cdom.$cnum.$role.adhoc"})) { |
if (ref($domdef{'adhocroles'}{$rolename}) eq 'HASH') { |
&Apache::lonnet::put('nohist_crslastlogin', |
&Apache::lonnet::appenv({'request.role.desc' => $domdef{'adhocroles'}{$rolename}{'desc'}}); |
{$env{'user.name'}.':'.$env{'user.domain'}. |
} |
':'.$csec.':'.$role => $now},$cdom,$cnum); |
} |
|
} |
|
my $crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum); |
|
$crstype = lc($crstype); |
|
my ($msg,$critmsg_check,$title,$loadmsg,$only_body); |
|
$critmsg_check = 1; |
|
$title = &mt("Loading $crstype"); |
|
$loadmsg = &mt("Please be patient while your $crstype loads"); |
|
if (($env{'request.deeplink.login'}) && ($env{'request.linkprot'})) { |
|
if ($env{'request.linkprot'} =~ /^\d+(c|d):\Q$env{'form.destinationurl'}\E$/) { |
|
$title = &mt('Loading LON-CAPA session'); |
|
$loadmsg = &mt('Please be patient while LON-CAPA loads'); |
|
$only_body = 1; |
|
$critmsg_check = 0; |
|
} |
|
} |
|
my $preamble = '<div id="LC_update_'.$cdom.'_'.$cnum.'" class="LC_info">'. |
|
'<br />'. |
|
$loadmsg. |
|
'<br /></div>'. |
|
'<div style="padding:0;clear:both;margin:0;border:0"></div>'; |
|
my $closure = <<ENDCLOSE; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
\$("#LC_update_${cdom}_${cnum}").hide('slow'); |
|
// ]]> |
|
</script> |
|
ENDCLOSE |
|
&start_loading_course($r,$title,$only_body); |
|
my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,undef,$preamble); |
|
&Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Loading ...')); |
|
$r->rflush(); |
|
if ($critmsg_check) { |
|
my $blockcrit = &Apache::loncommon::blocking_status('alert',$clientip,$cnum,$cdom,undef,1); |
|
if ($blockcrit) { |
|
my $checkrole = "cm./$cdom/$cnum"; |
|
if ($csec ne '') { |
|
$checkrole .= "/$csec"; |
|
} |
|
unless ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) && |
|
($trolecode !~ m{^st\./$cdom/$cnum})) { |
|
$critmsg_check = 0; |
|
} |
|
} |
|
} |
|
my ($furl,$ferr)= |
|
&Apache::lonuserstate::readmap($cdom.'/'.$cnum,$critmsg_check); |
|
&Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Finished!')); |
|
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
|
$r->print($closure); |
|
$r->rflush(); |
|
if ($ferr) { |
|
$furl = '/adm/roles?tryagain=1'; |
|
} else { |
|
&Apache::lonnet::appenv({'request.course.timechecked'=>$now}); |
|
unless (($env{'form.switchrole'}) || |
|
($env{"environment.internal.$cdom.$cnum.$role.adhoc"})) { |
|
&Apache::lonnet::put('nohist_crslastlogin', |
|
{$env{'user.name'}.':'.$env{'user.domain'}. |
|
':'.$csec.':'.$role => $now},$cdom,$cnum); |
|
} |
|
if (($env{"environment.internal.$cdom.$cnum.$role.adhoc"}) && |
|
(&Apache::lonnet::allowed('vxc',$cdom.'_'.$cnum))) { |
|
my $owner = $env{'course.'.$cdom.'_'.$cnum.'.internal.courseowner'}; |
|
my @coowners = split(/,/,$env{'course.'.$env{'request.course.id'}.'.internal.co-owners'}); |
|
my %auaccess; |
|
foreach my $user ($owner,@coowners) { |
|
my ($cpname,$cpdom) = split(/:/,$user); |
|
my %auroles = &Apache::lonnet::get_my_roles($cpname,$cpdom,'userroles',undef,['au','ca','aa'],[$cdom]); |
|
foreach my $key (keys(%auroles)) { |
|
my ($auname,$audom,$aurole) = split(/:/,$key); |
|
if ($aurole eq 'au') { |
|
$auaccess{$cpname} = 1; |
|
} else { |
|
$auaccess{$auname} = 1; |
|
} |
|
} |
|
} |
|
&Apache::lonnet::appenv({'request.course.adhocsrcaccess' => join(',',sort(keys(%auaccess))) }); |
|
} |
|
my ($feeds,$syllabus_time); |
|
&Apache::lonrss::advertisefeeds($cnum,$cdom,undef,\$feeds); |
|
&Apache::lonnet::appenv({'request.course.feeds' => $feeds}); |
|
unless ($env{'course.'.$cdom.'_'.$cnum.'.updatedsyllabus'}) { |
|
unless (($env{'course.'.$cdom.'_'.$cnum.'.externalsyllabus'}) || |
|
($env{'course.'.$cdom.'_'.$cnum.'.uploadedsyllabus'})) { |
|
my %syllabus=&Apache::lonnet::dump('syllabus',$cdom,$cnum); |
|
$syllabus_time = $syllabus{'uploaded.lastmodified'}; |
|
if ($syllabus_time) { |
|
&Apache::lonnet::appenv({'request.course.syllabustime' => $syllabus_time}); |
|
} |
|
} |
|
} |
} |
} |
if (($env{'form.orgurl'}) && |
if (($env{'form.orgurl'}) && |
($env{'form.orgurl'}!~/^\/adm\/flip/)) { |
($env{'form.orgurl'}!~/^\/adm\/flip/) && |
|
($env{'form.orgurl'} ne '/adm/roles')) { |
my $dest=$env{'form.orgurl'}; |
my $dest=$env{'form.orgurl'}; |
if ($env{'form.symb'}) { |
if ($env{'form.symb'}) { |
if ($dest =~ /\?/) { |
if ($dest =~ /\?/) { |
$dest .= '&'; |
$dest .= '&'; |
} else { |
} else { |
$dest .= '?' |
$dest .= '?'; |
} |
} |
$dest .= 'symb='.$env{'form.symb'}; |
$dest .= 'symb='.$env{'form.symb'}; |
} |
} |
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) { |
|
if ($env{'form.orgurl'}) { |
|
$furl .= '&orgurl='.&HTML::Entities::encode($env{'form.orgurl'},'<>&"'); |
|
} |
|
if ($env{'form.symb'}) { |
|
$furl .= '&symb='.&HTML::Entities::encode($env{'form.symb'},'<>&"'); |
|
} |
|
} else { |
|
&set_supplemental_access($cnum,$cdom); |
|
} |
if (($ferr) && ($tadv)) { |
if (($ferr) && ($tadv)) { |
&error_page($r,$ferr,$dest); |
&error_page($r,$ferr,$furl); |
} else { |
} else { |
|
if ($env{'request.course.id'} eq $cdom.'_'.$cnum) { |
|
if (($env{'form.orgurl'} ne '') && ($env{'form.symb'} ne '')) { |
|
unless (&Apache::lonnet::symbverify($env{'form.symb'},$env{'form.orgurl'})) { |
|
$dest=$env{'form.orgurl'}; |
|
} |
|
} |
|
} |
if ($dest =~ m{^/adm/coursedocs\?folderpath}) { |
if ($dest =~ m{^/adm/coursedocs\?folderpath}) { |
if ($env{'request.course.id'} eq $cdom.'_'.$cnum) { |
if ($env{'request.course.id'} eq $cdom.'_'.$cnum) { |
my $chome = &Apache::lonnet::homeserver($cnum,$cdom); |
my $chome = &Apache::lonnet::homeserver($cnum,$cdom); |
Line 547 ENDENTERKEY
|
Line 906 ENDENTERKEY
|
$cdom.'_'.$cnum); |
$cdom.'_'.$cnum); |
} |
} |
} |
} |
$r->internal_redirect($dest); |
if ($ferr) { |
|
if (!$env{'request.course.id'}) { |
|
&Apache::lonnet::appenv( |
|
{"request.course.id" => $cdom.'_'.$cnum}); |
|
$r->print('<p class="LC_error">'. |
|
&mt('Could not initialize [_1] at this time.', |
|
$env{'course.'.$cdom.'_'.$cnum.'.description'}). |
|
'</p>'. |
|
'<p><a href="'.$furl.'">'. |
|
&mt('Please try again.').'</a></p>'. |
|
&Apache::loncommon::end_page()); |
|
} |
|
} else { |
|
if (($env{'request.lti.login'}) && |
|
($env{'request.lti.rosterid'} || $env{'request.lti.passbackid'})) { |
|
&process_lti($r,$cdom,$cnum); |
|
} |
|
if ($env{'request.deeplink.login'}) { |
|
&set_deeplink_target($cnum,$cdom); |
|
} |
|
$msg = '<p>'.&mt('Entering [_1] ...', |
|
$env{'course.'.$cdom.'_'.$cnum.'.description'}). |
|
'</p>'; |
|
&finish_loading_course($r,$msg,$dest,$only_body); |
|
} |
} |
} |
|
$r->rflush(); |
return OK; |
return OK; |
} else { |
} else { |
if (!$env{'request.course.id'}) { |
if (!$env{'request.course.id'}) { |
&Apache::lonnet::appenv( |
&Apache::lonnet::appenv( |
{"request.course.id" => $cdom.'_'.$cnum}); |
{"request.course.id" => $cdom.'_'.$cnum}); |
$furl='/adm/roles?tryagain=1'; |
|
$msg='<p><span class="LC_error">' |
|
.&mt('Could not initialize [_1] at this time.', |
|
$env{'course.'.$cdom.'_'.$cnum.'.description'}) |
|
.'</span></p>' |
|
.'<p>'.&mt('Please try again.').'</p>' |
|
.'<p>'.$ferr.'</p>'; |
|
} |
} |
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) { |
if (($ferr) && ($tadv)) { |
if ($tadv) { |
&error_page($r,$ferr,$furl); |
&error_page($r,$ferr,$furl); |
|
} else { |
|
$r->print('<p class="LC_error">'. |
|
&mt('Could not initialize [_1] at this time.', |
|
$env{'course.'.$cdom.'_'.$cnum.'.description'}). |
|
'</p>'. |
|
'<p><a href="'.$furl.'">'.&mt('Please try again.').'</a></p>'. |
|
&Apache::loncommon::end_page()); |
|
} |
} else { |
} else { |
|
&set_supplemental_access($cnum,$cdom); |
|
if (($env{'request.lti.login'}) && |
|
($env{'request.lti.rosterid'} || $env{'request.lti.passbackid'})) { |
|
&process_lti($r,$cdom,$cnum); |
|
} |
|
if ($env{'request.deeplink.login'}) { |
|
&set_deeplink_target($cnum,$cdom); |
|
} |
# Check to see if the user is a CC entering a course |
# Check to see if the user is a CC entering a course |
# for the first time |
# for the first time |
my (undef, undef, $role, $courseid) = split(/\./, $envkey); |
|
if (substr($courseid, 0, 1) eq '/') { |
|
$courseid = substr($courseid, 1); |
|
} |
|
$courseid =~ s/\//_/; |
|
if ((($role eq 'cc') || ($role eq 'co')) |
if ((($role eq 'cc') || ($role eq 'co')) |
&& ($env{'course.' . $courseid .'.course.helper.not.run'})) { |
&& ($env{'course.'.$cdom.'_'.$cnum.'.course.helper.not.run'})) { |
$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 ((&Apache::loncommon::course_type() eq 'Placement') && |
|
(!$env{'request.role.adv'})) { |
|
my ($score,$incomplete) = |
|
&Apache::lonplacementtest::check_completion(undef,undef,1); |
|
if (($incomplete) && ($incomplete < 100)) { |
|
$msg = '<p>'.&mt('Entering [_1] ...', |
|
$env{'course.'.$cdom.'_'.$cnum.'.description'}). |
|
'</p>'; |
|
&finish_loading_course($r,$msg,'/adm/placement',$only_body); |
|
$r->rflush(); |
|
return OK; |
|
} |
|
} |
my ($dest,$destsymb,$checkenc); |
my ($dest,$destsymb,$checkenc); |
$dest = $env{'form.destinationurl'}; |
$dest = $env{'form.destinationurl'}; |
$destsymb = $env{'form.destsymb'}; |
$destsymb = $env{'form.destsymb'}; |
Line 592 ENDENTERKEY
|
Line 993 ENDENTERKEY
|
} |
} |
} |
} |
} |
} |
|
if (($dest =~ m{^\Q/public/$cdom/$cnum/syllabus\E.*(\?|\&)usehttp=1}) || |
|
($dest =~ m{^\Q/adm/wrapper/ext/\E(?!https:)})) { |
|
if ($ENV{'SERVER_PORT'} == 443) { |
|
my $hostname = $r->hostname(); |
|
unless ((&Apache::lonnet::uses_sts()) || |
|
(&Apache::lonnet::waf_allssl($hostname))) { |
|
if ($hostname ne '') { |
|
$dest = 'http://'.$hostname.$dest; |
|
} |
|
} |
|
} |
|
} |
if ($dest =~ m{^/enc/}) { |
if ($dest =~ m{^/enc/}) { |
if ($env{'request.role.adv'}) { |
if ($env{'request.role.adv'}) { |
$dest = &Apache::lonenc::unencrypted($dest); |
$dest = &Apache::lonenc::unencrypted($dest); |
Line 611 ENDENTERKEY
|
Line 1024 ENDENTERKEY
|
} |
} |
if (($checkenc) && ($destsymb ne '')) { |
if (($checkenc) && ($destsymb ne '')) { |
my ($encstate,$unencsymb,$res); |
my ($encstate,$unencsymb,$res); |
my $unencsymb = &Apache::lonnet::symbclean($destsymb); |
$unencsymb = &Apache::lonnet::symbclean($destsymb); |
(undef,undef,$res) = &Apache::lonnet::decode_symb($unencsymb); |
(undef,undef,$res) = &Apache::lonnet::decode_symb($unencsymb); |
&Apache::lonnet::symbverify($unencsymb,$res,\$encstate); |
&Apache::lonnet::symbverify($unencsymb,$res,\$encstate); |
if ($encstate) { |
if ($encstate) { |
Line 624 ENDENTERKEY
|
Line 1037 ENDENTERKEY
|
unless (($dest =~ m{^/enc/}) || ($dest =~ /(\?|\&)symb=.+___\d+___.+/)) { |
unless (($dest =~ m{^/enc/}) || ($dest =~ /(\?|\&)symb=.+___\d+___.+/)) { |
if (($destsymb ne '') && ($destsymb !~ m{^/enc/})) { |
if (($destsymb ne '') && ($destsymb !~ m{^/enc/})) { |
my $esc_symb = &escape($destsymb); |
my $esc_symb = &escape($destsymb); |
$dest .= '?symb='.$esc_symb; |
$dest .= (($dest =~/\?/)? '&':'?').'symb='.$esc_symb; |
} |
} |
} |
} |
&redirect_user($r, &mt('Entering [_1]', |
if ($env{'form.ttoken'}) { |
$env{'course.'.$courseid.'.description'}), |
$dest .= (($dest =~/\?/)? '&':'?').'ttoken='.$env{'form.ttoken'}; |
$dest, $msg); |
} |
|
unless (($env{'request.lti.login'}) || ($env{'request.deeplink.login'})) { |
|
$msg = '<p>'.&mt('Entering [_1] ...', |
|
$env{'course.'.$cdom.'_'.$cnum.'.description'}). |
|
'</p>'; |
|
} |
|
&finish_loading_course($r,$msg,$dest,$only_body); |
|
$r->rflush(); |
return OK; |
return OK; |
} |
} |
if (&Apache::lonnet::allowed('whn', |
if (&Apache::lonnet::allowed('whn', |
Line 638 ENDENTERKEY
|
Line 1058 ENDENTERKEY
|
$env{'request.course.id'}.'/' |
$env{'request.course.id'}.'/' |
.$env{'request.course.sec'}) |
.$env{'request.course.sec'}) |
) { |
) { |
my $startpage = &courseloadpage($courseid); |
my $startpage = &courseloadpage($env{'request.course.id'}); |
unless ($startpage eq 'firstres') { |
unless ($startpage eq 'firstres') { |
$msg = &mt('Entering [_1] ...', |
$msg = '<p>'.&mt('Entering [_1] ...', |
$env{'course.'.$courseid.'.description'}); |
$env{'course.'.$cdom.'_'.$cnum.'.description'}). |
&redirect_user($r, &mt('New in course'), |
'</p>'; |
'/adm/whatsnew?refpage=start', $msg); |
&finish_loading_course($r,$msg,'/adm/whatsnew?refpage=start',$only_body); |
|
$r->rflush(); |
return OK; |
return OK; |
} |
} |
} |
} |
} |
} |
# Are we allowed to look at the first resource? |
# Are we allowed to look at the first resource? |
if ($furl !~ m|^/adm/|) { |
# |
# Guess not ... |
# $furl returned by lonuserstate::readmap() has format: |
$furl=&Apache::lonpageflip::first_accessible_resource(); |
# $url?symb=escaped($symb). If the resource has the |
} |
# encrypturl parameter in effect, the entire string |
$msg = &mt('Entering [_1] ...', |
# $url?symb=escaped($symb) is encrypted as a string |
$env{'course.'.$courseid.'.description'}); |
# beginning /enc/. |
&redirect_user($r, &mt('Entering [_1]', |
# |
$env{'course.'.$courseid.'.description'}), |
my ($access,$unencfurl,$unencsymb); |
$furl, $msg); |
if ($furl =~ m{^(.+)(?:\?|\&)symb=([^&]+)(?:$|&)}) { |
|
my ($poss_url,$poss_symb) = ($1,$2); |
|
$unencsymb = &unescape($poss_symb); |
|
$unencfurl = $poss_url; |
|
} elsif ($furl =~ m{^/enc/}) { |
|
my $unenc = &Apache::lonenc::unencrypted($furl); |
|
if ($unenc =~ m{^(.+)(?:\?|\&)symb=([^&]+)(?:$|&)}) { |
|
($unencfurl,$unencsymb) = ($1,$2); |
|
$unencsymb = &unescape($unencsymb); |
|
} else { |
|
$unencfurl = $unenc; |
|
} |
|
} else { |
|
$unencfurl = $furl; |
|
} |
|
if ($unencsymb) { |
|
my $symb = &Apache::lonnet::symbclean($unencsymb); |
|
if (($symb ne '') && (&Apache::lonnet::symbverify($symb,$unencfurl))) { |
|
$access = &Apache::lonnet::allowed('bre',$unencfurl,$symb); |
|
} else { |
|
$access = &Apache::lonnet::allowed('bre',$unencfurl); |
|
} |
|
} else { |
|
$access = &Apache::lonnet::allowed('bre',$unencfurl); |
|
} |
|
if ((!$access) || ($access eq 'B') || ($access eq 'D')) { |
|
$furl = &Apache::lonpageflip::first_accessible_resource(); |
|
if ($furl eq '') { |
|
$furl = '/adm/navmaps?showOnlyHomework=1'; |
|
} |
|
} |
|
if ($env{'request.lti.login'}) { |
|
undef($msg); |
|
&finish_loading_course($r,$msg,$furl,$only_body); |
|
} else { |
|
$msg = '<p>'.&mt('Entering [_1] ...', |
|
$env{'course.'.$cdom.'_'.$cnum.'.description'}). |
|
'</p>'; |
|
&finish_loading_course($r,$msg,$furl,$only_body); |
|
} |
} |
} |
|
$r->rflush(); |
return OK; |
return OK; |
} |
} |
} |
} |
Line 672 ENDENTERKEY
|
Line 1133 ENDENTERKEY
|
$redirect_url .= $where; |
$redirect_url .= $where; |
} |
} |
$redirect_url .= '/'; |
$redirect_url .= '/'; |
&redirect_user($r,&mt('Entering Construction Space'), |
if ($env{'form.orgurl'} =~ /^\Q$redirect_url\E/) { |
|
my ($path) = ($env{'form.orgurl'} =~ m{^(.+)/[^/]+$}); |
|
if (($path ne '') && (-e $Apache::lonnet::perlvar{'lonDocRoot'}.$path)) { |
|
$redirect_url = $env{'form.orgurl'}; |
|
} |
|
} |
|
&redirect_user($r,&mt('Entering Authoring Space'), |
$redirect_url); |
$redirect_url); |
return OK; |
return OK; |
} |
} |
Line 682 ENDENTERKEY
|
Line 1149 ENDENTERKEY
|
$redirect_url); |
$redirect_url); |
return OK; |
return OK; |
} |
} |
|
if ($role eq 'dh') { |
|
my $redirect_url = '/adm/menu/'; |
|
&redirect_user($r,&mt('Loading Domain Helpdesk Menu'), |
|
$redirect_url); |
|
return OK; |
|
} |
|
if ($role eq 'da') { |
|
my $redirect_url = '/adm/menu/'; |
|
&redirect_user($r,&mt('Loading Domain Helpdesk Assistant Menu'), |
|
$redirect_url); |
|
return OK; |
|
} |
if ($role eq 'sc') { |
if ($role eq 'sc') { |
my $redirect_url = '/adm/grades?command=scantronupload'; |
my $redirect_url = '/adm/grades?command=scantronupload'; |
&redirect_user($r,&mt('Loading Data Upload Page'), |
&redirect_user($r,&mt('Loading Data Upload Page'), |
Line 704 ENDENTERKEY
|
Line 1183 ENDENTERKEY
|
my $crumbtext = 'User Roles'; |
my $crumbtext = 'User Roles'; |
my $pagetitle = 'My Roles'; |
my $pagetitle = 'My Roles'; |
my $recent = &mt('Recent Roles'); |
my $recent = &mt('Recent Roles'); |
|
my $standby = &mt('Role selected. Please stand by.'); |
my $show_course=&Apache::loncommon::show_course(); |
my $show_course=&Apache::loncommon::show_course(); |
if ($show_course) { |
if ($show_course) { |
$crumbtext = 'Courses'; |
$crumbtext = 'Courses'; |
$pagetitle = 'My Courses'; |
$pagetitle = 'My Courses'; |
$recent = &mt('Recent Courses'); |
$recent = &mt('Recent Courses'); |
|
$standby = &mt('Course selected. Please stand by.'); |
|
} |
|
if (($norolelist) && ((split(/:/,$env{'user.error.msg'}))[2])) { |
|
$crumbtext = 'Access Denied'; |
|
$pagetitle = 'Unauthorized'; |
} |
} |
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; |
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; |
|
|
Line 716 ENDENTERKEY
|
Line 1201 ENDENTERKEY
|
my $showcount = &roles_from_env(\%roles_in_env,$update); |
my $showcount = &roles_from_env(\%roles_in_env,$update); |
|
|
my $swinfo=&Apache::lonmenu::rawconfig(); |
my $swinfo=&Apache::lonmenu::rawconfig(); |
my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum}); |
my %domdefs=&Apache::lonnet::get_domain_defaults($env{'user.domain'}); |
my $funcs = &get_roles_functions($showcount); |
my $cattype = 'std'; |
my $standby=&mt('Role selected. Please stand by.'); |
if ($domdefs{'catauth'}) { |
$standby=~s/\n/\\n/g; |
$cattype = $domdefs{'catauth'}; |
|
} |
|
my $placementonly; |
|
if ($showcount == 1) { |
|
if ($env{'request.course.id'}) { |
|
if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Placement') { |
|
$placementonly = 1; |
|
} |
|
} else { |
|
foreach my $rolecode (keys(%roles_in_env)) { |
|
my ($cid) = ($rolecode =~ m{^\Quser.role.st./\E($match_domain/$match_courseid)(?:/|$)}); |
|
if ($cid) { |
|
my %coursedescription = |
|
&Apache::lonnet::coursedescription($cid,{'one_time' => '1'}); |
|
if ($coursedescription{'type'} eq 'Placement') { |
|
$placementonly = 1; |
|
} |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
my ($start_page,$funcs); |
|
if ($placementonly) { |
|
$start_page=&Apache::loncommon::start_page($pagetitle,undef, |
|
{bread_crumbs=>$brcrum,crstype=>'Placement'}); |
|
} else { |
|
my $crumbsright; |
|
unless (($norolelist) && ((split(/:/,$env{'user.error.msg'}))[2])) { |
|
$funcs = &get_roles_functions($showcount,$cattype); |
|
if ($env{'browser.mobile'}) { |
|
$crumbsright = $funcs; |
|
undef($funcs); |
|
} |
|
} |
|
$start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum, |
|
bread_crumbs_component=>$crumbsright}); |
|
} |
|
&js_escape(\$standby); |
my $noscript='<br /><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 />'; |
my $noscript='<br /><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); |
Line 822 ENDHEADER
|
Line 1345 ENDHEADER
|
} |
} |
if ($nochoose) { |
if ($nochoose) { |
$r->print("<h2>".&mt('Sorry ...')."</h2>\n<span class='LC_error'>". |
$r->print("<h2>".&mt('Sorry ...')."</h2>\n<span class='LC_error'>". |
&mt('This action is currently not authorized.').'</span>'. |
&mt('This action is currently not authorized.').'</span>'); |
&Apache::loncommon::end_page()); |
if ($error && $norolelist) { |
|
$r->print('<br /><br /><h4><span class="LC_error">'. |
|
&mt('As your session was launched from a web page external to LON-CAPA some course content may be unavailable, including the resource you were trying to access.'). |
|
'</span></h4>'. |
|
'<h4><span class="LC_error">'. |
|
&mt('You may need to login to LON-CAPA directly, or re-launch from a different external system.'). |
|
'</span></h4>'); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} else { |
} else { |
if ($updateresult || $reqauthor || $hotlist) { |
if ($updateresult || $reqauthor || $hotlist) { |
Line 852 ENDHEADER
|
Line 1383 ENDHEADER
|
$r->print('<input type="hidden" name="newrole" value="" />'); |
$r->print('<input type="hidden" name="newrole" value="" />'); |
$r->print('<input type="hidden" name="display" value="'.$display.'" />'); |
$r->print('<input type="hidden" name="display" value="'.$display.'" />'); |
$r->print('<input type="hidden" name="state" value="" />'); |
$r->print('<input type="hidden" name="state" value="" />'); |
|
if ($blocked_by_ip) { |
|
my $blocked_role = 'student'; |
|
if ($blocked_type eq 'Community') { |
|
$blocked_role = 'member'; |
|
} |
|
$r->print('<h3><span class="LC_error">'. |
|
&mt('The [_1] you selected is not available for access with a [_2] role from your current IP address: [_3].', |
|
lc($blocked_type),$blocked_role,$clientip). |
|
'</span></h3>'); |
|
} |
} |
} |
$r->rflush(); |
$r->rflush(); |
|
|
Line 861 ENDHEADER
|
Line 1402 ENDHEADER
|
\%sortrole,\%roleclass,\%futureroles,\%timezones,$loncaparev); |
\%sortrole,\%roleclass,\%futureroles,\%timezones,$loncaparev); |
$refresh = $now; |
$refresh = $now; |
&Apache::lonnet::appenv({'user.refresh.time' => $refresh}); |
&Apache::lonnet::appenv({'user.refresh.time' => $refresh}); |
unless ($env{'user.adv'}) { |
if ($countactive == 1) { |
|
if ($env{'request.course.id'}) { |
|
if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Placement') { |
|
$placementonly = 1; |
|
} |
|
} elsif ($possiblerole) { |
|
if ($possiblerole =~ m{^st\./($match_domain)/($match_courseid)(?:/|$)}) { |
|
if ($env{'course.'.$1.'_'.$2.'.type'} eq 'Placement') { |
|
$placementonly = 1; |
|
} |
|
} |
|
} |
|
} |
|
if ((($cattype eq 'std') || ($cattype eq 'domonly')) && (!$env{'user.adv'}) && |
|
(!$placementonly)) { |
if ($countactive > 0) { |
if ($countactive > 0) { |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
$r->print( |
$r->print( |
'<p>' |
'<p>' |
.&mt('[_1]Visit the [_2]Course/Community Catalog[_3]' |
.&mt('[_1]Visit the [_2]Course/Community Catalog[_3][_4]' |
.' to view all [_4] LON-CAPA courses and communities.' |
.' to view all [_5] LON-CAPA courses and communities.' |
,'<b>' |
,'<b>' |
,'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">' |
,'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">' |
,'</a></b>',$domdesc) |
,'</a>' |
|
,'</b>' |
|
,'"'.$domdesc.'"') |
.'<br />' |
.'<br />' |
.&mt('If a course or community is [_1]not[_2] in your list of current courses and communities below,' |
.&mt('If a course or community is [_1]not[_2] in your list of current courses and communities below,' |
.' you may be able to enroll if self-enrollment is permitted.' |
.' you may be able to enroll if self-enrollment is permitted.' |
Line 881 ENDHEADER
|
Line 1438 ENDHEADER
|
} |
} |
} |
} |
|
|
|
if ($norolelist) { |
|
if ($env{'request.role'}) { |
|
my ($roletext,$role_text_end) = &display_curr_role($env{'request.role'}); |
|
if ($roletext) { |
|
$r->print(&Apache::loncommon::start_data_table('LC_textsize_mobile'). |
|
&Apache::loncommon::start_data_table_row(). |
|
$roletext. |
|
&Apache::loncommon::end_data_table_row()); |
|
if ($role_text_end) { |
|
$r->print(&Apache::loncommon::continue_data_table_row(). |
|
$role_text_end. |
|
&Apache::loncommon::end_data_table_row()); |
|
} |
|
$r->print(&Apache::loncommon::end_data_table()); |
|
} |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
return OK; |
|
} |
|
|
# No active roles |
# No active roles |
if ($countactive==0) { |
if ($countactive==0) { |
if ($inrole) { |
my $elapsed = 0; |
$r->print('<h2>'.&mt('Currently no additional roles, courses or communities').'</h2>'); |
if ($now && $update) { |
} else { |
$elapsed = $now - $update; |
$r->print('<h2>'.&mt('Currently no active roles, courses or communities').'</h2>'); |
} |
} |
&requestcourse_advice($r,$cattype,$inrole,$elapsed); |
&findcourse_advice($r); |
|
&requestcourse_advice($r); |
|
$r->print('</form>'); |
$r->print('</form>'); |
if ($countfuture) { |
if ($countfuture) { |
$r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture)); |
$r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture)); |
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole, |
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole, |
$nochoose); |
$nochoose); |
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles, |
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles, |
\%roletext); |
\%roletext,$update,$then); |
my $tremark=''; |
my $tremark=''; |
my $tbg; |
my $tbg; |
if ($env{'request.role'} eq 'cm') { |
if ($env{'request.role'} eq 'cm') { |
Line 918 ENDHEADER
|
Line 1493 ENDHEADER
|
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
|
} elsif (($placementonly) && ($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></form>'); |
|
$r->rflush(); |
|
$r->print('<script type="text/javascript">document.forms.rolechoice.submit();</script>'); |
|
$r->print(&Apache::loncommon::end_page()); |
|
return OK; |
} |
} |
# ----------------------------------------------------------------------- Table |
# ----------------------------------------------------------------------- Table |
|
|
|
if (($numdc > 0) || (($numhelpdesk > 0) && ($numadhoc > 0))) { |
|
$r->print(&coursepick_jscript(). |
|
&Apache::loncommon::coursebrowser_javascript()); |
|
} |
if ($numdc > 0) { |
if ($numdc > 0) { |
$r->print(&coursepick_jscript()); |
$r->print(&Apache::loncommon::authorbrowser_javascript()); |
$r->print(&Apache::loncommon::coursebrowser_javascript(). |
|
&Apache::loncommon::authorbrowser_javascript()); |
|
} |
} |
|
|
unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) { |
unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) { |
Line 954 ENDHEADER
|
Line 1541 ENDHEADER
|
$roletext{'user.role.'.$role}->[1]. |
$roletext{'user.role.'.$role}->[1]. |
&Apache::loncommon::end_data_table_row(); |
&Apache::loncommon::end_data_table_row(); |
} |
} |
if ($role =~ m{dc\./($match_domain)/} |
if ($role =~ m{^dc\./($match_domain)/$} |
&& $dcroles{$1}) { |
&& $dcroles{$1}) { |
$output .= &adhoc_roles_row($1,'recent'); |
$output .= &adhoc_roles_row($1,'recent'); |
|
} elsif ($role =~ m{^(dh|da)\./($match_domain)/$}) { |
|
$output .= &adhoc_customroles_row($1,$2,'recent',$update,$then); |
} |
} |
} elsif ($numdc > 0) { |
} elsif ($numdc > 0) { |
unless ($role =~/^error\:/) { |
unless ($role =~/^error\:/) { |
Line 985 ENDHEADER
|
Line 1574 ENDHEADER
|
$doheaders ++; |
$doheaders ++; |
} |
} |
} |
} |
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext); |
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext,$update,$then); |
if ($countactive > 1) { |
if ($countactive > 1) { |
my $tremark=''; |
my $tremark=''; |
my $tbg; |
my $tbg; |
Line 1030 ENDHEADER
|
Line 1619 ENDHEADER
|
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
$r->print('<p><small><i>' |
$r->print('<p><small><i>' |
.&mt('This LON-CAPA server is version [_1]',$r->dir_config('lonVersion')) |
.&mt('This LON-CAPA server is version [_1]',$r->dir_config('lonVersion')) |
.'</i><br />' |
.'</i></small></p>'); |
.'<a href="/adm/logout">'.&mt('Logout').'</a> ' |
|
.'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">' |
|
.&mt('Course/Community Catalog') |
|
.'</a></small></p>'); |
|
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
Line 1065 sub gather_roles {
|
Line 1650 sub gather_roles {
|
my $advanced = $env{'user.adv'}; |
my $advanced = $env{'user.adv'}; |
my $tryagain = $env{'form.tryagain'}; |
my $tryagain = $env{'form.tryagain'}; |
my @ids = &Apache::lonnet::current_machine_ids(); |
my @ids = &Apache::lonnet::current_machine_ids(); |
|
my (%willtrust,%trustchecked); |
if (ref($roles_in_env) eq 'HASH') { |
if (ref($roles_in_env) eq 'HASH') { |
|
my %adhocdesc; |
foreach my $envkey (sort(keys(%{$roles_in_env}))) { |
foreach my $envkey (sort(keys(%{$roles_in_env}))) { |
my $button = 1; |
my $button = 1; |
my $switchserver=''; |
my $switchserver=''; |
Line 1117 sub gather_roles {
|
Line 1704 sub gather_roles {
|
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 />'; } |
unless ($rauthor eq $rdomain.'-domainconfig') { |
$tremark.=&mt('Customrole defined by [_1].',$rauthor.':'.$rdomain); |
if ($tremark) { $tremark.='<br />'; } |
|
$tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain); |
|
} |
} |
} |
$trole=Apache::lonnet::plaintext($role); |
$trole=Apache::lonnet::plaintext($role); |
my $ttype; |
my $ttype; |
my $twhere; |
my $twhere; |
|
my $skipcal; |
my ($tdom,$trest,$tsection)= |
my ($tdom,$trest,$tsection)= |
split(/\//,Apache::lonnet::declutter($where)); |
split(/\//,Apache::lonnet::declutter($where)); |
# First, Co-Authorship roles |
# First, Co-Authorship roles |
if (($role eq 'ca') || ($role eq 'aa')) { |
if (($role eq 'ca') || ($role eq 'aa')) { |
my $home = &Apache::lonnet::homeserver($trest,$tdom); |
my $home = &Apache::lonnet::homeserver($trest,$tdom); |
my $allowed=0; |
my $allowed=0; |
|
my $prohibited; |
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } |
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } |
if (!$allowed) { |
if (!$allowed) { |
$button=0; |
$button=0; |
$switchserver='otherserver='.$home.'&role='.$trolecode; |
unless ($trustchecked{$tdom}) { |
|
if ((&Apache::lonnet::will_trust('othcoau',$env{'user.domain'},$tdom)) && |
|
(&Apache::lonnet::will_trust('coaurem',$tdom,$env{'user.domain'}))) { |
|
$willtrust{$tdom} = 1; |
|
$trustchecked{$tdom} = 1; |
|
} |
|
} |
|
if ($willtrust{$tdom}) { |
|
$switchserver='otherserver='.$home.'&role='.$trolecode; |
|
} else { |
|
$prohibited = 1; |
|
$tremark .= &mt('Session switch required but prohibited.'); |
|
} |
} |
} |
#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='Authoring Space'; |
$twhere=&mt('User').': '.$trest.'<br />'.&mt('Domain'). |
$twhere=&mt('User').': '.$trest.'<br />'.&mt('Domain'). |
': '.$tdom.'<br />'. |
': '.$tdom.'<br />'. |
' '.&mt('Server').': '.$home; |
' '.&mt('Server').': '.$home; |
$env{'course.'.$tdom.'_'.$trest.'.description'}='ca'; |
$env{'course.'.$tdom.'_'.$trest.'.description'}='ca'; |
$tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/'); |
unless ($prohibited) { |
|
$tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/'); |
|
} |
$sortkey=$role."$trest:$tdom"; |
$sortkey=$role."$trest:$tdom"; |
} elsif ($role eq 'au') { |
} elsif ($role eq 'au') { |
# Authors |
# Authors |
Line 1155 sub gather_roles {
|
Line 1760 sub gather_roles {
|
} |
} |
#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='Authoring Space'; |
$twhere=&mt('Domain').': '.$tdom.'<br />'.&mt('Server'). |
$twhere=&mt('Domain').': '.$tdom.'<br />'.&mt('Server'). |
': '.$home; |
': '.$home; |
$env{'course.'.$tdom.'_'.$trest.'.description'}='ca'; |
$env{'course.'.$tdom.'_'.$trest.'.description'}='ca'; |
Line 1164 sub gather_roles {
|
Line 1769 sub gather_roles {
|
} elsif ($trest) { |
} elsif ($trest) { |
my $tcourseid=$tdom.'_'.$trest; |
my $tcourseid=$tdom.'_'.$trest; |
$ttype = &Apache::loncommon::course_type($tcourseid); |
$ttype = &Apache::loncommon::course_type($tcourseid); |
$trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid); |
if ($role !~ /^cr/) { |
|
$trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid); |
|
} elsif ($role =~ m{^\Qcr/$tdom/$tdom\E\-domainconfig/(\w+)$}) { |
|
my $rolename = $1; |
|
my $desc; |
|
if (ref($adhocdesc{$tdom}) eq 'HASH') { |
|
$desc = $adhocdesc{$tdom}{$rolename}; |
|
} else { |
|
my %domdef = &Apache::lonnet::get_domain_defaults($tdom); |
|
if (ref($domdef{'adhocroles'}) eq 'HASH') { |
|
foreach my $rolename (sort(keys(%{$domdef{'adhocroles'}}))) { |
|
if (ref($domdef{'adhocroles'}{$rolename}) eq 'HASH') { |
|
$adhocdesc{$tdom}{$rolename} = $domdef{'adhocroles'}{$rolename}{'desc'}; |
|
$desc = $adhocdesc{$tdom}{$rolename}; |
|
} |
|
} |
|
} |
|
} |
|
if ($desc ne '') { |
|
$trole = $desc; |
|
} else { |
|
$trole = &mt('Helpdesk[_1]',' '.$rolename); |
|
} |
|
} else { |
|
$trole = (split(/\//,$role,4))[-1]; |
|
} |
if ($env{'course.'.$tcourseid.'.description'}) { |
if ($env{'course.'.$tcourseid.'.description'}) { |
my $home=$env{'course.'.$tcourseid.'.home'}; |
my $home=$env{'course.'.$tcourseid.'.home'}; |
$twhere=$env{'course.'.$tcourseid.'.description'}; |
$twhere=$env{'course.'.$tcourseid.'.description'}; |
Line 1178 sub gather_roles {
|
Line 1808 sub gather_roles {
|
my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'}; |
my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'}; |
if ($required ne '') { |
if ($required ne '') { |
($switchserver,$switchwarning) = |
($switchserver,$switchwarning) = |
&check_release_required($loncaparev,$tcourseid,$trolecode,$required); |
&Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required); |
if ($switchserver || $switchwarning) { |
if ($switchserver || $switchwarning) { |
$button = 0; |
$button = 0; |
} |
} |
Line 1201 sub gather_roles {
|
Line 1831 sub gather_roles {
|
my $required = $newhash{'internal.releaserequired'}; |
my $required = $newhash{'internal.releaserequired'}; |
if ($required ne '') { |
if ($required ne '') { |
($switchserver,$switchwarning) = |
($switchserver,$switchwarning) = |
&check_release_required($loncaparev,$tcourseid,$trolecode,$required); |
&Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required); |
if ($switchserver || $switchwarning) { |
if ($switchserver || $switchwarning) { |
$button = 0; |
$button = 0; |
} |
} |
Line 1212 sub gather_roles {
|
Line 1842 sub gather_roles {
|
$env{'course.'.$tcourseid.'.description'}=$twhere; |
$env{'course.'.$tcourseid.'.description'}=$twhere; |
$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey; |
$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey; |
$ttype = 'Unavailable'; |
$ttype = 'Unavailable'; |
|
$skipcal = 1; |
} |
} |
} |
} |
|
if ($ttype eq 'Placement') { |
|
$ttype = 'Placement Test'; |
|
} |
if ($tsection) { |
if ($tsection) { |
$twhere.='<br />'.&mt('Section').': '.$tsection; |
$twhere.='<br />'.&mt('Section').': '.$tsection; |
} |
} |
Line 1230 sub gather_roles {
|
Line 1864 sub gather_roles {
|
($role_text,$role_text_end) = |
($role_text,$role_text_end) = |
&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain, |
&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain, |
$advanced,$tremark,$tbg,$trole,$twhere,$tpstart, |
$advanced,$tremark,$tbg,$trole,$twhere,$tpstart, |
$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning); |
$tpend,$nochoose,$button,$switchserver,$reinit, |
|
$switchwarning,$skipcal); |
$roletext->{$envkey}=[$role_text,$role_text_end]; |
$roletext->{$envkey}=[$role_text,$role_text_end]; |
if (!$sortkey) {$sortkey=$twhere."\0".$envkey;} |
if (!$sortkey) {$sortkey=$twhere."\0".$envkey;} |
$sortrole->{$sortkey}=$envkey; |
$sortrole->{$sortkey}=$envkey; |
Line 1302 sub roletable_headers {
|
Line 1937 sub roletable_headers {
|
my $doheaders; |
my $doheaders; |
if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) { |
if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) { |
$r->print('<br />' |
$r->print('<br />' |
.&Apache::loncommon::start_data_table() |
.&Apache::loncommon::start_data_table('LC_textsize_mobile') |
.&Apache::loncommon::start_data_table_header_row() |
.&Apache::loncommon::start_data_table_header_row() |
); |
); |
if (!$nochoose) { $r->print('<th> </th>'); } |
if (!$nochoose) { $r->print('<th> </th>'); } |
Line 1328 sub roletable_headers {
|
Line 1963 sub roletable_headers {
|
} |
} |
|
|
sub roletypes { |
sub roletypes { |
my @types = ('Domain','Construction Space','Course','Community','Unavailable','System'); |
my @types = ('Domain','Authoring Space','Course','Placement Test','Community','Unavailable','System'); |
return @types; |
return @types; |
} |
} |
|
|
sub print_rolerows { |
sub print_rolerows { |
my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext) = @_; |
my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext,$update,$then) = @_; |
if ((ref($roleclass) eq 'HASH') && (ref($sortrole) eq 'HASH')) { |
if ((ref($roleclass) eq 'HASH') && (ref($sortrole) eq 'HASH')) { |
my @types = &roletypes(); |
my @types = &roletypes(); |
foreach my $type (@types) { |
foreach my $type (@types) { |
Line 1351 sub print_rolerows {
|
Line 1986 sub print_rolerows {
|
&Apache::loncommon::end_data_table_row(); |
&Apache::loncommon::end_data_table_row(); |
} |
} |
} |
} |
if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) { |
if ($sortrole->{$which} =~ m{^user\.role\.dc\./($match_domain)/}) { |
if (ref($dcroles) eq 'HASH') { |
if (ref($dcroles) eq 'HASH') { |
if ($dcroles->{$1}) { |
if ($dcroles->{$1}) { |
$output .= &adhoc_roles_row($1,''); |
$output .= &adhoc_roles_row($1,''); |
} |
} |
} |
} |
|
} elsif ($sortrole->{$which} =~ m{^user\.role\.(dh|da)\./($match_domain)/}) { |
|
$output .= &adhoc_customroles_row($1,$2,'',$update,$then); |
} |
} |
} |
} |
} |
} |
Line 1377 sub print_rolerows {
|
Line 2014 sub print_rolerows {
|
} |
} |
|
|
sub findcourse_advice { |
sub findcourse_advice { |
my ($r) = @_; |
my ($r,$cattype,$elapsed) = @_; |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) { |
if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) { |
$r->print(&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).' |
$r->print('<p>'.&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).' |
<ul> |
<ul> |
<li>'.&mt('The course has yet to be created.').'</li> |
<li>'.&mt('The course has yet to be created.').'</li> |
<li>'.&mt('Automatic enrollment of registered students has not been enabled for the course.').'</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('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('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> |
<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>'); |
<li>'.&mt('Automated enrollment added you to the course in the time since you last logged-in.').' '.&mt('If that is the case you can use the "Check for changes" link in the gray Functions bar to update the list of your available course roles.').'</li> |
|
</ul></p>'); |
} else { |
} else { |
$r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'<br />'); |
$r->print('<p>'.&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'</p>'); |
|
if ($elapsed > 600) { |
|
$r->print('<p>'.&mt('You may also have been assigned to a course in the time since you last logged-in, or checked for changes.'). |
|
'<br />'. |
|
&mt('If that is the case you can use the "Check for changes" link in the gray Functions bar to update the list of your available course roles.').'</p>'); |
|
} |
|
} |
|
if (($cattype eq 'std') || ($cattype eq 'domonly')) { |
|
$r->print('<h3>'.&mt('Self-Enrollment').'</h3>'. |
|
'<p>'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a>',$domdesc).'<br />'); |
|
$r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'</p>'. |
|
&Apache::loncoursequeueadmin::queued_selfenrollment()); |
} |
} |
$r->print('<h3>'.&mt('Self-Enrollment').'</h3>'. |
|
'<p>'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a>',$domdesc).'<br />'); |
|
$r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'</p>'. |
|
&Apache::loncoursequeueadmin::queued_selfenrollment()); |
|
return; |
return; |
} |
} |
|
|
sub requestcourse_advice { |
sub requestcourse_advice { |
my ($r) = @_; |
my ($r,$cattype,$inrole,$elapsed) = @_; |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
my (%can_request,%request_doms); |
my (%can_request,%request_doms,$output); |
&Apache::lonnet::check_can_request($env{'user.domain'},\%can_request,\%request_doms); |
&Apache::lonnet::check_can_request($env{'user.domain'},\%can_request,\%request_doms); |
if (keys(%request_doms) > 0) { |
if (keys(%request_doms) > 0) { |
my ($types,$typename) = &Apache::loncommon::course_types(); |
my ($types,$typename) = &Apache::loncommon::course_types(); |
if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) { |
if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) { |
$r->print('<h3>'.&mt('Request creation of a course or community').'</h3>'. |
|
'<p>'.&mt('You have rights to request the creation of courses and/or communities in the following domain(s):').'<ul>'); |
|
my (@reqdoms,@reqtypes); |
my (@reqdoms,@reqtypes); |
foreach my $type (sort(keys(%request_doms))) { |
foreach my $type (sort(keys(%request_doms))) { |
push(@reqtypes,$type); |
push(@reqtypes,$type); |
if (ref($request_doms{$type}) eq 'ARRAY') { |
if (ref($request_doms{$type}) eq 'ARRAY') { |
my $domstr = join(', ',map { &Apache::lonnet::domain($_) } sort(@{$request_doms{$type}})); |
my $domstr = join(', ',map { &Apache::lonnet::domain($_) } sort(@{$request_doms{$type}})); |
$r->print( |
$output .= |
'<li>' |
'<li>' |
.&mt('[_1]'.$typename->{$type}.'[_2] in domain: [_3]', |
.&mt('[_1]'.$typename->{$type}.'[_2] in domain: [_3]', |
'<i>', |
'<i>', |
'</i>', |
'</i>', |
'<b>'.$domstr.'</b>') |
'<b>'.$domstr.'</b>') |
.'</li>' |
.'</li>'; |
); |
|
foreach my $dom (@{$request_doms{$type}}) { |
foreach my $dom (@{$request_doms{$type}}) { |
unless (grep(/^\Q$dom\E/,@reqdoms)) { |
unless (grep(/^\Q$dom\E/,@reqdoms)) { |
push(@reqdoms,$dom); |
push(@reqdoms,$dom); |
Line 1445 sub requestcourse_advice {
|
Line 2087 sub requestcourse_advice {
|
} |
} |
if (@reqdoms == 1 || @showtypes > 0) { |
if (@reqdoms == 1 || @showtypes > 0) { |
$requrl .= '&state=crstype&action=new'; |
$requrl .= '&state=crstype&action=new'; |
} |
} |
$r->print('</ul>'.&mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.','<a href="'.$requrl.'">','</a>').'</p>'); |
if ($output) { |
|
$r->print('<h3>'.&mt('Request creation of a course or community').'</h3>'. |
|
'<p>'. |
|
&mt('You have rights to request the creation of courses and/or communities in the following domain(s):'). |
|
'<ul>'. |
|
$output. |
|
'</ul>'. |
|
&mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.', |
|
'<a href="'.$requrl.'">','</a>'). |
|
'</p>'); |
|
} |
} |
} |
|
} elsif (!$env{'user.adv'}) { |
|
if ($inrole) { |
|
$r->print('<h3>'.&mt('Currently no additional roles, courses or communities').'</h3>'); |
|
} else { |
|
$r->print('<h3>'.&mt('Currently no active roles, courses or communities').'</h3>'); |
|
} |
|
&findcourse_advice($r,$cattype,$elapsed); |
} |
} |
return; |
return; |
} |
} |
Line 1467 sub privileges_info {
|
Line 2126 sub privileges_info {
|
my (undef,$tdom,$trest,$tsec)=split(m{/},$where); |
my (undef,$tdom,$trest,$tsec)=split(m{/},$where); |
if ($trest) { |
if ($trest) { |
if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') { |
if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') { |
$ttype='Construction Space'; |
$ttype='Authoring Space'; |
$twhere='User: '.$trest.', Domain: '.$tdom; |
$twhere='User: '.$trest.', Domain: '.$tdom; |
} else { |
} else { |
$ttype= &Apache::loncommon::course_type($tdom.'_'.$trest); |
$ttype= &Apache::loncommon::course_type($tdom.'_'.$trest); |
Line 1508 sub privileges_info {
|
Line 2167 sub privileges_info {
|
} |
} |
|
|
sub build_roletext { |
sub build_roletext { |
my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning) = @_; |
my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere, |
my ($roletext,$roletext_end); |
$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning,$skipcal) = @_; |
my $is_dc=($trolecode =~ m/^dc\./); |
my ($roletext,$roletext_end,$poss_adhoc); |
my $rowspan=($is_dc) ? '' |
if ($trolecode =~ m/^d(c|h|a)\./) { |
|
$poss_adhoc = 1; |
|
} |
|
my $rowspan=($poss_adhoc) ? '' |
: ' rowspan="2" '; |
: ' rowspan="2" '; |
|
|
unless ($nochoose) { |
unless ($nochoose) { |
Line 1564 sub build_roletext {
|
Line 2226 sub build_roletext {
|
$trolecode."','".$buttonname.'\');" /></td>'; |
$trolecode."','".$buttonname.'\');" /></td>'; |
} |
} |
} |
} |
if ($trolecode !~ m/^(dc|ca|au|aa)\./) { |
if (($trolecode !~ m/^(dc|ca|au|aa)\./) && (!$skipcal)) { |
$tremark.=&Apache::lonannounce::showday(time,1, |
$tremark.=&Apache::lonannounce::showday(time,1, |
&Apache::lonannounce::readcalendar($tdom.'_'.$trest)); |
&Apache::lonannounce::readcalendar($tdom.'_'.$trest)); |
} |
} |
Line 1572 sub build_roletext {
|
Line 2234 sub build_roletext {
|
.'<td>'.$twhere.'</td>' |
.'<td>'.$twhere.'</td>' |
.'<td>'.$tpstart.'</td>' |
.'<td>'.$tpstart.'</td>' |
.'<td>'.$tpend.'</td>'; |
.'<td>'.$tpend.'</td>'; |
if (!$is_dc) { |
unless ($poss_adhoc) { |
$roletext_end = '<td colspan="4">'. |
$roletext_end = '<td colspan="4">'. |
$tremark.' '. |
$tremark.' '. |
'</td>'; |
'</td>'; |
Line 1580 sub build_roletext {
|
Line 2242 sub build_roletext {
|
return ($roletext,$roletext_end); |
return ($roletext,$roletext_end); |
} |
} |
|
|
sub check_needs_switchserver { |
|
my ($possiblerole) = @_; |
|
my $needs_switchserver; |
|
my ($role,$where) = split(/\./,$possiblerole,2); |
|
my (undef,$tdom,$twho) = split(/\//,$where); |
|
my ($server_status,$home); |
|
if (($role eq 'ca') || ($role eq 'aa')) { |
|
($server_status,$home) = &check_author_homeserver($twho,$tdom); |
|
} else { |
|
($server_status,$home) = &check_author_homeserver($env{'user.name'}, |
|
$env{'user.domain'}); |
|
} |
|
if ($server_status eq 'switchserver') { |
|
$needs_switchserver = 1; |
|
} |
|
return $needs_switchserver; |
|
} |
|
|
|
sub check_author_homeserver { |
sub check_author_homeserver { |
my ($uname,$udom)=@_; |
my ($uname,$udom)=@_; |
if (($uname eq '') || ($udom eq '')) { |
if (($uname eq '') || ($udom eq '')) { |
Line 1615 sub check_author_homeserver {
|
Line 2259 sub check_author_homeserver {
|
} |
} |
} |
} |
|
|
sub check_fordc { |
sub check_for_adhoc { |
my ($dcroles,$update,$then) = @_; |
my ($dcroles,$helpdeskroles,$update,$then) = @_; |
my $numdc = 0; |
my $numdc = 0; |
if ($env{'user.adv'}) { |
my $numhelpdesk = 0; |
foreach my $envkey (sort keys %env) { |
my $numadhoc = 0; |
if ($envkey=~/^user\.role\.dc\.\/($match_domain)\/$/) { |
my $num_custom_adhoc = 0; |
my $dcdom = $1; |
if (($env{'user.adv'}) || ($env{'user.rar'})) { |
my $livedc = 1; |
foreach my $envkey (sort(keys(%env))) { |
|
if ($envkey=~/^user\.role\.(dc|dh|da)\.\/($match_domain)\/$/) { |
|
my $role = $1; |
|
my $roledom = $2; |
|
my $liverole = 1; |
my ($tstart,$tend)=split(/\./,$env{$envkey}); |
my ($tstart,$tend)=split(/\./,$env{$envkey}); |
my $limit = $update; |
my $limit = $update; |
if ($env{'request.role'} eq 'dc./'.$dcdom.'/') { |
if ($env{'request.role'} eq "$role./$roledom/") { |
$limit = $then; |
$limit = $then; |
} |
} |
if ($tstart && $tstart>$limit) { $livedc = 0; } |
if ($tstart && $tstart>$limit) { $liverole = 0; } |
if ($tend && $tend <$limit) { $livedc = 0; } |
if ($tend && $tend <$limit) { $liverole = 0; } |
if ($livedc) { |
if ($liverole) { |
$$dcroles{$dcdom} = $envkey; |
if ($role eq 'dc') { |
$numdc++; |
$dcroles->{$roledom} = $envkey; |
|
$numdc++; |
|
} else { |
|
$helpdeskroles->{$roledom} = $envkey; |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($roledom); |
|
if (ref($domdefaults{'adhocroles'}) eq 'HASH') { |
|
if (keys(%{$domdefaults{'adhocroles'}})) { |
|
$numadhoc ++; |
|
} |
|
} |
|
$numhelpdesk++; |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
return $numdc; |
return ($numdc,$numhelpdesk,$numadhoc); |
} |
} |
|
|
sub adhoc_course_role { |
sub adhoc_course_role { |
Line 1663 sub adhoc_course_role {
|
Line 2322 sub adhoc_course_role {
|
} |
} |
} |
} |
if ($setprivs) { |
if ($setprivs) { |
if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { |
if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)(.*?)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { |
my $role = $1; |
my $role = $1; |
my $custom_role = $2; |
my $custom_role = $2; |
my $usec = $3; |
my $usec = $3; |
Line 1678 sub adhoc_course_role {
|
Line 2337 sub adhoc_course_role {
|
my %cgroups = |
my %cgroups = |
&Apache::lonnet::get_active_groups($env{'user.domain'}, |
&Apache::lonnet::get_active_groups($env{'user.domain'}, |
$env{'user.name'},$cdom,$cnum); |
$env{'user.name'},$cdom,$cnum); |
|
my $ccrole; |
|
if ($crstype eq 'Community') { |
|
$ccrole = 'co'; |
|
} else { |
|
$ccrole = 'cc'; |
|
} |
foreach my $group (keys(%cgroups)) { |
foreach my $group (keys(%cgroups)) { |
$group_privs{$group} = |
$group_privs{$group} = |
$env{'user.priv.cc./'.$cdom.'/'.$cnum.'./'.$cdom.'/'.$cnum.'/'.$group}; |
$env{'user.priv.'.$ccrole.'./'.$cdom.'/'.$cnum.'./'.$cdom.'/'.$cnum.'/'.$group}; |
} |
} |
$newgroups{'/'.$cdom.'/'.$cnum} = \%group_privs; |
$newgroups{'/'.$cdom.'/'.$cnum} = \%group_privs; |
my $area = '/'.$cdom.'/'.$cnum; |
my $area = '/'.$cdom.'/'.$cnum; |
Line 1728 sub check_forcc {
|
Line 2393 sub check_forcc {
|
return $is_cc; |
return $is_cc; |
} |
} |
|
|
sub check_release_required { |
|
my ($loncaparev,$tcourseid,$trolecode,$required) = @_; |
|
my ($switchserver,$warning); |
|
if ($required ne '') { |
|
my ($reqdmajor,$reqdminor) = ($required =~ /^(\d+)\.(\d+)$/); |
|
my ($major,$minor) = ($loncaparev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/); |
|
if ($reqdmajor ne '' && $reqdminor ne '') { |
|
my $otherserver; |
|
if (($major eq '' && $minor eq '') || |
|
(($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) { |
|
my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'}); |
|
my $switchlcrev = |
|
&Apache::lonnet::get_server_loncaparev($env{'user.domain'}, |
|
$userdomserver); |
|
my ($swmajor,$swminor) = ($switchlcrev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/); |
|
if (($swmajor eq '' && $swminor eq '') || ($reqdmajor > $swmajor) || |
|
(($reqdmajor == $swmajor) && ($reqdminor > $swminor))) { |
|
my $cdom = $env{'course.'.$tcourseid.'.domain'}; |
|
if ($cdom ne $env{'user.domain'}) { |
|
my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom); |
|
my $serverhomeID = &Apache::lonnet::get_server_homeID($coursehostname); |
|
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
|
my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom); |
|
my %udomdefaults = &Apache::lonnet::get_domain_defaults($env{'user.domain'}); |
|
my $remoterev = &Apache::lonnet::get_server_loncaparev($serverhomedom,$coursedomserver); |
|
my $canhost = |
|
&Apache::lonnet::can_host_session($env{'user.domain'}, |
|
$coursedomserver, |
|
$remoterev, |
|
$udomdefaults{'remotesessions'}, |
|
$defdomdefaults{'hostedsessions'}); |
|
|
|
if ($canhost) { |
|
$otherserver = $coursedomserver; |
|
} else { |
|
$warning = &mt('Requires LON-CAPA version [_1].',$env{'course.'.$tcourseid.'.internal.releaserequired'}).'<br />'. &mt("No suitable server could be found amongst servers in either your own domain or in the course's domain."); |
|
} |
|
} else { |
|
$warning = &mt('Requires LON-CAPA version [_1].',$env{'course.'.$tcourseid.'.internal.releaserequired'}).'<br />'.&mt("No suitable server could be found amongst servers in your own domain (which is also the course's domain)."); |
|
} |
|
} else { |
|
$otherserver = $userdomserver; |
|
} |
|
} |
|
if ($otherserver ne '') { |
|
$switchserver = 'otherserver='.$otherserver.'&role='.$trolecode; |
|
} |
|
} |
|
} |
|
return ($switchserver,$warning); |
|
} |
|
|
|
sub courselink { |
sub courselink { |
my ($dcdom,$rowtype) = @_; |
my ($roledom,$rowtype,$role) = @_; |
my $courseform=&Apache::loncommon::selectcourse_link |
my $courseform=&Apache::loncommon::selectcourse_link |
('rolechoice','dccourse'.$rowtype.'_'.$dcdom, |
('rolechoice','course'.$rowtype.'_'.$roledom.'_'.$role, |
'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'. |
'domain'.$rowtype.'_'.$roledom.'_'.$role, |
$dcdom,$dcdom,undef,'Course/Community'); |
'coursedesc'.$rowtype.'_'.$roledom.'_'.$role, |
my $hiddenitems = '<input type="hidden" name="dcdomain'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'. |
$roledom.':'.$role,undef,'Course/Community'); |
'<input type="hidden" name="origdom'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'. |
my $hiddenitems = '<input type="hidden" name="domain'.$rowtype.'_'.$roledom.'_'.$role.'" value="'.$roledom.'" />'. |
'<input type="hidden" name="dccourse'.$rowtype.'_'.$dcdom.'" value="" />'. |
'<input type="hidden" name="origdom'.$rowtype.'_'.$roledom.'_'.$role.'" value="'.$roledom.'" />'. |
'<input type="hidden" name="coursedesc'.$rowtype.'_'.$dcdom.'" value="" />'; |
'<input type="hidden" name="course'.$rowtype.'_'.$roledom.'_'.$role.'" value="" />'. |
|
'<input type="hidden" name="coursedesc'.$rowtype.'_'.$roledom.'_'.$role.'" value="" />'; |
return $courseform.$hiddenitems; |
return $courseform.$hiddenitems; |
} |
} |
|
|
sub coursepick_jscript { |
sub coursepick_jscript { |
my %lt = &Apache::lonlocal::texthash( |
my %js_lt = &Apache::lonlocal::texthash( |
plsu => "Please use the 'Select Course/Community' link to open a separate pick course window where you may select the course or community you wish to enter.", |
plsu => "Please use the 'Select Course/Community' link to open a separate pick course window where you may select the course or community you wish to enter.", |
youc => 'You can only use this screen to select courses and communities in the current domain.', |
youc => 'You can only use this screen to select courses and communities in the current domain.', |
); |
); |
|
&js_escape(\%js_lt); |
my $verify_script = <<"END"; |
my $verify_script = <<"END"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
Line 1814 function verifyCoursePick(caller) {
|
Line 2429 function verifyCoursePick(caller) {
|
} |
} |
} |
} |
else { |
else { |
alert("$lt{'plsu'}"); |
alert("$js_lt{'plsu'}"); |
} |
} |
} |
} |
else { |
else { |
alert("$lt{'youc'}") |
alert("$js_lt{'youc'}") |
} |
} |
} |
} |
function getIndex(caller) { |
function getIndex(caller) { |
Line 1856 sub display_cc_role {
|
Line 2471 sub display_cc_role {
|
my $trolecode = $ccrole.'./'.$tdom.'/'.$trest; |
my $trolecode = $ccrole.'./'.$tdom.'/'.$trest; |
my $twhere; |
my $twhere; |
my $ttype; |
my $ttype; |
|
my $skipcal; |
my $tbg='LC_roles_is'; |
my $tbg='LC_roles_is'; |
my %newhash=&Apache::lonnet::coursedescription($tcourseid); |
my %newhash=&Apache::lonnet::coursedescription($tcourseid); |
if (%newhash) { |
if (%newhash) { |
Line 1867 sub display_cc_role {
|
Line 2483 sub display_cc_role {
|
} else { |
} else { |
$twhere=&mt('Currently not available'); |
$twhere=&mt('Currently not available'); |
$env{'course.'.$tcourseid.'.description'}=$twhere; |
$env{'course.'.$tcourseid.'.description'}=$twhere; |
|
$skipcal = 1; |
} |
} |
my $trole = &Apache::lonnet::plaintext($ccrole,$ttype,$tcourseid); |
my $trole = &Apache::lonnet::plaintext($ccrole,$ttype,$tcourseid); |
$twhere.="<br />".&mt('Domain').":".$tdom; |
$twhere.="<br />".&mt('Domain').":".$tdom; |
($roletext,$roletext_end) = &build_roletext($trolecode,$tdom,$trest,'is',$tryagain,$advanced,'',$tbg,$trole,$twhere,'','','',1,''); |
($roletext,$roletext_end) = &build_roletext($trolecode,$tdom,$trest,'is',$tryagain,$advanced,'',$tbg,$trole,$twhere,'','','',1,'','','',$skipcal); |
|
} |
|
} |
|
return ($roletext,$roletext_end); |
|
} |
|
|
|
sub display_curr_role { |
|
my ($currentrole) = @_; |
|
my ($roletext,$roletext_end); |
|
my $advanced = $env{'user.adv'}; |
|
my $tryagain = $env{'form.tryagain'}; |
|
my ($role,$rest) = split(m{\./},$currentrole,2); |
|
unless (!defined($role) || $role eq '') { |
|
if ($rest =~ m{^($match_domain)/($match_courseid)(?:/(\w+)|$)}) { |
|
my $cdom = $1; |
|
my $cnum = $2; |
|
my $csec = $3; |
|
my $cid = $cdom.'_'.$cnum; |
|
my $ttype = $env{'course.'.$cid.'.type'}; |
|
my $skipcal = 1; |
|
my $tbg='LC_roles_is'; |
|
my $twhere = $env{'course.'.$cid.'.description'}. |
|
' <span class="LC_fontsize_small">'. |
|
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$cnum,$cdom). |
|
'</span>'; |
|
my $trole = &Apache::lonnet::plaintext($role,$ttype,$cid); |
|
if ($csec) { |
|
$twhere.= ' '.&mt('Section').': '.$csec; |
|
} |
|
if ($role ne 'st') { |
|
$twhere.= ' '.&mt('Domain').': '.$cdom; |
|
} |
|
($roletext,$roletext_end) = &build_roletext($currentrole,$cdom,$cnum,'is',$tryagain,$advanced,'',$tbg,$trole,$twhere,'','','',1,'','','',$skipcal); |
} |
} |
} |
} |
return ($roletext,$roletext_end); |
return ($roletext,$roletext_end); |
Line 1879 sub display_cc_role {
|
Line 2528 sub display_cc_role {
|
sub adhoc_roles_row { |
sub adhoc_roles_row { |
my ($dcdom,$rowtype) = @_; |
my ($dcdom,$rowtype) = @_; |
my $output = &Apache::loncommon::continue_data_table_row() |
my $output = &Apache::loncommon::continue_data_table_row() |
.' <td colspan="5">' |
.' <td colspan="5" class="LC_textsize_mobile">' |
.&mt('[_1]Ad hoc[_2] roles in domain [_3] --' |
.&mt('[_1]Ad hoc[_2] roles in domain [_3]' |
,'<span class="LC_cusr_emph">','</span>',$dcdom) |
,'<span class="LC_cusr_emph">','</span>',$dcdom) |
.' '; |
.' -- '; |
my $selectcclink = &courselink($dcdom,$rowtype); |
my $role = 'cc'; |
|
my $selectcclink = &courselink($dcdom,$rowtype,$role); |
my $ccrole = &Apache::lonnet::plaintext('co',undef,undef,1); |
my $ccrole = &Apache::lonnet::plaintext('co',undef,undef,1); |
my $carole = &Apache::lonnet::plaintext('ca'); |
my $carole = &Apache::lonnet::plaintext('ca'); |
my $selectcalink = &coauthorlink($dcdom,$rowtype); |
my $selectcalink = &coauthorlink($dcdom,$rowtype); |
Line 1893 sub adhoc_roles_row {
|
Line 2543 sub adhoc_roles_row {
|
return $output; |
return $output; |
} |
} |
|
|
|
sub adhoc_customroles_row { |
|
my ($role,$dhdom,$rowtype,$update,$then) = @_; |
|
my $liverole = 1; |
|
my ($tstart,$tend)=split(/\./,$env{"user.role.$role./$dhdom/"}); |
|
my $limit = $update; |
|
if (($role eq 'dh') && ($env{'request.role'} eq 'dh./'.$dhdom.'/')) { |
|
$limit = $then; |
|
} |
|
if ($tstart && $tstart>$limit) { $liverole = 0; } |
|
if ($tend && $tend <$limit) { $liverole = 0; } |
|
return unless ($liverole); |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($dhdom); |
|
if (ref($domdefaults{'adhocroles'}) eq 'HASH') { |
|
if (scalar(keys(%{$domdefaults{'adhocroles'}})) > 0) { |
|
return &Apache::loncommon::continue_data_table_row() |
|
.' <td colspan="5" class="LC_textsize_mobile">' |
|
.&mt('[_1]Ad hoc[_2] course/community roles in domain [_3]', |
|
'<span class="LC_cusr_emph">','</span>',$dhdom) |
|
.' -- '.&courselink($dhdom,$rowtype,$role); |
|
} |
|
} |
|
return; |
|
} |
|
|
sub recent_filename { |
sub recent_filename { |
my $area=shift; |
my $area=shift; |
return 'nohist_recent_'.&escape($area); |
return 'nohist_recent_'.&escape($area); |
Line 2152 sub update_session_roles {
|
Line 2826 sub update_session_roles {
|
my $status_in_db = |
my $status_in_db = |
&curr_role_status($tstart,$tend,$refresh,$now); |
&curr_role_status($tstart,$tend,$refresh,$now); |
my ($rdummy,$rest) = split(/\//,$role,2); |
my ($rdummy,$rest) = split(/\//,$role,2); |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
|
my %currpriv; |
my %currpriv; |
unless (exists($crprivs{$rest})) { |
unless (exists($crprivs{$rest})) { |
my ($rdomain,$rauthor,$rrole)=split(/\//,$rest); |
my ($rdomain,$rauthor,$rrole)=split(/\//,$rest); |
Line 2210 sub update_session_roles {
|
Line 2883 sub update_session_roles {
|
my $status_in_env = |
my $status_in_env = |
&curr_role_status($currstart,$currend,$refresh,$update); |
&curr_role_status($currstart,$currend,$refresh,$update); |
my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/); |
my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/); |
my ($role,$rest)=split(/\./,$rolekey,2); |
my ($role,$rest)=split(m{\./},$rolekey,2); |
|
$rest = '/'.$rest; |
if (&Apache::lonnet::delenv($envkey,undef,[$role])) { |
if (&Apache::lonnet::delenv($envkey,undef,[$role])) { |
if ($status_in_env eq 'active') { |
if ($status_in_env eq 'active') { |
if ($role eq 'gr') { |
if ($role eq 'gr') { |
Line 2406 sub update_session_roles {
|
Line 3080 sub update_session_roles {
|
} |
} |
$groupmsg .= '<li><b>'. |
$groupmsg .= '<li><b>'. |
$env{'course.'.$cdom.'_'.$cnum.'.description'}.'</b><ul>'; |
$env{'course.'.$cdom.'_'.$cnum.'.description'}.'</b><ul>'; |
|
$currcrs = $cdom.'_'.$cnum; |
} |
} |
my ($cdom,$cnum) = split(/\//,$1); |
|
my $group = $2; |
|
my $groupdesc; |
my $groupdesc; |
unless (ref($curr_groups{$cdom.'_'.$cnum}) eq 'HASH') { |
unless (ref($curr_groups{$cdom.'_'.$cnum}) eq 'HASH') { |
%{$curr_groups{$cdom.'_'.$cnum}} = |
%{$curr_groups{$cdom.'_'.$cnum}} = |
Line 2423 sub update_session_roles {
|
Line 3096 sub update_session_roles {
|
&unescape($groupinfo{'description'}); |
&unescape($groupinfo{'description'}); |
} |
} |
$groupdesc = $groupdescs{$cdom.'_'.$cnum}{$group}; |
$groupdesc = $groupdescs{$cdom.'_'.$cnum}{$group}; |
$groupmsg .= '<li>'. |
if ($groupdesc) { |
&mt('[_1] with status: [_2].', |
$groupmsg .= '<li>'. |
'<b>'.$groupdesc.'</b>',$newgroup{$item}).'</li>'; |
&mt('[_1] with status: [_2].', |
|
'<b>'.$groupdesc.'</b>',$newgroup{$item}).'</li>'; |
|
} |
} |
} |
} |
} |
if ($groupmsg) { |
if ($groupmsg) { |
Line 2439 sub update_session_roles {
|
Line 3114 sub update_session_roles {
|
} |
} |
} |
} |
if (keys(%newrole) > 0) { |
if (keys(%newrole) > 0) { |
$changemsg .= '<li>'.&mt('New roles'). |
my $newmsg; |
'<ul>'; |
|
foreach my $item (sort(keys(%newrole))) { |
foreach my $item (sort(keys(%newrole))) { |
my $desc = &role_desc($item,$update,$refresh,$now); |
my $desc = &role_desc($item,$update,$refresh,$now); |
$changemsg .= '<li>'. |
if ($desc) { |
&mt('[_1] with status: [_2].', |
$newmsg .= '<li>'. |
$desc,$newrole{$item}).'</li>'; |
&mt('[_1] with status: [_2].', |
|
$desc,&mt($newrole{$item})).'</li>'; |
|
} |
|
} |
|
if ($newmsg) { |
|
$changemsg .= '<li>'.&mt('New roles'). |
|
'<ul>'.$newmsg.'</ul>'. |
|
'</li>'; |
} |
} |
$changemsg .= '</ul></li>'; |
|
} |
} |
if (keys(%customprivchg) > 0) { |
if (keys(%customprivchg) > 0) { |
$changemsg .= '<li>'. |
my $privmsg; |
&mt('Custom roles with privilege changes'). |
|
'<ul>'; |
|
foreach my $item (sort(keys(%customprivchg))) { |
foreach my $item (sort(keys(%customprivchg))) { |
my $desc = &role_desc($item,$update,$refresh,$now); |
my $desc = &role_desc($item,$update,$refresh,$now); |
$changemsg .= '<li>'.$desc.'</li>'; |
if ($desc) { |
|
$privmsg .= '<li>'.$desc.'</li>'; |
|
} |
} |
} |
$changemsg .= '</ul></li>'; |
if ($privmsg) { |
|
$changemsg .= '<li>'. |
|
&mt('Custom roles with privilege changes'). |
|
'<ul>'.$privmsg.'</ul>'. |
|
'</li>'; |
|
} |
} |
} |
if (keys(%rolechange) > 0) { |
if (keys(%rolechange) > 0) { |
$changemsg .= '<li>'. |
my $rolemsg; |
&mt('Existing roles with status changes').'</li>'. |
|
'<ul>'; |
|
foreach my $item (sort(keys(%rolechange))) { |
foreach my $item (sort(keys(%rolechange))) { |
my $desc = &role_desc($item,$update,$refresh,$now); |
my $desc = &role_desc($item,$update,$refresh,$now); |
|
if ($desc) { |
|
$rolemsg .= '<li>'. |
|
&mt('[_1] status now: [_2].',$desc, |
|
$rolechange{$item}).'</li>'; |
|
} |
|
} |
|
if ($rolemsg) { |
$changemsg .= '<li>'. |
$changemsg .= '<li>'. |
&mt('[_1] status now: [_2].',$desc, |
&mt('Existing roles with status changes').'</li>'. |
$rolechange{$item}).'</li>'; |
'<ul>'.$rolemsg.'</ul>'. |
|
'</li>'; |
} |
} |
$changemsg .= '</ul></li>'; |
|
} |
} |
if (keys(%deletedroles) > 0) { |
if (keys(%deletedroles) > 0) { |
$changemsg .= '<li>'. |
my $delmsg; |
&mt('Existing roles now expired').'</li>'. |
|
'<ul>'; |
|
foreach my $item (sort(keys(%deletedroles))) { |
foreach my $item (sort(keys(%deletedroles))) { |
my $desc = &role_desc($item,$update,$refresh,$now); |
my $desc = &role_desc($item,$update,$refresh,$now); |
$changemsg .= '<li>'.$desc.'</li>'; |
if ($desc) { |
|
$delmsg .= '<li>'.$desc.'</li>'; |
|
} |
|
} |
|
if ($delmsg) { |
|
$changemsg .= '<li>'. |
|
&mt('Existing roles now expired').'</li>'. |
|
'<ul>'.$delmsg.'</ul>'. |
|
'</li>'; |
} |
} |
$changemsg .= '</ul></li>'; |
|
} |
} |
} |
} |
if ((keys(%changed_groups) > 0) || (keys(%groupchange) > 0)) { |
if ((keys(%changed_groups) > 0) || (keys(%groupchange) > 0)) { |
Line 2539 sub update_session_roles {
|
Line 3234 sub update_session_roles {
|
} |
} |
if ($changemsg) { |
if ($changemsg) { |
$msg .= '<ul>'.$changemsg.'</ul>'; |
$msg .= '<ul>'.$changemsg.'</ul>'; |
|
} else { |
|
if (&Apache::loncommon::show_course()) { |
|
$msg = &mt('No new courses or communities'); |
|
} else { |
|
$msg = &mt('No role changes'); |
|
} |
} |
} |
return $msg; |
return $msg; |
} |
} |
Line 2547 sub role_desc {
|
Line 3248 sub role_desc {
|
my ($item,$update,$refresh,$now) = @_; |
my ($item,$update,$refresh,$now) = @_; |
my ($where,$trolecode,$role,$tstatus,$tend,$tstart,$twhere, |
my ($where,$trolecode,$role,$tstatus,$tend,$tstart,$twhere, |
$trole,$tremark); |
$trole,$tremark); |
&Apache::lonnet::role_status('user.role.'.$item,$update,$refresh, $now,\$role,\$where, \$trolecode, |
&Apache::lonnet::role_status('user.role.'.$item,$update,$refresh, |
|
$now,\$role,\$where,\$trolecode, |
\$tstatus,\$tstart,\$tend); |
\$tstatus,\$tstart,\$tend); |
|
return unless ($role); |
if ($role =~ /^cr\//) { |
if ($role =~ /^cr\//) { |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
$tremark = &mt('Customrole defined by [_1].',$rauthor.':'.$rdomain); |
$tremark = &mt('Custom role defined by [_1].',$rauthor.':'.$rdomain); |
} |
} |
$trole=Apache::lonnet::plaintext($role); |
$trole=Apache::lonnet::plaintext($role); |
my ($tdom,$trest,$tsection)= |
my ($tdom,$trest,$tsection)= |
Line 2590 sub role_desc {
|
Line 3293 sub role_desc {
|
} elsif ($tdom) { |
} elsif ($tdom) { |
$twhere = &mt('Domain').': '.$tdom; |
$twhere = &mt('Domain').': '.$tdom; |
} |
} |
my $output = "$trole -- $twhere"; |
my $output; |
if ($tremark) { |
if ($trole) { |
$output .= '<br />'.$tremark; |
$output = $trole; |
|
if ($twhere) { |
|
$output .= " -- $twhere"; |
|
} |
|
if ($tremark) { |
|
$output .= '<br />'.$tremark; |
|
} |
} |
} |
return $output; |
return $output; |
} |
} |
Line 2657 sub is_active_course {
|
Line 3366 sub is_active_course {
|
} |
} |
|
|
sub get_roles_functions { |
sub get_roles_functions { |
my ($rolescount) = @_; |
my ($rolescount,$cattype) = @_; |
my @links; |
my @links; |
push(@links,["javascript:rolesView('doupdate');",'start-here-22x22',&mt('Check for changes')]); |
push(@links,["javascript:rolesView('doupdate');",'start-here-22x22',&mt('Check for changes')]); |
if ($env{'environment.canrequest.author'}) { |
if ($env{'environment.canrequest.author'}) { |
Line 2678 sub get_roles_functions {
|
Line 3387 sub get_roles_functions {
|
} |
} |
if ($env{'user.adv'}) { |
if ($env{'user.adv'}) { |
if ($env{'form.display'} eq 'showall') { |
if ($env{'form.display'} eq 'showall') { |
push(@links,["javascript:rolesView('noshowall');",'edit-redo-22x22',&mt('Exclude expired roles')]); |
push(@links,["javascript:rolesView('noshowall');",'edit-redo-22x22',&mt('Exclude expired')]); |
} else { |
} else { |
push(@links,["javascript:rolesView('showall');",'edit-undo-22x22',&mt('Include expired roles')]); |
push(@links,["javascript:rolesView('showall');",'edit-undo-22x22',&mt('Include expired')]); |
} |
} |
} |
} |
my $funcs = &Apache::lonhtmlcommon::start_funclist(); |
unless ($cattype eq 'none') { |
foreach my $link (@links) { |
push(@links,['/adm/coursecatalog','ccat-22x22',&mt('Course catalog')]); |
$funcs .= &Apache::lonhtmlcommon::add_item_funclist( |
|
'<a href="'.$link->[0].'" class="LC_menubuttons_link">'. |
|
'<img src="/res/adm/pages/'.$link->[1].'.png" class="LC_icon" alt="'.$link->[2].'" />'. |
|
$link->[2].'</a>'); |
|
} |
} |
$funcs .= &Apache::lonhtmlcommon::end_funclist(); |
my $funcs; |
return &Apache::loncommon::head_subbox($funcs); |
if ($env{'browser.mobile'}) { |
|
my @functions; |
|
foreach my $link (@links) { |
|
push(@functions,[$link->[0],$link->[2]]); |
|
} |
|
my $title = 'Display options'; |
|
if ($env{'user.adv'}) { |
|
$title = 'Roles options'; |
|
} |
|
$funcs = &Apache::lonmenu::create_submenu('','',$title,\@functions,1,'LC_breadcrumbs_hoverable'); |
|
$funcs = '<ol class="LC_primary_menu LC_floatright">'.$funcs.'</ol>'; |
|
} else { |
|
$funcs = &Apache::lonhtmlcommon::start_funclist(); |
|
foreach my $link (@links) { |
|
$funcs .= &Apache::lonhtmlcommon::add_item_funclist( |
|
'<a href="'.$link->[0].'" class="LC_menubuttons_link">'. |
|
'<img src="/res/adm/pages/'.$link->[1].'.png" class="LC_icon" alt="'.$link->[2].'" />'. |
|
$link->[2].'</a>'); |
|
} |
|
$funcs .= &Apache::lonhtmlcommon::end_funclist(); |
|
$funcs = &Apache::loncommon::head_subbox($funcs); |
|
} |
|
return $funcs; |
} |
} |
|
|
sub get_queued { |
sub get_queued { |
Line 2701 sub get_queued {
|
Line 3428 sub get_queued {
|
$env{'user.name'},'^status:'); |
$env{'user.name'},'^status:'); |
foreach my $key (keys(%statusinfo)) { |
foreach my $key (keys(%statusinfo)) { |
next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')); |
next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')); |
(undef,my($cdom,$cnum)) = split(':',$key); |
(undef,my($cdom,$cnum)) = split(/:/,$key); |
my $requestkey = $cdom.'_'.$cnum; |
my $requestkey = $cdom.'_'.$cnum; |
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) { |
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) { |
my %history = &Apache::lonnet::restore($requestkey,'courserequests', |
my %history = &Apache::lonnet::restore($requestkey,'courserequests', |
Line 2751 sub get_queued {
|
Line 3478 sub get_queued {
|
if (($status eq 'approval') || ($status eq 'approved')) { |
if (($status eq 'approval') || ($status eq 'approved')) { |
$output .= '<p><b>'.&mt('Author role request').'</b><br />'; |
$output .= '<p><b>'.&mt('Author role request').'</b><br />'; |
if ($status eq 'approval') { |
if ($status eq 'approval') { |
$output .= &mt('A request for authoring space submitted on [_1] is awaiting approval', |
$output .= &mt('A request for Authoring Space submitted on [_1] is awaiting approval', |
&Apache::lonlocal::locallocaltime($timestamp)); |
&Apache::lonlocal::locallocaltime($timestamp)); |
} elsif ($status eq 'approved') { |
} elsif ($status eq 'approved') { |
my %roleshash = |
my %roleshash = |
Line 2780 sub get_queued {
|
Line 3507 sub get_queued {
|
$output.'</fieldset></div><br clear="all" />'; |
$output.'</fieldset></div><br clear="all" />'; |
} |
} |
|
|
|
sub process_lti { |
|
my ($r,$cdom,$cnum) = @_; |
|
my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider'); |
|
my $uriscope = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'}, |
|
$cdom,$cnum); |
|
my $lonhost = $r->dir_config('lonHostID'); |
|
my $internet_names = &Apache::lonnet::get_internet_names($lonhost); |
|
if ($env{'request.lti.rosterid'} && |
|
$env{'request.lti.rosterurl'}) { |
|
if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') { |
|
if ($lti{$env{'request.lti.login'}}{'roster'}) { |
|
my @lcroles = ('in','ta','ep','st'); |
|
my @possibleroles; |
|
foreach my $role (@lcroles) { |
|
if (&Apache::lonnet::allowed('c'.$role,"$cdom/$cnum")) { |
|
push(@possibleroles,$role); |
|
} |
|
} |
|
my $owner = $env{'course.'.$cdom.'_'.$cnum.'.internal.courseowner'}; |
|
if ($owner eq $env{'user.name'}.':'.$env{'user.domain'}) { |
|
my $crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum); |
|
if ($crstype eq 'Community') { |
|
unshift(@possibleroles,'co'); |
|
} else { |
|
unshift(@possibleroles,'cc'); |
|
} |
|
} |
|
if (@possibleroles) { |
|
push(@{$rosterupdates},{cid => $cdom.'_'.$cnum, |
|
lti => $env{'request.lti.login'}, |
|
ltiref => $lti{$env{'request.lti.login'}}, |
|
id => $env{'request.lti.rosterid'}, |
|
url => $env{'request.lti.rosterurl'}, |
|
sourcecrs => $env{'request.lti.sourcecrs'}, |
|
uriscope => $uriscope, |
|
possroles => \@possibleroles, |
|
intdoms => $internet_names, |
|
}); |
|
unless ($registered_cleanup) { |
|
my $handlers = $r->get_handlers('PerlCleanupHandler'); |
|
$r->set_handlers('PerlCleanupHandler' => |
|
[\<ienroll,@{$handlers}]); |
|
$registered_cleanup=1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($env{'request.lti.passbackid'} && |
|
$env{'request.lti.passbackurl'}) { |
|
if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') { |
|
if ($lti{$env{'request.lti.login'}}{'passback'}) { |
|
my ($pbnum,$error) = |
|
&LONCAPA::ltiutils::store_passbackurl($env{'request.lti.login'}, |
|
$env{'request.lti.passbackurl'}, |
|
$cdom,$cnum); |
|
if ($pbnum eq '') { |
|
$pbnum = $env{'request.lti.passbackurl'}; |
|
} |
|
&Apache::lonnet::put('nohist_'.$cdom.'_'.$cnum.'_passback', |
|
{"$uriscope\0$env{'request.lti.sourcecrs'}\0$env{'request.lti.login'}" => |
|
"$pbnum\0$env{'request.lti.passbackid'}"}); |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub ltienroll { |
|
if (ref($rosterupdates) eq 'ARRAY') { |
|
foreach my $item (@{$rosterupdates}) { |
|
if (ref($item) eq 'HASH') { |
|
&LONCAPA::ltiutils::batchaddroster($item); |
|
} |
|
} |
|
} |
|
} |
|
|
|
sub set_deeplink_target { |
|
my ($cnum,$cdom) = @_; |
|
if (($cnum ne '') && ($cdom ne '')) { |
|
my $deeplink_symb = &Apache::loncommon::deeplink_login_symb($cnum,$cdom); |
|
if ($deeplink_symb ne '') { |
|
my $deeplink; |
|
if ($deeplink_symb =~ /\.(page|sequence)$/) { |
|
my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($deeplink_symb))[2]); |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if (ref($navmap)) { |
|
$deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink'); |
|
} |
|
} elsif ($deeplink_symb ne '') { |
|
$deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$deeplink_symb); |
|
} |
|
if ($deeplink ne '') { |
|
my ($state,$others,$listed,$scope,$protect,$display,$target) = split(/,/,$deeplink); |
|
if ($target ne '') { |
|
&Apache::lonnet::appenv({'request.deeplink.target' => $target}); |
|
} elsif (exists($env{'request.deeplink.target'})) { |
|
&Apache::lonnet::delenv('request.deeplink.target'); |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub set_supplemental_access { |
|
my ($cnum,$cdom) = @_; |
|
my ($supplemental,$refs_updated) = &Apache::lonnet::get_supplemental($cnum,$cdom); |
|
unless ($refs_updated) { |
|
&Apache::loncommon::set_supp_httprefs($cnum,$cdom,$supplemental); |
|
} |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |
|
|