version 1.269.2.19, 2014/05/05 11:44:18
|
version 1.307, 2014/05/22 14:32:48
|
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 143 use Apache::lonrss;
|
Line 143 use Apache::lonrss;
|
use GDBM_File; |
use GDBM_File; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use HTML::Entities; |
use HTML::Entities; |
|
|
|
|
sub redirect_user { |
sub redirect_user { |
my ($r,$title,$url,$msg) = @_; |
my ($r,$title,$url,$msg) = @_; |
Line 151 sub redirect_user {
|
Line 151 sub redirect_user {
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::no_cache($r); |
&Apache::loncommon::no_cache($r); |
$r->send_http_header; |
$r->send_http_header; |
my $swinfo=&Apache::lonmenu::rawconfig(); |
|
|
|
# Breadcrumbs |
# Breadcrumbs |
my $brcrum = [{'href' => $url, |
my $brcrum = [{'href' => $url, |
Line 166 sub redirect_user {
|
Line 165 sub redirect_user {
|
$url=~s/ /\%20/g; |
$url=~s/ /\%20/g; |
$r->print(<<ENDREDIR); |
$r->print(<<ENDREDIR); |
$start_page |
$start_page |
<script type="text/javascript"> |
|
// <![CDATA[ |
|
$swinfo |
|
// ]]> |
|
</script> |
|
<p>$msg</p> |
<p>$msg</p> |
$end_page |
$end_page |
ENDREDIR |
ENDREDIR |
Line 208 sub handler {
|
Line 202 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 221 sub handler {
|
Line 223 sub handler {
|
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
|
|
# -------------------------------------------------- Check if setting hot list |
# -------------------------------------------------- Check if setting hot list |
my $hotlist; |
my $hotlist; |
if ($env{'form.action'} eq 'verify_and_change_rolespref') { |
if ($env{'form.action'} eq 'verify_and_change_rolespref') { |
$hotlist = &Apache::lonpreferences::verify_and_change_rolespref($r); |
$hotlist = &Apache::lonpreferences::verify_and_change_rolespref($r); |
Line 253 sub handler {
|
Line 255 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 526 ENDENTERKEY
|
Line 528 ENDENTERKEY
|
|
|
if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) { |
if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) { |
my $msg; |
my $msg; |
my ($furl,$ferr)= |
my ($furl,$ferr)= |
&Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
&Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
unless ($ferr) { |
unless ($ferr) { |
unless (($env{'form.switchrole'}) || |
unless (($env{'form.switchrole'}) || |
($env{"environment.internal.$cdom.$cnum.$role.adhoc"})) { |
($env{"environment.internal.$cdom.$cnum.$role.adhoc"})) { |
&Apache::lonnet::put('nohist_crslastlogin', |
&Apache::lonnet::put('nohist_crslastlogin', |
{$env{'user.name'}.':'.$env{'user.domain'}. |
{$env{'user.name'}.':'.$env{'user.domain'}. |
Line 552 ENDENTERKEY
|
Line 554 ENDENTERKEY
|
} |
} |
if (($env{'form.orgurl'}) && |
if (($env{'form.orgurl'}) && |
($env{'form.orgurl'}!~/^\/adm\/flip/) && |
($env{'form.orgurl'}!~/^\/adm\/flip/) && |
($env{'form.orgurl'} ne '/adm/roles')) { |
($env{'form.orgurl'} ne '/adm/roles')) { |
my $dest=$env{'form.orgurl'}; |
my $dest=$env{'form.orgurl'}; |
if ($env{'form.symb'}) { |
if ($env{'form.symb'}) { |
if ($dest =~ /\?/) { |
if ($dest =~ /\?/) { |
Line 618 ENDENTERKEY
|
Line 620 ENDENTERKEY
|
if ($env{'request.role.adv'}) { |
if ($env{'request.role.adv'}) { |
$dest = &Apache::lonenc::unencrypted($dest); |
$dest = &Apache::lonenc::unencrypted($dest); |
if ($destsymb eq '') { |
if ($destsymb eq '') { |
($destsymb) = ($dest =~ /(?:\?|\&)symb=([^\&]*)/); |
($destsymb) = ($dest =~ /(?:\?|\&)symb=([^\&]*)/); |
$destsymb = &unescape($destsymb); |
$destsymb = &unescape($destsymb); |
} |
} |
} |
} |
Line 643 ENDENTERKEY
|
Line 645 ENDENTERKEY
|
} |
} |
} |
} |
} |
} |
unless (($dest =~ m{^/enc/}) || ($dest =~ /(\?|\&)symb=.+___\d+___.+/)) { |
unless (($dest =~ m{^/enc/}) || ($dest =~ /(\?|\&)symb=.+___\d+___.+/)) { |
if (($destsymb ne '') && ($destsymb !~ m{^/enc/})) { |
if (($destsymb ne '') && ($destsymb !~ m{^/enc/})) { |
my $esc_symb = &escape($destsymb); |
my $esc_symb = &escape($destsymb); |
$dest .= '?symb='.$esc_symb; |
$dest .= '?symb='.$esc_symb; |
} |
} |
} |
} |
&redirect_user($r, &mt('Entering [_1]', |
&redirect_user($r, &mt('Entering [_1]', |
$env{'course.'.$env{'request.course.id'}.'.description'}), |
$env{'course.'.$cdom.'_'.$cnum.'.description'}), |
$dest, $msg); |
$dest, $msg); |
return OK; |
return OK; |
} |
} |
Line 685 ENDENTERKEY
|
Line 687 ENDENTERKEY
|
} elsif (!&Apache::lonnet::allowed('bre',$furl)) { |
} elsif (!&Apache::lonnet::allowed('bre',$furl)) { |
$furl = &Apache::lonpageflip::first_accessible_resource(); |
$furl = &Apache::lonpageflip::first_accessible_resource(); |
} |
} |
|
|
$msg = &mt('Entering [_1] ...', |
$msg = &mt('Entering [_1] ...', |
$env{'course.'.$cdom.'_'.$cnum.'.description'}); |
$env{'course.'.$cdom.'_'.$cnum.'.description'}); |
&redirect_user($r, &mt('Entering [_1]', |
&redirect_user($r, &mt('Entering [_1]', |
Line 743 ENDENTERKEY
|
Line 745 ENDENTERKEY
|
$crumbtext = 'Courses'; |
$crumbtext = 'Courses'; |
$pagetitle = 'My Courses'; |
$pagetitle = 'My Courses'; |
$recent = &mt('Recent Courses'); |
$recent = &mt('Recent Courses'); |
$standby = &mt('Course selected. Please stand by.'); |
$standby = &mt('Course selected. Please stand by.'); |
} |
} |
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; |
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; |
|
|
Line 791 function rolesView (caller) {
|
Line 793 function rolesView (caller) {
|
document.rolechoice.display.value = caller; |
document.rolechoice.display.value = caller; |
} else { |
} else { |
if ((caller == 'doupdate') || (caller == 'requestauthor') || |
if ((caller == 'doupdate') || (caller == 'requestauthor') || |
(caller == 'queued')) { |
(caller == 'queued')) { |
document.rolechoice.state.value = caller; |
document.rolechoice.state.value = caller; |
} |
} |
} |
} |
Line 875 ENDHEADER
|
Line 877 ENDHEADER
|
} |
} |
if ($hotlist) { |
if ($hotlist) { |
$showresult .= $hotlist; |
$showresult .= $hotlist; |
} |
} |
$showresult .= '</div>'; |
$showresult .= '</div>'; |
$r->print($showresult); |
$r->print($showresult); |
} elsif ($env{'form.state'} eq 'queued') { |
} elsif ($env{'form.state'} eq 'queued') { |
Line 924 ENDHEADER
|
Line 926 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>'); |
|
} |
|
&requestcourse_advice($r,$cattype); |
|
$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 1442 sub findcourse_advice {
|
Line 1439 sub findcourse_advice {
|
} |
} |
|
|
sub requestcourse_advice { |
sub requestcourse_advice { |
my ($r,$cattype) = @_; |
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 1487 sub requestcourse_advice {
|
Line 1481 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'}) { |
} 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); |
&findcourse_advice($r,$cattype); |
} |
} |
return; |
return; |
Line 1773 sub check_release_required {
|
Line 1782 sub check_release_required {
|
(($reqdmajor == $swmajor) && ($reqdminor > $swminor))) { |
(($reqdmajor == $swmajor) && ($reqdminor > $swminor))) { |
my $cdom = $env{'course.'.$tcourseid.'.domain'}; |
my $cdom = $env{'course.'.$tcourseid.'.domain'}; |
if ($cdom ne $env{'user.domain'}) { |
if ($cdom ne $env{'user.domain'}) { |
my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom,undef,$required,1); |
my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom,undef,$required,1); |
my $serverhomeID = &Apache::lonnet::get_server_homeID($coursehostname); |
my $serverhomeID = &Apache::lonnet::get_server_homeID($coursehostname); |
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom); |
my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom); |
Line 2236 sub update_session_roles {
|
Line 2245 sub update_session_roles {
|
&curr_role_status($currstart,$currend,$refresh,$update); |
&curr_role_status($currstart,$currend,$refresh,$update); |
my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/); |
my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/); |
my ($role,$rest)=split(m{\./},$rolekey,2); |
my ($role,$rest)=split(m{\./},$rolekey,2); |
$rest = '/'.$rest; |
$rest = '/'.$rest; |
if (&Apache::lonnet::delenv($envkey,undef,[$role])) { |
if (&Apache::lonnet::delenv($envkey,undef,[$role])) { |
if ($status_in_env eq 'active') { |
if ($status_in_env eq 'active') { |
if ($role eq 'gr') { |
if ($role eq 'gr') { |
Line 2436 sub update_session_roles {
|
Line 2445 sub update_session_roles {
|
} |
} |
my $groupdesc; |
my $groupdesc; |
unless (ref($curr_groups{$cdom.'_'.$cnum}) eq 'HASH') { |
unless (ref($curr_groups{$cdom.'_'.$cnum}) eq 'HASH') { |
%{$curr_groups{$cdom.'_'.$cnum}} = |
%{$curr_groups{$cdom.'_'.$cnum}} = |
&Apache::longroup::coursegroups($cdom,$cnum); |
&Apache::longroup::coursegroups($cdom,$cnum); |
} |
} |
unless ((ref($groupdescs{$cdom.'_'.$cnum}) eq 'HASH') && |
unless ((ref($groupdescs{$cdom.'_'.$cnum}) eq 'HASH') && |
($groupdescs{$cdom.'_'.$cnum}{$group})) { |
($groupdescs{$cdom.'_'.$cnum}{$group})) { |
|
|
my %groupinfo = |
my %groupinfo = |
&Apache::longroup::get_group_settings($curr_groups{$cdom.'_'.$cnum}{$group}); |
&Apache::longroup::get_group_settings($curr_groups{$cdom.'_'.$cnum}{$group}); |
$groupdescs{$cdom.'_'.$cnum}{$group} = |
$groupdescs{$cdom.'_'.$cnum}{$group} = |
&unescape($groupinfo{'description'}); |
&unescape($groupinfo{'description'}); |
} |
} |
$groupdesc = $groupdescs{$cdom.'_'.$cnum}{$group}; |
$groupdesc = $groupdescs{$cdom.'_'.$cnum}{$group}; |
Line 2563 sub update_session_roles {
|
Line 2572 sub update_session_roles {
|
my $cdom = $env{'course.'.$cid.'.domain'}; |
my $cdom = $env{'course.'.$cid.'.domain'}; |
my $cnum = $env{'course.'.$cid.'.num'}; |
my $cnum = $env{'course.'.$cid.'.num'}; |
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); |
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); |
my %groupdesc; |
my %groupdesc; |
if (ref($groupchange{$crs}) eq 'HASH') { |
if (ref($groupchange{$crs}) eq 'HASH') { |
$groupchgmsg .= '<li>'.&mt('Course/Community: [_1]','<b>'.$crsdesc.'</b><ul>'); |
$groupchgmsg .= '<li>'.&mt('Course/Community: [_1]','<b>'.$crsdesc.'</b><ul>'); |
foreach my $group (sort(keys(%{$groupchange{$crs}}))) { |
foreach my $group (sort(keys(%{$groupchange{$crs}}))) { |
Line 2781 sub get_queued {
|
Line 2790 sub get_queued {
|
if (ref($history{'details'}) eq 'HASH') { |
if (ref($history{'details'}) eq 'HASH') { |
$description = $history{details}{'cdescr'}; |
$description = $history{details}{'cdescr'}; |
} |
} |
@{$reqcrs{$reqtime}} = ($description,$showtype); |
@{$reqcrs{$reqtime}} = ($description,$showtype); |
} |
} |
} |
} |
my @sortedtimes = sort {$a <=> $b} (keys(%reqcrs)); |
my @sortedtimes = sort {$a <=> $b} (keys(%reqcrs)); |