version 1.269.2.30, 2017/01/22 14:28:20
|
version 1.308, 2014/05/31 12:49:12
|
Line 143 use Apache::lonrss;
|
Line 143 use Apache::lonrss;
|
use GDBM_File; |
use GDBM_File; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use HTML::Entities; |
use HTML::Entities; |
|
|
|
|
sub redirect_user { |
sub redirect_user { |
my ($r,$title,$url,$msg) = @_; |
my ($r,$title,$url,$msg) = @_; |
Line 151 sub redirect_user {
|
Line 151 sub redirect_user {
|
&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 $swinfo=&Apache::lonmenu::rawconfig(); |
|
|
|
# Breadcrumbs |
# Breadcrumbs |
my $brcrum = [{'href' => $url, |
my $brcrum = [{'href' => $url, |
Line 166 sub redirect_user {
|
Line 165 sub redirect_user {
|
$url=~s/ /\%20/g; |
$url=~s/ /\%20/g; |
$r->print(<<ENDREDIR); |
$r->print(<<ENDREDIR); |
$start_page |
$start_page |
<script type="text/javascript"> |
|
// <![CDATA[ |
|
$swinfo |
|
// ]]> |
|
</script> |
|
<p>$msg</p> |
<p>$msg</p> |
$end_page |
$end_page |
ENDREDIR |
ENDREDIR |
Line 229 sub handler {
|
Line 223 sub handler {
|
|
|
&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 260 sub handler {
|
Line 254 sub handler {
|
|
|
my $envkey; |
my $envkey; |
my %dcroles = (); |
my %dcroles = (); |
my %dhroles = (); |
my $numdc = &check_fordc(\%dcroles,$update,$then); |
my ($numdc,$numdh,$numadhoc) = &check_for_adhoc(\%dcroles,\%dhroles,$update,$then); |
|
my $loncaparev = $r->dir_config('lonVersion'); |
my $loncaparev = $r->dir_config('lonVersion'); |
|
|
# ================================================================== Roles Init |
# ================================================================== Roles Init |
Line 270 sub handler {
|
Line 263 sub handler {
|
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 role trying to enter a course |
|
if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/\w+\./\1/$match_courseid$}) { |
|
if ($dhroles{$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 300 sub handler {
|
Line 286 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.course.timechecked" => '', |
"request.role" => 'cm', |
"request.role" => 'cm', |
"request.role.adv" => $env{'user.adv'}, |
"request.role.adv" => $env{'user.adv'}, |
"request.role.domain" => $env{'user.domain'}}); |
"request.role.domain" => $env{'user.domain'}}); |
|
# Check if Domain Helpdesk role trying to enter a course needs privs to be created |
|
if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)(?:/(\w+)|$)}) { |
|
my $cdom = $1; |
|
my $rolename = $2; |
|
my $cnum = $3; |
|
my $sec = $4; |
|
if ($custom_adhoc) { |
|
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}); |
|
} |
|
} |
|
} |
|
} |
|
} elsif (($numdc > 0) || ($numdh > 0)) { |
|
# Check if user is a DC trying to enter a course or author space and needs privs to be created |
# Check if user is a DC trying to enter a course or author space and needs privs to be created |
# Check if user is a DH trying to enter a course and needs privs to be created |
if ($numdc > 0) { |
foreach my $envkey (keys(%env)) { |
foreach my $envkey (keys(%env)) { |
if ($numdc) { |
|
# Is this an ad-hoc Coordinator role? |
# Is this an ad-hoc Coordinator role? |
if (my ($ccrole,$domain,$coursenum) = |
if (my ($ccrole,$domain,$coursenum) = |
($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) { |
($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) { |
if ($dcroles{$domain}) { |
if ($dcroles{$domain}) { |
if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum, |
if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum, |
$update,$refresh,$now,$ccrole)) { |
$update,$refresh,$now,$ccrole)) { |
&Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.$ccrole.adhoc" => time}); |
&Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.$ccrole.adhoc" => time}); |
} |
|
} |
} |
last; |
|
} |
} |
|
last; |
|
} |
# Is this an ad-hoc CA-role? |
# Is this an ad-hoc CA-role? |
if (my ($domain,$user) = |
if (my ($domain,$user) = |
($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) { |
($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) { |
if (($domain eq $env{'user.domain'}) && ($user eq $env{'user.name'})) { |
if (($domain eq $env{'user.domain'}) && ($user eq $env{'user.name'})) { |
delete($env{$envkey}); |
delete($env{$envkey}); |
$env{'form.au./'.$domain.'/'} = 1; |
$env{'form.au./'.$domain.'/'} = 1; |
|
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
|
if ($server_status eq 'switchserver') { |
|
my $trolecode = 'au./'.$domain.'/'; |
|
my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode; |
|
$r->internal_redirect($switchserver); |
|
return OK; |
|
} |
|
last; |
|
} |
|
if (my ($castart,$caend) = ($env{'user.role.ca./'.$domain.'/'.$user} =~ /^(\d*)\.(\d*)$/)) { |
|
if (((($castart) && ($castart < $now)) || !$castart) && |
|
((!$caend) || (($caend) && ($caend > $now)))) { |
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
if ($server_status eq 'switchserver') { |
if ($server_status eq 'switchserver') { |
my $trolecode = 'au./'.$domain.'/'; |
my $trolecode = 'ca./'.$domain.'/'.$user; |
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; |
return OK; |
} |
} |
last; |
last; |
} |
} |
if (my ($castart,$caend) = ($env{'user.role.ca./'.$domain.'/'.$user} =~ /^(\d*)\.(\d*)$/)) { |
} |
if (((($castart) && ($castart < $now)) || !$castart) && |
# Check if author blocked ca-access |
((!$caend) || (($caend) && ($caend > $now)))) { |
my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user); |
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
if ($blocked{'domcoord.author'} eq 'blocked') { |
if ($server_status eq 'switchserver') { |
delete($env{$envkey}); |
my $trolecode = 'ca./'.$domain.'/'.$user; |
$env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access'; |
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}) { |
if ($numdh) { |
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
# Is this an ad hoc custom role in a course/community? |
if (($server_status eq 'ok') || ($server_status eq 'switchserver')) { |
if (my ($domain,$rolename,$coursenum,$sec) = ($envkey =~ m{^form\.cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)(?:/(\w+)|$)})) { |
&Apache::lonnet::check_adhoc_privs($domain,$user,$update, |
if ($dhroles{$domain}) { |
$refresh,$now,'ca'); |
my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($domain.'_'.$coursenum,1); |
if ($server_status eq 'switchserver') { |
if (ref($possroles) eq 'ARRAY') { |
my $trolecode = 'ca./'.$domain.'/'.$user; |
if (grep(/^\Q$rolename\E$/,@{$possroles})) { |
my $switchserver = '/adm/switchserver?' |
if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum,$update,$refresh,$now, |
.'otherserver='.$home.'&role='.$trolecode; |
"cr/$domain/$domain".'-domainconfig/'.$rolename, |
$r->internal_redirect($switchserver); |
undef,$sec)) { |
return OK; |
&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}); |
} |
} |
last; |
} else { |
|
delete($env{$envkey}); |
} |
} |
} |
last; |
|
} |
} |
} |
} |
} |
|
|
Line 442 sub handler {
|
Line 382 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) = |
&Apache::loncommon::check_release_required($loncaparev,$cdom.'_'.$cnum,$trolecode, |
&check_release_required($loncaparev,$cdom.'_'.$cnum,$trolecode,$curr_reqd_hash{'internal.releaserequired'}); |
$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; |
$r->print(&Apache::loncommon::check_release_result($switchwarning,$switchserver)); |
my $end_page=&Apache::loncommon::end_page(); |
|
$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 561 ENDENTERKEY
|
Line 518 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 570 ENDENTERKEY
|
Line 527 ENDENTERKEY
|
my $tadv=0; |
my $tadv=0; |
|
|
if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) { |
if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) { |
if ($role =~ m{^\Qcr/$cdom/$cdom\E\-domainconfig/(\w+)$}) { |
|
my $rolename = $1; |
|
my %domdef = &Apache::lonnet::get_domain_defaults($cdom); |
|
if (ref($domdef{'adhocroles'}) eq 'HASH') { |
|
if (ref($domdef{'adhocroles'}{$rolename}) eq 'HASH') { |
|
&Apache::lonnet::appenv({'request.role.desc' => $domdef{'adhocroles'}{$rolename}{'desc'}}); |
|
} |
|
} |
|
} |
|
my $msg; |
my $msg; |
my ($furl,$ferr)= |
my ($furl,$ferr)= |
&Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
&Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
unless ($ferr) { |
unless ($ferr) { |
unless (($env{'form.switchrole'}) || |
unless (($env{'form.switchrole'}) || |
($env{"environment.internal.$cdom.$cnum.$role.adhoc"})) { |
($env{"environment.internal.$cdom.$cnum.$role.adhoc"})) { |
&Apache::lonnet::put('nohist_crslastlogin', |
&Apache::lonnet::put('nohist_crslastlogin', |
{$env{'user.name'}.':'.$env{'user.domain'}. |
{$env{'user.name'}.':'.$env{'user.domain'}. |
Line 606 ENDENTERKEY
|
Line 554 ENDENTERKEY
|
} |
} |
if (($env{'form.orgurl'}) && |
if (($env{'form.orgurl'}) && |
($env{'form.orgurl'}!~/^\/adm\/flip/) && |
($env{'form.orgurl'}!~/^\/adm\/flip/) && |
($env{'form.orgurl'} ne '/adm/roles')) { |
($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 =~ /\?/) { |
Line 672 ENDENTERKEY
|
Line 620 ENDENTERKEY
|
if ($env{'request.role.adv'}) { |
if ($env{'request.role.adv'}) { |
$dest = &Apache::lonenc::unencrypted($dest); |
$dest = &Apache::lonenc::unencrypted($dest); |
if ($destsymb eq '') { |
if ($destsymb eq '') { |
($destsymb) = ($dest =~ /(?:\?|\&)symb=([^\&]*)/); |
($destsymb) = ($dest =~ /(?:\?|\&)symb=([^\&]*)/); |
$destsymb = &unescape($destsymb); |
$destsymb = &unescape($destsymb); |
} |
} |
} |
} |
Line 697 ENDENTERKEY
|
Line 645 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 .= '?symb='.$esc_symb; |
Line 725 ENDENTERKEY
|
Line 673 ENDENTERKEY
|
} |
} |
} |
} |
# Are we allowed to look at the first resource? |
# Are we allowed to look at the first resource? |
my $access; |
|
if ($furl =~ m{^(/adm/wrapper|)/ext/}) { |
if ($furl =~ m{^(/adm/wrapper|)/ext/}) { |
# If it's an external resource, |
# If it's an external resource, |
# strip off the symb argument and possible query |
# strip off the symb argument and possible query |
Line 733 ENDENTERKEY
|
Line 680 ENDENTERKEY
|
# Unencode $symb |
# Unencode $symb |
$symb = &unescape($symb); |
$symb = &unescape($symb); |
# Then check for permission |
# Then check for permission |
$access = &Apache::lonnet::allowed('bre',$exturl,$symb); |
if (!&Apache::lonnet::allowed('bre',$exturl,$symb)) { |
|
$furl = &Apache::lonpageflip::first_accessible_resource(); |
|
} |
# For other resources just check for permission |
# For other resources just check for permission |
} else { |
} elsif (!&Apache::lonnet::allowed('bre',$furl)) { |
$access = &Apache::lonnet::allowed('bre',$furl); |
|
} |
|
if (!$access) { |
|
$furl = &Apache::lonpageflip::first_accessible_resource(); |
$furl = &Apache::lonpageflip::first_accessible_resource(); |
} elsif ($access eq 'B') { |
|
$furl = '/adm/navmaps?showOnlyHomework=1'; |
|
} |
} |
|
|
$msg = &mt('Entering [_1] ...', |
$msg = &mt('Entering [_1] ...', |
$env{'course.'.$cdom.'_'.$cnum.'.description'}); |
$env{'course.'.$cdom.'_'.$cnum.'.description'}); |
&redirect_user($r, &mt('Entering [_1]', |
&redirect_user($r, &mt('Entering [_1]', |
Line 772 ENDENTERKEY
|
Line 717 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 '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 806 ENDENTERKEY
|
Line 745 ENDENTERKEY
|
$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.'); |
$standby = &mt('Course selected. Please stand by.'); |
} |
} |
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; |
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; |
|
|
Line 814 ENDENTERKEY
|
Line 753 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 %domdefs=&Apache::lonnet::get_domain_defaults($env{'user.domain'}); |
my $cattype = 'std'; |
my $cattype = 'std'; |
if ($domdefs{'catauth'}) { |
if ($domdefs{'catauth'}) { |
$cattype = $domdefs{'catauth'}; |
$cattype = $domdefs{'catauth'}; |
} |
} |
my $funcs = &get_roles_functions($showcount,$cattype); |
my $funcs = &get_roles_functions($showcount,$cattype); |
my $crumbsright; |
$standby=~s/\n/\\n/g; |
if ($env{'browser.mobile'}) { |
|
$crumbsright = $funcs; |
|
undef($funcs); |
|
} |
|
my $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 860 function rolesView (caller) {
|
Line 793 function rolesView (caller) {
|
document.rolechoice.display.value = caller; |
document.rolechoice.display.value = caller; |
} else { |
} else { |
if ((caller == 'doupdate') || (caller == 'requestauthor') || |
if ((caller == 'doupdate') || (caller == 'requestauthor') || |
(caller == 'queued')) { |
(caller == 'queued')) { |
document.rolechoice.state.value = caller; |
document.rolechoice.state.value = caller; |
} |
} |
} |
} |
Line 944 ENDHEADER
|
Line 877 ENDHEADER
|
} |
} |
if ($hotlist) { |
if ($hotlist) { |
$showresult .= $hotlist; |
$showresult .= $hotlist; |
} |
} |
$showresult .= '</div>'; |
$showresult .= '</div>'; |
$r->print($showresult); |
$r->print($showresult); |
} elsif ($env{'form.state'} eq 'queued') { |
} elsif ($env{'form.state'} eq 'queued') { |
Line 1000 ENDHEADER
|
Line 933 ENDHEADER
|
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,$update,$then); |
\%roletext); |
my $tremark=''; |
my $tremark=''; |
my $tbg; |
my $tbg; |
if ($env{'request.role'} eq 'cm') { |
if ($env{'request.role'} eq 'cm') { |
Line 1025 ENDHEADER
|
Line 958 ENDHEADER
|
} |
} |
# ----------------------------------------------------------------------- Table |
# ----------------------------------------------------------------------- Table |
|
|
if (($numdc > 0) || (($numdh > 0) && ($numadhoc > 0))) { |
if ($numdc > 0) { |
$r->print(&coursepick_jscript()); |
$r->print(&coursepick_jscript()); |
$r->print(&Apache::loncommon::coursebrowser_javascript(). |
$r->print(&Apache::loncommon::coursebrowser_javascript(). |
&Apache::loncommon::authorbrowser_javascript()); |
&Apache::loncommon::authorbrowser_javascript()); |
Line 1058 ENDHEADER
|
Line 991 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)\./($match_domain)/$}) { |
|
$output .= &adhoc_customroles_row($1,$2,'recent',$update,$then); |
|
} |
} |
} elsif ($numdc > 0) { |
} elsif ($numdc > 0) { |
unless ($role =~/^error\:/) { |
unless ($role =~/^error\:/) { |
Line 1091 ENDHEADER
|
Line 1022 ENDHEADER
|
$doheaders ++; |
$doheaders ++; |
} |
} |
} |
} |
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext,$update,$then); |
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext); |
if ($countactive > 1) { |
if ($countactive > 1) { |
my $tremark=''; |
my $tremark=''; |
my $tbg; |
my $tbg; |
Line 1168 sub gather_roles {
|
Line 1099 sub gather_roles {
|
my $tryagain = $env{'form.tryagain'}; |
my $tryagain = $env{'form.tryagain'}; |
my @ids = &Apache::lonnet::current_machine_ids(); |
my @ids = &Apache::lonnet::current_machine_ids(); |
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 1220 sub gather_roles {
|
Line 1150 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); |
unless ($rauthor eq $rdomain.'-domainconfig') { |
if ($tremark) { $tremark.='<br />'; } |
if ($tremark) { $tremark.='<br />'; } |
$tremark.=&mt('Custom role 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 $ttype; |
my $ttype; |
Line 1269 sub gather_roles {
|
Line 1197 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); |
if ($role !~ /^cr/) { |
$trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid); |
$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 1308 sub gather_roles {
|
Line 1211 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) = |
&Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required); |
&check_release_required($loncaparev,$tcourseid,$trolecode,$required); |
if ($switchserver || $switchwarning) { |
if ($switchserver || $switchwarning) { |
$button = 0; |
$button = 0; |
} |
} |
Line 1331 sub gather_roles {
|
Line 1234 sub gather_roles {
|
my $required = $newhash{'internal.releaserequired'}; |
my $required = $newhash{'internal.releaserequired'}; |
if ($required ne '') { |
if ($required ne '') { |
($switchserver,$switchwarning) = |
($switchserver,$switchwarning) = |
&Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required); |
&check_release_required($loncaparev,$tcourseid,$trolecode,$required); |
if ($switchserver || $switchwarning) { |
if ($switchserver || $switchwarning) { |
$button = 0; |
$button = 0; |
} |
} |
Line 1432 sub roletable_headers {
|
Line 1335 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('LC_textsize_mobile') |
.&Apache::loncommon::start_data_table() |
.&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 1463 sub roletypes {
|
Line 1366 sub roletypes {
|
} |
} |
|
|
sub print_rolerows { |
sub print_rolerows { |
my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext,$update,$then) = @_; |
my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext) = @_; |
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 1481 sub print_rolerows {
|
Line 1384 sub print_rolerows {
|
&Apache::loncommon::end_data_table_row(); |
&Apache::loncommon::end_data_table_row(); |
} |
} |
} |
} |
if ($sortrole->{$which} =~ m{^user\.role\.dc\./($match_domain)/}) { |
if ($sortrole->{$which} =~ m-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)\./($match_domain)/}) { |
|
$output .= &adhoc_customroles_row($1,$2,'',$update,$then); |
|
} |
} |
} |
} |
} |
} |
Line 1656 sub privileges_info {
|
Line 1557 sub privileges_info {
|
} |
} |
|
|
sub build_roletext { |
sub build_roletext { |
my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere, |
my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning) = @_; |
$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning) = @_; |
|
my ($roletext,$roletext_end); |
my ($roletext,$roletext_end); |
my $is_dc=($trolecode =~ m/^dc\./); |
my $is_dc=($trolecode =~ m/^dc\./); |
my $rowspan=($is_dc) ? '' |
my $rowspan=($is_dc) ? '' |
Line 1746 sub check_author_homeserver {
|
Line 1646 sub check_author_homeserver {
|
} |
} |
} |
} |
|
|
sub check_for_adhoc { |
sub check_fordc { |
my ($dcroles,$dhroles,$update,$then) = @_; |
my ($dcroles,$update,$then) = @_; |
my $numdc = 0; |
my $numdc = 0; |
my $numdh = 0; |
|
my $numadhoc = 0; |
|
my $num_custom_adhoc = 0; |
|
if ($env{'user.adv'}) { |
if ($env{'user.adv'}) { |
foreach my $envkey (sort(keys(%env))) { |
foreach my $envkey (sort keys %env) { |
if ($envkey=~/^user\.role\.(dc|dh)\.\/($match_domain)\/$/) { |
if ($envkey=~/^user\.role\.dc\.\/($match_domain)\/$/) { |
my $role = $1; |
my $dcdom = $1; |
my $roledom = $2; |
my $livedc = 1; |
my $liverole = 1; |
|
my ($tstart,$tend)=split(/\./,$env{$envkey}); |
my ($tstart,$tend)=split(/\./,$env{$envkey}); |
my $limit = $update; |
my $limit = $update; |
if ((($role eq 'dc') && ($env{'request.role'} eq 'dc./'.$roledom.'/')) || |
if ($env{'request.role'} eq 'dc./'.$dcdom.'/') { |
(($role eq 'dh') && ($env{'request.role'} eq 'dh./'.$roledom.'/'))) { |
|
$limit = $then; |
$limit = $then; |
} |
} |
if ($tstart && $tstart>$limit) { $liverole = 0; } |
if ($tstart && $tstart>$limit) { $livedc = 0; } |
if ($tend && $tend <$limit) { $liverole = 0; } |
if ($tend && $tend <$limit) { $livedc = 0; } |
if ($liverole) { |
if ($livedc) { |
if ($role eq 'dc') { |
$$dcroles{$dcdom} = $envkey; |
$dcroles->{$roledom} = $envkey; |
$numdc++; |
$numdc++; |
|
} else { |
|
$dhroles->{$roledom} = $envkey; |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($roledom); |
|
if (ref($domdefaults{'adhocroles'}) eq 'HASH') { |
|
if (keys(%{$domdefaults{'adhocroles'}})) { |
|
$numadhoc ++; |
|
} |
|
} |
|
$numdh++; |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
} |
return ($numdc,$numdh,$numadhoc); |
return $numdc; |
} |
} |
|
|
sub adhoc_course_role { |
sub adhoc_course_role { |
Line 1825 sub adhoc_course_role {
|
Line 1709 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.'.$ccrole.'./'.$cdom.'/'.$cnum.'./'.$cdom.'/'.$cnum.'/'.$group}; |
$env{'user.priv.cc./'.$cdom.'/'.$cnum.'./'.$cdom.'/'.$cnum.'/'.$group}; |
} |
} |
$newgroups{'/'.$cdom.'/'.$cnum} = \%group_privs; |
$newgroups{'/'.$cdom.'/'.$cnum} = \%group_privs; |
my $area = '/'.$cdom.'/'.$cnum; |
my $area = '/'.$cdom.'/'.$cnum; |
Line 1881 sub check_forcc {
|
Line 1759 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'},undef,$required,1); |
|
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,undef,$required,1); |
|
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 ($roledom,$rowtype,$role) = @_; |
my ($dcdom,$rowtype) = @_; |
my $courseform=&Apache::loncommon::selectcourse_link |
my $courseform=&Apache::loncommon::selectcourse_link |
('rolechoice','course'.$rowtype.'_'.$roledom.'_'.$role, |
('rolechoice','dccourse'.$rowtype.'_'.$dcdom, |
'domain'.$rowtype.'_'.$roledom.'_'.$role, |
'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'. |
'coursedesc'.$rowtype.'_'.$roledom.'_'.$role, |
$dcdom,$dcdom,undef,'Course/Community'); |
$roledom.':'.$role,undef,'Course/Community'); |
my $hiddenitems = '<input type="hidden" name="dcdomain'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'. |
my $hiddenitems = '<input type="hidden" name="domain'.$rowtype.'_'.$roledom.'_'.$role.'" value="'.$roledom.'" />'. |
'<input type="hidden" name="origdom'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'. |
'<input type="hidden" name="origdom'.$rowtype.'_'.$roledom.'_'.$role.'" value="'.$roledom.'" />'. |
'<input type="hidden" name="dccourse'.$rowtype.'_'.$dcdom.'" value="" />'. |
'<input type="hidden" name="course'.$rowtype.'_'.$roledom.'_'.$role.'" value="" />'. |
'<input type="hidden" name="coursedesc'.$rowtype.'_'.$dcdom.'" value="" />'; |
'<input type="hidden" name="coursedesc'.$rowtype.'_'.$roledom.'_'.$role.'" value="" />'; |
|
return $courseform.$hiddenitems; |
return $courseform.$hiddenitems; |
} |
} |
|
|
sub coursepick_jscript { |
sub coursepick_jscript { |
my %js_lt = &Apache::lonlocal::texthash( |
my %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 1917 function verifyCoursePick(caller) {
|
Line 1845 function verifyCoursePick(caller) {
|
} |
} |
} |
} |
else { |
else { |
alert("$js_lt{'plsu'}"); |
alert("$lt{'plsu'}"); |
} |
} |
} |
} |
else { |
else { |
alert("$js_lt{'youc'}") |
alert("$lt{'youc'}") |
} |
} |
} |
} |
function getIndex(caller) { |
function getIndex(caller) { |
Line 1982 sub display_cc_role {
|
Line 1910 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" class="LC_textsize_mobile">' |
.' <td colspan="5">' |
.&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 $role = 'cc'; |
my $selectcclink = &courselink($dcdom,$rowtype); |
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 1997 sub adhoc_roles_row {
|
Line 1924 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 2338 sub update_session_roles {
|
Line 2241 sub update_session_roles {
|
&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(m{\./},$rolekey,2); |
my ($role,$rest)=split(m{\./},$rolekey,2); |
$rest = '/'.$rest; |
$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 2538 sub update_session_roles {
|
Line 2441 sub update_session_roles {
|
} |
} |
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}} = |
&Apache::longroup::coursegroups($cdom,$cnum); |
&Apache::longroup::coursegroups($cdom,$cnum); |
} |
} |
unless ((ref($groupdescs{$cdom.'_'.$cnum}) eq 'HASH') && |
unless ((ref($groupdescs{$cdom.'_'.$cnum}) eq 'HASH') && |
($groupdescs{$cdom.'_'.$cnum}{$group})) { |
($groupdescs{$cdom.'_'.$cnum}{$group})) { |
|
|
my %groupinfo = |
my %groupinfo = |
&Apache::longroup::get_group_settings($curr_groups{$cdom.'_'.$cnum}{$group}); |
&Apache::longroup::get_group_settings($curr_groups{$cdom.'_'.$cnum}{$group}); |
$groupdescs{$cdom.'_'.$cnum}{$group} = |
$groupdescs{$cdom.'_'.$cnum}{$group} = |
&unescape($groupinfo{'description'}); |
&unescape($groupinfo{'description'}); |
} |
} |
$groupdesc = $groupdescs{$cdom.'_'.$cnum}{$group}; |
$groupdesc = $groupdescs{$cdom.'_'.$cnum}{$group}; |
Line 2665 sub update_session_roles {
|
Line 2568 sub update_session_roles {
|
my $cdom = $env{'course.'.$cid.'.domain'}; |
my $cdom = $env{'course.'.$cid.'.domain'}; |
my $cnum = $env{'course.'.$cid.'.num'}; |
my $cnum = $env{'course.'.$cid.'.num'}; |
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); |
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); |
my %groupdesc; |
my %groupdesc; |
if (ref($groupchange{$crs}) eq 'HASH') { |
if (ref($groupchange{$crs}) eq 'HASH') { |
$groupchgmsg .= '<li>'.&mt('Course/Community: [_1]','<b>'.$crsdesc.'</b><ul>'); |
$groupchgmsg .= '<li>'.&mt('Course/Community: [_1]','<b>'.$crsdesc.'</b><ul>'); |
foreach my $group (sort(keys(%{$groupchange{$crs}}))) { |
foreach my $group (sort(keys(%{$groupchange{$crs}}))) { |
Line 2849 sub get_roles_functions {
|
Line 2752 sub get_roles_functions {
|
unless ($cattype eq 'none') { |
unless ($cattype eq 'none') { |
push(@links,['/adm/coursecatalog','ccat-22x22',&mt('Course catalog')]); |
push(@links,['/adm/coursecatalog','ccat-22x22',&mt('Course catalog')]); |
} |
} |
my $funcs; |
my $funcs = &Apache::lonhtmlcommon::start_funclist(); |
if ($env{'browser.mobile'}) { |
foreach my $link (@links) { |
my @functions; |
$funcs .= &Apache::lonhtmlcommon::add_item_funclist( |
foreach my $link (@links) { |
'<a href="'.$link->[0].'" class="LC_menubuttons_link">'. |
push(@functions,[$link->[0],$link->[2]]); |
'<img src="/res/adm/pages/'.$link->[1].'.png" class="LC_icon" alt="'.$link->[2].'" />'. |
} |
$link->[2].'</a>'); |
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; |
$funcs .= &Apache::lonhtmlcommon::end_funclist(); |
|
return &Apache::loncommon::head_subbox($funcs); |
} |
} |
|
|
sub get_queued { |
sub get_queued { |
Line 2898 sub get_queued {
|
Line 2786 sub get_queued {
|
if (ref($history{'details'}) eq 'HASH') { |
if (ref($history{'details'}) eq 'HASH') { |
$description = $history{details}{'cdescr'}; |
$description = $history{details}{'cdescr'}; |
} |
} |
@{$reqcrs{$reqtime}} = ($description,$showtype); |
@{$reqcrs{$reqtime}} = ($description,$showtype); |
} |
} |
} |
} |
my @sortedtimes = sort {$a <=> $b} (keys(%reqcrs)); |
my @sortedtimes = sort {$a <=> $b} (keys(%reqcrs)); |