version 1.278, 2012/12/27 18:31:09
|
version 1.313, 2016/04/02 04:31:33
|
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 138 use Apache::lonlocal;
|
Line 138 use Apache::lonlocal;
|
use Apache::lonpageflip(); |
use Apache::lonpageflip(); |
use Apache::lonnavdisplay(); |
use Apache::lonnavdisplay(); |
use Apache::loncoursequeueadmin; |
use Apache::loncoursequeueadmin; |
|
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; |
Line 200 sub handler {
|
Line 203 sub handler {
|
|
|
my $r = shift; |
my $r = shift; |
|
|
|
# Check for critical messages and redirect if present. |
|
my ($redirect,$url) = &Apache::loncommon::critical_redirect(300); |
|
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 245 sub handler {
|
Line 256 sub handler {
|
my $envkey; |
my $envkey; |
my %dcroles = (); |
my %dcroles = (); |
my $numdc = &check_fordc(\%dcroles,$update,$then); |
my $numdc = &check_fordc(\%dcroles,$update,$then); |
my $loncaparev = $Apache::lonnet::perlvar{'lonVersion'}; |
my $loncaparev = $r->dir_config('lonVersion'); |
|
|
# ================================================================== Roles Init |
# ================================================================== Roles Init |
if ($env{'form.selectrole'}) { |
if ($env{'form.selectrole'}) { |
Line 276 sub handler {
|
Line 287 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.role" => 'cm', |
"request.role.domain" => $env{'user.domain'}}); |
"request.role.adv" => $env{'user.adv'}, |
|
"request.role.domain" => $env{'user.domain'}}); |
# Check if user is a DC trying to enter a course or author space and needs privs to be created |
# Check if user is a DC trying to enter a course or author space and needs privs to be created |
if ($numdc > 0) { |
if ($numdc > 0) { |
foreach my $envkey (keys %env) { |
foreach my $envkey (keys(%env)) { |
# Is this an ad-hoc 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)$-)) { |
Line 309 sub handler {
|
Line 321 sub handler {
|
my $trolecode = 'au./'.$domain.'/'; |
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; |
} |
} |
Line 320 sub handler {
|
Line 333 sub handler {
|
my $trolecode = 'ca./'.$domain.'/'.$user; |
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; |
} |
} |
last; |
last; |
} |
} |
Line 341 sub handler {
|
Line 355 sub handler {
|
my $switchserver = '/adm/switchserver?' |
my $switchserver = '/adm/switchserver?' |
.'otherserver='.$home.'&role='.$trolecode; |
.'otherserver='.$home.'&role='.$trolecode; |
$r->internal_redirect($switchserver); |
$r->internal_redirect($switchserver); |
|
return OK; |
} |
} |
} else { |
} else { |
delete($env{$envkey}); |
delete($env{$envkey}); |
Line 353 sub handler {
|
Line 368 sub handler {
|
} |
} |
} |
} |
|
|
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 369 sub handler {
|
Line 384 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 517 ENDENTERKEY
|
Line 515 ENDENTERKEY
|
my $msg; |
my $msg; |
my ($furl,$ferr)= |
my ($furl,$ferr)= |
&Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
&Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
unless (($ferr) || ($env{'form.switchrole'}) || |
unless ($ferr) { |
($env{"environment.internal.$cdom.$cnum.$role.adhoc"})) { |
unless (($env{'form.switchrole'}) || |
&Apache::lonnet::put('nohist_crslastlogin', |
($env{"environment.internal.$cdom.$cnum.$role.adhoc"})) { |
{$env{'user.name'}.':'.$env{'user.domain'}. |
&Apache::lonnet::put('nohist_crslastlogin', |
':'.$csec.':'.$role => $now},$cdom,$cnum); |
{$env{'user.name'}.':'.$env{'user.domain'}. |
|
':'.$csec.':'.$role => $now},$cdom,$cnum); |
|
} |
|
my ($feeds,$syllabus_time); |
|
&Apache::lonrss::advertisefeeds($cnum,$cdom,undef,\$feeds); |
|
&Apache::lonnet::appenv({'request.course.feeds' => $feeds}); |
|
&Apache::lonnet::get_numsuppfiles($cnum,$cdom,1); |
|
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'}; |
} |
} |
Line 569 ENDENTERKEY
|
Line 584 ENDENTERKEY
|
} else { |
} else { |
# 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)) { |
|
&redirect_user($r, &mt('Entering [_1]', |
|
$env{'course.'.$cdom.'_'.$cnum.'.description'}), |
|
'/adm/placement', $msg); |
|
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 601 ENDENTERKEY
|
Line 622 ENDENTERKEY
|
} |
} |
} else { |
} else { |
if ($destsymb eq '') { |
if ($destsymb eq '') { |
($destsymb) = ($dest =~ /(:\?|\&)symb=([^\&]+)/); |
($destsymb) = ($dest =~ /(?:\?|\&)symb=([^\&]+)/); |
$destsymb = &unescape($destsymb); |
$destsymb = &unescape($destsymb); |
} |
} |
unless ($env{'request.role.adv'}) { |
unless ($env{'request.role.adv'}) { |
Line 610 ENDENTERKEY
|
Line 631 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 627 ENDENTERKEY
|
Line 648 ENDENTERKEY
|
} |
} |
} |
} |
&redirect_user($r, &mt('Entering [_1]', |
&redirect_user($r, &mt('Entering [_1]', |
$env{'course.'.$courseid.'.description'}), |
$env{'course.'.$cdom.'_'.$cnum.'.description'}), |
$dest, $msg); |
$dest, $msg); |
return OK; |
return OK; |
} |
} |
Line 637 ENDENTERKEY
|
Line 658 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 = &mt('Entering [_1] ...', |
$env{'course.'.$courseid.'.description'}); |
$env{'course.'.$env{'request.course.id'}.'.description'}); |
&redirect_user($r, &mt('New in course'), |
&redirect_user($r, &mt('New in course'), |
'/adm/whatsnew?refpage=start', $msg); |
'/adm/whatsnew?refpage=start', $msg); |
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/|) { |
my $access; |
# Guess not ... |
if ($furl =~ m{^(/adm/wrapper|)/ext/}) { |
$furl=&Apache::lonpageflip::first_accessible_resource(); |
# If it's an external resource, |
} |
# strip off the symb argument and possible query |
|
my ($exturl,$symb) = ($furl =~ m{^(.+)(?:\?|\&)symb=(.+)$}); |
|
# Unencode $symb |
|
$symb = &unescape($symb); |
|
# Then check for permission |
|
$access = &Apache::lonnet::allowed('bre',$exturl,$symb); |
|
# For other resources just check for permission |
|
} else { |
|
$access = &Apache::lonnet::allowed('bre',$furl); |
|
} |
|
if (!$access) { |
|
$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.'.$courseid.'.description'}); |
$env{'course.'.$cdom.'_'.$cnum.'.description'}); |
&redirect_user($r, &mt('Entering [_1]', |
&redirect_user($r, &mt('Entering [_1]', |
$env{'course.'.$courseid.'.description'}), |
$env{'course.'.$cdom.'_'.$cnum.'.description'}), |
$furl, $msg); |
$furl, $msg); |
} |
} |
return OK; |
return OK; |
Line 671 ENDENTERKEY
|
Line 706 ENDENTERKEY
|
$redirect_url .= $where; |
$redirect_url .= $where; |
} |
} |
$redirect_url .= '/'; |
$redirect_url .= '/'; |
&redirect_user($r,&mt('Entering Construction Space'), |
&redirect_user($r,&mt('Entering Authoring Space'), |
$redirect_url); |
$redirect_url); |
return OK; |
return OK; |
} |
} |
Line 703 ENDENTERKEY
|
Line 738 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.'); |
} |
} |
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; |
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; |
|
|
Line 715 ENDENTERKEY
|
Line 752 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 { |
|
$start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum}); |
|
$funcs = &get_roles_functions($showcount,$cattype); |
|
} |
|
&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 ENDHEADER
|
Line 927 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 882 ENDHEADER
|
Line 965 ENDHEADER
|
|
|
# No active roles |
# No active roles |
if ($countactive==0) { |
if ($countactive==0) { |
if ($inrole) { |
&requestcourse_advice($r,$cattype,$inrole); |
$r->print('<h2>'.&mt('Currently no additional roles, courses or communities').'</h2>'); |
|
} else { |
|
$r->print('<h2>'.&mt('Currently no active roles, courses or communities').'</h2>'); |
|
} |
|
&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)); |
Line 917 ENDHEADER
|
Line 994 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 |
|
|
Line 1029 ENDHEADER
|
Line 1116 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 1117 sub gather_roles {
|
Line 1200 sub gather_roles {
|
if ($role =~ /^cr\//) { |
if ($role =~ /^cr\//) { |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
if ($tremark) { $tremark.='<br />'; } |
if ($tremark) { $tremark.='<br />'; } |
$tremark.=&mt('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 $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 |
Line 1135 sub gather_roles {
|
Line 1219 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('User').': '.$trest.'<br />'.&mt('Domain'). |
$twhere=&mt('User').': '.$trest.'<br />'.&mt('Domain'). |
': '.$tdom.'<br />'. |
': '.$tdom.'<br />'. |
' '.&mt('Server').': '.$home; |
' '.&mt('Server').': '.$home; |
Line 1154 sub gather_roles {
|
Line 1238 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 1177 sub gather_roles {
|
Line 1261 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 1200 sub gather_roles {
|
Line 1284 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 1211 sub gather_roles {
|
Line 1295 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 1229 sub gather_roles {
|
Line 1317 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 1327 sub roletable_headers {
|
Line 1416 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; |
} |
} |
|
|
Line 1376 sub print_rolerows {
|
Line 1465 sub print_rolerows {
|
} |
} |
|
|
sub findcourse_advice { |
sub findcourse_advice { |
my ($r) = @_; |
my ($r,$cattype) = @_; |
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'})) { |
Line 1391 sub findcourse_advice {
|
Line 1480 sub findcourse_advice {
|
} else { |
} else { |
$r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'<br />'); |
$r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'<br />'); |
} |
} |
$r->print('<h3>'.&mt('Self-Enrollment').'</h3>'. |
if (($cattype eq 'std') || ($cattype eq 'domonly')) { |
'<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('<h3>'.&mt('Self-Enrollment').'</h3>'. |
$r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'</p>'. |
'<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 />'); |
&Apache::loncoursequeueadmin::queued_selfenrollment()); |
$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) = @_; |
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 1444 sub requestcourse_advice {
|
Line 1532 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); |
} |
} |
return; |
return; |
} |
} |
Line 1466 sub privileges_info {
|
Line 1571 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 1507 sub privileges_info {
|
Line 1612 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, |
|
$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning,$skipcal) = @_; |
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 1563 sub build_roletext {
|
Line 1669 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 1579 sub build_roletext {
|
Line 1685 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 1618 sub check_fordc {
|
Line 1706 sub check_fordc {
|
my ($dcroles,$update,$then) = @_; |
my ($dcroles,$update,$then) = @_; |
my $numdc = 0; |
my $numdc = 0; |
if ($env{'user.adv'}) { |
if ($env{'user.adv'}) { |
foreach my $envkey (sort keys %env) { |
foreach my $envkey (sort(keys(%env))) { |
if ($envkey=~/^user\.role\.dc\.\/($match_domain)\/$/) { |
if ($envkey=~/^user\.role\.dc\.\/($match_domain)\/$/) { |
my $dcdom = $1; |
my $dcdom = $1; |
my $livedc = 1; |
my $livedc = 1; |
Line 1662 sub adhoc_course_role {
|
Line 1750 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 1727 sub check_forcc {
|
Line 1815 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 ($dcdom,$rowtype) = @_; |
my $courseform=&Apache::loncommon::selectcourse_link |
my $courseform=&Apache::loncommon::selectcourse_link |
Line 1793 sub courselink {
|
Line 1829 sub courselink {
|
} |
} |
|
|
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 1813 function verifyCoursePick(caller) {
|
Line 1850 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 1855 sub display_cc_role {
|
Line 1892 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 1866 sub display_cc_role {
|
Line 1904 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); |
return ($roletext,$roletext_end); |
Line 2151 sub update_session_roles {
|
Line 2190 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 2176 sub update_session_roles {
|
Line 2214 sub update_session_roles {
|
} |
} |
} |
} |
} |
} |
$currpriv{sys} = $env{"user.priv.$rolekey./"}; |
my $status_in_env = |
$currpriv{dom} = $env{"user.priv.$rolekey./$udom/"}; |
&curr_role_status($currstart,$currend,$refresh,$update); |
$currpriv{crs} = $env{"user.priv.$rolekey.$where"}; |
if ($status_in_env eq 'active') { |
if (keys(%crprivs)) { |
$currpriv{sys} = $env{"user.priv.$rolekey./"}; |
if (($crprivs{$rest}{sys} ne $currpriv{sys}) || |
$currpriv{dom} = $env{"user.priv.$rolekey./$udom/"}; |
($crprivs{$rest}{dom} ne $currpriv{dom}) |
$currpriv{crs} = $env{"user.priv.$rolekey.$where"}; |
|
if (keys(%crprivs)) { |
|
if (($crprivs{$rest}{sys} ne $currpriv{sys}) || |
|
($crprivs{$rest}{dom} ne $currpriv{dom}) |
|| |
|| |
($crprivs{$rest}{crs} ne $currpriv{crs})) { |
($crprivs{$rest}{crs} ne $currpriv{crs})) { |
&gather_roleprivs(\%allroles,\%allgroups,\%userroles,$where,$role,$tstart,$tend,$status_in_db); |
&gather_roleprivs(\%allroles,\%allgroups, |
unless (grep(/^\Q$role\E$/,@changed_roles)) { |
\%userroles,$where,$role, |
push(@changed_roles,$role); |
$tstart,$tend,$status_in_db); |
} |
unless (grep(/^\Q$role\E$/,@changed_roles)) { |
my $status_in_env = |
push(@changed_roles,$role); |
&curr_role_status($currstart,$currend,$refresh,$update); |
} |
if ($status_in_env eq 'active') { |
|
$customprivchg{$rolekey} = $status_in_env; |
$customprivchg{$rolekey} = $status_in_env; |
} |
} |
} |
} |
Line 2207 sub update_session_roles {
|
Line 2247 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 2272 sub update_session_roles {
|
Line 2313 sub update_session_roles {
|
} |
} |
$msg .= '<br />'.&mt('However you can continue to use this role until you logout, click the "Re-Select" button, or your session has been idle for more than 24 hours.').'</p>'; |
$msg .= '<br />'.&mt('However you can continue to use this role until you logout, click the "Re-Select" button, or your session has been idle for more than 24 hours.').'</p>'; |
} |
} |
|
&Apache::lonnet::set_userprivs(\%userroles,\%allroles,\%allgroups,\%groups_roles); |
|
my ($curr_is_adv,$curr_role_adv,$curr_author,$curr_role_author); |
|
$curr_author = $env{'user.author'}; |
|
if (($env{'request.role'} =~/^au/) || ($env{'request.role'} =~/^ca/) || |
|
($env{'request.role'} =~/^aa/)) { |
|
$curr_role_author=1; |
|
} |
|
$curr_is_adv = $env{'user.adv'}; |
|
$curr_role_adv = $env{'request.role.adv'}; |
|
if (keys(%userroles) > 0) { |
|
foreach my $role (@changed_roles) { |
|
unless(grep(/^\Q$role\E$/,@rolecodes)) { |
|
push(@rolecodes,$role); |
|
} |
|
} |
|
unless(grep(/^\Qcm\E$/,@rolecodes)) { |
|
push(@rolecodes,'cm'); |
|
} |
|
&Apache::lonnet::appenv(\%userroles,\@rolecodes); |
|
} |
|
my %newenv; |
|
if (&Apache::lonnet::is_advanced_user($env{'user.domain'},$env{'user.name'})) { |
|
unless ($curr_is_adv) { |
|
$newenv{'user.adv'} = 1; |
|
} |
|
} elsif ($curr_is_adv && !$curr_role_adv) { |
|
&Apache::lonnet::delenv('user.adv'); |
|
} |
|
my %authorroleshash = |
|
&Apache::lonnet::get_my_roles('','','userroles',['active'],['au','ca','aa']); |
|
if (keys(%authorroleshash)) { |
|
unless ($curr_author) { |
|
$newenv{'user.author'} = 1; |
|
} |
|
} elsif ($curr_author && !$curr_role_author) { |
|
&Apache::lonnet::delenv('user.author'); |
|
} |
|
if ($env{'request.course.id'}) { |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my (@activecrsgroups,$crsgroupschanged); |
|
if ($env{'request.course.groups'}) { |
|
@activecrsgroups = split(/:/,$env{'request.course.groups'}); |
|
foreach my $item (keys(%deletedroles)) { |
|
if ($item =~ m{^gr\./\Q$cdom\E/\Q$cnum\E/(\w+)$}) { |
|
if (grep(/^\Q$1\E$/,@activecrsgroups)) { |
|
$crsgroupschanged = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
unless ($crsgroupschanged) { |
|
foreach my $item (keys(%newgroup)) { |
|
if ($item =~ m{^gr\./\Q$cdom\E/\Q$cnum\E/(\w+)$}) { |
|
if ($newgroup{$item} eq 'active') { |
|
$crsgroupschanged = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
if ((ref($changed_groups{$env{'request.course.id'}}) eq 'HASH') || |
|
(ref($groupchange{"/$cdom/$cnum"}) eq 'HASH') || |
|
($crsgroupschanged)) { |
|
my %grouproles = &Apache::lonnet::get_my_roles('','','userroles', |
|
['active'],['gr'],[$cdom],1); |
|
my @activegroups; |
|
foreach my $item (keys(%grouproles)) { |
|
next unless($item =~ /^\Q$cnum\E:\Q$cdom\E/); |
|
my $group; |
|
my ($crsn,$crsd,$role,$remainder) = split(/:/,$item,4); |
|
if ($remainder =~ /:/) { |
|
(my $other,$group) = ($remainder =~ /^([\w:]+):([^:]+)$/); |
|
} else { |
|
$group = $remainder; |
|
} |
|
if ($group ne '') { |
|
push(@activegroups,$group); |
|
} |
|
} |
|
$newenv{'request.course.groups'} = join(':',@activegroups); |
|
} |
|
} |
|
if (keys(%newenv)) { |
|
&Apache::lonnet::appenv(\%newenv); |
|
} |
if (!@changed_roles || !(keys(%changed_groups))) { |
if (!@changed_roles || !(keys(%changed_groups))) { |
my ($rolesmsg,$groupsmsg); |
my ($rolesmsg,$groupsmsg); |
if (!@changed_roles) { |
if (!@changed_roles) { |
Line 2304 sub update_session_roles {
|
Line 2432 sub update_session_roles {
|
if (@changed_roles > 0) { |
if (@changed_roles > 0) { |
if (keys(%newgroup) > 0) { |
if (keys(%newgroup) > 0) { |
my $groupmsg; |
my $groupmsg; |
|
my (%curr_groups,%groupdescs,$currcrs); |
foreach my $item (sort(keys(%newgroup))) { |
foreach my $item (sort(keys(%newgroup))) { |
if (&is_active_course($item,$refresh,$update,\%roleshash)) { |
if (&is_active_course($item,$refresh,$update,\%roleshash)) { |
$groupmsg .= '<li>'. |
if ($item =~ m{^gr\./($match_domain/$match_courseid)/(\w+)$}) { |
&mt('[_1] with status: [_2].', |
my ($cdom,$cnum) = split(/\//,$1); |
$item,$newgroup{$item}).'</li>'; |
my $group = $2; |
|
if ($currcrs ne $cdom.'_'.$cnum) { |
|
if ($currcrs) { |
|
$groupmsg .= '</ul><li>'; |
|
} |
|
$groupmsg .= '<li><b>'. |
|
$env{'course.'.$cdom.'_'.$cnum.'.description'}.'</b><ul>'; |
|
$currcrs = $cdom.'_'.$cnum; |
|
} |
|
my $groupdesc; |
|
unless (ref($curr_groups{$cdom.'_'.$cnum}) eq 'HASH') { |
|
%{$curr_groups{$cdom.'_'.$cnum}} = |
|
&Apache::longroup::coursegroups($cdom,$cnum); |
|
} |
|
unless ((ref($groupdescs{$cdom.'_'.$cnum}) eq 'HASH') && |
|
($groupdescs{$cdom.'_'.$cnum}{$group})) { |
|
|
|
my %groupinfo = |
|
&Apache::longroup::get_group_settings($curr_groups{$cdom.'_'.$cnum}{$group}); |
|
$groupdescs{$cdom.'_'.$cnum}{$group} = |
|
&unescape($groupinfo{'description'}); |
|
} |
|
$groupdesc = $groupdescs{$cdom.'_'.$cnum}{$group}; |
|
if ($groupdesc) { |
|
$groupmsg .= '<li>'. |
|
&mt('[_1] with status: [_2].', |
|
'<b>'.$groupdesc.'</b>',$newgroup{$item}).'</li>'; |
|
} |
|
} |
|
} |
|
if ($groupmsg) { |
|
$groupmsg .= '</ul></li>'; |
} |
} |
} |
} |
if ($groupmsg) { |
if ($groupmsg) { |
Line 2318 sub update_session_roles {
|
Line 2478 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))) { |
$changemsg .= '<li>'. |
my $desc = &role_desc($item,$update,$refresh,$now); |
&mt('[_1] with status: [_2].', |
if ($desc) { |
$item,$newrole{$item}).'</li>'; |
$newmsg .= '<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))) { |
$changemsg .= '<li>'.$item.'</li>'; |
my $desc = &role_desc($item,$update,$refresh,$now); |
|
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); |
|
if ($desc) { |
|
$rolemsg .= '<li>'. |
|
&mt('[_1] status now: [_2].',$desc, |
|
$rolechange{$item}).'</li>'; |
|
} |
|
} |
|
if ($rolemsg) { |
$changemsg .= '<li>'. |
$changemsg .= '<li>'. |
&mt('[_1] status now: [_2].',$item, |
&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))) { |
$changemsg .= '<li>'.$item.'</li>'; |
my $desc = &role_desc($item,$update,$refresh,$now); |
|
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 2384 sub update_session_roles {
|
Line 2568 sub update_session_roles {
|
&mt('Existing course/community groups with status changes').'</li>'. |
&mt('Existing course/community groups with status changes').'</li>'. |
'<ul>'; |
'<ul>'; |
foreach my $crs (sort(keys(%groupchange))) { |
foreach my $crs (sort(keys(%groupchange))) { |
|
my $cid = $crs; |
|
$cid=~s{^/}{}; |
|
$cid=~s{/}{_}; |
|
my $crsdesc = $env{'course.'.$cid.'.description'}; |
|
my $cdom = $env{'course.'.$cid.'.domain'}; |
|
my $cnum = $env{'course.'.$cid.'.num'}; |
|
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); |
|
my %groupdesc; |
if (ref($groupchange{$crs}) eq 'HASH') { |
if (ref($groupchange{$crs}) eq 'HASH') { |
$groupchgmsg .= '<li>'.&mt('Course/Community: [_1]','<b>'.$crs.'</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}}))) { |
$groupchgmsg .= '<li>'.&mt('Group: [_1] status now: [_2].','<b>'.$group.'</b>',$groupchange{$crs}{$group}).'</li>'; |
unless ($groupdesc{$group}) { |
|
my %groupinfo = &Apache::longroup::get_group_settings($curr_groups{$group}); |
|
$groupdesc{$group} = &unescape($groupinfo{'description'}); |
|
} |
|
$groupchgmsg .= '<li>'.&mt('Group: [_1] status now: [_2].','<b>'.$groupdesc{$group}.'</b>',$groupchange{$crs}{$group}).'</li>'; |
} |
} |
$groupchgmsg .= '</ul></li>'; |
$groupchgmsg .= '</ul></li>'; |
} |
} |
Line 2402 sub update_session_roles {
|
Line 2598 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'); |
|
} |
} |
} |
&Apache::lonnet::set_userprivs(\%userroles,\%allroles,\%allgroups,\%groups_roles); |
return $msg; |
my ($curr_is_adv,$curr_role_adv,$curr_author,$curr_role_author); |
} |
$curr_author = $env{'user.author'}; |
|
if (($env{'request.role'} =~/^au/) || ($env{'request.role'} =~/^ca/) || |
sub role_desc { |
($env{'request.role'} =~/^aa/)) { |
my ($item,$update,$refresh,$now) = @_; |
$curr_role_author=1; |
my ($where,$trolecode,$role,$tstatus,$tend,$tstart,$twhere, |
} |
$trole,$tremark); |
$curr_is_adv = $env{'user.adv'}; |
&Apache::lonnet::role_status('user.role.'.$item,$update,$refresh, |
$curr_role_adv = $env{'request.role.adv'}; |
$now,\$role,\$where,\$trolecode, |
if (keys(%userroles) > 0) { |
\$tstatus,\$tstart,\$tend); |
foreach my $role (@changed_roles) { |
return unless ($role); |
unless(grep(/^\Q$role\E$/,@rolecodes)) { |
if ($role =~ /^cr\//) { |
push(@rolecodes,$role); |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
|
$tremark = &mt('Custom role defined by [_1].',$rauthor.':'.$rdomain); |
|
} |
|
$trole=Apache::lonnet::plaintext($role); |
|
my ($tdom,$trest,$tsection)= |
|
split(/\//,Apache::lonnet::declutter($where)); |
|
if (($role eq 'ca') || ($role eq 'aa')) { |
|
my $home = &Apache::lonnet::homeserver($trest,$tdom); |
|
$home = &Apache::lonnet::hostname($home); |
|
$twhere=&mt('User').': '.$trest.' '.&mt('Domain'). |
|
': '.$tdom.' '.&mt('Server').': '.$home; |
|
} elsif ($role eq 'au') { |
|
my $home = &Apache::lonnet::homeserver |
|
($env{'user.name'},$env{'user.domain'}); |
|
$home = &Apache::lonnet::hostname($home); |
|
$twhere=&mt('Domain').': '.$tdom.' '.&mt('Server'). |
|
': '.$home; |
|
} elsif ($trest) { |
|
my $tcourseid=$tdom.'_'.$trest; |
|
my $crstype = &Apache::loncommon::course_type($tcourseid); |
|
$trole = &Apache::lonnet::plaintext($role,$crstype,$tcourseid); |
|
if ($env{'course.'.$tcourseid.'.description'}) { |
|
$twhere=$env{'course.'.$tcourseid.'.description'}; |
|
} else { |
|
my %newhash=&Apache::lonnet::coursedescription($tcourseid); |
|
if (%newhash) { |
|
$twhere=$newhash{'description'}; |
|
} else { |
|
$twhere=&mt('Currently not available'); |
} |
} |
} |
} |
unless(grep(/^\Qcm\E$/,@rolecodes)) { |
if ($tsection) { |
push(@rolecodes,'cm'); |
$twhere.= ' '.&mt('Section').': '.$tsection; |
} |
} |
&Apache::lonnet::appenv(\%userroles,\@rolecodes); |
if ($role ne 'st') { |
} |
$twhere.= ' '.&mt('Domain').': '.$tdom; |
my %newenv; |
|
if (&Apache::lonnet::is_advanced_user($env{'user.domain'},$env{'user.name'})) { |
|
unless ($curr_is_adv) { |
|
$newenv{'user.adv'} = 1; |
|
} |
} |
} elsif ($curr_is_adv && !$curr_role_adv) { |
} elsif ($tdom) { |
&Apache::lonnet::delenv('user.adv'); |
$twhere = &mt('Domain').': '.$tdom; |
} |
} |
my %authorroleshash = |
my $output; |
&Apache::lonnet::get_my_roles('','','userroles',['active'],['au','ca','aa']); |
if ($trole) { |
if (keys(%authorroleshash)) { |
$output = $trole; |
unless ($curr_author) { |
if ($twhere) { |
$newenv{'user.author'} = 1; |
$output .= " -- $twhere"; |
} |
|
} elsif ($curr_author && !$curr_role_author) { |
|
&Apache::lonnet::delenv('user.author'); |
|
} |
|
if ($env{'request.course.id'}) { |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my (@activecrsgroups,$crsgroupschanged); |
|
if ($env{'request.course.groups'}) { |
|
@activecrsgroups = split(/:/,$env{'request.course.groups'}); |
|
foreach my $item (keys(%deletedroles)) { |
|
if ($item =~ m{^gr\./\Q$cdom\E/\Q$cnum\E/(\w+)$}) { |
|
if (grep(/^\Q$1\E$/,@activecrsgroups)) { |
|
$crsgroupschanged = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
unless ($crsgroupschanged) { |
|
foreach my $item (keys(%newgroup)) { |
|
if ($item =~ m{^gr\./\Q$cdom\E/\Q$cnum\E/(\w+)$}) { |
|
if ($newgroup{$item} eq 'active') { |
|
$crsgroupschanged = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
} |
if ((ref($changed_groups{$env{'request.course.id'}}) eq 'HASH') || |
if ($tremark) { |
(ref($groupchange{"/$cdom/$cnum"}) eq 'HASH') || |
$output .= '<br />'.$tremark; |
($crsgroupschanged)) { |
|
my %grouproles = &Apache::lonnet::get_my_roles('','','userroles', |
|
['active'],['gr'],[$cdom],1); |
|
my @activegroups; |
|
foreach my $item (keys(%grouproles)) { |
|
next unless($item =~ /^\Q$cnum\E:\Q$cdom\E/); |
|
my $group; |
|
my ($crsn,$crsd,$role,$remainder) = split(/:/,$item,4); |
|
if ($remainder =~ /:/) { |
|
(my $other,$group) = ($remainder =~ /^([\w:]+):([^:]+)$/); |
|
} else { |
|
$group = $remainder; |
|
} |
|
if ($group ne '') { |
|
push(@activegroups,$group); |
|
} |
|
} |
|
$newenv{'request.course.groups'} = join(':',@activegroups); |
|
} |
} |
} |
} |
if (keys(%newenv)) { |
return $output; |
&Apache::lonnet::appenv(\%newenv); |
|
} |
|
return $msg; |
|
} |
} |
|
|
sub curr_role_status { |
sub curr_role_status { |
Line 2553 sub is_active_course {
|
Line 2730 sub is_active_course {
|
} |
} |
|
|
sub get_roles_functions { |
sub get_roles_functions { |
my ($rolescount) = @_; |
my ($rolescount,$cattype) = @_; |
my @links; |
my @links; |
if ($env{'user.adv'}) { |
|
if ($env{'form.display'} eq 'showall') { |
|
push(@links,["javascript:rolesView('noshowall');",'edit-redo-22x22',&mt('Exclude expired roles')]); |
|
} else { |
|
push(@links,["javascript:rolesView('showall');",'edit-undo-22x22',&mt('Include expired roles')]); |
|
} |
|
} |
|
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'}) { |
unless (&Apache::loncoursequeueadmin::is_active_author()) { |
unless (&Apache::loncoursequeueadmin::is_active_author()) { |
push(@links,["javascript:rolesView('requestauthor');",'list-add-22x22',&mt('Request author role')]); |
push(@links,["javascript:rolesView('requestauthor');",'list-add-22x22',&mt('Request author role')]); |
} |
} |
} |
} |
|
if (($rolescount > 3) || ($env{'environment.recentroles'})) { |
|
push(@links,['/adm/preferences?action=changerolespref&returnurl=/adm/roles','role_hotlist-22x22',&mt('Hotlist')]); |
|
} |
if (&Apache::lonmenu::check_for_rcrs()) { |
if (&Apache::lonmenu::check_for_rcrs()) { |
push(@links,['/adm/requestcourse','rcrs-22x22',&mt('Request course')]); |
push(@links,['/adm/requestcourse','rcrs-22x22',&mt('Request course')]); |
} |
} |
Line 2576 sub get_roles_functions {
|
Line 2749 sub get_roles_functions {
|
} else { |
} else { |
push(@links,["javascript:rolesView('queued');",'selfenrl-queue-22x22',&mt('Show queued')]); |
push(@links,["javascript:rolesView('queued');",'selfenrl-queue-22x22',&mt('Show queued')]); |
} |
} |
if (($rolescount > 3) || ($env{'environment.recentroles'})) { |
if ($env{'user.adv'}) { |
push(@links,['/adm/preferences?action=changerolespref&returnurl=/adm/roles','role_hotlist-22x22',&mt('Hotlist')]); |
if ($env{'form.display'} eq 'showall') { |
|
push(@links,["javascript:rolesView('noshowall');",'edit-redo-22x22',&mt('Exclude expired')]); |
|
} else { |
|
push(@links,["javascript:rolesView('showall');",'edit-undo-22x22',&mt('Include expired')]); |
|
} |
|
} |
|
unless ($cattype eq 'none') { |
|
push(@links,['/adm/coursecatalog','ccat-22x22',&mt('Course catalog')]); |
} |
} |
|
|
my $funcs = &Apache::lonhtmlcommon::start_funclist(); |
my $funcs = &Apache::lonhtmlcommon::start_funclist(); |
foreach my $link (@links) { |
foreach my $link (@links) { |
$funcs .= &Apache::lonhtmlcommon::add_item_funclist( |
$funcs .= &Apache::lonhtmlcommon::add_item_funclist( |
Line 2598 sub get_queued {
|
Line 2777 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 2648 sub get_queued {
|
Line 2827 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 = |