version 1.267, 2012/06/01 16:00:29
|
version 1.269.2.4, 2012/12/13 21:11:17
|
Line 149 sub redirect_user {
|
Line 149 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 163 sub redirect_user {
|
Line 164 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 211 sub handler {
|
Line 217 sub handler {
|
$update = $then; |
$update = $then; |
} |
} |
|
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
|
|
|
# -------------------------------------------------- Check if setting hot list |
|
my $hotlist; |
|
if ($env{'form.action'} eq 'verify_and_change_rolespref') { |
|
$hotlist = &Apache::lonpreferences::verify_and_change_rolespref($r); |
|
} |
|
|
# -------------------------------------------------------- Check for new roles |
# -------------------------------------------------------- Check for new roles |
my $updateresult; |
my $updateresult; |
if ($env{'form.doupdate'}) { |
if ($env{'form.state'} eq 'doupdate') { |
my $show_course=&Apache::loncommon::show_course(); |
my $show_course=&Apache::loncommon::show_course(); |
my $checkingtxt; |
my $checkingtxt; |
if ($show_course) { |
if ($show_course) { |
Line 221 sub handler {
|
Line 235 sub handler {
|
} else { |
} else { |
$checkingtxt = &mt('Checking for new roles ...'); |
$checkingtxt = &mt('Checking for new roles ...'); |
} |
} |
$updateresult = '<span class="LC_info">'.$checkingtxt.'</span>'; |
$updateresult = $checkingtxt; |
$updateresult .= &update_session_roles(); |
$updateresult .= &update_session_roles(); |
&Apache::lonnet::appenv({'user.update.time' => $now}); |
&Apache::lonnet::appenv({'user.update.time' => $now}); |
$update = $now; |
$update = $now; |
|
&Apache::loncoursequeueadmin::reqauthor_check(); |
|
} |
|
|
|
# -------------------------------------------------- Check for author requests |
|
my $reqauthor; |
|
if ($env{'form.state'} eq 'requestauthor') { |
|
$reqauthor = &Apache::loncoursequeueadmin::process_reqauthor(\$update); |
} |
} |
|
|
my $envkey; |
my $envkey; |
my %dcroles = (); |
my %dcroles = (); |
my $numdc = &check_fordc(\%dcroles,$update,$then); |
my $numdc = &check_fordc(\%dcroles,$update,$then); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
|
my $loncaparev = $Apache::lonnet::perlvar{'lonVersion'}; |
my $loncaparev = $Apache::lonnet::perlvar{'lonVersion'}; |
|
|
# ================================================================== Roles Init |
# ================================================================== Roles Init |
Line 266 sub handler {
|
Line 286 sub handler {
|
"request.course.fn" => '', |
"request.course.fn" => '', |
"request.course.uri" => '', |
"request.course.uri" => '', |
"request.course.sec" => '', |
"request.course.sec" => '', |
|
"request.course.tied" => '', |
"request.role" => 'cm', |
"request.role" => 'cm', |
"request.role.adv" => $env{'user.adv'}, |
"request.role.adv" => $env{'user.adv'}, |
"request.role.domain" => $env{'user.domain'}}); |
"request.role.domain" => $env{'user.domain'}}); |
Line 276 sub handler {
|
Line 297 sub handler {
|
if (my ($ccrole,$domain,$coursenum) = |
if (my ($ccrole,$domain,$coursenum) = |
($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) { |
($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) { |
if ($dcroles{$domain}) { |
if ($dcroles{$domain}) { |
&Apache::lonnet::check_adhoc_privs($domain,$coursenum, |
if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum, |
$update,$refresh,$now,$ccrole); |
$update,$refresh,$now,$ccrole)) { |
|
&Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.$ccrole.adhoc" => time}); |
|
} |
} |
} |
last; |
last; |
} |
} |
Line 500 ENDENTERKEY
|
Line 523 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'}) || |
|
($env{"environment.internal.$cdom.$cnum.$role.adhoc"})) { |
|
&Apache::lonnet::put('nohist_crslastlogin', |
|
{$env{'user.name'}.':'.$env{'user.domain'}. |
|
':'.$csec.':'.$role => $now},$cdom,$cnum); |
|
} |
if (($env{'form.orgurl'}) && |
if (($env{'form.orgurl'}) && |
($env{'form.orgurl'}!~/^\/adm\/flip/)) { |
($env{'form.orgurl'}!~/^\/adm\/flip/)) { |
my $dest=$env{'form.orgurl'}; |
my $dest=$env{'form.orgurl'}; |
Line 519 ENDENTERKEY
|
Line 548 ENDENTERKEY
|
if ($dest =~ m{^/adm/coursedocs\?folderpath}) { |
if ($dest =~ m{^/adm/coursedocs\?folderpath}) { |
if ($env{'request.course.id'} eq $cdom.'_'.$cnum) { |
if ($env{'request.course.id'} eq $cdom.'_'.$cnum) { |
my $chome = &Apache::lonnet::homeserver($cnum,$cdom); |
my $chome = &Apache::lonnet::homeserver($cnum,$cdom); |
&update_content_constraints($cdom,$cnum,$chome,$cdom.'_'.$cnum); |
&Apache::loncommon::update_content_constraints($cdom,$cnum,$chome, |
|
$cdom.'_'.$cnum); |
} |
} |
} |
} |
$r->internal_redirect($dest); |
$r->internal_redirect($dest); |
Line 555 ENDENTERKEY
|
Line 585 ENDENTERKEY
|
$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 ($env{'form.destinationurl'}) { |
my ($dest,$destsymb,$checkenc); |
my $dest = $env{'form.destinationurl'}; |
$dest = $env{'form.destinationurl'}; |
if ($env{'form.destsymb'} ne '') { |
$destsymb = $env{'form.destsymb'}; |
my $esc_symb = &HTML::Entities::encode($env{'form.destsymb'},'"<>&'); |
if ($dest ne '') { |
$dest .= '?symb='.$esc_symb; |
if ($env{'form.switchrole'}) { |
|
if ($destsymb ne '') { |
|
if ($destsymb !~ m{^/enc/}) { |
|
unless ($env{'request.role.adv'}) { |
|
$checkenc = 1; |
|
} |
|
} |
|
} |
|
if ($dest =~ m{^/enc/}) { |
|
if ($env{'request.role.adv'}) { |
|
$dest = &Apache::lonenc::unencrypted($dest); |
|
if ($destsymb eq '') { |
|
($destsymb) = ($dest =~ /(?:\?|\&)symb=([^\&]*)/); |
|
$destsymb = &unescape($destsymb); |
|
} |
|
} |
|
} else { |
|
if ($destsymb eq '') { |
|
($destsymb) = ($dest =~ /(?:\?|\&)symb=([^\&]+)/); |
|
$destsymb = &unescape($destsymb); |
|
} |
|
unless ($env{'request.role.adv'}) { |
|
$checkenc = 1; |
|
} |
|
} |
|
if (($checkenc) && ($destsymb ne '')) { |
|
my ($encstate,$unencsymb,$res); |
|
my $unencsymb = &Apache::lonnet::symbclean($destsymb); |
|
(undef,undef,$res) = &Apache::lonnet::decode_symb($unencsymb); |
|
&Apache::lonnet::symbverify($unencsymb,$res,\$encstate); |
|
if ($encstate) { |
|
if (($dest ne '') && ($dest !~ m{^/enc/})) { |
|
$dest=&Apache::lonenc::encrypted($dest); |
|
} |
|
} |
|
} |
|
} |
|
unless (($dest =~ m{^/enc/}) || ($dest =~ /(\?|\&)symb=.+___\d+___.+/)) { |
|
if (($destsymb ne '') && ($destsymb !~ m{^/enc/})) { |
|
my $esc_symb = &escape($destsymb); |
|
$dest .= '?symb='.$esc_symb; |
|
} |
} |
} |
&redirect_user($r, &mt('Entering [_1]', |
&redirect_user($r, &mt('Entering [_1]', |
$env{'course.'.$courseid.'.description'}), |
$env{'course.'.$courseid.'.description'}), |
Line 645 ENDENTERKEY
|
Line 716 ENDENTERKEY
|
$recent = &mt('Recent Courses'); |
$recent = &mt('Recent Courses'); |
} |
} |
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; |
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; |
|
|
|
my %roles_in_env; |
|
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 $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum}); |
|
my $funcs = &get_roles_functions($showcount); |
my $standby=&mt('Role selected. Please stand by.'); |
my $standby=&mt('Role selected. Please stand by.'); |
$standby=~s/\n/\\n/g; |
$standby=~s/\n/\\n/g; |
my $noscript='<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); |
$start_page |
$start_page |
<br /> |
$funcs |
<noscript> |
<noscript> |
$noscript |
$noscript |
</noscript> |
</noscript> |
Line 676 function enterrole (thisform,rolecode,bu
|
Line 752 function enterrole (thisform,rolecode,bu
|
} |
} |
} |
} |
|
|
function setToUpdate(thisform) { |
function rolesView (caller) { |
thisform.doupdate.value='1'; |
if ((caller == 'showall') || (caller == 'noshowall')) { |
thisform.selectrole.value=''; |
document.rolechoice.display.value = caller; |
thisform.submit(); |
} else { |
|
if ((caller == 'doupdate') || (caller == 'requestauthor') || |
|
(caller == 'queued')) { |
|
document.rolechoice.state.value = caller; |
|
} |
|
} |
|
document.rolechoice.selectrole.value=''; |
|
document.rolechoice.submit(); |
} |
} |
|
|
// ]]> |
// ]]> |
Line 748 ENDHEADER
|
Line 831 ENDHEADER
|
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} else { |
} else { |
$r->print($updateresult); |
if ($updateresult || $reqauthor || $hotlist) { |
|
my $showresult = '<div>'; |
|
if ($updateresult) { |
|
$showresult .= &Apache::lonhtmlcommon::confirm_success($updateresult); |
|
} |
|
if ($reqauthor) { |
|
$showresult .= &Apache::lonhtmlcommon::confirm_success($reqauthor); |
|
} |
|
if ($hotlist) { |
|
$showresult .= $hotlist; |
|
} |
|
$showresult .= '</div>'; |
|
$r->print($showresult); |
|
} elsif ($env{'form.state'} eq 'queued') { |
|
$r->print(&get_queued()); |
|
} |
if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) { |
if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) { |
$fn.='?'.$ENV{'REDIRECT_QUERY_STRING'}; |
$fn.='?'.$ENV{'REDIRECT_QUERY_STRING'}; |
} |
} |
|
my $display = ($env{'form.display'} =~ /^(showall)$/); |
$r->print('<form method="post" name="rolechoice" action="'.(($fn)?$fn:$r->uri).'">'); |
$r->print('<form method="post" name="rolechoice" action="'.(($fn)?$fn:$r->uri).'">'); |
$r->print('<input type="hidden" name="orgurl" value="'.$fn.'" />'); |
$r->print('<input type="hidden" name="orgurl" value="'.$fn.'" />'); |
$r->print('<input type="hidden" name="selectrole" value="1" />'); |
$r->print('<input type="hidden" name="selectrole" value="1" />'); |
$r->print('<input type="hidden" name="newrole" value="" />'); |
$r->print('<input type="hidden" name="newrole" value="" />'); |
|
$r->print('<input type="hidden" name="display" value="'.$display.'" />'); |
|
$r->print('<input type="hidden" name="state" value="" />'); |
} |
} |
$r->rflush(); |
$r->rflush(); |
|
|
my (%roletext,%sortrole,%roleclass,%futureroles,%timezones); |
my (%roletext,%sortrole,%roleclass,%futureroles,%timezones); |
my ($countactive,$countfuture,$inrole,$possiblerole) = |
my ($countactive,$countfuture,$inrole,$possiblerole) = |
&gather_roles($update,$refresh,$now,$reinit,$nochoose,\%roletext,\%sortrole,\%roleclass, |
&gather_roles($update,$refresh,$now,$reinit,$nochoose,\%roles_in_env,\%roletext, |
\%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}); |
my $updatebutton = &mt('Check for role changes'); |
unless ($env{'user.adv'}) { |
my $show_course=&Apache::loncommon::show_course(); |
|
if ($show_course) { |
|
$updatebutton = &mt('Check for new courses'); |
|
} |
|
my $do_update; |
|
unless (($env{'form.source'} eq 'login') || ($env{'form.doupdate'})) { |
|
$do_update = '<input type="hidden" name="doupdate" value="" />'. |
|
'<input type="button" name="update" value="'. |
|
$updatebutton.'" onclick="javascript:setToUpdate(this.form)" />'; |
|
} |
|
if ($env{'user.adv'}) { |
|
my $showall = '<label><input type="checkbox" name="showall"'; |
|
if ($env{'form.showall'}) { |
|
$showall .= ' checked="checked" '; |
|
} |
|
$showall .= ' />'.&mt('Show all roles').'</label> '. |
|
'<input type="submit" value="'.&mt('Update display').'" />'; |
|
if ($do_update) { |
|
$r->print('<div class="LC_left_float"><fieldset>'. |
|
'<legend>'. &mt('Display').'</legend>'. |
|
$showall.'</fieldset></div>'. |
|
'<div class="LC_left_float"><fieldset><legend>'. |
|
&mt('Changes?').'</legend>'. |
|
$do_update.'</fieldset></div><br clear="all" />'); |
|
} else { |
|
$r->print($showall); |
|
} |
|
} else { |
|
$r->print('<p>'.$do_update.'</p>'); |
|
if ($countactive > 0) { |
if ($countactive > 0) { |
$r->print(&Apache::loncoursequeueadmin::queued_selfenrollment()); |
|
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( |
Line 974 ENDHEADER
|
Line 1045 ENDHEADER
|
return OK; |
return OK; |
} |
} |
|
|
|
sub roles_from_env { |
|
my ($roleshash,$update) = @_; |
|
my $count = 0; |
|
if (ref($roleshash) eq 'HASH') { |
|
foreach my $envkey (keys(%env)) { |
|
if ($envkey =~ m{^user\.role\.(\w+)[./]}) { |
|
next if ($1 eq 'gr'); |
|
$roleshash->{$envkey} = $env{$envkey}; |
|
my ($start,$end) = split(/\./,$env{$envkey}); |
|
unless ($end && $end<$update) { |
|
$count ++; |
|
} |
|
} |
|
} |
|
} |
|
return $count; |
|
} |
|
|
sub gather_roles { |
sub gather_roles { |
my ($update,$refresh,$now,$reinit,$nochoose,$roletext,$sortrole,$roleclass,$futureroles,$timezones,$loncaparev) = @_; |
my ($update,$refresh,$now,$reinit,$nochoose,$roles_in_env,$roletext,$sortrole,$roleclass,$futureroles, |
|
$timezones,$loncaparev) = @_; |
my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,''); |
my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,''); |
my $advanced = $env{'user.adv'}; |
my $advanced = $env{'user.adv'}; |
my $tryagain = $env{'form.tryagain'}; |
my $tryagain = $env{'form.tryagain'}; |
my @ids = &Apache::lonnet::current_machine_ids(); |
my @ids = &Apache::lonnet::current_machine_ids(); |
foreach my $envkey (sort(keys(%env))) { |
if (ref($roles_in_env) eq 'HASH') { |
my $button = 1; |
foreach my $envkey (sort(keys(%{$roles_in_env}))) { |
my $switchserver=''; |
my $button = 1; |
my $switchwarning; |
my $switchserver=''; |
my ($role_text,$role_text_end,$sortkey); |
my $switchwarning; |
if ($envkey=~/^user\.role\./) { |
my ($role_text,$role_text_end,$sortkey,$role,$where,$trolecode,$tstart, |
my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend); |
$tend,$tremark,$tstatus,$tpstart,$tpend); |
&Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where, |
&Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where, |
\$trolecode,\$tstatus,\$tstart,\$tend); |
\$trolecode,\$tstatus,\$tstart,\$tend); |
next if (!defined($role) || $role eq '' || $role =~ /^gr/); |
next if (!defined($role) || $role eq '' || $role =~ /^gr/); |
Line 1000 sub gather_roles {
|
Line 1090 sub gather_roles {
|
if (($tstatus eq 'is') |
if (($tstatus eq 'is') |
|| ($tstatus eq 'selected') |
|| ($tstatus eq 'selected') |
|| ($tstatus eq 'future') |
|| ($tstatus eq 'future') |
|| ($env{'form.showall'})) { |
|| ($env{'form.display'} eq 'showall')) { |
my $timezone = &role_timezone($where,$timezones); |
my $timezone = &role_timezone($where,$timezones); |
if ($tstart) { |
if ($tstart) { |
$tpstart=&Apache::lonlocal::locallocaltime($tstart,$timezone); |
$tpstart=&Apache::lonlocal::locallocaltime($tstart,$timezone); |
Line 1686 sub check_release_required {
|
Line 1776 sub check_release_required {
|
return ($switchserver,$warning); |
return ($switchserver,$warning); |
} |
} |
|
|
sub update_content_constraints { |
|
my ($cdom,$cnum,$chome,$cid) = @_; |
|
my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired'); |
|
my ($reqdmajor,$reqdminor) = split(/\./,$curr_reqd_hash{'internal.releaserequired'}); |
|
my %checkresponsetypes; |
|
foreach my $key (keys(%Apache::lonnet::needsrelease)) { |
|
my ($item,$name,$value) = split(/:/,$key); |
|
if ($item eq 'resourcetag') { |
|
if ($name eq 'responsetype') { |
|
$checkresponsetypes{$value} = $Apache::lonnet::needsrelease{$key} |
|
} |
|
} |
|
} |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if (defined($navmap)) { |
|
my %allresponses; |
|
foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) { |
|
my %responses = $res->responseTypes(); |
|
foreach my $key (keys(%responses)) { |
|
next unless(exists($checkresponsetypes{$key})); |
|
$allresponses{$key} += $responses{$key}; |
|
} |
|
} |
|
foreach my $key (keys(%allresponses)) { |
|
my ($major,$minor) = split(/\./,$checkresponsetypes{$key}); |
|
if (($major > $reqdmajor) || ($major == $reqdmajor && $minor > $reqdminor)) { |
|
($reqdmajor,$reqdminor) = ($major,$minor); |
|
} |
|
} |
|
undef($navmap); |
|
} |
|
unless (($reqdmajor eq '') && ($reqdminor eq '')) { |
|
&Apache::lonnet::update_released_required($reqdmajor.'.'.$reqdminor,$cdom,$cnum,$chome,$cid); |
|
} |
|
return; |
|
} |
|
|
|
sub courselink { |
sub courselink { |
my ($dcdom,$rowtype) = @_; |
my ($dcdom,$rowtype) = @_; |
my $courseform=&Apache::loncommon::selectcourse_link |
my $courseform=&Apache::loncommon::selectcourse_link |
Line 1924 sub update_session_roles {
|
Line 1977 sub update_session_roles {
|
} |
} |
if ($env{$envkey} eq '') { |
if ($env{$envkey} eq '') { |
my $status_in_db = |
my $status_in_db = |
&curr_role_status($tstart,$tend,$refresh,$now); |
&curr_role_status($tstart,$tend,$now,$now); |
&gather_roleprivs(\%allroles,\%allgroups,\%userroles,$where,$role,$tstart,$tend,$status_in_db); |
&gather_roleprivs(\%allroles,\%allgroups,\%userroles,$where,$role,$tstart,$tend,$status_in_db); |
if (($role eq 'st') && ($env{'request.role'} =~ m{^\Q$role\E\.\Q/$udom/$uname\E})) { |
if (($role eq 'st') && ($env{'request.role'} =~ m{^\Q$role\E\.\Q/$udom/$uname\E})) { |
if ($status_in_db eq 'active') { |
if ($status_in_db eq 'active') { |
Line 1968 sub update_session_roles {
|
Line 2021 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 $status_in_db = |
my $status_in_db = |
&curr_role_status($tstart,$tend,$refresh,$now); |
&curr_role_status($tstart,$tend,$now,$now); |
if ($status_in_env ne $status_in_db) { |
if ($status_in_env ne $status_in_db) { |
if ($status_in_env eq 'active') { |
if ($status_in_env eq 'active') { |
if ($role eq 'st') { |
if ($role eq 'st') { |
Line 2170 sub update_session_roles {
|
Line 2223 sub update_session_roles {
|
} |
} |
if (($oldsec) && (@newsec > 0)) { |
if (($oldsec) && (@newsec > 0)) { |
if (@newsec > 1) { |
if (@newsec > 1) { |
$msg = '<div class="LC_warning">'.&mt('The section has changed for your current role. Log-out and log-in again to select a role for the new section.').'</div>'; |
$msg = '<p class="LC_warning">'.&mt('The section has changed for your current role. Log-out and log-in again to select a role for the new section.').'</p>'; |
} else { |
} else { |
my $newrole = $env{'request.role'}; |
my $newrole = $env{'request.role'}; |
if ($newsec[0] eq 'none') { |
if ($newsec[0] eq 'none') { |
Line 2208 sub update_session_roles {
|
Line 2261 sub update_session_roles {
|
$msg .= '</form></p>'; |
$msg .= '</form></p>'; |
} |
} |
} elsif ($currrole_expired) { |
} elsif ($currrole_expired) { |
$msg .= '<div class="LC_warning">'; |
$msg .= '<p class="LC_warning">'; |
if (&Apache::loncommon::show_course()) { |
if (&Apache::loncommon::show_course()) { |
$msg .= &mt('Your role in the current course has expired.'); |
$msg .= &mt('Your role in the current course has expired.'); |
} else { |
} else { |
$msg .= &mt('Your current role has expired.'); |
$msg .= &mt('Your current role has expired.'); |
} |
} |
$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.').'</div>'; |
$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>'; |
} |
} |
if (!@changed_roles || !(keys(%changed_groups))) { |
if (!@changed_roles || !(keys(%changed_groups))) { |
my ($rolesmsg,$groupsmsg); |
my ($rolesmsg,$groupsmsg); |
Line 2239 sub update_session_roles {
|
Line 2292 sub update_session_roles {
|
} |
} |
$msg .= '</ul>'; |
$msg .= '</ul>'; |
} else { |
} else { |
$msg = ' <span class="LC_cusr_emph">'.$rolesmsg.'</span><br /><br />'; |
$msg = ' <span class="LC_cusr_emph">'.$rolesmsg.'</span><br />'; |
} |
} |
return $msg; |
return $msg; |
} |
} |
Line 2293 sub update_session_roles {
|
Line 2346 sub update_session_roles {
|
} |
} |
if (keys(%deletedroles) > 0) { |
if (keys(%deletedroles) > 0) { |
$changemsg .= '<li>'. |
$changemsg .= '<li>'. |
&mt('Existing roles deleted').'</li>'. |
&mt('Existing roles now expired').'</li>'. |
'<ul>'; |
'<ul>'; |
foreach my $item (sort(keys(%deletedroles))) { |
foreach my $item (sort(keys(%deletedroles))) { |
$changemsg .= '<li>'.$item.'</li>'; |
$changemsg .= '<li>'.$item.'</li>'; |
Line 2496 sub is_active_course {
|
Line 2549 sub is_active_course {
|
return $is_active; |
return $is_active; |
} |
} |
|
|
|
sub get_roles_functions { |
|
my ($rolescount) = @_; |
|
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')]); |
|
if ($env{'environment.canrequest.author'}) { |
|
unless (&Apache::loncoursequeueadmin::is_active_author()) { |
|
push(@links,["javascript:rolesView('requestauthor');",'list-add-22x22',&mt('Request author role')]); |
|
} |
|
} |
|
if (&Apache::lonmenu::check_for_rcrs()) { |
|
push(@links,['/adm/requestcourse','rcrs-22x22',&mt('Request course')]); |
|
} |
|
if ($env{'form.state'} eq 'queued') { |
|
push(@links,["javascript:rolesView('noqueued');",'selfenrl-queue-22x22',&mt('Hide queued')]); |
|
} else { |
|
push(@links,["javascript:rolesView('queued');",'selfenrl-queue-22x22',&mt('Show queued')]); |
|
} |
|
if (($rolescount > 3) || ($env{'environment.recentroles'})) { |
|
push(@links,['/adm/preferences?action=changerolespref&returnurl=/adm/roles','role_hotlist-22x22',&mt('Hotlist')]); |
|
} |
|
|
|
my $funcs = &Apache::lonhtmlcommon::start_funclist(); |
|
foreach my $link (@links) { |
|
$funcs .= &Apache::lonhtmlcommon::add_item_funclist( |
|
'<a href="'.$link->[0].'" class="LC_menubuttons_link">'. |
|
'<img src="/res/adm/pages/'.$link->[1].'.png" class="LC_icon" alt="'.$link->[2].'" />'. |
|
$link->[2].'</a>'); |
|
} |
|
$funcs .= &Apache::lonhtmlcommon::end_funclist(); |
|
return &Apache::loncommon::head_subbox($funcs); |
|
} |
|
|
|
sub get_queued { |
|
my ($output,%reqcrs); |
|
my ($types,$typenames) = &Apache::loncommon::course_types(); |
|
my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'}, |
|
$env{'user.name'},'^status:'); |
|
foreach my $key (keys(%statusinfo)) { |
|
next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')); |
|
(undef,my($cdom,$cnum)) = split(':',$key); |
|
my $requestkey = $cdom.'_'.$cnum; |
|
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) { |
|
my %history = &Apache::lonnet::restore($requestkey,'courserequests', |
|
$env{'user.domain'},$env{'user.name'}); |
|
next if ((exists($history{'status'})) && ($history{'status'} eq 'created')); |
|
my $reqtime = $history{'reqtime'}; |
|
my $lastupdate = $history{'timestamp'}; |
|
my $showtype = $history{'crstype'}; |
|
if (defined($typenames->{$history{'crstype'}})) { |
|
$showtype = $typenames->{$history{'crstype'}}; |
|
} |
|
my $description; |
|
if (ref($history{'details'}) eq 'HASH') { |
|
$description = $history{details}{'cdescr'}; |
|
} |
|
@{$reqcrs{$reqtime}} = ($description,$showtype); |
|
} |
|
} |
|
my @sortedtimes = sort {$a <=> $b} (keys(%reqcrs)); |
|
if (@sortedtimes > 0) { |
|
$output .= '<p><b>'.&mt('Course/Community requests').'</b><br />'. |
|
&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_header_row(). |
|
'<th>'.&mt('Date requested').'</th>'. |
|
'<th>'.&mt('Course title').'</th>'. |
|
'<th>'.&mt('Course type').'</th>'; |
|
&Apache::loncommon::end_data_table_header_row(); |
|
foreach my $reqtime (@sortedtimes) { |
|
next unless (ref($reqcrs{$reqtime}) eq 'ARRAY'); |
|
$output .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.&Apache::lonlocal::locallocaltime($reqtime).'</td>'. |
|
'<td>'.join('</td><td>',@{$reqcrs{$reqtime}}).'</td>'. |
|
&Apache::loncommon::end_data_table_row(); |
|
} |
|
$output .= &Apache::loncommon::end_data_table(). |
|
'<br /></p>'; |
|
} |
|
my $queuedselfenroll = &Apache::loncoursequeueadmin::queued_selfenrollment(1); |
|
if ($queuedselfenroll) { |
|
$output .= '<p><b>'.&mt('Enrollment requests').'</b><br />'. |
|
$queuedselfenroll.'<br /></p>'; |
|
} |
|
if ($env{'environment.canrequest.author'}) { |
|
unless (&Apache::loncoursequeueadmin::is_active_author()) { |
|
my $requestauthor; |
|
my ($status,$timestamp) = split(/:/,$env{'environment.requestauthorqueued'}); |
|
if (($status eq 'approval') || ($status eq 'approved')) { |
|
$output .= '<p><b>'.&mt('Author role request').'</b><br />'; |
|
if ($status eq 'approval') { |
|
$output .= &mt('A request for authoring space submitted on [_1] is awaiting approval', |
|
&Apache::lonlocal::locallocaltime($timestamp)); |
|
} elsif ($status eq 'approved') { |
|
my %roleshash = |
|
&Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', |
|
['active'],['au'],[$env{'user.domain'}]); |
|
if (keys(%roleshash)) { |
|
$output .= '<span class="LC_info">'. |
|
&mt('Your request for an author role has been approved.').'<br />'. |
|
&mt('Use the "Check for changes" link to update your list of roles.'). |
|
'</span>'; |
|
} |
|
} |
|
$output .= '</p>'; |
|
} |
|
} |
|
} |
|
unless ($output) { |
|
if ($env{'environment.canrequest.author'} || $env{'environment.canrequest.official'} || |
|
$env{'environment.canrequest.unofficial'} || $env{'environment.canrequest.community'}) { |
|
$output = &mt('No requests for courses, communities or authoring currently queued'); |
|
} else { |
|
$output = &mt('No enrollment requests currently queued awaiting approval'); |
|
} |
|
} |
|
return '<div class="LC_left_float"><fieldset><legend>'.&mt('Queued requests').'</legend>'. |
|
$output.'</fieldset></div><br clear="all" />'; |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |
|
|