version 1.279, 2013/01/01 03:06:27
|
version 1.302, 2014/05/04 21:49:05
|
Line 139 use Apache::lonpageflip();
|
Line 139 use Apache::lonpageflip();
|
use Apache::lonnavdisplay(); |
use Apache::lonnavdisplay(); |
use Apache::loncoursequeueadmin; |
use Apache::loncoursequeueadmin; |
use Apache::longroup; |
use Apache::longroup; |
|
use Apache::lonrss; |
use GDBM_File; |
use GDBM_File; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use HTML::Entities; |
use HTML::Entities; |
Line 287 sub handler {
|
Line 288 sub handler {
|
"request.role.domain" => $env{'user.domain'}}); |
"request.role.domain" => $env{'user.domain'}}); |
# Check if user is a DC trying to enter a course or author space and needs privs to be created |
# Check if user is a DC trying to enter a course 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 310 sub handler {
|
Line 311 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 321 sub handler {
|
Line 323 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 342 sub handler {
|
Line 345 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 354 sub handler {
|
Line 358 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 518 ENDENTERKEY
|
Line 522 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 570 ENDENTERKEY
|
Line 591 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'}) { |
Line 602 ENDENTERKEY
|
Line 618 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 611 ENDENTERKEY
|
Line 627 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 628 ENDENTERKEY
|
Line 644 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 638 ENDENTERKEY
|
Line 654 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/|) { |
if ($furl =~ m{^(/adm/wrapper|)/ext/}) { |
# Guess not ... |
# If it's an external resource, |
$furl=&Apache::lonpageflip::first_accessible_resource(); |
# strip off the symb argument and possible query |
} |
my ($exturl,$symb) = ($furl =~ m{^(.+)(?:\?|\&)symb=(.+)$}); |
|
# Unencode $symb |
|
$symb = &unescape($symb); |
|
# Then check for permission |
|
if (!&Apache::lonnet::allowed('bre',$exturl,$symb)) { |
|
$furl = &Apache::lonpageflip::first_accessible_resource(); |
|
} |
|
# For other resources just check for permission |
|
} elsif (!&Apache::lonnet::allowed('bre',$furl)) { |
|
$furl = &Apache::lonpageflip::first_accessible_resource(); |
|
} |
|
|
$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 672 ENDENTERKEY
|
Line 699 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 704 ENDENTERKEY
|
Line 731 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 717 ENDENTERKEY
|
Line 746 ENDENTERKEY
|
|
|
my $swinfo=&Apache::lonmenu::rawconfig(); |
my $swinfo=&Apache::lonmenu::rawconfig(); |
my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum}); |
my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum}); |
my $funcs = &get_roles_functions($showcount); |
my %domdefs=&Apache::lonnet::get_domain_defaults($env{'user.domain'}); |
my $standby=&mt('Role selected. Please stand by.'); |
my $cattype = 'std'; |
|
if ($domdefs{'catauth'}) { |
|
$cattype = $domdefs{'catauth'}; |
|
} |
|
my $funcs = &get_roles_functions($showcount,$cattype); |
$standby=~s/\n/\\n/g; |
$standby=~s/\n/\\n/g; |
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 />'; |
|
|
Line 861 ENDHEADER
|
Line 894 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 ((($cattype eq 'std') || ($cattype eq 'domonly')) && (!$env{'user.adv'})) { |
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 888 ENDHEADER
|
Line 923 ENDHEADER
|
} else { |
} else { |
$r->print('<h2>'.&mt('Currently no active roles, courses or communities').'</h2>'); |
$r->print('<h2>'.&mt('Currently no active roles, courses or communities').'</h2>'); |
} |
} |
&findcourse_advice($r); |
&requestcourse_advice($r,$cattype); |
&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 1118 sub gather_roles {
|
Line 1152 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; |
Line 1136 sub gather_roles {
|
Line 1170 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 1155 sub gather_roles {
|
Line 1189 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 1328 sub roletable_headers {
|
Line 1362 sub roletable_headers {
|
} |
} |
|
|
sub roletypes { |
sub roletypes { |
my @types = ('Domain','Construction Space','Course','Community','Unavailable','System'); |
my @types = ('Domain','Authoring Space','Course','Community','Unavailable','System'); |
return @types; |
return @types; |
} |
} |
|
|
Line 1377 sub print_rolerows {
|
Line 1411 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 1392 sub findcourse_advice {
|
Line 1426 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) = @_; |
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); |
Line 1448 sub requestcourse_advice {
|
Line 1484 sub requestcourse_advice {
|
} |
} |
$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>'); |
$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>'); |
} |
} |
|
} elsif (!$env{'user.adv'}) { |
|
&findcourse_advice($r,$cattype); |
} |
} |
return; |
return; |
} |
} |
Line 1467 sub privileges_info {
|
Line 1505 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 1580 sub build_roletext {
|
Line 1618 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 1663 sub adhoc_course_role {
|
Line 1683 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 1738 sub check_release_required {
|
Line 1758 sub check_release_required {
|
my $otherserver; |
my $otherserver; |
if (($major eq '' && $minor eq '') || |
if (($major eq '' && $minor eq '') || |
(($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) { |
(($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) { |
my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'}); |
my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'},undef,$required); |
my $switchlcrev = |
my $switchlcrev = |
&Apache::lonnet::get_server_loncaparev($env{'user.domain'}, |
&Apache::lonnet::get_server_loncaparev($env{'user.domain'}, |
$userdomserver); |
$userdomserver); |
Line 2152 sub update_session_roles {
|
Line 2172 sub update_session_roles {
|
my $status_in_db = |
my $status_in_db = |
&curr_role_status($tstart,$tend,$refresh,$now); |
&curr_role_status($tstart,$tend,$refresh,$now); |
my ($rdummy,$rest) = split(/\//,$role,2); |
my ($rdummy,$rest) = split(/\//,$role,2); |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
|
my %currpriv; |
my %currpriv; |
unless (exists($crprivs{$rest})) { |
unless (exists($crprivs{$rest})) { |
my ($rdomain,$rauthor,$rrole)=split(/\//,$rest); |
my ($rdomain,$rauthor,$rrole)=split(/\//,$rest); |
Line 2210 sub update_session_roles {
|
Line 2229 sub update_session_roles {
|
my $status_in_env = |
my $status_in_env = |
&curr_role_status($currstart,$currend,$refresh,$update); |
&curr_role_status($currstart,$currend,$refresh,$update); |
my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/); |
my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/); |
my ($role,$rest)=split(/\./,$rolekey,2); |
my ($role,$rest)=split(m{\./},$rolekey,2); |
|
$rest = '/'.$rest; |
if (&Apache::lonnet::delenv($envkey,undef,[$role])) { |
if (&Apache::lonnet::delenv($envkey,undef,[$role])) { |
if ($status_in_env eq 'active') { |
if ($status_in_env eq 'active') { |
if ($role eq 'gr') { |
if ($role eq 'gr') { |
Line 2406 sub update_session_roles {
|
Line 2426 sub update_session_roles {
|
} |
} |
$groupmsg .= '<li><b>'. |
$groupmsg .= '<li><b>'. |
$env{'course.'.$cdom.'_'.$cnum.'.description'}.'</b><ul>'; |
$env{'course.'.$cdom.'_'.$cnum.'.description'}.'</b><ul>'; |
|
$currcrs = $cdom.'_'.$cnum; |
} |
} |
my ($cdom,$cnum) = split(/\//,$1); |
|
my $group = $2; |
|
my $groupdesc; |
my $groupdesc; |
unless (ref($curr_groups{$cdom.'_'.$cnum}) eq 'HASH') { |
unless (ref($curr_groups{$cdom.'_'.$cnum}) eq 'HASH') { |
%{$curr_groups{$cdom.'_'.$cnum}} = |
%{$curr_groups{$cdom.'_'.$cnum}} = |
Line 2423 sub update_session_roles {
|
Line 2442 sub update_session_roles {
|
&unescape($groupinfo{'description'}); |
&unescape($groupinfo{'description'}); |
} |
} |
$groupdesc = $groupdescs{$cdom.'_'.$cnum}{$group}; |
$groupdesc = $groupdescs{$cdom.'_'.$cnum}{$group}; |
$groupmsg .= '<li>'. |
if ($groupdesc) { |
&mt('[_1] with status: [_2].', |
$groupmsg .= '<li>'. |
'<b>'.$groupdesc.'</b>',$newgroup{$item}).'</li>'; |
&mt('[_1] with status: [_2].', |
|
'<b>'.$groupdesc.'</b>',$newgroup{$item}).'</li>'; |
|
} |
} |
} |
} |
} |
if ($groupmsg) { |
if ($groupmsg) { |
Line 2439 sub update_session_roles {
|
Line 2460 sub update_session_roles {
|
} |
} |
} |
} |
if (keys(%newrole) > 0) { |
if (keys(%newrole) > 0) { |
$changemsg .= '<li>'.&mt('New roles'). |
my $newmsg; |
'<ul>'; |
|
foreach my $item (sort(keys(%newrole))) { |
foreach my $item (sort(keys(%newrole))) { |
my $desc = &role_desc($item,$update,$refresh,$now); |
my $desc = &role_desc($item,$update,$refresh,$now); |
$changemsg .= '<li>'. |
if ($desc) { |
&mt('[_1] with status: [_2].', |
$newmsg .= '<li>'. |
$desc,$newrole{$item}).'</li>'; |
&mt('[_1] with status: [_2].', |
|
$desc,&mt($newrole{$item})).'</li>'; |
|
} |
|
} |
|
if ($newmsg) { |
|
$changemsg .= '<li>'.&mt('New roles'). |
|
'<ul>'.$newmsg.'</ul>'. |
|
'</li>'; |
} |
} |
$changemsg .= '</ul></li>'; |
|
} |
} |
if (keys(%customprivchg) > 0) { |
if (keys(%customprivchg) > 0) { |
$changemsg .= '<li>'. |
my $privmsg; |
&mt('Custom roles with privilege changes'). |
|
'<ul>'; |
|
foreach my $item (sort(keys(%customprivchg))) { |
foreach my $item (sort(keys(%customprivchg))) { |
my $desc = &role_desc($item,$update,$refresh,$now); |
my $desc = &role_desc($item,$update,$refresh,$now); |
$changemsg .= '<li>'.$desc.'</li>'; |
if ($desc) { |
|
$privmsg .= '<li>'.$desc.'</li>'; |
|
} |
} |
} |
$changemsg .= '</ul></li>'; |
if ($privmsg) { |
|
$changemsg .= '<li>'. |
|
&mt('Custom roles with privilege changes'). |
|
'<ul>'.$privmsg.'</ul>'. |
|
'</li>'; |
|
} |
} |
} |
if (keys(%rolechange) > 0) { |
if (keys(%rolechange) > 0) { |
$changemsg .= '<li>'. |
my $rolemsg; |
&mt('Existing roles with status changes').'</li>'. |
|
'<ul>'; |
|
foreach my $item (sort(keys(%rolechange))) { |
foreach my $item (sort(keys(%rolechange))) { |
my $desc = &role_desc($item,$update,$refresh,$now); |
my $desc = &role_desc($item,$update,$refresh,$now); |
|
if ($desc) { |
|
$rolemsg .= '<li>'. |
|
&mt('[_1] status now: [_2].',$desc, |
|
$rolechange{$item}).'</li>'; |
|
} |
|
} |
|
if ($rolemsg) { |
$changemsg .= '<li>'. |
$changemsg .= '<li>'. |
&mt('[_1] status now: [_2].',$desc, |
&mt('Existing roles with status changes').'</li>'. |
$rolechange{$item}).'</li>'; |
'<ul>'.$rolemsg.'</ul>'. |
|
'</li>'; |
} |
} |
$changemsg .= '</ul></li>'; |
|
} |
} |
if (keys(%deletedroles) > 0) { |
if (keys(%deletedroles) > 0) { |
$changemsg .= '<li>'. |
my $delmsg; |
&mt('Existing roles now expired').'</li>'. |
|
'<ul>'; |
|
foreach my $item (sort(keys(%deletedroles))) { |
foreach my $item (sort(keys(%deletedroles))) { |
my $desc = &role_desc($item,$update,$refresh,$now); |
my $desc = &role_desc($item,$update,$refresh,$now); |
$changemsg .= '<li>'.$desc.'</li>'; |
if ($desc) { |
|
$delmsg .= '<li>'.$desc.'</li>'; |
|
} |
|
} |
|
if ($delmsg) { |
|
$changemsg .= '<li>'. |
|
&mt('Existing roles now expired').'</li>'. |
|
'<ul>'.$delmsg.'</ul>'. |
|
'</li>'; |
} |
} |
$changemsg .= '</ul></li>'; |
|
} |
} |
} |
} |
if ((keys(%changed_groups) > 0) || (keys(%groupchange) > 0)) { |
if ((keys(%changed_groups) > 0) || (keys(%groupchange) > 0)) { |
Line 2539 sub update_session_roles {
|
Line 2580 sub update_session_roles {
|
} |
} |
if ($changemsg) { |
if ($changemsg) { |
$msg .= '<ul>'.$changemsg.'</ul>'; |
$msg .= '<ul>'.$changemsg.'</ul>'; |
|
} else { |
|
if (&Apache::loncommon::show_course()) { |
|
$msg = &mt('No new courses or communities'); |
|
} else { |
|
$msg = &mt('No role changes'); |
|
} |
} |
} |
return $msg; |
return $msg; |
} |
} |
Line 2547 sub role_desc {
|
Line 2594 sub role_desc {
|
my ($item,$update,$refresh,$now) = @_; |
my ($item,$update,$refresh,$now) = @_; |
my ($where,$trolecode,$role,$tstatus,$tend,$tstart,$twhere, |
my ($where,$trolecode,$role,$tstatus,$tend,$tstart,$twhere, |
$trole,$tremark); |
$trole,$tremark); |
&Apache::lonnet::role_status('user.role.'.$item,$update,$refresh, $now,\$role,\$where, \$trolecode, |
&Apache::lonnet::role_status('user.role.'.$item,$update,$refresh, |
|
$now,\$role,\$where,\$trolecode, |
\$tstatus,\$tstart,\$tend); |
\$tstatus,\$tstart,\$tend); |
|
return unless ($role); |
if ($role =~ /^cr\//) { |
if ($role =~ /^cr\//) { |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
$tremark = &mt('Customrole defined by [_1].',$rauthor.':'.$rdomain); |
$tremark = &mt('Custom role defined by [_1].',$rauthor.':'.$rdomain); |
} |
} |
$trole=Apache::lonnet::plaintext($role); |
$trole=Apache::lonnet::plaintext($role); |
my ($tdom,$trest,$tsection)= |
my ($tdom,$trest,$tsection)= |
Line 2590 sub role_desc {
|
Line 2639 sub role_desc {
|
} elsif ($tdom) { |
} elsif ($tdom) { |
$twhere = &mt('Domain').': '.$tdom; |
$twhere = &mt('Domain').': '.$tdom; |
} |
} |
my $output = "$trole -- $twhere"; |
my $output; |
if ($tremark) { |
if ($trole) { |
$output .= '<br />'.$tremark; |
$output = $trole; |
|
if ($twhere) { |
|
$output .= " -- $twhere"; |
|
} |
|
if ($tremark) { |
|
$output .= '<br />'.$tremark; |
|
} |
} |
} |
return $output; |
return $output; |
} |
} |
Line 2657 sub is_active_course {
|
Line 2712 sub is_active_course {
|
} |
} |
|
|
sub get_roles_functions { |
sub get_roles_functions { |
my ($rolescount) = @_; |
my ($rolescount,$cattype) = @_; |
my @links; |
my @links; |
push(@links,["javascript:rolesView('doupdate');",'start-here-22x22',&mt('Check for changes')]); |
push(@links,["javascript:rolesView('doupdate');",'start-here-22x22',&mt('Check for changes')]); |
if ($env{'environment.canrequest.author'}) { |
if ($env{'environment.canrequest.author'}) { |
Line 2678 sub get_roles_functions {
|
Line 2733 sub get_roles_functions {
|
} |
} |
if ($env{'user.adv'}) { |
if ($env{'user.adv'}) { |
if ($env{'form.display'} eq 'showall') { |
if ($env{'form.display'} eq 'showall') { |
push(@links,["javascript:rolesView('noshowall');",'edit-redo-22x22',&mt('Exclude expired roles')]); |
push(@links,["javascript:rolesView('noshowall');",'edit-redo-22x22',&mt('Exclude expired')]); |
} else { |
} else { |
push(@links,["javascript:rolesView('showall');",'edit-undo-22x22',&mt('Include expired roles')]); |
push(@links,["javascript:rolesView('showall');",'edit-undo-22x22',&mt('Include expired')]); |
} |
} |
} |
} |
|
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 2702 sub get_queued {
|
Line 2759 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 2752 sub get_queued {
|
Line 2809 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 = |