version 1.271, 2012/08/14 17:35:04
|
version 1.275, 2012/08/19 03:11:43
|
Line 211 sub handler {
|
Line 211 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 229 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; |
&reqauthor_check(); |
&Apache::loncoursequeueadmin::reqauthor_check(); |
} |
} |
|
|
# -------------------------------------------------- Check for author requests |
# -------------------------------------------------- Check for author requests |
|
|
my $reqauthor; |
my $reqauthor; |
if ($env{'form.requestauthor'}) { |
if ($env{'form.state'} eq 'requestauthor') { |
if ($env{'environment.canrequest.author'}) { |
$reqauthor = &Apache::loncoursequeueadmin::process_reqauthor(\$update); |
unless (&is_active_author()) { |
|
my $queued = &reqauthor_check(); |
|
my $skipreq; |
|
if ($queued =~ /^approval:\d+$/) { |
|
my ($status,$timestamp) = split(/:/,$env{'environment.requestauthorqueued'}); |
|
if ($status eq 'approval') { |
|
$reqauthor = '<span class="LC_info">'. |
|
&mt('A request for authoring space submitted on [_1] is awaiting approval', |
|
&Apache::lonlocal::locallocaltime($timestamp)). |
|
'</span>'; |
|
} |
|
$skipreq = 1; |
|
} elsif ($queued =~ /^approved:\d+$/) { |
|
my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', |
|
['active'],['au'],[$env{'user.domain'}]); |
|
if (keys(%roleshash) > 0) { |
|
$skipreq = 1; |
|
} |
|
} |
|
unless ($skipreq) { |
|
my (@inststatuses,%domconfig); |
|
%domconfig = |
|
&Apache::lonnet::get_dom('configuration', |
|
['requestauthor'],$env{'user.domain'}); |
|
my $val = &Apache::loncoursequeueadmin::get_processtype('requestauthor',$env{'user.name'}, |
|
$env{'user.domain'},$env{'user.adv'}, |
|
$env{'user.domain'},undef, |
|
\@inststatuses,\%domconfig); |
|
if ($val eq 'automatic') { |
|
my $start = $now-1; |
|
if (&Apache::lonnet::assignrole($env{'user.domain'},$env{'user.name'},'/'.$env{'user.domain'}.'/', |
|
'au',undef,$start,undef,undef,'requestauthor') eq 'ok') { |
|
$reqauthor = '<span class="LC_info">'. |
|
&mt('Access to authoring space has been activated').'</span><br />'; |
|
&update_session_roles(); |
|
&Apache::lonnet::appenv({'user.update.time' => $now}); |
|
$update = $now; |
|
} else { |
|
$reqauthor = '<span class="LC_info">'. |
|
&mt('An error occurred while activating your access to authoring space'); |
|
} |
|
} elsif ($val eq 'approval') { |
|
my $domconfiguser = &Apache::lonnet::get_domainconfiguser($env{'user.domain'}); |
|
if (&Apache::lonnet::put('requestauthorqueue',{ $env{'user.name'}.'_'.$val => $now }, |
|
$env{'user.domain'},$domconfiguser) eq 'ok') { |
|
my %userrequest = ( |
|
author => { |
|
timestamp => $now, |
|
status => $val, |
|
}, |
|
author_status => $val, |
|
); |
|
my $req_notifylist; |
|
if (ref($domconfig{'requestauthor'}) eq 'HASH') { |
|
if (ref($domconfig{'requestauthor'}{'notify'}) eq 'HASH') { |
|
my $req_notifylist = $domconfig{'requestauthor'}{'notify'}{'approval'}; |
|
if ($req_notifylist) { |
|
my $fullname = &Apache::loncommon::plainname($env{'user.name'}, |
|
$env{'user.domain'}); |
|
my $sender = $env{'user.name'}.':'.$env{'user.domain'}; |
|
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
|
&Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist, |
|
"$fullname ($env{'user.name'}:$env{'user.domain'})",undef,$domdesc, |
|
$now,'authorreq',$sender); |
|
} |
|
} |
|
} |
|
my $userresult = |
|
&Apache::lonnet::put('requestauthor',\%userrequest,$env{'user.domain'},$env{'user.name'}); |
|
$reqauthor = '<span class="LC_info">'. |
|
&mt('Your request for authoring space has been submitted for approval.'). |
|
'</span>'; |
|
&Apache::lonnet::appenv({'environment.requestauthorqueued' => $val.':'.$now}); |
|
} else { |
|
$reqauthor = '<span class="LC_info">'. |
|
&mt('An error occurred saving your request for authoring space.'). |
|
'</span>'; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
} |
|
|
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 367 sub handler {
|
Line 291 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 591 ENDENTERKEY
|
Line 517 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 737 ENDENTERKEY
|
Line 669 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 768 function enterrole (thisform,rolecode,bu
|
Line 705 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')) { |
function setToRequestAuthor(thisform) { |
document.rolechoice.state.value = caller; |
thisform.requestauthor.value='1'; |
} |
thisform.selectrole.value=''; |
} |
thisform.submit(); |
document.rolechoice.selectrole.value=''; |
|
document.rolechoice.submit(); |
} |
} |
|
|
// ]]> |
// ]]> |
Line 846 ENDHEADER
|
Line 784 ENDHEADER
|
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} else { |
} else { |
if ($updateresult || $reqauthor) { |
if ($updateresult || $reqauthor || $hotlist) { |
$r->print('<div>'. |
my $showresult = '<div>'; |
$updateresult. |
if ($updateresult) { |
$reqauthor. |
$showresult .= &Apache::lonhtmlcommon::confirm_success($updateresult); |
'</div>'); |
} |
|
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)" />'; |
|
} |
|
my ($requestauthor,$requestcrs); |
|
unless ($reqauthor) { |
|
if ($env{'environment.canrequest.author'}) { |
|
unless (&is_active_author()) { |
|
my ($status,$timestamp) = split(/:/,$env{'environment.requestauthorqueued'}); |
|
if ($status eq 'approval') { |
|
$requestauthor = &mt('A request for authoring space submitted on [_1] is awaiting approval',&Apache::lonlocal::locallocaltime($timestamp)); |
|
} elsif (($status eq 'approved') && ($do_update)) { |
|
my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', |
|
['active'],['au'],[$env{'user.domain'}]); |
|
if (keys(%roleshash)) { |
|
$requestauthor = &mt('Your request for an author role has been approved.').'<br />'; |
|
if ($show_course) { |
|
$requestauthor .= &mt('Use the "Check for new courses" button to update your list of roles.'); |
|
} else { |
|
$requestauthor .= &mt('Use the "Check for new roles" button to update your list of roles.'); |
|
} |
|
$requestauthor = '<span class="LC_info">'.$requestauthor.'</span>'; |
|
} |
|
} |
|
unless ($requestauthor) { |
|
$requestauthor = |
|
'<input type="hidden" name="requestauthor" value="" />'. |
|
'<input type="button" name="reqauthor" value="'. |
|
&mt('Request author space').'" '. |
|
'onclick="javascript:setToRequestAuthor(this.form)" />'; |
|
} |
|
} |
|
} |
|
} |
|
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 || $requestauthor) { |
|
$r->print('<div class="LC_left_float"><fieldset>'. |
|
'<legend>'. &mt('Display').'</legend>'. |
|
$showall.'</fieldset></div>'); |
|
if ($do_update) { |
|
$r->print('<div class="LC_left_float">'. |
|
'<fieldset><legend>'.&mt('Changes?').'</legend>'. |
|
$do_update.'</fieldset></div>'); |
|
} |
|
if ($requestauthor) { |
|
$r->print('<div class="LC_left_float">'. |
|
'<fieldset><legend>'.&mt('Add author role').'</legend>'. |
|
$requestauthor.'</fieldset>'); |
|
} |
|
$r->print('</div><br clear="all" />'); |
|
} else { |
|
$r->print($showall); |
|
} |
|
} else { |
|
if ($do_update && $requestauthor) { |
|
$r->print('<div class="LC_left_float">'. |
|
'<fieldset><legend>'.&mt('Changes?').'</legend>'. |
|
$do_update.'</fieldset></div>'. |
|
'<div class="LC_left_float">'. |
|
'<fieldset><legend>'.&mt('Add author role').'</legend>'. |
|
$requestauthor.'</fieldset></div><br clear="all" />'); |
|
} elsif ($do_update) { |
|
$r->print('<p>'.$do_update.'</p>'); |
|
} elsif ($requestauthor) { |
|
$r->print('<p>'.$requestauthor.'</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 1132 ENDHEADER
|
Line 998 ENDHEADER
|
return OK; |
return OK; |
} |
} |
|
|
sub is_active_author { |
sub roles_from_env { |
if ($env{'user.role.au./'.$env{'user.domain'}.'/'} =~ /^(\d*)\.(\d*)$/) { |
my ($roleshash,$update) = @_; |
if ((!$1 || $1 < time) && |
my $count = 0; |
(!$2 || $2 > time)) { |
if (ref($roleshash) eq 'HASH') { |
return 1; |
foreach my $envkey (keys(%env)) { |
} |
if ($envkey =~ m{^user\.role\.(\w+)[./]}) { |
} |
next if ($1 eq 'gr'); |
return; |
$roleshash->{$envkey} = $env{$envkey}; |
} |
my ($start,$end) = split(/\./,$env{$envkey}); |
|
unless ($end && $end<$update) { |
sub reqauthor_check { |
$count ++; |
my $queued = $env{'environment.requestauthorqueued'}; |
} |
my %reqauthor = &Apache::lonnet::get('requestauthor',['author_status','author'], |
} |
$env{'user.domain'},$env{'user.name'}); |
|
my $reqstatus = $reqauthor{'author_status'}; |
|
if (($reqstatus eq '' && $queued ne '') || |
|
($env{'environment.requestauthorqueued'} !~ /^\Q$reqstatus\E/)) { |
|
if (ref($reqauthor{'author'}) eq 'HASH') { |
|
$queued = $reqstatus.':'.$reqauthor{'author'}{'timestamp'}; |
|
} else { |
|
undef($queued); |
|
} |
} |
&Apache::lonnet::appenv({'environment.requestauthorqueued' => $queued}); |
|
} |
} |
return $queued; |
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 1185 sub gather_roles {
|
Line 1043 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 2318 sub update_session_roles {
|
Line 2176 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 2356 sub update_session_roles {
|
Line 2214 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 2644 sub is_active_course {
|
Line 2502 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__ |
|
|