version 1.264, 2011/12/14 21:02:30
|
version 1.280, 2013/01/01 03:45:13
|
Line 138 use Apache::lonlocal;
|
Line 138 use Apache::lonlocal;
|
use Apache::lonpageflip(); |
use Apache::lonpageflip(); |
use Apache::lonnavdisplay(); |
use Apache::lonnavdisplay(); |
use Apache::loncoursequeueadmin; |
use Apache::loncoursequeueadmin; |
|
use Apache::longroup; |
use 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 211 sub handler {
|
Line 212 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 230 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 281 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 292 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 518 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 543 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 580 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 711 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 747 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 826 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 954 ENDHEADER
|
Line 1020 ENDHEADER
|
$r->print('<hr /><h2>'.&mt('Current Privileges').'</h2>'); |
$r->print('<hr /><h2>'.&mt('Current Privileges').'</h2>'); |
$r->print(&privileges_info()); |
$r->print(&privileges_info()); |
} |
} |
$r->print(&Apache::lonnet::getannounce()); |
my $announcements = &Apache::lonnet::getannounce(); |
|
$r->print( |
|
'<br />'. |
|
'<h2>'.&mt('Announcements').'</h2>'. |
|
$announcements |
|
) unless (!$announcements); |
if ($advanced) { |
if ($advanced) { |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
$r->print('<p><small><i>' |
$r->print('<p><small><i>' |
Line 969 ENDHEADER
|
Line 1040 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 995 sub gather_roles {
|
Line 1085 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 1567 sub adhoc_course_role {
|
Line 1657 sub adhoc_course_role {
|
$setprivs = 1; |
$setprivs = 1; |
} |
} |
} |
} |
|
unless ($setprivs) { |
|
if (!exists($env{'user.priv.'.$env{'form.switchrole'}.'./'})) { |
|
$setprivs = 1; |
|
} |
|
} |
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)([\w/]*)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { |
my $role = $1; |
my $role = $1; |
Line 1594 sub adhoc_course_role {
|
Line 1689 sub adhoc_course_role {
|
$spec .= '/'.$usec; |
$spec .= '/'.$usec; |
$area .= '/'.$usec; |
$area .= '/'.$usec; |
} |
} |
&Apache::lonnet::standard_roleprivs(\%newrole,$role,$cdom,$spec,$cnum,$area); |
if ($role =~ /^cr/) { |
|
&Apache::lonnet::custom_roleprivs(\%newrole,$role,$cdom,$cnum,$spec,$area); |
|
} else { |
|
&Apache::lonnet::standard_roleprivs(\%newrole,$role,$cdom,$spec,$cnum,$area); |
|
} |
&Apache::lonnet::set_userprivs(\%userroles,\%newrole,\%newgroups); |
&Apache::lonnet::set_userprivs(\%userroles,\%newrole,\%newgroups); |
my $adhocstart = $refresh-1; |
my $adhocstart = $refresh-1; |
$userroles{'user.role.'.$spec} = $adhocstart.'.'; |
$userroles{'user.role.'.$spec} = $adhocstart.'.'; |
Line 1613 sub check_forcc {
|
Line 1712 sub check_forcc {
|
} else { |
} else { |
$ccrole = 'cc'; |
$ccrole = 'cc'; |
} |
} |
if ($cdom ne '' && $cnum ne '') { |
if (&Apache::lonnet::is_course($cdom,$cnum)) { |
if (&Apache::lonnet::is_course($cdom,$cnum)) { |
my $envkey = 'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum; |
my $envkey = 'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum; |
if (defined($env{$envkey})) { |
if (defined($env{$envkey})) { |
$is_cc = 1; |
$is_cc = 1; |
my ($tstart,$tend)=split(/\./,$env{$envkey}); |
my ($tstart,$tend)=split(/\./,$env{$envkey}); |
my $limit = $update; |
my $limit = $update; |
if ($env{'request.role'} eq $ccrole.'./'.$cdom.'/'.$cnum) { |
if ($env{'request.role'} eq $ccrole.'./'.$cdom.'/'.$cnum) { |
$limit = $then; |
$limit = $then; |
|
} |
|
if ($tstart && $tstart>$refresh) { $is_cc = 0; } |
|
if ($tend && $tend <$limit) { $is_cc = 0; } |
|
} |
} |
|
if ($tstart && $tstart>$refresh) { $is_cc = 0; } |
|
if ($tend && $tend <$limit) { $is_cc = 0; } |
} |
} |
} |
} |
return $is_cc; |
return $is_cc; |
Line 1683 sub check_release_required {
|
Line 1780 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 1921 sub update_session_roles {
|
Line 1981 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 1965 sub update_session_roles {
|
Line 2025 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 2117 sub update_session_roles {
|
Line 2177 sub update_session_roles {
|
} |
} |
} |
} |
} |
} |
$currpriv{sys} = $env{"user.priv.$rolekey./"}; |
my $status_in_env = |
$currpriv{dom} = $env{"user.priv.$rolekey./$udom/"}; |
&curr_role_status($currstart,$currend,$refresh,$update); |
$currpriv{crs} = $env{"user.priv.$rolekey.$where"}; |
if ($status_in_env eq 'active') { |
if (keys(%crprivs)) { |
$currpriv{sys} = $env{"user.priv.$rolekey./"}; |
if (($crprivs{$rest}{sys} ne $currpriv{sys}) || |
$currpriv{dom} = $env{"user.priv.$rolekey./$udom/"}; |
($crprivs{$rest}{dom} ne $currpriv{dom}) |
$currpriv{crs} = $env{"user.priv.$rolekey.$where"}; |
|
if (keys(%crprivs)) { |
|
if (($crprivs{$rest}{sys} ne $currpriv{sys}) || |
|
($crprivs{$rest}{dom} ne $currpriv{dom}) |
|| |
|| |
($crprivs{$rest}{crs} ne $currpriv{crs})) { |
($crprivs{$rest}{crs} ne $currpriv{crs})) { |
&gather_roleprivs(\%allroles,\%allgroups,\%userroles,$where,$role,$tstart,$tend,$status_in_db); |
&gather_roleprivs(\%allroles,\%allgroups, |
unless (grep(/^\Q$role\E$/,@changed_roles)) { |
\%userroles,$where,$role, |
push(@changed_roles,$role); |
$tstart,$tend,$status_in_db); |
} |
unless (grep(/^\Q$role\E$/,@changed_roles)) { |
my $status_in_env = |
push(@changed_roles,$role); |
&curr_role_status($currstart,$currend,$refresh,$update); |
} |
if ($status_in_env eq 'active') { |
|
$customprivchg{$rolekey} = $status_in_env; |
$customprivchg{$rolekey} = $status_in_env; |
} |
} |
} |
} |
Line 2167 sub update_session_roles {
|
Line 2229 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 2205 sub update_session_roles {
|
Line 2267 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>'; |
|
} |
|
&Apache::lonnet::set_userprivs(\%userroles,\%allroles,\%allgroups,\%groups_roles); |
|
my ($curr_is_adv,$curr_role_adv,$curr_author,$curr_role_author); |
|
$curr_author = $env{'user.author'}; |
|
if (($env{'request.role'} =~/^au/) || ($env{'request.role'} =~/^ca/) || |
|
($env{'request.role'} =~/^aa/)) { |
|
$curr_role_author=1; |
|
} |
|
$curr_is_adv = $env{'user.adv'}; |
|
$curr_role_adv = $env{'request.role.adv'}; |
|
if (keys(%userroles) > 0) { |
|
foreach my $role (@changed_roles) { |
|
unless(grep(/^\Q$role\E$/,@rolecodes)) { |
|
push(@rolecodes,$role); |
|
} |
|
} |
|
unless(grep(/^\Qcm\E$/,@rolecodes)) { |
|
push(@rolecodes,'cm'); |
|
} |
|
&Apache::lonnet::appenv(\%userroles,\@rolecodes); |
|
} |
|
my %newenv; |
|
if (&Apache::lonnet::is_advanced_user($env{'user.domain'},$env{'user.name'})) { |
|
unless ($curr_is_adv) { |
|
$newenv{'user.adv'} = 1; |
|
} |
|
} elsif ($curr_is_adv && !$curr_role_adv) { |
|
&Apache::lonnet::delenv('user.adv'); |
|
} |
|
my %authorroleshash = |
|
&Apache::lonnet::get_my_roles('','','userroles',['active'],['au','ca','aa']); |
|
if (keys(%authorroleshash)) { |
|
unless ($curr_author) { |
|
$newenv{'user.author'} = 1; |
|
} |
|
} elsif ($curr_author && !$curr_role_author) { |
|
&Apache::lonnet::delenv('user.author'); |
|
} |
|
if ($env{'request.course.id'}) { |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my (@activecrsgroups,$crsgroupschanged); |
|
if ($env{'request.course.groups'}) { |
|
@activecrsgroups = split(/:/,$env{'request.course.groups'}); |
|
foreach my $item (keys(%deletedroles)) { |
|
if ($item =~ m{^gr\./\Q$cdom\E/\Q$cnum\E/(\w+)$}) { |
|
if (grep(/^\Q$1\E$/,@activecrsgroups)) { |
|
$crsgroupschanged = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
unless ($crsgroupschanged) { |
|
foreach my $item (keys(%newgroup)) { |
|
if ($item =~ m{^gr\./\Q$cdom\E/\Q$cnum\E/(\w+)$}) { |
|
if ($newgroup{$item} eq 'active') { |
|
$crsgroupschanged = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
if ((ref($changed_groups{$env{'request.course.id'}}) eq 'HASH') || |
|
(ref($groupchange{"/$cdom/$cnum"}) eq 'HASH') || |
|
($crsgroupschanged)) { |
|
my %grouproles = &Apache::lonnet::get_my_roles('','','userroles', |
|
['active'],['gr'],[$cdom],1); |
|
my @activegroups; |
|
foreach my $item (keys(%grouproles)) { |
|
next unless($item =~ /^\Q$cnum\E:\Q$cdom\E/); |
|
my $group; |
|
my ($crsn,$crsd,$role,$remainder) = split(/:/,$item,4); |
|
if ($remainder =~ /:/) { |
|
(my $other,$group) = ($remainder =~ /^([\w:]+):([^:]+)$/); |
|
} else { |
|
$group = $remainder; |
|
} |
|
if ($group ne '') { |
|
push(@activegroups,$group); |
|
} |
|
} |
|
$newenv{'request.course.groups'} = join(':',@activegroups); |
|
} |
|
} |
|
if (keys(%newenv)) { |
|
&Apache::lonnet::appenv(\%newenv); |
} |
} |
if (!@changed_roles || !(keys(%changed_groups))) { |
if (!@changed_roles || !(keys(%changed_groups))) { |
my ($rolesmsg,$groupsmsg); |
my ($rolesmsg,$groupsmsg); |
Line 2245 sub update_session_roles {
|
Line 2394 sub update_session_roles {
|
if (@changed_roles > 0) { |
if (@changed_roles > 0) { |
if (keys(%newgroup) > 0) { |
if (keys(%newgroup) > 0) { |
my $groupmsg; |
my $groupmsg; |
|
my (%curr_groups,%groupdescs,$currcrs); |
foreach my $item (sort(keys(%newgroup))) { |
foreach my $item (sort(keys(%newgroup))) { |
if (&is_active_course($item,$refresh,$update,\%roleshash)) { |
if (&is_active_course($item,$refresh,$update,\%roleshash)) { |
$groupmsg .= '<li>'. |
if ($item =~ m{^gr\./($match_domain/$match_courseid)/(\w+)$}) { |
&mt('[_1] with status: [_2].', |
my ($cdom,$cnum) = split(/\//,$1); |
$item,$newgroup{$item}).'</li>'; |
my $group = $2; |
|
if ($currcrs ne $cdom.'_'.$cnum) { |
|
if ($currcrs) { |
|
$groupmsg .= '</ul><li>'; |
|
} |
|
$groupmsg .= '<li><b>'. |
|
$env{'course.'.$cdom.'_'.$cnum.'.description'}.'</b><ul>'; |
|
} |
|
my ($cdom,$cnum) = split(/\//,$1); |
|
my $group = $2; |
|
my $groupdesc; |
|
unless (ref($curr_groups{$cdom.'_'.$cnum}) eq 'HASH') { |
|
%{$curr_groups{$cdom.'_'.$cnum}} = |
|
&Apache::longroup::coursegroups($cdom,$cnum); |
|
} |
|
unless ((ref($groupdescs{$cdom.'_'.$cnum}) eq 'HASH') && |
|
($groupdescs{$cdom.'_'.$cnum}{$group})) { |
|
|
|
my %groupinfo = |
|
&Apache::longroup::get_group_settings($curr_groups{$cdom.'_'.$cnum}{$group}); |
|
$groupdescs{$cdom.'_'.$cnum}{$group} = |
|
&unescape($groupinfo{'description'}); |
|
} |
|
$groupdesc = $groupdescs{$cdom.'_'.$cnum}{$group}; |
|
$groupmsg .= '<li>'. |
|
&mt('[_1] with status: [_2].', |
|
'<b>'.$groupdesc.'</b>',$newgroup{$item}).'</li>'; |
|
} |
|
} |
|
if ($groupmsg) { |
|
$groupmsg .= '</ul></li>'; |
} |
} |
} |
} |
if ($groupmsg) { |
if ($groupmsg) { |
Line 2262 sub update_session_roles {
|
Line 2442 sub update_session_roles {
|
$changemsg .= '<li>'.&mt('New roles'). |
$changemsg .= '<li>'.&mt('New roles'). |
'<ul>'; |
'<ul>'; |
foreach my $item (sort(keys(%newrole))) { |
foreach my $item (sort(keys(%newrole))) { |
|
my $desc = &role_desc($item,$update,$refresh,$now); |
$changemsg .= '<li>'. |
$changemsg .= '<li>'. |
&mt('[_1] with status: [_2].', |
&mt('[_1] with status: [_2].', |
$item,$newrole{$item}).'</li>'; |
$desc,$newrole{$item}).'</li>'; |
} |
} |
$changemsg .= '</ul></li>'; |
$changemsg .= '</ul></li>'; |
} |
} |
Line 2273 sub update_session_roles {
|
Line 2454 sub update_session_roles {
|
&mt('Custom roles with privilege changes'). |
&mt('Custom roles with privilege changes'). |
'<ul>'; |
'<ul>'; |
foreach my $item (sort(keys(%customprivchg))) { |
foreach my $item (sort(keys(%customprivchg))) { |
$changemsg .= '<li>'.$item.'</li>'; |
my $desc = &role_desc($item,$update,$refresh,$now); |
|
$changemsg .= '<li>'.$desc.'</li>'; |
} |
} |
$changemsg .= '</ul></li>'; |
$changemsg .= '</ul></li>'; |
} |
} |
Line 2282 sub update_session_roles {
|
Line 2464 sub update_session_roles {
|
&mt('Existing roles with status changes').'</li>'. |
&mt('Existing roles with status changes').'</li>'. |
'<ul>'; |
'<ul>'; |
foreach my $item (sort(keys(%rolechange))) { |
foreach my $item (sort(keys(%rolechange))) { |
|
my $desc = &role_desc($item,$update,$refresh,$now); |
$changemsg .= '<li>'. |
$changemsg .= '<li>'. |
&mt('[_1] status now: [_2].',$item, |
&mt('[_1] status now: [_2].',$desc, |
$rolechange{$item}).'</li>'; |
$rolechange{$item}).'</li>'; |
} |
} |
$changemsg .= '</ul></li>'; |
$changemsg .= '</ul></li>'; |
} |
} |
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>'; |
my $desc = &role_desc($item,$update,$refresh,$now); |
|
$changemsg .= '<li>'.$desc.'</li>'; |
} |
} |
$changemsg .= '</ul></li>'; |
$changemsg .= '</ul></li>'; |
} |
} |
Line 2325 sub update_session_roles {
|
Line 2509 sub update_session_roles {
|
&mt('Existing course/community groups with status changes').'</li>'. |
&mt('Existing course/community groups with status changes').'</li>'. |
'<ul>'; |
'<ul>'; |
foreach my $crs (sort(keys(%groupchange))) { |
foreach my $crs (sort(keys(%groupchange))) { |
|
my $cid = $crs; |
|
$cid=~s{^/}{}; |
|
$cid=~s{/}{_}; |
|
my $crsdesc = $env{'course.'.$cid.'.description'}; |
|
my $cdom = $env{'course.'.$cid.'.domain'}; |
|
my $cnum = $env{'course.'.$cid.'.num'}; |
|
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); |
|
my %groupdesc; |
if (ref($groupchange{$crs}) eq 'HASH') { |
if (ref($groupchange{$crs}) eq 'HASH') { |
$groupchgmsg .= '<li>'.&mt('Course/Community: [_1]','<b>'.$crs.'</b><ul>'); |
$groupchgmsg .= '<li>'.&mt('Course/Community: [_1]','<b>'.$crsdesc.'</b><ul>'); |
foreach my $group (sort(keys(%{$groupchange{$crs}}))) { |
foreach my $group (sort(keys(%{$groupchange{$crs}}))) { |
$groupchgmsg .= '<li>'.&mt('Group: [_1] status now: [_2].','<b>'.$group.'</b>',$groupchange{$crs}{$group}).'</li>'; |
unless ($groupdesc{$group}) { |
|
my %groupinfo = &Apache::longroup::get_group_settings($curr_groups{$group}); |
|
$groupdesc{$group} = &unescape($groupinfo{'description'}); |
|
} |
|
$groupchgmsg .= '<li>'.&mt('Group: [_1] status now: [_2].','<b>'.$groupdesc{$group}.'</b>',$groupchange{$crs}{$group}).'</li>'; |
} |
} |
$groupchgmsg .= '</ul></li>'; |
$groupchgmsg .= '</ul></li>'; |
} |
} |
Line 2344 sub update_session_roles {
|
Line 2540 sub update_session_roles {
|
if ($changemsg) { |
if ($changemsg) { |
$msg .= '<ul>'.$changemsg.'</ul>'; |
$msg .= '<ul>'.$changemsg.'</ul>'; |
} |
} |
&Apache::lonnet::set_userprivs(\%userroles,\%allroles,\%allgroups,\%groups_roles); |
return $msg; |
my ($curr_is_adv,$curr_role_adv,$curr_author,$curr_role_author); |
} |
$curr_author = $env{'user.author'}; |
|
if (($env{'request.role'} =~/^au/) || ($env{'request.role'} =~/^ca/) || |
sub role_desc { |
($env{'request.role'} =~/^aa/)) { |
my ($item,$update,$refresh,$now) = @_; |
$curr_role_author=1; |
my ($where,$trolecode,$role,$tstatus,$tend,$tstart,$twhere, |
} |
$trole,$tremark); |
$curr_is_adv = $env{'user.adv'}; |
&Apache::lonnet::role_status('user.role.'.$item,$update,$refresh, $now,\$role,\$where, \$trolecode, |
$curr_role_adv = $env{'request.role.adv'}; |
\$tstatus,\$tstart,\$tend); |
if (keys(%userroles) > 0) { |
if ($role =~ /^cr\//) { |
foreach my $role (@changed_roles) { |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
unless(grep(/^\Q$role\E$/,@rolecodes)) { |
$tremark = &mt('Customrole defined by [_1].',$rauthor.':'.$rdomain); |
push(@rolecodes,$role); |
} |
} |
$trole=Apache::lonnet::plaintext($role); |
} |
my ($tdom,$trest,$tsection)= |
unless(grep(/^\Qcm\E$/,@rolecodes)) { |
split(/\//,Apache::lonnet::declutter($where)); |
push(@rolecodes,'cm'); |
if (($role eq 'ca') || ($role eq 'aa')) { |
} |
my $home = &Apache::lonnet::homeserver($trest,$tdom); |
&Apache::lonnet::appenv(\%userroles,\@rolecodes); |
$home = &Apache::lonnet::hostname($home); |
} |
$twhere=&mt('User').': '.$trest.' '.&mt('Domain'). |
my %newenv; |
': '.$tdom.' '.&mt('Server').': '.$home; |
if (&Apache::lonnet::is_advanced_user($env{'user.domain'},$env{'user.name'})) { |
} elsif ($role eq 'au') { |
unless ($curr_is_adv) { |
my $home = &Apache::lonnet::homeserver |
$newenv{'user.adv'} = 1; |
($env{'user.name'},$env{'user.domain'}); |
} |
$home = &Apache::lonnet::hostname($home); |
} elsif ($curr_is_adv && !$curr_role_adv) { |
$twhere=&mt('Domain').': '.$tdom.' '.&mt('Server'). |
&Apache::lonnet::delenv('user.adv'); |
': '.$home; |
} |
} elsif ($trest) { |
my %authorroleshash = |
my $tcourseid=$tdom.'_'.$trest; |
&Apache::lonnet::get_my_roles('','','userroles',['active'],['au','ca','aa']); |
my $crstype = &Apache::loncommon::course_type($tcourseid); |
if (keys(%authorroleshash)) { |
$trole = &Apache::lonnet::plaintext($role,$crstype,$tcourseid); |
unless ($curr_author) { |
if ($env{'course.'.$tcourseid.'.description'}) { |
$newenv{'user.author'} = 1; |
$twhere=$env{'course.'.$tcourseid.'.description'}; |
} |
} else { |
} elsif ($curr_author && !$curr_role_author) { |
my %newhash=&Apache::lonnet::coursedescription($tcourseid); |
&Apache::lonnet::delenv('user.author'); |
if (%newhash) { |
} |
$twhere=$newhash{'description'}; |
if ($env{'request.course.id'}) { |
} else { |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$twhere=&mt('Currently not available'); |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my (@activecrsgroups,$crsgroupschanged); |
|
if ($env{'request.course.groups'}) { |
|
@activecrsgroups = split(/:/,$env{'request.course.groups'}); |
|
foreach my $item (keys(%deletedroles)) { |
|
if ($item =~ m{^gr\./\Q$cdom\E/\Q$cnum\E/(\w+)$}) { |
|
if (grep(/^\Q$1\E$/,@activecrsgroups)) { |
|
$crsgroupschanged = 1; |
|
last; |
|
} |
|
} |
|
} |
} |
} |
} |
unless ($crsgroupschanged) { |
if ($tsection) { |
foreach my $item (keys(%newgroup)) { |
$twhere.= ' '.&mt('Section').': '.$tsection; |
if ($item =~ m{^gr\./\Q$cdom\E/\Q$cnum\E/(\w+)$}) { |
|
if ($newgroup{$item} eq 'active') { |
|
$crsgroupschanged = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
} |
if ((ref($changed_groups{$env{'request.course.id'}}) eq 'HASH') || |
if ($role ne 'st') { |
(ref($groupchange{"/$cdom/$cnum"}) eq 'HASH') || |
$twhere.= ' '.&mt('Domain').': '.$tdom; |
($crsgroupschanged)) { |
|
my %grouproles = &Apache::lonnet::get_my_roles('','','userroles', |
|
['active'],['gr'],[$cdom],1); |
|
my @activegroups; |
|
foreach my $item (keys(%grouproles)) { |
|
next unless($item =~ /^\Q$cnum\E:\Q$cdom\E/); |
|
my $group; |
|
my ($crsn,$crsd,$role,$remainder) = split(/:/,$item,4); |
|
if ($remainder =~ /:/) { |
|
(my $other,$group) = ($remainder =~ /^([\w:]+):([^:]+)$/); |
|
} else { |
|
$group = $remainder; |
|
} |
|
if ($group ne '') { |
|
push(@activegroups,$group); |
|
} |
|
} |
|
$newenv{'request.course.groups'} = join(':',@activegroups); |
|
} |
} |
|
} elsif ($tdom) { |
|
$twhere = &mt('Domain').': '.$tdom; |
} |
} |
if (keys(%newenv)) { |
my $output = "$trole -- $twhere"; |
&Apache::lonnet::appenv(\%newenv); |
if ($tremark) { |
|
$output .= '<br />'.$tremark; |
} |
} |
return $msg; |
return $output; |
} |
} |
|
|
sub curr_role_status { |
sub curr_role_status { |
Line 2493 sub is_active_course {
|
Line 2656 sub is_active_course {
|
return $is_active; |
return $is_active; |
} |
} |
|
|
|
sub get_roles_functions { |
|
my ($rolescount) = @_; |
|
my @links; |
|
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 (($rolescount > 3) || ($env{'environment.recentroles'})) { |
|
push(@links,['/adm/preferences?action=changerolespref&returnurl=/adm/roles','role_hotlist-22x22',&mt('Hotlist')]); |
|
} |
|
if (&Apache::lonmenu::check_for_rcrs()) { |
|
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 ($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')]); |
|
} |
|
} |
|
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__ |
|
|